Browse Source

Add powershell scripts bootstrap and escriptize

pull/2293/head
Regan Heath 5 years ago
parent
commit
256db79f81
6 changed files with 17 additions and 4 deletions
  1. +2
    -2
      .github/workflows/main.yml
  2. +1
    -0
      bootstrap.ps1
  3. +1
    -0
      rebar.config
  4. +2
    -0
      rebar.config.sample
  5. +1
    -0
      rebar3.ps1
  6. +10
    -2
      src/rebar_prv_escriptize.erl

+ 2
- 2
.github/workflows/main.yml View File

@ -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

+ 1
- 0
bootstrap.ps1 View File

@ -0,0 +1 @@
& escript.exe bootstrap @args

+ 1
- 0
rebar.config View File

@ -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.

+ 2
- 0
rebar.config.sample View File

@ -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

+ 1
- 0
rebar3.ps1 View File

@ -0,0 +1 @@
& escript.exe (Get-Item $PSCommandPath).Basename @args

+ 10
- 2
src/rebar_prv_escriptize.erl View File

@ -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, []))
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 (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).

Loading…
Cancel
Save