summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.hgignore1
-rwxr-xr-xbootstrap53
-rw-r--r--ebin/rebar.app3
-rwxr-xr-xinstall20
-rwxr-xr-xpriv/rebar37
-rw-r--r--src/rebar_app_utils.erl4
-rw-r--r--src/rebar_core.erl2
7 files changed, 59 insertions, 61 deletions
diff --git a/.hgignore b/.hgignore
index 6ade340..71962ca 100644
--- a/.hgignore
+++ b/.hgignore
@@ -1 +1,2 @@
.beam
+rebar
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..04f94dc
--- /dev/null
+++ b/bootstrap
@@ -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").
+
+
+
diff --git a/ebin/rebar.app b/ebin/rebar.app
index 7d98148..07b0c72 100644
--- a/ebin/rebar.app
+++ b/ebin/rebar.app
@@ -1,7 +1,8 @@
{application, rebar,
[{description, "Rebar: Erlang Build Tool"},
{vsn, "1"},
- {modules, [ rebar_app_utils,
+ {modules, [ rebar,
+ rebar_app_utils,
rebar_config,
rebar_core,
rebar_ct,
diff --git a/install b/install
deleted file mode 100755
index e11b547..0000000
--- a/install
+++ /dev/null
@@ -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 ${@}
diff --git a/priv/rebar b/priv/rebar
deleted file mode 100755
index 83e5c80..0000000
--- a/priv/rebar
+++ /dev/null
@@ -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.
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl
index 900fff0..f879537 100644
--- a/src/rebar_app_utils.erl
+++ b/src/rebar_app_utils.erl
@@ -51,8 +51,8 @@ load_app_file(Filename) ->
{ok, AppName, AppData};
{error, Reason} ->
?ERROR("Failed to load app file from ~s: ~p\n", [Filename, Reason]),
- error;
+ ?FAIL;
Other ->
?ERROR("Unexpected terms from app file ~s: ~p\n", [Filename, Other]),
- error
+ ?FAIL
end.
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 5b9c8c7..7a40200 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -38,7 +38,7 @@ run(Args) ->
Commands = filter_flags(Args, []),
%% Pre-load the rebar app so that we get default configuration
- application:load(rebar),
+ ok = application:load(rebar),
%% Initialize logging system
rebar_log:init(),