Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added --compile flag to 'fetch' command

  • Loading branch information...
commit 8a9961df3b0e0a064ea1438812c7069ab0cc1e9c 1 parent 09c55e5
@yrashk yrashk authored
View
BIN  rebar
Binary file not shown
View
2  rebar.config
@@ -1,5 +1,5 @@
{compile_post_script, "./scripts/escriptize"}.
-{escript_incl_apps,[getopt]}.
+{escript_incl_apps,[getopt,rebar]}.
{deps, [
{typespecs, "0.1", {agner, "typespecs"}},
{getopt, "0.3.0", {agner, "getopt"}}
View
12 scripts/add_rebar
@@ -0,0 +1,12 @@
+#! /usr/bin/env escript
+
+main([]) ->
+ {ok, [{shebang,_}, {comment,_}, {emu_args,_},
+ {archive, RebarArch}]} = escript:extract("./rebar",[]),
+ {ok, RebarFileList} = zip:extract(RebarArch,[memory]),
+ {ok, [Shebang, Comment, EmuArgs,
+ {archive, AgnerArch}]} = escript:extract("./agner",[]),
+ {ok, AgnerFileList} = zip:extract(AgnerArch,[memory]),
+ {ok, {_, Arch}} = zip:create("agner",lists:ukeysort(1,AgnerFileList ++ RebarFileList),[memory]),
+ escript:create("agner", [Shebang, Comment, EmuArgs, {archive, Arch}]).
+
View
2  scripts/escriptize
@@ -1,3 +1,5 @@
#! /bin/sh
CWD=`dirname $0`/..
+cd $CWD
$CWD/rebar -C $CWD/rebar.config escriptize skip_deps=true
+$CWD/scripts/add_rebar
View
24 src/agner_main.erl
@@ -42,7 +42,8 @@ arg_proplist() ->
[
{package, undefined, undefined, string, "Package name"},
{directory, undefined, undefined, string, "Directory to check package out to"},
- {version, $v, "version", {string, "@master"}, "Version"}
+ {version, $v, "version", {string, "@master"}, "Version"},
+ {compile, $c, "compile", {boolean, false}, "Compile fetched package"}
]}},
{"verify",
{verify,
@@ -168,13 +169,30 @@ handle_command(fetch, Opts) ->
io:format("ERROR: Package name required.~n");
Package ->
Version = proplists:get_value(version, Opts),
+ Directory = proplists:get_value(directory, Opts, Package),
io:format("~p~n",[agner:fetch(Package,Version,
- proplists:get_value(directory, Opts, Package))]),
- case proplists:get_value(caveats, agner:spec(Package, Version)) of
+ Directory)]),
+ Spec = agner:spec(Package, Version),
+ case proplists:get_value(caveats, Spec) of
undefined ->
ignore;
Caveats when is_list(Caveats) ->
io:format("=== CAVEATS ===~n~n~s~n~n",[Caveats])
+ end,
+ case proplists:get_value(compile, Opts) of
+ true ->
+ case proplists:get_value(rebar_compatible, Spec) of
+ true ->
+ io:format("Compiling...~n"),
+ {ok, Cwd} = file:get_cwd(),
+ file:set_cwd(Directory),
+ rebar:main(["compile"]),
+ file:set_cwd(Cwd);
+ _ ->
+ io:format("ERROR: Can't compile rebar-incompatible packages at this moment. To be fixed.~n")
+ end;
+ false ->
+ ignore
end
end;
Please sign in to comment.
Something went wrong with that request. Please try again.