summaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
authorDave Smith <dizzyd@dizzyd.com>2010-07-28 07:19:25 -0600
committerDave Smith <dizzyd@dizzyd.com>2010-07-28 07:19:25 -0600
commit27f638b45ee46857373d22f27b8dc9e31c98dd02 (patch)
treed577c8cfbb6450645ae770987f91307f7b375bd9 /bootstrap
parent370d8df02fa4d9fac5e1c932205cc301fcfcfdb4 (diff)
downloadrebar-27f638b45ee46857373d22f27b8dc9e31c98dd02.tar.gz
Add support for embedding git version; make sure to always rebuild rebar_core so that the VCS_INFO constant gets updated
Diffstat (limited to 'bootstrap')
-rwxr-xr-xbootstrap18
1 files changed, 15 insertions, 3 deletions
diff --git a/bootstrap b/bootstrap
index d9327ba..4766058 100755
--- a/bootstrap
+++ b/bootstrap
@@ -6,8 +6,9 @@ main(Args) ->
%% Get a string repr of build time
Built = build_time(),
- %% Get a string repr of hg changeset
- HgInfo = "hg " ++ string:strip(os:cmd("hg identify -i"), both, $\n),
+ %% Get a string repr of first matching VCS changeset
+ VcsInfo = vcs_info([{hg, ".hg", "hg identify -i"},
+ {git, ".git", "git describe --always"}]),
%% Check for force=1 flag to force a rebuild
case lists:member("force=1", Args) of
@@ -15,13 +16,14 @@ main(Args) ->
[] = os:cmd("rm -rf ebin/*.beam"),
ok;
false ->
+ os:cmd("rm -f ebin/rebar_core.beam"),
ok
end,
%% Compile all src/*.erl to ebin
case make:files(filelib:wildcard("src/*.erl"), [{outdir, "ebin"}, {i, "include"},
{d, 'BUILD_TIME', Built},
- {d, 'VCS_INFO', HgInfo}]) of
+ {d, 'VCS_INFO', VcsInfo}]) of
up_to_date ->
ok;
error ->
@@ -86,3 +88,13 @@ load_files(Wildcard, Dir) ->
read_file(Filename, Dir) ->
{ok, Bin} = file:read_file(filename:join(Dir, Filename)),
{Filename, Bin}.
+
+vcs_info([]) ->
+ "No VCS info available.";
+vcs_info([{Id, Dir, Cmd} | Rest]) ->
+ case filelib:is_dir(Dir) of
+ true ->
+ lists:concat([Id, " ", string:strip(os:cmd(Cmd), both, $\n)]);
+ false ->
+ vcs_info(Rest)
+ end.