diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7aba218d8..2520196a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,6 +50,6 @@ jobs: - name: Install Erlang run: choco install erlang - name: Compile - run: cmd.exe /c 'bootstrap.bat' + run: .\bootstrap.ps1 - name: CT tests - run: cmd.exe /c 'rebar3.cmd ct' + run: .\rebar3.ps1 ct diff --git a/.gitignore b/.gitignore index 8d8813e1d..27a482843 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ _checkouts .rebar3 rebar3 rebar3.cmd +rebar3.ps1 _build .depsolver_plt *.beam diff --git a/bootstrap.ps1 b/bootstrap.ps1 new file mode 100644 index 000000000..2e521bf0f --- /dev/null +++ b/bootstrap.ps1 @@ -0,0 +1 @@ +& escript.exe bootstrap @args diff --git a/rebar.config b/rebar.config index f6cfb8add..a42a398ff 100644 --- a/rebar.config +++ b/rebar.config @@ -24,6 +24,7 @@ ]}. {escript_name, rebar3}. +{escript_wrappers_windows, ["cmd", "powershell"]}. {escript_comment, "%%Rebar3 3.14.0-rc1\n"}. {escript_emu_args, "%%! +sbtu +A1\n"}. %% escript_incl_extra is for internal rebar-private use only. diff --git a/rebar.config.sample b/rebar.config.sample index aa1575f03..2e7304888 100644 --- a/rebar.config.sample +++ b/rebar.config.sample @@ -149,6 +149,8 @@ {escript_main_app, application}. %% Name of the resulting escript executable {escript_name, "application"}. +%% Wrapper type(s) for escript executable on windows +{escript_wrappers_windows, ["cmd","powershell"]}. %% apps (other than main and deps) to be included {escript_incl_apps, []}. %% Executable escript lines diff --git a/src/rebar_prv_escriptize.erl b/src/rebar_prv_escriptize.erl index bd393c900..9399a5bf8 100644 --- a/src/rebar_prv_escriptize.erl +++ b/src/rebar_prv_escriptize.erl @@ -143,7 +143,7 @@ escriptize(State0, App) -> {ok, #file_info{mode = Mode}} = file:read_file_info(Filename), ok = file:change_mode(Filename, Mode bor 8#00111); {win32, _} -> - write_windows_script(Filename) + write_windows_scripts(Filename, rebar_state:get(State, escript_wrappers_windows, ["cmd"])) end, {ok, State}. @@ -272,9 +272,17 @@ def(Rm, State, Key, Default) -> rm_newline(String) -> [C || C <- String, C =/= $\n]. -write_windows_script(Target) -> +write_windows_scripts(Target, Wrappers) -> + lists:foreach(fun(Wrapper) -> write_windows_script(Target, Wrapper) end, Wrappers). + +write_windows_script(Target, "powershell") -> + CmdPath = unicode:characters_to_list(Target) ++ ".ps1", + CmdScript="& escript.exe \"$PSScriptRoot\\$((Get-Item $PSCommandPath).Basename)\" @args\r\n", + ok = file:write_file(CmdPath, CmdScript); +write_windows_script(Target, _) -> CmdPath = unicode:characters_to_list(Target) ++ ".cmd", CmdScript= "@echo off\r\n" "escript.exe \"%~dpn0\" %*\r\n", ok = file:write_file(CmdPath, CmdScript). +