Skip to content

Commit

Permalink
Rewrite build-installer.bat with a recipe.
Browse files Browse the repository at this point in the history
  • Loading branch information
ds14050 committed Dec 4, 2018
1 parent f3b9136 commit 7c6c1e3
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 95 deletions.
74 changes: 44 additions & 30 deletions build-installer.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@echo off
set platform=%1
set configuration=%2
set ISS_LOG_FILE=iss-%platform%-%configuration%.log

if "%platform%" == "Win32" (
@rem OK
Expand All @@ -21,45 +20,60 @@ if "%configuration%" == "Release" (
exit /b 1
)

call %~dp0tools\ISCC\find-ISCC.bat
if "%CMD_ISCC%" == "" (
rem Definitions & Dependencies

if not defined Build^
set Build=%~dp0%Platform%\%Configuration%
set RECIPE_BAT=%~dp0tools\recipeProcessor.bat
set RECIPE=%~dp0installer\recipe.txt
set DST=%Build%\installer
set SRC=%~dp0
set SRC=%SRC:~0,-1%
call :Set_RELATIVE_To "%Build%" "%SRC%"
set BLD=%RELATIVE%
set ISS=%DST%\sakura-%platform%.iss
set ISS_LOG=%SRC%\iss-%platform%-%configuration%.log

rem Setup

mkdir 2>nul "%DST%"

call "%~dp0tools\ISCC\find-ISCC.bat"
if not defined CMD_ISCC (
echo ISCC.exe was not found.
exit /b 1
)

set INSTALLER_WORK=installer\sakura
set INSTALLER_OUTPUT=installer\Output-%platform%

set INSTALLER_RESOURCES_SINT=installer\sinst_src
set INSTALLER_RESOURCES_BRON=installer\temp\bron
set INSTALLER_RESOURCES_CTAGS=installer\temp\ctags
rem Build

if exist "%INSTALLER_WORK%" rmdir /s /q "%INSTALLER_WORK%"
if exist "%INSTALLER_OUTPUT%" rmdir /s /q "%INSTALLER_OUTPUT%"
call|"%RECIPE_BAT%" "%RECIPE%" "%SRC%" "%DST%"^
|| (rmdir 2>nul /S /Q "%DST" & exit /b 1)

mkdir %INSTALLER_WORK%
mkdir %INSTALLER_WORK%\license\bregonig
mkdir %INSTALLER_WORK%\keyword
mkdir %INSTALLER_WORK%\license\ctags\
@echo running "%CMD_ISCC%" "%ISS%"
"%CMD_ISCC%" "%ISS%" > "%ISS_LOG%"^
|| (echo error && exit /b 1)
exit /b 0

copy /Y .\LICENSE %INSTALLER_WORK%\license\ > NUL
copy /Y %INSTALLER_RESOURCES_SINT%\sakura.exe.manifest.x %INSTALLER_WORK%\ > NUL
copy /Y %INSTALLER_RESOURCES_SINT%\sakura.exe.manifest.v %INSTALLER_WORK%\ > NUL
copy /Y %INSTALLER_RESOURCES_SINT%\sakura.exe.ini %INSTALLER_WORK%\ > NUL
copy /Y %INSTALLER_RESOURCES_SINT%\keyword\*.* %INSTALLER_WORK%\keyword\ > NUL
copy /Y %INSTALLER_RESOURCES_BRON%\*.txt %INSTALLER_WORK%\license\bregonig\ > NUL
copy /Y %INSTALLER_RESOURCES_CTAGS%\license\*.* %INSTALLER_WORK%\license\ctags\ > NUL
rem ---------------------------------------------------

copy /Y /B help\sakura\sakura.chm %INSTALLER_WORK%\ > NUL
copy /Y /B help\plugin\plugin.chm %INSTALLER_WORK%\ > NUL
copy /Y /B help\macro\macro.chm %INSTALLER_WORK%\ > NUL
:Set_RELATIVE_To
setlocal

copy /Y /B %platform%\%configuration%\*.exe %INSTALLER_WORK%\ > NUL
copy /Y /B %platform%\%configuration%\*.dll %INSTALLER_WORK%\ > NUL
set To=?%~dpnx1
set From=?%~dpnx2
if not "%From:~-1%" == "\" set From=%From%\
set _Parents=%~3
call set Relative=%%To:%From%=%%

set SAKURA_ISS=installer\sakura-%platform%.iss
@echo running "%CMD_ISCC%" %SAKURA_ISS%
"%CMD_ISCC%" %SAKURA_ISS% > %ISS_LOG_FILE% || (echo error && exit /b 1)
if not "%To%" == "%Relative%" (
endlocal & set "RELATIVE=%_Parents%%Relative%"
exit /b 0
)
if "%~dp2" == "%~dpnx2" (
endlocal & set RELATIVE=
exit /b 1
)
endlocal & call %0 "%~dpnx1" "%~dp2" "..\%_Parents%"
exit /b 0

@rem ------------------------------------------------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions installer/recipe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.\ .\ installer\sakura-*.iss
sakura\
!BLD!\sakura.exe
!BLD!\sakura_lang*.dll
installer\sinst_src\sakura.exe.ini
installer\sinst_src\sakura.exe.manifest.x
installer\sinst_src\sakura.exe.manifest.v
installer\externals\bregonig\bron412.zip\bregonig.dll
installer\externals\bregonig\bron412.zip\!platform!\bregonig.dll
installer\externals\universal-ctags\ctags-2018-09-16_e522743d-!platform:Win32=x86!.zip\ctags.exe
help\sakura\sakura.chm
help\plugin\plugin.chm
help\macro\macro.chm
sakura\keyword\
installer\sinst_src\keyword\*.*
sakura\license\
LICENSE
sakura\license\bregonig\
installer\externals\bregonig\bron412.zip\*.txt
sakura\license\ctags\
installer\externals\universal-ctags\ctags-2018-09-16_e522743d-!platform:Win32=x86!.zip\license\*.*
instmaterials\
installer\instmaterials\*.*
64 changes: 0 additions & 64 deletions sakura/postBuild.bat
Original file line number Diff line number Diff line change
@@ -1,64 +0,0 @@
@echo off

SETLOCAL

set UNZIP_CMD=%~dp0..\tools\zip\unzip.bat

@echo =======================
@echo postBuild
@echo =======================

: ---- arguments ---- :
: "Win32" or "x64"
set PLATFORM=%1
@echo PLATFORM=%PLATFORM%

: "Debug" or "Release"
set CONFIGURATION=%2
@echo CONFIGURATION=%CONFIGURATION%

set DEST_DIR=..\%PLATFORM%\%CONFIGURATION%

: ---- bron412 ---- :
set INSTALLER_RESOURCES_BRON=%~dp0..\installer\temp\bron
set BRON_ZIP=%~dp0..\installer\externals\bregonig\bron412.zip
set DLL_BREGONIG_NAME=bregonig.dll
if "%platform%" == "x64" (
set INSTALLER_RESOURCES_BRON_DLL=%INSTALLER_RESOURCES_BRON%\x64
) else (
set INSTALLER_RESOURCES_BRON_DLL=%INSTALLER_RESOURCES_BRON%
)

if not exist "%INSTALLER_RESOURCES_BRON_DLL%\%DLL_BREGONIG_NAME%" (
@echo extract %BRON_ZIP%
call %UNZIP_CMD% %BRON_ZIP% %INSTALLER_RESOURCES_BRON% || (echo error && exit /b 1)
)
if not exist "%DEST_DIR%\%DLL_BREGONIG_NAME%" (
@echo %DLL_BREGONIG_NAME% to destination directory.
copy /Y /B %INSTALLER_RESOURCES_BRON_DLL%\%DLL_BREGONIG_NAME% %DEST_DIR%\
)

: ---- ctags.exe ---- :
set INSTALLER_RESOURCES_CTAGS=%~dp0..\installer\temp\ctags
set INSTALLER_RESOURCES_CTAGS_EXE=%INSTALLER_RESOURCES_CTAGS%
if "%PLATFORM%" == "Win32" (
set CTAGS_PREFIX=x86
) else if "%PLATFORM%" == "x64" (
set CTAGS_PREFIX=x64
) else (
@echo unknown PLATFORM %PLATFORM%
exit /b 1
)
set CTAGS_ZIP=%~dp0..\installer\externals\universal-ctags\ctags-2018-09-16_e522743d-%CTAGS_PREFIX%.zip
set EXE_CTAGS_NAME=ctags.exe

if not exist "%INSTALLER_RESOURCES_CTAGS_DLL%\%EXE_CTAGS_NAME%" (
@echo extract %CTAGS_ZIP%
call %UNZIP_CMD% %CTAGS_ZIP% %INSTALLER_RESOURCES_CTAGS% || (echo error && exit /b 1)
)
if not exist "%DEST_DIR%\%EXE_CTAGS_NAME%" (
@echo %EXE_CTAGS_NAME% to destination directory.
copy /Y /B %INSTALLER_RESOURCES_CTAGS_EXE%\%EXE_CTAGS_NAME% %DEST_DIR%\
)

ENDLOCAL
2 changes: 1 addition & 1 deletion zipArtifacts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
installer\externals\universal-ctags\ctags-2018-09-16_e522743d-!platform:Win32=x86!.zip\license\*.*
!BASENAME!-Installer.zip
Installer\
installer\Output-!platform!\*.exe
!platform!\!configuration!\installer\Output-!platform!\*.exe
installer\warning.txt
installer\warning-!ALPHA!.txt
!BASENAME!-Log.zip
Expand Down

0 comments on commit 7c6c1e3

Please sign in to comment.