mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 11:09:55 +00:00
Updating bootstrap to embed the build time into a macro that we can pull via "version" command
This commit is contained in:
parent
95d52f860d
commit
ffa0cda467
2 changed files with 30 additions and 3 deletions
20
bootstrap
20
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])).
|
||||
|
||||
|
||||
|
|
|
@ -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, []),
|
||||
|
|
Loading…
Reference in a new issue