@ -1 +1,2 @@ | |||
.beam | |||
rebar |
@ -0,0 +1,53 @@ | |||
#!/usr/bin/env escript | |||
%% -*- erlang -*- | |||
main(Args) -> | |||
%% Compile all src/*.erl to ebin | |||
case make:files(filelib:wildcard("src/*.erl"), [{outdir, "ebin"}, {i, "include"}]) of | |||
up_to_date -> | |||
ok; | |||
error -> | |||
io:format("Failed to compile rebar files!\n"), | |||
halt(1) | |||
end, | |||
%% Make sure file:consult can parse the .app file | |||
case file:consult("ebin/rebar.app") of | |||
{ok, _} -> | |||
ok; | |||
{error, Reason} -> | |||
io:format("Invalid syntax in ebin/rebar.app: ~p\n", [Reason]), | |||
halt(1) | |||
end, | |||
%% Add ebin/ to our path | |||
true = code:add_path("ebin"), | |||
%% Run rebar to do proper .app validation and such | |||
rebar:main(["compile"] ++ Args), | |||
%% Construct the archive of everything in ebin/ dir -- put it on the | |||
%% top-level of the zip file so that code loading works properly. | |||
Files = filelib:wildcard("*", "ebin"), | |||
case zip:create("mem", Files, [{cwd, "ebin"}, memory]) of | |||
{ok, {"mem", ZipBin}} -> | |||
%% Archive was successfully created. Prefix that binary with our | |||
%% header and write to "rebar" file | |||
Script = <<"#!/usr/bin/env escript\n", ZipBin/binary>>, | |||
case file:write_file("rebar", Script) of | |||
ok -> | |||
ok; | |||
{error, WriteError} -> | |||
io:format("Failed to write rebar script: ~p\n", [WriteError]), | |||
halt(1) | |||
end; | |||
{error, ZipError} -> | |||
io:format("Failed to construct rebar script archive: ~p\n", [ZipError]), | |||
halt(1) | |||
end, | |||
%% Finally, update executable perms for our script | |||
[] = os:cmd("chmod u+x rebar"). | |||
@ -1,20 +0,0 @@ | |||
#!/bin/bash | |||
## Check path for exiting rebar instance -- if it's around, use it | |||
## for compilation (NOT installation!) | |||
`which -s rebar` | |||
if [ $? == 0 ]; then | |||
rebar compile ${@} | |||
else | |||
## Use raw erlc.. | |||
erlc -I include -o ebin src/*.erl | |||
fi | |||
if [ $? != 0 ]; then | |||
exit $? | |||
fi | |||
## Use application installer to perform actual installation | |||
## into erlang distro | |||
export ERL_LIBS=`(cd .. && pwd)` | |||
priv/rebar install ${@} |
@ -1,37 +0,0 @@ | |||
#!/usr/bin/env escript | |||
%% -*- erlang -*- | |||
%% ------------------------------------------------------------------- | |||
%% | |||
%% rebar: Erlang Build Tools | |||
%% | |||
%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com) | |||
%% | |||
%% Permission is hereby granted, free of charge, to any person obtaining a copy | |||
%% of this software and associated documentation files (the "Software"), to deal | |||
%% in the Software without restriction, including without limitation the rights | |||
%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
%% copies of the Software, and to permit persons to whom the Software is | |||
%% furnished to do so, subject to the following conditions: | |||
%% | |||
%% The above copyright notice and this permission notice shall be included in | |||
%% all copies or substantial portions of the Software. | |||
%% | |||
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||
%% THE SOFTWARE. | |||
%% ------------------------------------------------------------------- | |||
-include_lib("rebar/include/rebar.hrl"). | |||
main(Args) -> | |||
case rebar_core:run(Args) of | |||
ok -> | |||
ok; | |||
_ -> | |||
halt(1) | |||
end. |