mirror of
https://github.com/correl/rebar.git
synced 2024-11-27 11:09:55 +00:00
bootstrap: generate windows scripts
This commit is contained in:
parent
e4c427be21
commit
8c01734e98
3 changed files with 22 additions and 5 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,3 +6,5 @@ rebar
|
||||||
rt.work
|
rt.work
|
||||||
.hgignore
|
.hgignore
|
||||||
.eunit
|
.eunit
|
||||||
|
rebar.cmd
|
||||||
|
rebar.ps1
|
||||||
|
|
21
bootstrap
21
bootstrap
|
@ -79,11 +79,15 @@ main(Args) ->
|
||||||
halt(1)
|
halt(1)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
%% Finally, update executable perms for our script
|
%% Finally, update executable perms for our script on *nix,
|
||||||
|
%% or write out script files on win32.
|
||||||
case os:type() of
|
case os:type() of
|
||||||
{unix,_} ->
|
{unix,_} ->
|
||||||
[] = os:cmd("chmod u+x rebar"),
|
[] = os:cmd("chmod u+x rebar"),
|
||||||
ok;
|
ok;
|
||||||
|
{win32,_} ->
|
||||||
|
write_windows_scripts(),
|
||||||
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
|
@ -126,3 +130,18 @@ vcs_info([{Id, Dir, Cmd} | Rest]) ->
|
||||||
false ->
|
false ->
|
||||||
vcs_info(Rest)
|
vcs_info(Rest)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
write_windows_scripts() ->
|
||||||
|
PowershellScript=
|
||||||
|
"$basedir = Split-Path -Parent $MyInvocation.MyCommand.Path\r\n"
|
||||||
|
"$rebar = Join-Path $basedir \"rebar\"\r\n"
|
||||||
|
"escript.exe $rebar $args\r\n",
|
||||||
|
CmdScript=
|
||||||
|
"@echo off\r\n"
|
||||||
|
"setlocal\r\n"
|
||||||
|
"set rebarscript=%~f0\r\n"
|
||||||
|
"escript.exe \"%rebarscript:.bat=%i\" %*\r\n",
|
||||||
|
file:write_file("rebar.cmd", CmdScript),
|
||||||
|
UTF16BE = {utf16, big},
|
||||||
|
file:write_file("rebar.ps1", [unicode:encoding_to_bom(UTF16BE),
|
||||||
|
unicode:characters_to_binary(PowershellScript, utf8, UTF16BE)]).
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
@echo off
|
|
||||||
setlocal
|
|
||||||
set rebarscript=%~f0
|
|
||||||
escript.exe "%rebarscript:.bat=%" %*
|
|
Loading…
Reference in a new issue