Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

66 wiersze
1.8 KiB

#!/usr/bin/env escript
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
main(Args) ->
case lists:member("--help", Args) of
true ->
usage(),
halt(0);
false ->
ok
end,
%% Check for force=1 flag to force a rebuild
case lists:member("force=1", Args) of
true ->
rm("ebin/*.beam");
false ->
rm("ebin/rebar.beam")
end,
%% Extract the system info of the version of OTP we use to compile rebar
os:cmd("./bootstrap/rebar get-deps compile escriptize"),
%% Finally, update executable perms for our script on *nix,
%% or write out script files on win32.
case os:type() of
{unix,_} ->
[] = os:cmd("chmod u+x rebar3"),
ok;
{win32,_} ->
write_windows_scripts(),
ok;
_ ->
ok
end,
%% Add a helpful message
io:format("Congratulations! You now have a self-contained script called"
" \"rebar3\" 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").
usage() ->
io:format("Usage: bootstrap [OPTION]...~n"),
io:format(" force=1 unconditional build~n"),
io:format(" debug add debug information~n").
rm(Path) ->
NativePath = filename:nativename(Path),
Cmd = case os:type() of
{unix,_} -> "rm -f ";
{win32,_} -> "del /q "
end,
[] = os:cmd(Cmd ++ NativePath),
ok.
write_windows_scripts() ->
CmdScript=
"@echo off\r\n"
"setlocal\r\n"
"set rebarscript=%~f0\r\n"
"escript.exe \"%rebarscript:.cmd=%\" %*\r\n",
ok = file:write_file("rebar.cmd", CmdScript).