Skip to content

Commit

Permalink
Now using goxc for build process.
Browse files Browse the repository at this point in the history
  • Loading branch information
coreybutler committed Oct 15, 2014
1 parent af6827b commit 87356a4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 24 deletions.
39 changes: 32 additions & 7 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
@echo off
SET INNOSETUP=%CD%\nvm.iss
SET ORIG=%CD%
SET GOPATH=%CD%\src
SET GOBIN=%CD%\bin
SET GOARCH=386

REM Get the version number from the setup file
for /f "tokens=*" %%i in ('findstr /n . %INNOSETUP% ^| findstr ^4:#define') do set L=%%i
set version=%L:~24,-1%

REM Get the version number from the core executable
for /f "tokens=*" %%i in ('findstr /n . %GOPATH%\nvm.go ^| findstr ^NvmVersion^| findstr ^21^') do set L=%%i
set goversion=%L:~19,-1%

IF NOT %version%==%goversion% GOTO VERSIONMISMATCH

SET DIST=%CD%\dist\%version%

REM Build the executable
echo Building NVM for Windows
SET DIST=%CD%\dist\%version%
SET GOPATH=%CD%\src
SET GOBIN=%CD%\bin
SET GOARCH=386
go build -o %GOBIN%\nvm.exe %GOPATH%\nvm.go
rm %GOBIN%\nvm.exe
cd %GOPATH%
goxc -arch="386" -os="windows" -n="nvm" -d="%GOBIN%" -o="%GOBIN%\nvm{{.Ext}}" -tasks-=package
cd %ORIG%
rm %GOBIN%\src.exe
rm %GOPATH%\src.exe
rm %GOPATH%\nvm.exe

REM Clean the dist directory
rm -rf "%DIST%"
mkdir "%DIST%"

REM Create the "noinstall" zip
echo Generating nvm-noinstall.zip
Expand All @@ -22,8 +40,15 @@ echo Generating nvm-setup.zip
buildtools\iscc %INNOSETUP% /o%DIST%
buildtools\zip -j -9 -r "%DIST%\nvm-setup.zip" "%DIST%\nvm-setup.exe"
rm "%DIST%\nvm-setup.exe"

cls
echo --------------------------
echo Release %version% available in %DIST%
GOTO COMPLETE

:VERSIONMISMATCH
echo The version number in nvm.iss does not match the version in src\nvm.go
echo - nvm.iss line #4: %version%
echo - nvm.go line #21: %goversion%
EXIT /B

:COMPLETE
@echo on
34 changes: 17 additions & 17 deletions nvm.iss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define MyAppName "NVM for Windows"
#define MyAppShortName "nvm"
#define MyAppLCShortName "nvm"
#define MyAppVersion "1.0.4"
#define MyAppVersion "1.0.5"
#define MyAppPublisher "Ecor Ventures, LLC"
#define MyAppURL "http://github.com/coreybutler/nvm"
#define MyAppExeName "nvm.exe"
Expand Down Expand Up @@ -55,7 +55,7 @@ var
SymlinkPage: TInputDirWizardPage;
function IsDirEmpty(dir: string): Boolean;
var
var
FindRec: TFindRec;
ct: Integer;
begin
Expand All @@ -73,8 +73,8 @@ begin
end;
end;
//function getInstalledVErsions(dir: string):
var
//function getInstalledVErsions(dir: string):
var
nodeInUse: string;
function TakeControl(np: string; nv: string): string;
Expand All @@ -93,7 +93,7 @@ begin
StringChangeEx(path,np+';;',';',True);
RegWriteExpandStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', path);
RegQueryStringValue(HKEY_CURRENT_USER,
'Environment',
'Path', path);
Expand All @@ -105,7 +105,7 @@ begin
RegWriteExpandStringValue(HKEY_CURRENT_USER, 'Environment', 'Path', path);
nodeInUse := ExpandConstant('{app}')+'\'+nv;
end;
function Ansi2String(AString:AnsiString):String;
Expand Down Expand Up @@ -134,7 +134,7 @@ begin
// Create a file to check for Node.JS
TmpJS := ExpandConstant('{tmp}') + '\nvm_check.js';
SaveStringToFile(TmpJS, 'console.log(require("path").dirname(process.execPath));', False);
// Execute the node file and save the output temporarily
TmpResultFile := ExpandConstant('{tmp}') + '\nvm_node_check.txt';
Exec(ExpandConstant('{cmd}'), '/C node "'+TmpJS+'" > "' + TmpResultFile + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Expand Down Expand Up @@ -163,7 +163,7 @@ begin
TakeControl(NodePath, NodeVersion);
end;
end;
// Make sure the symlink directory doesn't exist
if DirExists(SymlinkPage.Values[0]) then begin
// If the directory is empty, just delete it since it will be recreated anyway.
Expand Down Expand Up @@ -200,14 +200,14 @@ var
nvm_symlink: string;
begin
MsgBox('Removing NVM for Windows will remove the nvm command and all versions of node.js, including global npm modules.', mbInformation, MB_OK);
// Remove the symlink
RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'NVM_SYMLINK', nvm_symlink);
RemoveDir(nvm_symlink);
// Clean the registry
// Clean the registry
RegDeleteValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'NVM_HOME')
Expand All @@ -228,19 +228,19 @@ begin
StringChangeEx(path,'%NVM_HOME%','',True);
StringChangeEx(path,'%NVM_SYMLINK%','',True);
StringChangeEx(path,';;',';',True);
RegWriteExpandStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', path);
RegQueryStringValue(HKEY_CURRENT_USER,
'Environment',
'Path', path);
StringChangeEx(path,'%NVM_HOME%','',True);
StringChangeEx(path,'%NVM_SYMLINK%','',True);
StringChangeEx(path,';;',';',True);
RegWriteExpandStringValue(HKEY_CURRENT_USER, 'Environment', 'Path', path);
Result := True;
end;
Expand All @@ -249,7 +249,7 @@ procedure CurStepChanged(CurStep: TSetupStep);
var
path: string;
begin
if CurStep = ssPostInstall then
if CurStep = ssPostInstall then
begin
SaveStringToFile(ExpandConstant('{app}\settings.txt'), 'root: ' + ExpandConstant('{app}') + #13#10 + 'path: ' + SymlinkPage.Values[0] + #13#10, False);
Expand Down Expand Up @@ -314,4 +314,4 @@ Type: files; Name: "{app}\elevate.cmd";
Type: files; Name: "{app}\elevate.vbs";
Type: files; Name: "{app}\nodejs.ico";
Type: files; Name: "{app}\settings.txt";
Type: filesandordirs; Name: "{app}";
Type: filesandordirs; Name: "{app}";

0 comments on commit 87356a4

Please sign in to comment.