Browse Source

mad warnings

Namdak Tonpa 9 years ago
parent
commit
7c7e769cb5

+ 1 - 1
include/mad.hrl

@@ -1 +1 @@
--define(VERSION,"2c1413").
+-define(VERSION,"ae21eb").

BIN
mad


+ 1 - 1
rebar.config

@@ -1,3 +1,3 @@
 {deps_dir,"deps"}.
 {deps, [%{ling, ".*", {git, "git://github.com/cloudozer/ling", {tag, "master"}}},
-        {sh, ".*",   {git, "git://github.com/synrc/sh",       {tag, "1.9"}}}]}.
+        {sh, ".*",   {git, "git://github.com/synrc/sh",       {tag, "master"}}}]}.

+ 10 - 6
src/compile/mad_erl.erl

@@ -1,7 +1,7 @@
 -module(mad_erl).
 -copyright('Sina Samavati').
 -compile(export_all).
--define(COMPILE_OPTS(Inc, Ebin, Opts, Deps), [return_errors, {i, [Inc]}, {outdir, Ebin}] ++ Opts++Deps).
+-define(COMPILE_OPTS(Inc, Ebin, Opts, Deps), [return_errors, return_warnings, {i, [Inc]}, {outdir, Ebin}] ++ Opts++Deps).
 
 erl_to_beam(Bin, F) -> filename:join(Bin, filename:basename(F, ".erl") ++ ".beam").
 
@@ -15,9 +15,13 @@ compile(File,Inc,Bin,Opt,Deps) ->
     true -> false end.
 
 ret(error) -> true;
-ret({error,Errors,_}) ->
-    S=case file:get_cwd() of {ok,Cwd} -> length(Cwd); _ -> 0 end,
-    [[ mad:info("Line ~p: ~p in ~p~n",[ L,R,lists:nthtail(S,F) ]) || {L,_,R} <- E ] || {F,E} <- Errors ], true;
+ret({error,X}) -> lines(error,X);
+ret({error,X,_}) -> lines(error,X);
 ret({ok,_}) -> false;
-ret({ok,_,_}) -> false;
-ret({ok,_,_,_}) -> false.
+ret({ok,_,[]}) -> false;
+ret({ok,_,X}) -> lines(warning,X), false;
+ret({ok,_,X,_}) -> lines(warning,X), false.
+
+lines(Tag,X) ->
+    S=case file:get_cwd() of {ok,Cwd} -> length(Cwd); _ -> 0 end,
+    [[ mad:info("Line ~p: ~p ~p in ~p~n",[ L,Tag,R,lists:nthtail(S,F) ]) || {L,_,R} <- E ] || {F,E} <- X ], true.

+ 5 - 7
src/mad.erl

@@ -16,10 +16,8 @@ main(Params)      ->
                                 (_) -> false end,
            lists:flatten(
            lists:foldl(
-                 fun ({Fun,Arg},[])  -> errors((profile()):Fun(Arg));
-                     ({Fun,Arg},Err) -> errors(Invalid),
-                                        { return, Err } end,
-                 [], Valid)))).
+                 fun ({Fun,Arg},[]) -> errors((profile()):Fun(Arg));
+                        ({_,_},Err) -> errors(Invalid), {return,Err} end, [], Valid)))).
 
 atomize("static") -> 'static';
 atomize("deploy") -> 'deploy';
@@ -44,9 +42,9 @@ profile()         -> application:get_env(mad,profile,mad_local).
 errors([])        -> [];
 errors(false)     -> [];
 errors(true)      -> {error,unknown};
-errors({error,L}) -> info("ERROR: ~tp~n",[L]), {error,L};
+errors({error,L}) -> info("ERROR: ~tp~n",[L]), [{error,L}];
 errors({ok,_})    -> info("OK~n",[]), [];
-errors(X)         -> info("RETURN: ~tp~n",[X]), {error,X}.
+errors(X)         -> info("RETURN: ~tp~n",[X]), [{error,X}].
 
 return(true)      -> 1;
 return(false)     -> 0;
@@ -56,7 +54,7 @@ info(Format)      -> io:format(lists:concat([Format,"\r"])).
 info(Format,Args) -> io:format(lists:concat([Format,"\r"]),Args).
 
 help(Reason,D)    -> help(io_lib:format("~s ~p", [Reason, D])).
-help(Msg)         -> help().
+help(_Msg)        -> help().
 help()            -> info("MAD Container Tool version ~s~n",[?VERSION]),
                      info("~n"),
                      info("    invoke = mad params~n"),

+ 1 - 1
src/package/mad_escript.erl

@@ -7,7 +7,7 @@ main(N) ->
     mad_resolve:main([]),
     EmuArgs = "-noshell -noinput +pc unicode",
     Files = static() ++ beams(fun filename:basename/1, fun read_file/1) ++ overlay(),
-%   [ io:format("Escript: ~ts~n",[File]) || { File, _ } <- Files ],
+   [ io:format("Escript: ~ts~n",[File]) || { File, _ } <- Files ],
     escript:create(App,[shebang,{comment,""},{emu_args,EmuArgs},{archive,Files,[memory]}]),
     file:change_mode(App, 8#764),
     {ok,App}.

+ 2 - 2
src/package/mad_systools.erl

@@ -22,14 +22,14 @@ apps(List) ->
 
 release(Name) ->
     Triples = mad_resolve:triples(),
-    Apps = lists:usort(fun({Name,_},{Name2,_})-> Name =< Name2 end,
+    Apps = lists:usort(fun({Name1,_},{Name2,_})-> Name1 =< Name2 end,
                 [{A,{B,F}}||{_,A,{B,F}}<-Triples]) ++
       [{kernel,{proplists:get_value(vsn,element(2,
                 application:get_all_key(kernel)),[]),
                 filename:absname(code:lib_dir(kernel))}}],
     Sorted = [ lists:keyfind(A,1,Apps) || A <- element(2,mad_resolve:orderapps())],
     {L,R}     = lists:unzip(Sorted),
-    {Ver,Dir} = lists:unzip(R),
+    {Ver,_Dir} = lists:unzip(R),
     NameVer   = [ X || X <- lists:zip(L,Ver), element(1,X) /= active,
                                               element(1,X) /= fs ],
     Version = case lists:keyfind(list_to_atom(Name),2,Triples) of

+ 1 - 1
src/provision/mad_vz.erl

@@ -19,7 +19,7 @@ start(App) ->
     mad:info("Oneliner: ~p~n",[Concat]),
     {ret(R),S}.
 
-stop(App) -> ok.
+stop(_App) -> ok.
 
 ret(0) -> ok;
 ret(_) -> error.

+ 1 - 1
src/sources/mad_git.erl

@@ -1,7 +1,7 @@
 -module(mad_git).
 -compile(export_all).
 
-deps(Params) ->
+deps(_Params) ->
     { Cwd, ConfigFile, Conf } = mad_utils:configs(),
     case mad_utils:get_value(deps, Conf, []) of
         [] -> {ok,[]};

+ 1 - 1
src/sources/mad_synrc.erl

@@ -1,7 +1,7 @@
 -module(mad_synrc).
 -compile(export_all).
 
-deps(Params) ->
+deps(_Params) ->
     { Cwd, ConfigFile, Conf } = mad_utils:configs(),
     case mad_utils:get_value(deps, Conf, []) of
         [] -> {ok,[]};