Skip to content

Commit 256db79

Browse files
committed
Add powershell scripts bootstrap and escriptize
1 parent 7c4b1a7 commit 256db79

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ jobs:
5050
- name: Install Erlang
5151
run: choco install erlang
5252
- name: Compile
53-
run: cmd.exe /c 'bootstrap.bat'
53+
run: bootstrap.ps1
5454
- name: CT tests
55-
run: cmd.exe /c 'rebar3.cmd ct'
55+
run: rebar3.ps1 ct

bootstrap.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
& escript.exe bootstrap @args

rebar.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
]}.
2525

2626
{escript_name, rebar3}.
27+
{escript_wrappers_windows, ["cmd", "powershell"]}.
2728
{escript_comment, "%%Rebar3 3.14.0-rc1\n"}.
2829
{escript_emu_args, "%%! +sbtu +A1\n"}.
2930
%% escript_incl_extra is for internal rebar-private use only.

rebar.config.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@
149149
{escript_main_app, application}.
150150
%% Name of the resulting escript executable
151151
{escript_name, "application"}.
152+
%% Wrapper type(s) for escript executable on windows
153+
{escript_wrappers_windows, ["cmd","powershell"]}.
152154
%% apps (other than main and deps) to be included
153155
{escript_incl_apps, []}.
154156
%% Executable escript lines

rebar3.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
& escript.exe (Get-Item $PSCommandPath).Basename @args

src/rebar_prv_escriptize.erl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ escriptize(State0, App) ->
143143
{ok, #file_info{mode = Mode}} = file:read_file_info(Filename),
144144
ok = file:change_mode(Filename, Mode bor 8#00111);
145145
{win32, _} ->
146-
write_windows_script(Filename)
146+
write_windows_scripts(Filename, rebar_state:get(State, escript_wrappers_windows, []))
147147
end,
148148
{ok, State}.
149149

@@ -272,9 +272,17 @@ def(Rm, State, Key, Default) ->
272272
rm_newline(String) ->
273273
[C || C <- String, C =/= $\n].
274274

275-
write_windows_script(Target) ->
275+
write_windows_scripts(Target, Wrappers) ->
276+
lists:foreach(fun(Wrapper) -> write_windows_script(Target, Wrapper) end, Wrappers).
277+
278+
write_windows_script(Target, "powershell") ->
279+
CmdPath = unicode:characters_to_list(Target) ++ ".ps1",
280+
CmdScript="& escript.exe (Get-Item $PSCommandPath).Basename @args\r\n",
281+
ok = file:write_file(CmdPath, CmdScript);
282+
write_windows_script(Target, _) ->
276283
CmdPath = unicode:characters_to_list(Target) ++ ".cmd",
277284
CmdScript=
278285
"@echo off\r\n"
279286
"escript.exe \"%~dpn0\" %*\r\n",
280287
ok = file:write_file(CmdPath, CmdScript).
288+

0 commit comments

Comments
 (0)