mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-04 18:20:42 +00:00
Windows batch files rework - buildall.bat and deploy.bat
This commit is contained in:
parent
b1313dc5ca
commit
25402ffe7a
@ -1,60 +1,372 @@
|
||||
@echo off
|
||||
setlocal
|
||||
:::@echo off
|
||||
::: You must set these paths to your QT configuration
|
||||
set qtpath=E:\Qt
|
||||
set qtVersion=5.12.12
|
||||
:: todo add help / descriptions
|
||||
|
||||
::: This script assumes that it resides OSCAR-data/Building/Windows
|
||||
::: You must defined the path to QT configuration or passit as a parameter
|
||||
::: The version is detected based on the path
|
||||
::: The compiler to use is based on the qt verson.
|
||||
::: @echo off
|
||||
::: CONFIGURATION SECTION
|
||||
|
||||
set QtPath=C:\Qt
|
||||
|
||||
::: END CONFIGURATION SECTION
|
||||
:::============================================
|
||||
:::
|
||||
::: Build 32- and 64-bit versions of OSCAR for Windows.
|
||||
::: Includes code to build BrokenGL (LegacyGFX) versions, but that option is not currently used
|
||||
::: Uses Timer 4.0 - Command Line Timer - www.Gammadyne.com - to show time it takes to compile. This could be removed.
|
||||
timer /nologo
|
||||
::: START INITIALIZATIO SECTION
|
||||
echo Command line: %0 %*
|
||||
call :parse %*
|
||||
if NOT %ERRORLEVEL%==0 goto :endProgram
|
||||
|
||||
:::call :buildone 32 brokengl
|
||||
set buildErrorLevel=0
|
||||
|
||||
call :buildone 64
|
||||
::: basedir is OSCAR-code folder - contains folders Building , oscar , ...
|
||||
::: parentdir is the folder that contains OSCAR-code.
|
||||
::: change relative paths into absolute paths
|
||||
::: Get path to this script. then cd parent folder. %cd% retunrs absolute pathname.
|
||||
cd %~dp0 & cd ../../../
|
||||
set parentdir=%cd%
|
||||
set basedir=%parentdir%\OSCAR-code
|
||||
IF NOT "%basedir%"=="%basedir: =%" (
|
||||
call :configError absolute path of OSCAR-code contains a space - not handled by Qt.
|
||||
echo %basedir%
|
||||
goto :endProgram)
|
||||
IF NOT exist "%basedir%\Building" (
|
||||
call :notfound2 OSCAR-code: "%basedir%"
|
||||
goto :endProgram)
|
||||
set baseBuildName=%basedir%\build-oscar-win
|
||||
::: Construct name of our build directory
|
||||
::: Build Directory can be based on the directories the QtCreator uses for either OSCAR_QT.pro or oscar.pro
|
||||
::: For OSCAR_QT.pro is at parentDir\OSCAR-code\OCASR_QT.pro the build will be at parentDir\BuildDir
|
||||
::: For oscar.pro is at OSCAR-code\oscar\oscar.pro the build will be at OSCAR-code\BuildDir
|
||||
|
||||
call :buildone 32
|
||||
:: check if QtPath from parameters list
|
||||
set defaultQtPath=%QtPath%
|
||||
if NOT "%requestQtPath%"=="" (set QtPath=%requestQtPath%)
|
||||
|
||||
:::call :buildone 64 brokengl
|
||||
timer /s /nologo
|
||||
:: check valid qt folder to find version and tool folders
|
||||
IF NOT exist %QtPath%\nul (
|
||||
call :configError InvalidPath to Qt. QtPath:%QtPath%
|
||||
echo The QtPath can be added as a parameter to %~nx0
|
||||
|
||||
call :helpInfo
|
||||
goto :endProgram
|
||||
)
|
||||
|
||||
set foundQtVersion=
|
||||
set foundQtToolsDir=
|
||||
set foundQtVersionDir=
|
||||
|
||||
for /d %%i in (%QtPath%\*) do (call :parseQtVersion %%i)
|
||||
if "%foundQtVersion%"=="" (
|
||||
echo :configError %QtPath% is not a valid Qt folder. Must contain version 5.xx.xx or 6.xx.xx folder
|
||||
echo Please enter a valid Qt Path as a parameter
|
||||
call :helpInfo
|
||||
goto :endProgram
|
||||
)
|
||||
if "%foundQtToolsDir%"=="" (
|
||||
. echo :configError %QtPath% is not a valid Qt folder. Must contain a Tools folder
|
||||
echo Please enter a valid Qt Path as a parameter
|
||||
call :helpInfo
|
||||
goto :endProgram
|
||||
)
|
||||
echo Using QtVersion %foundQtVersion%
|
||||
set qtVersion=%foundQtVersion%
|
||||
set QtVersionDir=%QtPath%\%qtVersion%
|
||||
set QtToolsDir=%QtPath%\Tools
|
||||
|
||||
::: Compiler Tools for creating Makefile (linux qmake features)
|
||||
if "5.15."=="%qtVersion:~0,5%" (
|
||||
:: For qt release 5.15
|
||||
set mingwQmakeVersion=mingw81
|
||||
set mingwQmakeTools=mingw810
|
||||
) else (
|
||||
:: For qt previous releases
|
||||
set mingwQmakeVersion=mingw73
|
||||
set mingwQmakeTools=mingw730
|
||||
)
|
||||
::: END INITIALIZATIO SECTION
|
||||
|
||||
|
||||
:::============================================
|
||||
:main
|
||||
::: Start BUILDING ON WINDOWS
|
||||
|
||||
call :startTimer "Start Time is"
|
||||
|
||||
if %do32%==1 (
|
||||
call :buildone 32 || goto :finished
|
||||
if %doBrokenGl%==1 (
|
||||
call :elapseTime "Elapse Time is"
|
||||
call :buildone 32 brokengl || goto :finished
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if %do64%==1 (
|
||||
if %do32%==1 (call :elapseTime "Elapse Time is")
|
||||
call :buildone 64 || goto :finished
|
||||
if %doBrokenGl%==1 (
|
||||
call :elapseTime "Elapse Time is"
|
||||
call :buildone 64 brokengl || goto :finished
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
:finished
|
||||
|
||||
:: this does work. dir %baseBuildName%*_bit\Installer\OSCAR*.exe
|
||||
echo Start Time is %saveStartTime%
|
||||
call :endTimer "End Time is"
|
||||
|
||||
FOR /D %%j in ("%baseBuildName%*") do (call :sub1 %%j)
|
||||
goto :endProgram
|
||||
::: return to caller
|
||||
:endProgram
|
||||
pause
|
||||
exit /b
|
||||
|
||||
|
||||
|
||||
:::============================================
|
||||
:sub1
|
||||
FOR /F %%i in ("%1\Installer\") do (call :sub2 %%i )
|
||||
FOR /F %%i in ("%1\Release\") do (call :sub2 %%i )
|
||||
goto :eof
|
||||
:sub2
|
||||
FOR %%k in ("%1\*.exe") do (call :sub3 %%k )
|
||||
goto :eof
|
||||
:sub3
|
||||
echo %~t1 %1
|
||||
goto :eof
|
||||
|
||||
:parseQtVersion
|
||||
set tmpf=%~nx1
|
||||
if "5."=="%tmpf:~0,2%" call :gotVersion %1 %tmpf% & goto :eof
|
||||
if "6."=="%tmpf:~0,2%" call :gotVersion %1 %tmpf% & goto :eof
|
||||
if "Tools"=="%tmpf%" call :gotTools %1 %tmpf% & goto :eof
|
||||
goto :eof
|
||||
:gotTools
|
||||
:: if NOT "%foundQtToolsDir%"=="" (echo Duplicate Qt Versions %1 and %foundQtToolsDir% Error & exit /b 101)
|
||||
set foundQtToolsDir=%1
|
||||
:: echo Found QtTools %1
|
||||
goto :eof
|
||||
:gotVersion
|
||||
:: if NOT "%foundQtVersion%"=="" (echo Duplicate Qt Versions %1 and %foundQtVersion% Error & exit /b 101)
|
||||
set foundQtVersion=%2
|
||||
set foundQtVersionDir=%1
|
||||
:: echo Found QtVersion %foundQtVersion%
|
||||
goto :eof
|
||||
|
||||
:::============================================
|
||||
:parse
|
||||
set do32=0
|
||||
set do64=0
|
||||
set doBrokenGl=0
|
||||
set useExistingBuild=0
|
||||
set skipCompile=0
|
||||
set skipDeploy=0
|
||||
set requestQtPath=
|
||||
set toggleEcho="off"
|
||||
:parseLoop
|
||||
IF "%1"=="" GOTO :exitParseLoop
|
||||
set arg=%1
|
||||
::: echo ^<%arg%^>
|
||||
IF "%arg%"=="32" (set do32=1 & GOTO :endLoop )
|
||||
IF "%arg%"=="64" (set do64=1 & GOTO :endLoop )
|
||||
IF /I "%arg%"=="brokenGl" (set doBrokenGl=1 & GOTO :endLoop )
|
||||
IF /I "%arg:~0,5%"=="SKIPD" (set skipDeploy=1 & GOTO :endLoop )
|
||||
IF /I "%arg:~0,5%"=="SKIPC" (
|
||||
set useExistingBuild=1
|
||||
set skipCompile=1
|
||||
GOTO :endLoop )
|
||||
IF /I "%arg:~0,4%"=="SKIP" (set useExistingBuild=1 & GOTO :endLoop )
|
||||
IF /I "%arg:~0,3%"=="ver" ( echo on & GOTO :endLoop )
|
||||
IF exist %arg%\Tools\nul IF exist %arg%\Licenses\nul (
|
||||
set requestQtPath=%arg%
|
||||
GOTO :endLoop)
|
||||
IF NOT "%arg:~0,2%"=="he" (
|
||||
echo _
|
||||
echo Invalid argument '%arg%'
|
||||
) else (
|
||||
echo _
|
||||
)
|
||||
call :helpInfo
|
||||
exit /b 123
|
||||
:endLoop
|
||||
SHIFT
|
||||
GOTO :parseLoop
|
||||
:exitParseLoop
|
||||
:: echo requestQtPath ^<%requestQtPath%^>
|
||||
set /a sum=%do32%+%do64%
|
||||
if %sum% == 0 (set do32=1 & set do64=1 )
|
||||
goto :eof
|
||||
|
||||
::: Subroutine to build one version
|
||||
:buildone
|
||||
setlocal
|
||||
timer /nologo
|
||||
set QTDIR=%qtpath%\%qtversion%\mingw73_%1
|
||||
echo QTDIR is %qtdir%
|
||||
set path=%qtpath%\Tools\mingw730_%1\bin;%qtpath%\%qtversion%\mingw73_%1\bin;%qtpath%\Tools\mingw730_%1\bin;%PATH%
|
||||
|
||||
:::============================================
|
||||
::: Timer functions
|
||||
::: Allows personalization of timer functions.
|
||||
::: defaults displaying the curr ent time
|
||||
::: Could Use Timer 4.0 - Command Line Timer - www.Gammadyne.com - to show time it takes to compile.
|
||||
:startTimer
|
||||
set saveStartTime=%TIME%
|
||||
:: timer.exe /nologo
|
||||
echo %~1 %saveStartTime%
|
||||
goto :eof
|
||||
:elapseTime
|
||||
:: timer.exe /r /nologo
|
||||
echo %~1 %TIME%
|
||||
goto :eof
|
||||
:endTimer
|
||||
:: timer.exe /s /et /nologo
|
||||
echo %~1 %TIME%
|
||||
goto :eof
|
||||
|
||||
:::===============================================================================
|
||||
|
||||
:configError
|
||||
set buildErrorLevel=24
|
||||
echo *** CONFIGURATION ERROR ***
|
||||
echo %*
|
||||
goto :eof
|
||||
|
||||
:notfound
|
||||
echo *** CONFIGURATION ERROR ***
|
||||
set buildErrorLevel=25
|
||||
echo NotFound %*
|
||||
goto :eof
|
||||
|
||||
|
||||
|
||||
:::===============================================================================
|
||||
:: Subroutine to "build one" version
|
||||
:buildOne
|
||||
setLocal
|
||||
set bitSize=%1
|
||||
set brokenGL=%2
|
||||
echo Building %1 %2
|
||||
::: echo do not remove this line - batch bug? 1>nul:::
|
||||
|
||||
set QtVersionCompilerDir=%qtVersionDir%\%mingwQmakeVersion%_%bitSize%
|
||||
if NOT exist %QtVersionCompilerDir%\nul (
|
||||
call :buildOneError 21 notfound QtCompiler: %QtVersionCompilerDir%
|
||||
goto :endBuildOne
|
||||
)
|
||||
|
||||
set QtToolsCompilerDir=%QtToolsDir%\%mingwQmakeTools%_%bitSize%
|
||||
if NOT exist %QtToolsCompilerDir% (
|
||||
call :buildOneError 22 notfound QTToolCompiler: %QtToolsCompilerDir%
|
||||
goto :endBuildOne
|
||||
)
|
||||
|
||||
set path=%QtToolsCompilerDir%\bin;%QtVersionCompilerDir%\bin;%PATH%
|
||||
:: echo ===================================
|
||||
:: echo %path%
|
||||
:: echo ===================================
|
||||
:::goto :eof
|
||||
|
||||
::: Verify all configuration parameters
|
||||
set savedir=%cd%
|
||||
: Construct name of our build directory
|
||||
set dirname=build-oscar-win_%1_bit
|
||||
if "%2"=="brokengl" (
|
||||
|
||||
set dirname=%baseBuildName%
|
||||
if "%brokenGL%"=="brokengl" (
|
||||
set dirname=%dirname%-LegacyGFX
|
||||
set extraparams=DEFINES+=BrokenGL
|
||||
)
|
||||
echo Build directory is %dirname%
|
||||
set buildDir=%dirname%_%bitSize%_bit
|
||||
|
||||
set basedir=..\..
|
||||
if exist %basedir%\%dirname%\nul rmdir /s /q %basedir%\%dirname%
|
||||
mkdir %basedir%\%dirname%
|
||||
cd %basedir%\%dirname%
|
||||
|
||||
%qtpath%\%qtversion%\mingw73_%1\bin\qmake.exe ..\oscar\OSCAR.pro -spec win32-g++ %extraparams% >qmake.log 2>&1 && %qtpath%/Tools/mingw730_%1/bin/mingw32-make.exe qmake_all >>qmake.log 2>&1
|
||||
mingw32-make.exe -j8 >make.log 2>&1 || goto :makefail
|
||||
:: allow rebuild without removing build when a parameter is "SKIP"
|
||||
if NOT exist %buildDir%\nul goto :makeBuildDir
|
||||
if %useExistingBuild%==1 goto :skipBuildDir
|
||||
rmdir /s /q %buildDir%
|
||||
IF NOT %ERRORLEVEL%==0 (
|
||||
call :buildOneError %ERRORLEVEL% error removing Build Folder: %buildDir%
|
||||
GOTO :endBuildOne )
|
||||
|
||||
call ..\Building\Windows\deploy.bat
|
||||
:makeBuildDir
|
||||
mkdir %buildDir% || (
|
||||
call :buildOneError 23 mkdir %buildDir% failed %ERRORLEVEL%
|
||||
goto :endBuildOne )
|
||||
echo created %buildDir%
|
||||
:skipBuildDir
|
||||
cd %buildDir%
|
||||
if %skipCompile%==1 goto :doDeploy
|
||||
|
||||
timer /s /nologo
|
||||
echo === MAKE %1 %2 SUCCESSFUL ===
|
||||
cd %savedir%
|
||||
endlocal
|
||||
exit /b
|
||||
|
||||
:makefail
|
||||
endlocal
|
||||
timer /s /nologo
|
||||
echo *** MAKE %1 %2 FAILED ***
|
||||
pause
|
||||
exit /b
|
||||
|
||||
if NOT exist %buildDir%\Makefile goto :createMakefile
|
||||
if %useExistingBuild%==1 goto :skipMakefile
|
||||
if NOT exist ..\oscar\oscar.pro {
|
||||
call :buildOneError 24 notfound oscar.pro is not found.
|
||||
goto :endBuildOne)
|
||||
|
||||
:createMakefile
|
||||
echo Creating Oscar's Makefile
|
||||
%QtVersionCompilerDir%\bin\qmake.exe ..\oscar\oscar.pro -spec win32-g++ %extraparams% >qmake.log 2>&1 || (
|
||||
call :buildOneError 25 Failed to create Makefile part1
|
||||
type qmake.log
|
||||
goto :endBuildOne)
|
||||
%QtToolsCompilerDir%/bin/mingw32-make.exe qmake_all >>qmake.log 2>&1 || (
|
||||
call :buildOneError 26 Failed to create Makefile part2
|
||||
type qmake.log
|
||||
goto :endBuildOne)
|
||||
:skipMakefile
|
||||
|
||||
:: Always compile build
|
||||
echo Compiling Oscar
|
||||
mingw32-make.exe -j8 >make.log 2>&1 || (
|
||||
call :buildOneError 27 Make Failed
|
||||
type qmake.log
|
||||
goto :endbuildOne
|
||||
)
|
||||
|
||||
|
||||
::: echo skipDeploy: %skipDeploy%
|
||||
:doDeploy
|
||||
if %skipDeploy%==1 goto :endBuildOne
|
||||
|
||||
echo Deploying and Creating Installation Exec in %cd%
|
||||
call "%~dp0\deploy.bat"
|
||||
set buildErrorLevel=%ERRORLEVEL%
|
||||
|
||||
|
||||
if %buildErrorLevel% == 0 (
|
||||
echo === MAKE %bitSize% %brokenGL% SUCCESSFUL ===
|
||||
goto :endBuildOne
|
||||
) else (
|
||||
call :buildOneError %buildErrorLevel% DEPLOY FAILED
|
||||
goto :endBuildOne
|
||||
)
|
||||
:buildOneError
|
||||
echo *** MAKE %bitSize% %brokenGL% FAILED ***
|
||||
echo %*
|
||||
exit /b %1
|
||||
:endBuildOne
|
||||
cd %savedir% 1>nul 2>nul
|
||||
endLocal
|
||||
exit /b %buildErrorLevel%
|
||||
:::============================================
|
||||
:helpInfo
|
||||
echo _
|
||||
echo The %~nx0 script file creates Release and Install 32 and 64 bit versions of Oscar.
|
||||
echo The %~nx0 has parameters to configure the default options.
|
||||
echo %~nx0 can be executed from the File Manager
|
||||
echo Parameter can be added using a short cut and adding parameters to the shortcut's target.
|
||||
echo _
|
||||
echo options Description
|
||||
echo brokenGl Builds the brokenGL versions of OSCAR
|
||||
echo 32 Builds just 32 bit versions
|
||||
echo 64 Builds just 64 bit versions
|
||||
echo QtPath Overrides the default path (C:\Qt) to QT's installation - contains Tools, License, ... folders
|
||||
echo _
|
||||
echo The offical builds of OSCAR should not use the following options. These facilate development
|
||||
echo skip Skips recreating Makefile, but executes make in existing build folder
|
||||
echo skipCompile Skips all compiling. Leaves build folder untouched.
|
||||
echo skipDeploy Skip calling deploy.bat. Does not create Release or install versions.
|
||||
echo verbose Start verbose logging
|
||||
echo help Display this help message
|
||||
echo _
|
||||
echo Anything Displays invalid parameter message and help message then exits.
|
||||
goto :eof
|
||||
|
@ -1,98 +1,210 @@
|
||||
:::
|
||||
::: Build Release and Installer subdirectories of the current shadow build directory.
|
||||
::: The Release directory contains everything needed to run OSCAR.
|
||||
::: The Installer directory contains a single executable -- the OSCAR installer.
|
||||
:::
|
||||
::: DEPLOY.BAT should be run as the last step of a QT Build Release kit.
|
||||
::: QT Shadow build should be specified (this is the QT default).
|
||||
::: A command line parameter is optional. Any text on the command line will be appended
|
||||
::: to the file name of the installer.
|
||||
:::
|
||||
::: Requirements:
|
||||
::: Inno Setup 6 - http://www.jrsoftware.org/isinfo.php, installed to default Program Files (x86) location
|
||||
::: gawk - somewhere in the PATH or in Git for Windows installed in its default lolcation
|
||||
:::
|
||||
::: Deploy.bat resides in .../OSCAR-code/Nuilding/Windows, along with
|
||||
::: buildinstall.iss -- script for Inno Setup to create installer
|
||||
::: getBuildInfo.awk -- gawk script for extracting version fields from various files
|
||||
::: setup.ico -- Icon to be used for the installer.
|
||||
:::
|
||||
::: When building a release version in QT, QT will start this batch file which will prepare
|
||||
::: additional files, run WinDeployQt, and create an installer.
|
||||
:::
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
::: toolDir is where the Windows install/deploy tools are located
|
||||
set toolDir=%~dp0
|
||||
:::echo tooldir is %toolDir%
|
||||
|
||||
::: Set shadowBuildDir and sourceDir for oscar_qt.pro vs oscar\oscar.pro projects
|
||||
if exist ..\oscar-code\oscar\oscar.pro (
|
||||
::: oscar_QT.pro
|
||||
set sourceDir=..\oscar-code\oscar
|
||||
set shadowBuildDir=%cd%\oscar
|
||||
) else (
|
||||
::: oscar\oscar.pro
|
||||
set sourceDir=..\oscar
|
||||
set shadowBuildDir=%cd%
|
||||
)
|
||||
echo sourceDir is %sourceDir%
|
||||
echo shadowBuildDir is %shadowBuildDir%
|
||||
|
||||
::: Now copy the base installation control file
|
||||
|
||||
copy %toolDir%buildInstall.iss %shadowBuildDir% || exit 45
|
||||
copy %toolDir%setup.ico %shadowBuildDir% || exit 46
|
||||
:::copy %toolDir%use*.reg %shadowBuildDir% || exit 47
|
||||
|
||||
:::
|
||||
::: If gawk.exe is in the PATH, use it. If not, add Git mingw tools (awk) to path. They cannot
|
||||
::: be added to global path as they break CMD.exe (find etc.)
|
||||
where /q gawk.exe || set PATH=%PATH%;%ProgramW6432%\Git\usr\bin
|
||||
|
||||
::: Create and copy installer control files
|
||||
::: Create file with all version numbers etc. ready for use by buildinstall.iss
|
||||
::: Extract the version info from various header files using gawk and
|
||||
::: #define fields for each data item in buildinfo.iss which will be
|
||||
::: used by the installer script.
|
||||
where /q gawk.exe || set PATH=%PATH%;%ProgramW6432%\Git\usr\bin
|
||||
echo ; This script auto-generated by DEPLOY.BAT >%shadowBuildDir%\buildinfo.iss
|
||||
gawk -f %toolDir%getBuildInfo.awk %sourcedir%\VERSION >>%shadowBuildDir%\buildInfo.iss || exit 60
|
||||
gawk -f %toolDir%getBuildInfo.awk %sourcedir%\git_info.h >>%shadowBuildDir%\buildInfo.iss || exit 62
|
||||
echo %shadowBuildDir% | gawk -f %toolDir%getBuildInfo.awk >>%shadowBuildDir%\buildInfo.iss || exit 63
|
||||
echo #define MySuffix "%1" >>%shadowBuildDir%\buildinfo.iss || exit 64
|
||||
:::echo #define MySourceDir "%sourcedir%" >>%shadowBuildDir%\buildinfo.iss
|
||||
|
||||
::: Create Release directory and subdirectories
|
||||
if exist %shadowBuildDir%\Release\*.* rmdir /s /q %shadowBuildDir%\Release
|
||||
mkdir %shadowBuildDir%\Release
|
||||
cd %shadowBuildDir%\Release
|
||||
copy %shadowBuildDir%\oscar.exe . || exit 71
|
||||
:::copy %shadowBuildDir%\use*.reg . || exit 72
|
||||
|
||||
::: Now in Release subdirectory
|
||||
::: If QT created a help directory, copy it. But it might not have if "helpless" option was set
|
||||
if exist Help\*.* rmdir /s /q Help
|
||||
mkdir Help
|
||||
if exist ..\help\*.qch copy ..\help Help
|
||||
|
||||
if exist Html\*.* rmdir /s /q Html
|
||||
mkdir Html
|
||||
copy ..\html html || exit 80
|
||||
|
||||
if exist Translations\*.* rmdir /s /q Translations
|
||||
mkdir Translations
|
||||
copy ..\translations Translations || exit 84
|
||||
|
||||
::: Run deployment tool
|
||||
windeployqt.exe --release --force --compiler-runtime --no-translations --verbose 1 OSCAR.exe || exit 87
|
||||
|
||||
::: Clean up unwanted translation files
|
||||
:::For unknown reasons, Win64 build copies the .ts files into the release directory, while Win32 does not
|
||||
if exist Translations\*.ts del /q Translations\*.ts
|
||||
|
||||
::: Create installer
|
||||
cd ..
|
||||
:::"%ProgramFiles(x86)%\Inno Setup 6\compil32" /cc BuildInstall.iss
|
||||
"%ProgramFiles(x86)%\Inno Setup 6\iscc" /Q BuildInstall.iss
|
||||
:::
|
||||
::: Build Release and Installer subdirectories of the current shadow build directory.
|
||||
::: The Release directory contains everything needed to run OSCAR.
|
||||
::: The Installer directory contains a single executable -- the OSCAR installer.
|
||||
:::
|
||||
::: DEPLOY.BAT should be run as the last step of a QT Build Release kit.
|
||||
::: QT Shadow build should be specified (this is the QT default).
|
||||
::: A command line parameter is optional. Any text on the command line will be appended
|
||||
::: to the file name of the installer.
|
||||
:::
|
||||
::: Requirements:
|
||||
::: Inno Setup 6 - http://www.jrsoftware.org/isinfo.php, installed to default Program Files (x86) location:%ProgramFiles(x86)%
|
||||
::: gawk - somewhere in the PATH or in Git for Windows installed with Git\cmd in the path
|
||||
:::
|
||||
::: Deploy.bat resides in ...\OSCAR-code\Building\Windows, along with
|
||||
::: buildinstall.iss -- script for Inno Setup to create installer
|
||||
::: getBuildInfo.awk -- gawk script for extracting version fields from various files
|
||||
::: setup.ico -- Icon to be used for the installer.
|
||||
:::
|
||||
::: When building a release version in QT, QT will start this batch file which will prepare
|
||||
::: additional files, run WinDeployQt, and create an installer.
|
||||
:::
|
||||
@echo off
|
||||
setlocal
|
||||
set errDescription=
|
||||
set errvalue=0
|
||||
::: Current Directory is the shadowBuildDir
|
||||
set shadowBuildDir=%cd%
|
||||
::: toolDir is where the Window install\deploy tools are located
|
||||
cd %~dp0 && cd ..\..\..
|
||||
set parentDir=%cd%
|
||||
if exist %shadowBuildDir%\oscar\nul set shadowBuildDir=%shadowBuildDir%\oscar
|
||||
cd %shadowBuildDir%
|
||||
set toolDir=%parentDir%\OSCAR-code\Building\Windows
|
||||
::: Calculate directory where OSCAR-code is located.
|
||||
set sourceDir=%parentDir%\OSCAR-code\oscar
|
||||
|
||||
echo tooldir is %toolDir%
|
||||
::echo parentDir is %parentDir%
|
||||
:: echo sourceDir is %sourceDir%
|
||||
echo shadowBuildDir is %shadowBuildDir%
|
||||
if NOT exist %shadowBuildDir%\OSCAR.exe (
|
||||
call :err 41 %shadowBuildDir%\OSCAR.exe does not exist
|
||||
goto :endProgram
|
||||
)
|
||||
|
||||
call :cleanFolder
|
||||
if exist %shadowBuildDir%\buildInfo.iss del /q %shadowBuildDir%\buildInfo.iss || (call :err 42 & goto :endProgram)
|
||||
if exist %shadowBuildDir%\buildInstall.iss del /q %shadowBuildDir%\buildInstall.iss || (call :err 43 & goto :endProgram)
|
||||
if exist %shadowBuildDir%\setup.ico del /q %shadowBuildDir%\setup.ico || (call :err 44 & goto :endProgram)
|
||||
|
||||
where gawk > temp.txt 2>nul
|
||||
set er=%errorlevel%
|
||||
set gawk=<temp.txt
|
||||
if %er%==0 (del temp.txt && goto :eof)
|
||||
:: get location of Git command - then find where Git was downloaded.
|
||||
where Git > temp.txt 2>nul
|
||||
set er=%errorlevel%
|
||||
set /p git=<temp.txt
|
||||
del temp.txt
|
||||
if NOT %er%==0 (echo git command not found && exit /b 33)
|
||||
::: found the location of GIT. because git has gawk
|
||||
:: have fullpath of git.exe which is in Git\cmd\git.exe need Git\usr\bin\gawk
|
||||
FOR %%i IN ("%git%") DO (set git=%%~dpi)
|
||||
:: get rid of trailing \ for above command to decend one level
|
||||
FOR %%i IN ("%git:~0,-1%") DO (set git=%%~dpi)
|
||||
set path=%git:~0,-1%\usr\bin;%path%
|
||||
|
||||
::: Now have gawk. -- do not delete this line.
|
||||
::: Now copy the base installation control file
|
||||
copy %toolDir%\buildInstall.iss %shadowBuildDir% 1>nul
|
||||
if NOT %ERRORLEVEL%==0 (
|
||||
call :err 45 %ERRORLEVEL% failure to copy %toolDir%\buildInstall.iss to %shadowBuildDir%
|
||||
goto :endProgram
|
||||
)
|
||||
copy %toolDir%\setup.ico %shadowBuildDir% 1>nul
|
||||
if NOT %ERRORLEVEL%==0 (
|
||||
call :err failure to copy %toolDir%\setup.ico to %shadowBuildDir%
|
||||
goto :endProgram
|
||||
)
|
||||
:::copy %toolDir%\use*.reg %shadowBuildDir% || call :err 47 & goto :endProgram
|
||||
|
||||
::: Create and copy installer control files
|
||||
::: Create file with all version numbers etc. ready for use by buildinstall.iss
|
||||
::: Extract the version info from various header files using gawk and
|
||||
::: #define fields for each data item in buildinfo.iss which will be
|
||||
::: used by the installer script.
|
||||
echo ; This script auto-generated by DEPLOY.BAT >%shadowBuildDir%\buildinfo.iss
|
||||
gawk -f %toolDir%\getBuildInfo.awk %sourcedir%\VERSION >>%shadowBuildDir%\buildInfo.iss
|
||||
if NOT %ERRORLEVEL%==0 (
|
||||
call :err 60 & goto :endProgram)
|
||||
gawk -f %toolDir%\getBuildInfo.awk %sourcedir%\git_info.h >>%shadowBuildDir%\buildInfo.iss
|
||||
if NOT %ERRORLEVEL%==0 (
|
||||
call :err 62 & goto :endProgram)
|
||||
echo %shadowBuildDir% | gawk -f %toolDir%\getBuildInfo.awk >>%shadowBuildDir%\buildInfo.iss
|
||||
if NOT %ERRORLEVEL%==0 (
|
||||
call :err 63 & goto :endProgram)
|
||||
echo #define MySuffix "%1" >>%shadowBuildDir%\buildinfo.iss
|
||||
if NOT %ERRORLEVEL%==0 (
|
||||
call :err 64 & goto :endProgram)
|
||||
:::echo #define MySourceDir "%sourcedir%" >>%shadowBuildDir%\buildinfo.iss
|
||||
|
||||
set releaseDir=%shadowBuildDir%\Release
|
||||
|
||||
::: Create Release directory and subdirectories
|
||||
::: if exist %shadowBuildDir%\Release\*.* rmdir /s /q %shadowBuildDir%\Release
|
||||
mkdir %releaseDir%
|
||||
cd %shadowBuildDir%\Release
|
||||
copy %shadowBuildDir%\oscar.exe . 1>nul
|
||||
if NOT %ERRORLEVEL%==0 (
|
||||
call :err 71 & goto :endProgram)
|
||||
:::copy %shadowBuildDir%\use*.reg . || call :err 72 & goto :endProgram
|
||||
::: if exist %shadowBuildDir%\Installer\*.* rmdir /s /q %shadowBuildDir%\Installer (call :err 73 & goto :endProgram)
|
||||
|
||||
::: starting to copy files
|
||||
::: Now in Release subdirectory
|
||||
::: If QT created a help directory, copy it. But it might not have if "helpless" option was set
|
||||
|
||||
::: if exist Help\*.* rmdir /s /q Help
|
||||
mkdir Help
|
||||
if exist %shadowBuildDir%\help\*.qch copy %shadowBuildDir%\help %releaseDir%\Help 1>nul || (call :err 80 & goto :endProgram)
|
||||
|
||||
::: if exist Html\*.* rmdir /s /q Html
|
||||
mkdir Html
|
||||
copy %shadowBuildDir%\html %releaseDir%\html 1>nul || (call :err 81 & goto :endProgram)
|
||||
|
||||
::: if exist Translations\*.* rmdir /s /q Translations
|
||||
mkdir Translations
|
||||
copy %shadowBuildDir%\translations %releaseDir%\Translations 1>nul || (call :err 84 & goto :endProgram)
|
||||
|
||||
::: Run deployment tool
|
||||
echo Running Qt Deployment tool
|
||||
windeployqt.exe --release --force --compiler-runtime --no-translations --verbose 1 OSCAR.exe 1>nul 2>nul
|
||||
if %errorlevel% == 0 goto :cleanup
|
||||
::: echo windeployqt error = %errorlevel% executing next version
|
||||
::: Post mingw 8.0 --release Must not be used.
|
||||
windeployqt.exe --force --compiler-runtime --no-translations --verbose 1 OSCAR.exe 1>nul || (call :err 87 & goto :endProgram)
|
||||
|
||||
|
||||
:cleanup
|
||||
::: Clean up unwanted translation files
|
||||
::::For unknown reasons, Win64 build copies the .ts files into the release dir/ectory, while Win32 does not
|
||||
if exist Translations\*.ts del /q Translations\*.ts
|
||||
|
||||
::: Create installer
|
||||
echo Creating OSCAR Installation Exec
|
||||
cd ..
|
||||
"%ProgramFiles(x86)%\Inno Setup 6\iscc" /Q BuildInstall.iss || (call :err 88 & goto :endProgram)
|
||||
if NOT exist %shadowBuildDir%\Installer\OSCAR*.exe (call :err 89 & goto :endProgram)
|
||||
:endProgram
|
||||
echo Finished %~nx0 %errDescription%
|
||||
exit /b %errvalue%
|
||||
:::: =======================
|
||||
|
||||
:err
|
||||
set errvalue=%1
|
||||
set errDescription=%*
|
||||
echo %~nx0 detected error: %*
|
||||
|
||||
exit /b %errvalue%
|
||||
|
||||
|
||||
::: =====================================================================================
|
||||
|
||||
:getGawk
|
||||
:: check if gawk is already available.
|
||||
where gawk > temp.txt 2>nul
|
||||
set er=%errorlevel%
|
||||
set gawk=<temp.txt
|
||||
if %er%==0 (del temp.txt && goto :eof)
|
||||
:: get location of Git command - then find where Git was downloaded.
|
||||
where Git > temp.txt 2>nul
|
||||
set er=%errorlevel%
|
||||
set /p git=<temp.txt
|
||||
del temp.txt
|
||||
if NOT %er%==0 (echo git command not found && exit /b 33)
|
||||
::: found the location of GIT. because git has gawk
|
||||
:: have fullpath of git.exe which is in Git\cmd\git.exe need Git\usr\bin\gawk
|
||||
FOR %%i IN ("%git%") DO (set git=%%~dpi)
|
||||
:: get rid of trailing \ for above command to decend one level
|
||||
FOR %%i IN ("%git:~0,-1%") DO (set git=%%~dpi)
|
||||
set path=%git:~0,-1%\usr\bin;%path%
|
||||
echo %path%
|
||||
goto :eof
|
||||
|
||||
::: =====================================================================================
|
||||
:cleanFolder
|
||||
for /d %%i in (%shadowBuildDir%\*) do (
|
||||
call :handClean %%i
|
||||
)
|
||||
goto :eof
|
||||
:handClean
|
||||
::: Qt adds hidden files to build folder for glang compiler. .qtc_clangd (for windows builds)
|
||||
::: This results is no file name, however it does exist in the full path name %1
|
||||
set xpath=%1
|
||||
set fname=%~n1
|
||||
:: if fname is empty then directory is hidden and is in xpath
|
||||
::: if "%fname%"=="" goto :endhandClean:::
|
||||
if /I "%fname%"=="Help" goto :endhandClean
|
||||
if /I "%fname%"=="Html" goto :endhandClean
|
||||
if /I "%fname%"=="Translations" goto :endhandClean
|
||||
if /I "%fname%"=="Release" goto :cleanDir
|
||||
if /I "%fname%"=="Installer" goto :cleanDir
|
||||
echo Folder %fname% was not cleaned
|
||||
goto :endhandClean
|
||||
:cleanDir
|
||||
echo Cleaning %xpath%
|
||||
rmdir /Q /S %xpath%
|
||||
:endhandClean
|
||||
goto :eof
|
||||
|
Loading…
Reference in New Issue
Block a user