From 8c01734e98c3eedfd299884e1553ca315e55bda4 Mon Sep 17 00:00:00 2001 From: Matt Campbell Date: Wed, 21 Dec 2011 23:27:42 -0600 Subject: bootstrap: generate windows scripts --- bootstrap | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'bootstrap') diff --git a/bootstrap b/bootstrap index 024fa6d..75c2ffc 100755 --- a/bootstrap +++ b/bootstrap @@ -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)]). -- cgit v1.1