Browse files

arg0 trick for rebar invocation doesn't work, replacing it with a hid…

…den "rebar" command
  • Loading branch information...
1 parent e76b1f2 commit b7e0b47d31cf245484117fe8a729135843f5e05b @yrashk yrashk committed Feb 24, 2011
Showing with 17 additions and 30 deletions.
  1. +1 −0 Makefile
  2. BIN rebar
  3. +11 −29 src/agner_fetch.erl
  4. +5 −1 src/agner_main.erl
View
1 Makefile
@@ -17,6 +17,7 @@ build-plt:
compile: deps
@./rebar compile
+ @cp deps/*/ebin/* ebin/
@./rebar escriptize
install:
View
BIN rebar
Binary file not shown.
View
40 src/agner_fetch.erl
@@ -452,38 +452,20 @@ build_dep(ReqName, ReqVersion, #opts_rec{ spec = {spec, Spec}, directory = Direc
{directory, filename:join(deps_dir(Spec, Directory),ReqName)}|
proplists:delete(spec,rec_to_opts(Opts))]).
-rebar(#opts_rec{ spec = {spec, Spec}, quiet = Quiet, directory = Directory }) ->
+rebar(#opts_rec{ spec = {spec, Spec} } = Opts) ->
case proplists:get_value(rebar_compatible, Spec) of
true ->
- io:format("[Building...]~n"),
RebarCommands = proplists:get_value(rebar_commands, Spec),
-
- Port = open_port({spawn_executable,escript:script_name()},[{cd, Directory},{arg0, filename:join(filename:dirname(escript:script_name()), "rebar")}, {args, RebarCommands}, exit_status,stderr_to_stdout,use_stdio, stream]),
- unlink(Port),
- PortHandler = fun (F) ->
- receive
- {'EXIT', Port, normal} ->
- ok;
- {'EXIT', Port, _} ->
- error;
- {Port,{exit_status,0}} ->
- ok;
- {Port,{exit_status,_}} ->
- error;
- {Port, {data, D}} when not Quiet andalso is_list(D) ->
- io:format("~s",[D]),
- F(F);
- _ ->
- F(F)
- end
- end,
- Result = PortHandler(PortHandler),
- receive
- {'EXIT', Port, normal} -> %% flush port exit
- ok
- after 0 ->
- ok
- end,
+ ScriptName = filename:absname(escript:script_name()),
+
+ Spec1 =
+ case filename:basename(ScriptName) of
+ "agner" ->
+ [{build_command, ScriptName ++ " rebar " ++ string:join(RebarCommands," ")}|Spec];
+ "rebar" ->
+ [{build_command, ScriptName ++ " " ++ string:join(RebarCommands," ")}|Spec]
+ end,
+ Result = build_command(Opts#opts_rec{ spec = {spec, Spec1} }),
Result;
_ ->
ignore
View
6 src/agner_main.erl
@@ -128,7 +128,7 @@ arg_proplist() ->
[
{variable, undefined, undefined, string, "Variable name, omit to list all of them"}
]}}].
-
+
command_descriptions() ->
[{Cmd, Desc} || {Cmd, {_Atom, Desc, _Opts}} <- arg_proplist()].
@@ -150,6 +150,9 @@ usage() ->
io:format("Valid commands are:~n", []),
[io:format(" ~-10s ~s~n", [Cmd, Desc]) || {Cmd, Desc} <- command_descriptions()].
+main(["rebar"|Args]) ->
+ rebar:main(Args);
+
main(Args) ->
os:putenv("AGNER", filename:absname(escript:script_name())),
case parse_args(Args) of
@@ -418,6 +421,7 @@ handle_command(config, [{variable, "prefix"}]) ->
io:format("~s~n",[os:getenv("AGNER_PREFIX")]);
handle_command(config, [{variable, "bin"}]) ->
io:format("~s~n",[os:getenv("AGNER_BIN")]).
+
%%%

0 comments on commit b7e0b47

Please sign in to comment.