diff options
author | Matt Campbell <matthew.campbell@asolutions.com> | 2011-12-21 23:27:42 -0600 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-12-25 16:46:13 +0100 |
commit | 8c01734e98c3eedfd299884e1553ca315e55bda4 (patch) | |
tree | 89dd12234c2da1b055a37b0021317e5c97e9e2ac | |
parent | e4c427be2142a08e5f287050116837ae70d502f8 (diff) |
bootstrap: generate windows scripts
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | bootstrap | 21 | ||||
-rw-r--r-- | rebar.bat | 4 |
3 files changed, 22 insertions, 5 deletions
@@ -6,3 +6,5 @@ rebar rt.work .hgignore .eunit +rebar.cmd +rebar.ps1 @@ -79,11 +79,15 @@ main(Args) -> halt(1) 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 {unix,_} -> [] = os:cmd("chmod u+x rebar"), ok; + {win32,_} -> + write_windows_scripts(), + ok; _ -> ok end, @@ -126,3 +130,18 @@ vcs_info([{Id, Dir, Cmd} | Rest]) -> false -> vcs_info(Rest) 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)]). diff --git a/rebar.bat b/rebar.bat deleted file mode 100644 index 5cb5681..0000000 --- a/rebar.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -setlocal -set rebarscript=%~f0 -escript.exe "%rebarscript:.bat=%" %* |