diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2009-12-07 16:03:56 -0700 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2009-12-07 16:03:56 -0700 |
commit | ffa0cda467ce851ff57aa23b92ab8f3fd679fb33 (patch) | |
tree | bb7617149d8c3d73b33c4864157a233d0fd63cf8 | |
parent | 95d52f860df1be7d2df5d7fce0c499ec4832add9 (diff) |
Updating bootstrap to embed the build time into a macro that we can pull via "version" command
-rwxr-xr-x | bootstrap | 20 | ||||
-rw-r--r-- | src/rebar_core.erl | 13 |
2 files changed, 30 insertions, 3 deletions
@@ -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, []), |