Skip to content

Commit

Permalink
Build scripts show executable version.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgjackson committed Dec 10, 2021
1 parent 4db8d2f commit c9d56c1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
21 changes: 17 additions & 4 deletions build-installer.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ SETLOCAL EnableDelayedExpansion
CD /D %~dp0

rem If launched from anything other than cmd.exe, will have "%WINDIR%\system32\cmd.exe" in the command line
set INTERACTIVE_IBUILD=
IF "%1"=="/NONINTERACTIVE" GOTO NONINTERACTIVE
ECHO.%CMDCMDLINE% | FINDSTR /C:"%COMSPEC% /c" >NUL
IF ERRORLEVEL 1 GOTO NONINTERACTIVE
rem Preserve this as it seems to be corrupted below otherwise?!
Expand All @@ -11,9 +13,20 @@ rem If launched from anything other than cmd.exe, last character of command line
IF NOT ^!CMDCMDLINE:~-1!==^" GOTO NONINTERACTIVE
rem If run from Explorer, last-but-one character of command line will be a space
IF NOT "!CMDLINE:~-2,1!"==" " GOTO NONINTERACTIVE
SET INTERACTIVE=1
SET INTERACTIVE_IBUILD=1
:NONINTERACTIVE

::: Build first
CALL ./build.cmd
IF ERRORLEVEL 1 GOTO ERROR

::: Extract version
set VER=
for /f "tokens=3 usebackq" %%f in (`type toggle.rc ^| findstr /R /C:"#define[ ]VER_MAJOR"`) do set VER=%%f
for /f "tokens=3 usebackq" %%f in (`type toggle.rc ^| findstr /R /C:"#define[ ]VER_MINOR"`) do set VER=%VER%.%%f
for /f "tokens=3 usebackq" %%f in (`type toggle.rc ^| findstr /R /C:"#define[ ]VER_BUILD"`) do set VER=%VER%.%%f
rem for /f "tokens=3 usebackq" %%f in (`type toggle.rc ^| findstr /R /C:"#define[ ]VER_REVISION"`) do set VER=%VER%.%%f

:PATH_CANDLE
SET WIX_PATH=
SET FIND_CANDLE=
Expand Down Expand Up @@ -78,12 +91,12 @@ rem IF ERRORLEVEL 1 GOTO ERROR
"%WINDOWSKIT_PATH%signtool.exe" sign /debug /v /a /f "D:\Certificates\mycert.pfx" /d "Toggle Light/Dark" %TIMESTAMP_SERVER% "toggle.msi"
IF ERRORLEVEL 1 GOTO ERROR

ECHO Done.
IF DEFINED INTERACTIVE COLOR 2F & PAUSE & COLOR
ECHO Done: V%VER%
IF DEFINED INTERACTIVE_IBUILD COLOR 2F & PAUSE & COLOR
GOTO :EOF

:ERROR
ECHO ERROR: An error occured.
IF DEFINED INTERACTIVE COLOR 4F & PAUSE & COLOR
IF DEFINED INTERACTIVE_IBUILD COLOR 4F & PAUSE & COLOR
EXIT /B 1
GOTO :EOF
18 changes: 14 additions & 4 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ SETLOCAL EnableDelayedExpansion
CD /D %~dp0

rem If launched from anything other than cmd.exe, will have "%WINDIR%\system32\cmd.exe" in the command line
set INTERACTIVE_BUILD=
IF "%1"=="/NONINTERACTIVE" GOTO NONINTERACTIVE
ECHO.%CMDCMDLINE% | FINDSTR /C:"%COMSPEC% /c" >NUL
IF ERRORLEVEL 1 GOTO NONINTERACTIVE
rem Preserve this as it seems to be corrupted below otherwise?!
Expand All @@ -11,9 +13,16 @@ rem If launched from anything other than cmd.exe, last character of command line
IF NOT ^!CMDCMDLINE:~-1!==^" GOTO NONINTERACTIVE
rem If run from Explorer, last-but-one character of command line will be a space
IF NOT "!CMDLINE:~-2,1!"==" " GOTO NONINTERACTIVE
SET INTERACTIVE=1
SET INTERACTIVE_BUILD=1
:NONINTERACTIVE

::: Extract version
set VER=
for /f "tokens=3 usebackq" %%f in (`type toggle.rc ^| findstr /R /C:"#define[ ]VER_MAJOR"`) do set VER=%%f
for /f "tokens=3 usebackq" %%f in (`type toggle.rc ^| findstr /R /C:"#define[ ]VER_MINOR"`) do set VER=%VER%.%%f
for /f "tokens=3 usebackq" %%f in (`type toggle.rc ^| findstr /R /C:"#define[ ]VER_BUILD"`) do set VER=%VER%.%%f
rem for /f "tokens=3 usebackq" %%f in (`type toggle.rc ^| findstr /R /C:"#define[ ]VER_REVISION"`) do set VER=%VER%.%%f

SET FIND_CL=
FOR %%p IN (cl.exe) DO SET "FIND_CL=%%~$PATH:p"
IF DEFINED FIND_CL (
Expand Down Expand Up @@ -43,12 +52,13 @@ ECHO Linking...
rem /manifest:embed -- now external .manifest is included in .rc file
link %NOLOGO% /out:toggle.exe toggle toggle.res /subsystem:windows
IF ERRORLEVEL 1 GOTO ERROR
ECHO Done.
IF DEFINED INTERACTIVE COLOR 2F & PAUSE & COLOR
ECHO Done: V%VER%

IF DEFINED INTERACTIVE_BUILD COLOR 2F & PAUSE & COLOR
GOTO :EOF

:ERROR
ECHO ERROR: An error occured.
IF DEFINED INTERACTIVE COLOR 4F & PAUSE & COLOR
IF DEFINED INTERACTIVE_BUILD COLOR 4F & PAUSE & COLOR
EXIT /B 1
GOTO :EOF

0 comments on commit c9d56c1

Please sign in to comment.