summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbootstrap24
-rw-r--r--rebar.config5
-rw-r--r--src/rebar_prv_escriptize.erl20
3 files changed, 22 insertions, 27 deletions
diff --git a/bootstrap b/bootstrap
index 8b9b001..b797b6e 100755
--- a/bootstrap
+++ b/bootstrap
@@ -52,21 +52,7 @@ main(_) ->
rebar3:run(["escriptize"]),
%% Done with compile, can turn back on error logger
- error_logger:tty(true),
-
- %% Finally, update executable perms for our script on *nix,
- %% or write out script files on win32.
- ec_file:copy("_build/default/bin/rebar3", "./rebar3"),
- case os:type() of
- {unix,_} ->
- [] = os:cmd("chmod u+x rebar3"),
- ok;
- {win32,_} ->
- write_windows_scripts(),
- ok;
- _ ->
- ok
- end.
+ error_logger:tty(true).
default_registry_file() ->
{ok, [[Home]]} = init:get_argument(home),
@@ -305,14 +291,6 @@ reset_env() ->
application:unload(rebar),
application:load(rebar).
-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("rebar3.cmd", CmdScript).
-
get_deps() ->
case file:consult("rebar.lock") of
{ok, [[]]} ->
diff --git a/rebar.config b/rebar.config
index 1d853c4..e76f04e 100644
--- a/rebar.config
+++ b/rebar.config
@@ -14,7 +14,10 @@
{post_hooks, [{"(linux|darwin|solaris|freebsd|netbsd|openbsd)",
escriptize,
- "cp $REBAR_BUILD_DIR/bin/rebar3 ./rebar3 && chmod u+x rebar3"}]}.
+ "cp $REBAR_BUILD_DIR/bin/rebar3 ./rebar3"},
+ {"win32",
+ "robocopy $REBAR_BUILD_DIR/bin/ ./ rebar3*"}
+ ]}.
{escript_name, rebar3}.
{escript_emu_args, "%%! +sbtu +A0\n"}.
diff --git a/src/rebar_prv_escriptize.erl b/src/rebar_prv_escriptize.erl
index 7ee20c2..5c0c989 100644
--- a/src/rebar_prv_escriptize.erl
+++ b/src/rebar_prv_escriptize.erl
@@ -130,9 +130,15 @@ escriptize(State0, App) ->
throw(?PRV_ERROR({escript_creation_failed, AppName, EscriptError}))
end,
- %% Finally, update executable perms for our script
- {ok, #file_info{mode = Mode}} = file:read_file_info(Filename),
- ok = file:change_mode(Filename, Mode bor 8#00111),
+ %% Finally, update executable perms for our script on *nix or write out
+ %% script files on win32
+ case os:type() of
+ {unix, _} ->
+ {ok, #file_info{mode = Mode}} = file:read_file_info(Filename),
+ ok = file:change_mode(Filename, Mode bor 8#00111);
+ {win32, _} ->
+ write_windows_script(Filename)
+ end,
{ok, State}.
-spec format_error(any()) -> iolist().
@@ -258,3 +264,11 @@ def(Rm, State, Key, Default) ->
rm_newline(String) ->
[C || C <- String, C =/= $\n].
+
+write_windows_script(Target) ->
+ CmdScript=
+ "@echo off\r\n"
+ "setlocal\r\n"
+ "set rebarscript=%~f0\r\n"
+ "escript.exe \"%rebarscript:.cmd=%\" %*\r\n",
+ ok = file:write_file(Target ++ ".cmd", CmdScript).