summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbootstrap20
-rw-r--r--src/rebar_core.erl13
2 files changed, 30 insertions, 3 deletions
diff --git a/bootstrap b/bootstrap
index 237c5b2..37145aa 100755
--- a/bootstrap
+++ b/bootstrap
@@ -2,8 +2,21 @@
%% -*- erlang -*-
main(Args) ->
+ %% Get a string repr of build time
+ Built = build_time(),
+
+ %% Check for force=1 flag to force a rebuild
+ case lists:member("force=1", Args) of
+ true ->
+ [] = os:cmd("rm -rf ebin/*.beam"),
+ ok;
+ false ->
+ ok
+ end,
+
%% Compile all src/*.erl to ebin
- case make:files(filelib:wildcard("src/*.erl"), [{outdir, "ebin"}, {i, "include"}]) of
+ case make:files(filelib:wildcard("src/*.erl"), [{outdir, "ebin"}, {i, "include"},
+ {d, 'BUILD_TIME', Built}]) of
up_to_date ->
ok;
error ->
@@ -55,5 +68,8 @@ main(Args) ->
"and you can use rebar to build OTP-compliant apps.\n").
-
+build_time() ->
+ {{Y, M, D}, {H, Min, S}} = calendar:now_to_universal_time(now()),
+ lists:flatten(io_lib:format("~4..0w~2..0w~2..0w_~2..0w~2..0w~2..0w", [Y, M, D, H, Min, S])).
+
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 7a40200..d39a425 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -28,11 +28,22 @@
-include("rebar.hrl").
+-ifndef(BUILD_TIME).
+-define(BUILD_TIME, "undefined").
+-endif.
+
%% ===================================================================
%% Public API
%% ===================================================================
-run(Args) ->
+run(["version"]) ->
+ %% Load application spec and display vsn and build time info
+ ok = application:load(rebar),
+ {ok, Vsn} = application:get_key(rebar, vsn),
+ ?CONSOLE("Version ~s built ~s\n", [Vsn, ?BUILD_TIME]),
+ ok;
+run(Args) ->
+ ?CONSOLE("Args: ~p\n", [Args]),
%% Filter all the flags (i.e. string of form key=value) from the
%% command line arguments. What's left will be the commands to run.
Commands = filter_flags(Args, []),