221V 1 year ago
parent
commit
3a9790dede

+ 1 - 1
include/mad.hrl

@@ -1 +1 @@
--define(VERSION,"3a6c99").
+-define(VERSION,"818d3f").

BIN
mad


+ 11 - 2
priv/web/apps/sample/src/index.erl

@@ -1,8 +1,16 @@
 -module(index).
--compile([export_all, nowarn_export_all]).
--include_lib("n2o/include/wf.hrl").
+
+-include_lib("n4u/include/wf.hrl").
 -include_lib("nitro/include/nitro.hrl").
 
+
+-export([
+  main/0,
+  event/1
+]).
+
+
+
 peer()    -> wf:to_list(wf:peer(?REQ)).
 message() -> wf:js_escape(wf:html_encode(wf:to_list(wf:q(message)))).
 main()    -> #dtl{file="index",app=sample,bindings=[{body,body()}]}.
@@ -13,3 +21,4 @@ event(init) -> wf:reg(room);
 event(chat) -> wf:send(room,{client,{peer(),message()}});
 event({client,{P,M}}) -> wf:insert_bottom(history,#panel{id=history,body=[P,": ",M,#br{}]});
 event(Event) -> wf:info(?MODULE,"Unknown Event: ~p~n",[Event]).
+

+ 12 - 3
priv/web/apps/sample/src/sample.erl

@@ -1,8 +1,16 @@
 -module(sample).
+
 -behaviour(supervisor).
+
 -behaviour(application).
+
+
 -export([init/1, start/2, stop/1, main/1]).
--compile([export_all, nowarn_export_all]).
+
+-export([
+  log_modules/0
+]).
+
 
 main(A)    -> mad_repl:sh(A).
 start(_,_) -> supervisor:start_link({local,sample},sample,[]).
@@ -14,13 +22,14 @@ init([])   -> case cowboy:start_http(http,3,port(),env()) of
 sup()    -> { ok, { { one_for_one, 5, 100 }, [] } }.
 env()    -> [ { env, [ { dispatch, points() } ] } ].
 static() ->   { dir, "apps/sample/priv/static", mime() }.
-n2o()    ->   { dir, "deps/n2o/priv",           mime() }.
+n4u()    ->   { dir, "deps/n4u/priv",           mime() }.
 mime()   -> [ { mimetypes, cow_mimetypes, all   } ].
 port()   -> [ { port, wf:config(n2o,port,8001)  } ].
 points() -> cowboy_router:compile([{'_', [
               { "/static/[...]", n2o_static, static() },
-              { "/n2o/[...]",    n2o_static, n2o()    },
+              { "/n4u/[...]",    n2o_static, n4u()    },
               { "/ws/[...]",     n2o_stream, []       },
               { '_',             n2o_cowboy, []       }]}]).
 
 log_modules() -> [n2o_client,n2o_nitrogen,n2o_stream,wf_convert].
+

+ 7 - 2
src/compile/mad_app.erl

@@ -1,6 +1,11 @@
 -module(mad_app).
--copyright('Sina Samavati').
--compile([export_all, nowarn_export_all]).
+%%-copyright('Sina Samavati').
+
+
+-export([
+  compile/5
+]).
+
 
 app_src_to_app(Filename) -> filename:basename(Filename, ".app.src") ++ ".app".
 

+ 11 - 4
src/compile/mad_compile.erl

@@ -1,18 +1,24 @@
 -module(mad_compile).
 %%-author('Sina Samavati').
 
--compile([export_all, nowarn_export_all]).
+-export([
+  compile/1,
+  deps/4,
+  dep/4,
+  is_compiled/2,
+  list/1
+]).
 
 
 compile(Params) ->
     { Cwd, ConfigFile, Conf } = mad_utils:configs(),
     Res = case Params of
-         [] -> mad_compile:'compile-deps'(Cwd, ConfigFile, Conf);
-         _ -> mad_compile:deps(Cwd, Conf, ConfigFile, [Params])
+         [] -> 'compile-deps'(Cwd, ConfigFile, Conf);
+         _ -> deps(Cwd, Conf, ConfigFile, [Params])
     end,
     case bool(Res) of
          true -> {error,Params};
-         false -> mad_compile:'compile-apps'(Cwd, ConfigFile, Conf) end.
+         false -> 'compile-apps'(Cwd, ConfigFile, Conf) end.
 
 deps(_, _, _, []) -> {ok,deps};
 deps(Cwd, Conf, ConfigFile, [H|T]) ->
@@ -103,3 +109,4 @@ is_compiled(BeamFile, File) -> mad_utils:last_modified(BeamFile) >= mad_utils:la
 
 list(X) when is_atom(X) -> atom_to_list(X);
 list(X) -> X.
+

+ 3 - 1
src/compile/mad_dtl.erl

@@ -1,7 +1,9 @@
 -module(mad_dtl).
 %%-copyright('Sina Samavati').
 
--compile([export_all, nowarn_export_all]).
+-export([
+  compile/2
+]).
 
 
 compile(Dir,Config) ->

+ 6 - 2
src/compile/mad_leex.erl

@@ -1,6 +1,10 @@
 -module(mad_leex).
--copyright('Sina Samavati').
--compile([export_all, nowarn_export_all]).
+%%-copyright('Sina Samavati').
+
+-export([
+  compile/5
+]).
+
 
 xrl_to_erl(F) -> filename:join(filename:dirname(F),filename:basename(F, ".xrl")) ++ ".erl".
 

+ 6 - 1
src/compile/mad_none.erl

@@ -1,4 +1,9 @@
 -module(mad_none).
--compile([export_all, nowarn_export_all]).
+
+-export([
+  compile/5
+]).
+
 
 compile(_,_,_,_,_) -> false.
+

+ 3 - 1
src/compile/mad_port.erl

@@ -1,7 +1,9 @@
 -module(mad_port).
 %%-copyright('Maxim Sokhatsky').
 
--compile([export_all, nowarn_export_all]).
+-export([
+  compile/2
+]).
 
 
 compile(Dir,Config) ->

+ 7 - 2
src/compile/mad_script.erl

@@ -1,6 +1,10 @@
 -module(mad_script).
--copyright('Sina Samavati').
--compile([export_all, nowarn_export_all]).
+%%-copyright('Sina Samavati').
+
+-export([
+  script/3
+]).
+
 
 script(ConfigFile, Conf, _) ->
     File = ConfigFile ++ ".script",
@@ -9,3 +13,4 @@ script(ConfigFile, Conf, _) ->
         {ok, Out} -> Out;
         {error, _} -> Conf
     end.
+

+ 6 - 2
src/compile/mad_yecc.erl

@@ -1,6 +1,10 @@
 -module(mad_yecc).
--copyright('Sina Samavati').
--compile([export_all, nowarn_export_all]).
+%%-copyright('Sina Samavati').
+
+-export([
+  compile/5
+]).
+
 
 yrl_to_erl(F) -> filename:join(filename:dirname(F),filename:basename(F, ".yrl")) ++ ".erl".
 

+ 10 - 2
src/mad.erl

@@ -3,8 +3,16 @@
 
 -include("mad.hrl").
 
--compile([export_all, nowarn_export_all]).
--export([main/1]).
+
+-export([
+  main/1,
+  profile/0,
+  host/0,
+  help/2,
+  help/1,
+  info/1,
+  info/2
+]).
 
 
 main([])     -> help();

+ 7 - 1
src/mad_release.erl

@@ -1,5 +1,10 @@
 -module(mad_release).
--compile([export_all, nowarn_export_all]).
+
+
+-export([
+  release/1
+]).
+
 
 release([])              -> release(["script"]);
 release(["depot"])       -> release(["depot", "sample"]);
@@ -11,3 +16,4 @@ release(["script",N])    -> mad_escript:main(N);
 release(["beam",N])      -> mad_systools:beam_release(N);
 release(["depot",N])     -> mad_synrc:depot_release(N);
 release([X])             -> release(["script",X]).
+

+ 5 - 1
src/mad_resolve.erl

@@ -1,7 +1,10 @@
 -module(mad_resolve).
 %%-author('Maxim Sokhatsky').
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  main/1
+]).
 
 
 %% dependency graph solver
@@ -52,3 +55,4 @@ main(_) ->
          {ok,Ordered}   -> mad:info("Generating .applist ~p~n",[Ordered]),
                            file:write_file(".applist", io_lib:format("~w",[Ordered])), {ok,Ordered};
          {error,Reason} -> {error,Reason} end.
+

+ 6 - 1
src/mad_static.erl

@@ -1,7 +1,12 @@
 -module(mad_static).
 %-author('Yuri Artemev').
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  main/2,
+  app/1
+]).
+
 
 -define(NODE(Bin), "node_modules/.bin/" ++ Bin).
 

+ 29 - 2
src/mad_utils.erl

@@ -1,6 +1,32 @@
 -module(mad_utils).
--copyright('Sina Samavati').
--compile([export_all, nowarn_export_all]).
+%%-copyright('Sina Samavati').
+
+
+-export([
+  name_and_repo/1,
+  cwd/0,
+  home/0,
+  consult/1,
+  src/1,
+  include/1,
+  ebin/1,
+  priv/1,
+  deps/1,
+  get_value/3,
+  script/3,
+  sub_dirs/3,
+  sub_dirs/4,
+  lib_dirs/2,
+  lib_dirs/3,
+  raw_deps/1,
+  raw_deps/2,
+  last_modified/1,
+  to_atom/1,
+  verbose/2,
+  compile/5,
+  configs/0
+]).
+
 
 %% internal
 name_and_repo({Name, _, Repo}) when is_list(Name) -> {Name, Repo};
@@ -94,3 +120,4 @@ configs() ->
     Conf           = mad_utils:consult(ConfigFileAbs),
     Conf1          = mad_script:script(ConfigFileAbs, Conf, ""),
     {Cwd,ConfigFile,Conf1}.
+

+ 10 - 2
src/package/mad_escript.erl

@@ -1,6 +1,14 @@
 -module(mad_escript).
--description("ESCRIPT bundles").
--compile([export_all, nowarn_export_all]).
+%% ESCRIPT bundles
+
+
+-export([
+  main/1,
+  beams/0,
+  privs/0,
+  system_files/0
+]).
+
 
 main(N) ->
         App = filename:basename(case N of [] -> mad_utils:cwd(); E -> E end),

+ 13 - 3
src/package/mad_ling.erl

@@ -1,7 +1,17 @@
 -module(mad_ling).
--description("LING Erlang Virtual Machine Bundle Packaging").
--copyright('Cloudozer, LLP').
--compile([export_all, nowarn_export_all]).
+%%-copyright('Cloudozer, LLP').
+
+%% LING Erlang Virtual Machine Bundle Packaging
+
+-export([
+  ling/1,
+  cache_dir/0,
+  local_map/1,
+  apps/1,
+  boot/1
+]).
+
+
 -define(ARCH, list_to_atom( case os:getenv("ARCH") of false -> "posix"; A -> A end)).
 
 ling(Params) ->

+ 8 - 2
src/package/mad_systools.erl

@@ -1,6 +1,11 @@
 -module(mad_systools).
--description("ERTS releases with systools").
--compile([export_all, nowarn_export_all]).
+%% ERTS releases with systools
+
+-export([
+  apps/1,
+  beam_release/1
+]).
+
 
 % beam releases
 
@@ -53,3 +58,4 @@ beam_release(N) ->
     erl_tar:create(N ++ ".tgz",Files,[compressed]),
     mad:info("~s.boot: ~p~n",[N,Res]),
     {ok,N}.
+

+ 19 - 1
src/profile/mad_local.erl

@@ -1,5 +1,23 @@
 -module(mad_local).
--compile([export_all, nowarn_export_all]).
+
+-export([
+  compile/1,
+  app/1,
+  release/1,
+  resolve/1,
+  clean/1,
+  start/1,
+  attach/1,
+  stop/1,
+  sh/1,
+  deps/1,
+  up/1,
+  fetch/1,
+  static/1,
+  eunit/1,
+  strip/1
+]).
+
 
 compile(Params)   -> mad_compile:compile(Params).
 app(Params)       -> mad_static:app(Params).

+ 17 - 1
src/profile/mad_vz.erl

@@ -1,5 +1,20 @@
 -module(mad_vz).
--compile([export_all, nowarn_export_all]).
+
+-export([
+  compile/1,
+  app/1,
+  clean/1,
+  start/1,
+  attach/1,
+  stop/1,
+  release/1,
+  resolve/1,
+  sh/1,
+  deps/1,
+  up/1,
+  fetch/1
+]).
+
 
 compile(Params)   -> mad_compile:compile(Params).
 app(Params)       -> mad_static:app(Params).
@@ -13,3 +28,4 @@ sh(_Params)        -> {error,'N/A'}.
 deps(Params)      -> mad_synrc:deps(Params).
 up(Params)        -> mad_synrc:up(Params).
 fetch(Params)     -> mad_synrc:fetch(Params).
+

+ 9 - 3
src/provision/mad_repl.erl

@@ -1,7 +1,13 @@
 -module(mad_repl).
 %%-copyright('Maxim Sokhatsky').
 
--compile([export_all, nowarn_export_all]).
+-export([
+  local_app/0,
+  applist/0,
+  load_sysconfig/0,
+  application_config/1,
+  sh/1
+]).
 
 
 disabled() -> [].
@@ -18,7 +24,7 @@ applist() ->
     case file:read_file(Name) of
          {ok,Binary} -> parse_applist(Binary);
          {error,_} ->
-           case mad_repl:load_file(Name) of
+           case load_file(Name) of
               {error,_} -> mad_resolve:main([]);
               {ok,Plan} -> parse_applist(Plan) end end.
 
@@ -31,7 +37,7 @@ parse_applist(AppList) ->
 load_sysconfig() ->
    Config = wildcards(["sys.config", lists:concat( ["etc/", mad:host(), "/sys.config"] )]),
    case Config of
-      [] -> case mad_repl:load_file("sys.config") of
+      [] -> case load_file("sys.config") of
              {error,_} -> [];
              {ok,Bin} -> parse(unicode:characters_to_list(Bin)) end;
       File -> case file:consult(hd(File)) of

+ 6 - 1
src/provision/mad_run.erl

@@ -1,6 +1,11 @@
 -module(mad_run).
 
--compile([export_all, nowarn_export_all]).
+-export([
+  start/1,
+  attach/1,
+  stop/1,
+  clean/1
+]).
 
 
 start(App) ->                            % run_dir > < log_dir

+ 9 - 1
src/provision/mad_vz.erl

@@ -1,5 +1,12 @@
 -module(mad_vz).
--compile([export_all, nowarn_export_all]).
+
+-export([
+  create/2,
+  create/1,
+  start/1,
+  stop/1
+]).
+
 
 create(App,_) -> create(App).
 create(App) ->
@@ -23,3 +30,4 @@ stop(_App) -> ok.
 
 ret(0) -> ok;
 ret(_) -> error.
+

+ 7 - 2
src/sources/mad_git.erl

@@ -1,5 +1,11 @@
 -module(mad_git).
--compile([export_all, nowarn_export_all]).
+
+-export([
+  deps/1,
+  fetch/1,
+  up/1
+]).
+
 
 deps(_Params) ->
     { Cwd, ConfigFile, Conf } = mad_utils:configs(),
@@ -35,7 +41,6 @@ git_clone(Uri,_Fast,TrunkPath,Rev) ->
     {["git clone ",Uri," ",TrunkPath," && cd ",TrunkPath," && git checkout \"",Rev,"\"" ],Rev}.
 
 fetch_dep(Cwd, Config, ConfigFile, Name, Cmd, Uri, Co, Cache) ->
-
     TrunkPath = case Cache of
         deps_fetch -> filename:join([mad_utils:get_value(deps_dir,Config,"deps"),Name]);
         Dir -> filename:join([Dir,get_publisher(Uri),Name]) end,

+ 7 - 1
src/sources/mad_synrc.erl

@@ -1,5 +1,10 @@
 -module(mad_synrc).
--compile([export_all, nowarn_export_all]).
+
+-export([
+  deps/1,
+  depot_release/1
+]).
+
 
 deps(_Params) ->
     { Cwd, ConfigFile, Conf } = mad_utils:configs(),
@@ -31,3 +36,4 @@ depot_release(Name) ->
     || {_,[X],_} <- lists:flatten(Apps) ]),
     io:format("DEPOT Apps: ~p~n",[Files]),
     {ok,Name}.
+

+ 3 - 1
src/test/mad_eunit.erl

@@ -1,6 +1,8 @@
 -module(mad_eunit).
 
--compile(export_all).
+-export([
+  main_test/1
+]).
 
 
 main_test(_Params) ->