mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Reformat bootstrap
This commit is contained in:
parent
92129d6dd2
commit
461335acf9
1 changed files with 20 additions and 13 deletions
33
bootstrap
33
bootstrap
|
@ -25,10 +25,11 @@ main(Args) ->
|
||||||
end,
|
end,
|
||||||
|
|
||||||
%% Compile all src/*.erl to ebin
|
%% Compile all src/*.erl to ebin
|
||||||
case make:files(filelib:wildcard("src/*.erl"), [{outdir, "ebin"}, {i, "include"},
|
case make:files(filelib:wildcard("src/*.erl"),
|
||||||
DebugFlag,
|
[{outdir, "ebin"}, {i, "include"},
|
||||||
{d, 'BUILD_TIME', Built},
|
DebugFlag,
|
||||||
{d, 'VCS_INFO', VcsInfo}]) of
|
{d, 'BUILD_TIME', Built},
|
||||||
|
{d, 'VCS_INFO', VcsInfo}]) of
|
||||||
up_to_date ->
|
up_to_date ->
|
||||||
ok;
|
ok;
|
||||||
error ->
|
error ->
|
||||||
|
@ -51,9 +52,9 @@ main(Args) ->
|
||||||
%% Run rebar to do proper .app validation and such
|
%% Run rebar to do proper .app validation and such
|
||||||
rebar:main(["compile"] ++ Args),
|
rebar:main(["compile"] ++ Args),
|
||||||
|
|
||||||
%% Read the contents of the files in ebin and templates; note that we place
|
%% Read the contents of the files in ebin and templates; note that we
|
||||||
%% all the beam files at the top level of the code archive so that code loading
|
%% place all the beam files at the top level of the code archive so
|
||||||
%% works properly.
|
%% that code loading works properly.
|
||||||
Files = load_files("*", "ebin") ++ load_files("priv/templates/*", "."),
|
Files = load_files("*", "ebin") ++ load_files("priv/templates/*", "."),
|
||||||
|
|
||||||
case zip:create("mem", Files, [memory]) of
|
case zip:create("mem", Files, [memory]) of
|
||||||
|
@ -62,16 +63,19 @@ main(Args) ->
|
||||||
%% header and write to "rebar" file.
|
%% header and write to "rebar" file.
|
||||||
%% Without -noshell -noinput escript consumes all input that would
|
%% Without -noshell -noinput escript consumes all input that would
|
||||||
%% otherwise go to the shell for the next command.
|
%% otherwise go to the shell for the next command.
|
||||||
Script = <<"#!/usr/bin/env escript\n%%! -noshell -noinput\n", ZipBin/binary>>,
|
Script = <<"#!/usr/bin/env escript\n%%! -noshell -noinput\n",
|
||||||
|
ZipBin/binary>>,
|
||||||
case file:write_file("rebar", Script) of
|
case file:write_file("rebar", Script) of
|
||||||
ok ->
|
ok ->
|
||||||
ok;
|
ok;
|
||||||
{error, WriteError} ->
|
{error, WriteError} ->
|
||||||
io:format("Failed to write rebar script: ~p\n", [WriteError]),
|
io:format("Failed to write rebar script: ~p\n",
|
||||||
|
[WriteError]),
|
||||||
halt(1)
|
halt(1)
|
||||||
end;
|
end;
|
||||||
{error, ZipError} ->
|
{error, ZipError} ->
|
||||||
io:format("Failed to construct rebar script archive: ~p\n", [ZipError]),
|
io:format("Failed to construct rebar script archive: ~p\n",
|
||||||
|
[ZipError]),
|
||||||
halt(1)
|
halt(1)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -85,8 +89,10 @@ main(Args) ->
|
||||||
end,
|
end,
|
||||||
|
|
||||||
%% Add a helpful message
|
%% Add a helpful message
|
||||||
io:format("Congratulations! You now have a self-contained script called \"rebar\" in\n"
|
io:format("Congratulations! You now have a self-contained script called"
|
||||||
"your current working directory. Place this script anywhere in your path\n"
|
" \"rebar\" in\n"
|
||||||
|
"your current working directory. "
|
||||||
|
"Place this script anywhere in your path\n"
|
||||||
"and you can use rebar to build OTP-compliant apps.\n").
|
"and you can use rebar to build OTP-compliant apps.\n").
|
||||||
|
|
||||||
rm(Path) ->
|
rm(Path) ->
|
||||||
|
@ -100,7 +106,8 @@ rm(Path) ->
|
||||||
|
|
||||||
build_time() ->
|
build_time() ->
|
||||||
{{Y, M, D}, {H, Min, S}} = calendar:now_to_universal_time(now()),
|
{{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])).
|
lists:flatten(io_lib:format("~4..0w~2..0w~2..0w_~2..0w~2..0w~2..0w",
|
||||||
|
[Y, M, D, H, Min, S])).
|
||||||
|
|
||||||
|
|
||||||
load_files(Wildcard, Dir) ->
|
load_files(Wildcard, Dir) ->
|
||||||
|
|
Loading…
Reference in a new issue