Merge pull request #10 from OpenVR-Advanced-Settings/new-windows-build

Add new windows build scripts
This commit is contained in:
Robin Appelman
2018-12-26 22:32:35 +01:00
committed by GitHub
8 changed files with 418 additions and 50 deletions
+3
View File
@@ -8,4 +8,7 @@ Makefile*
*.vs
*.stash
*.appxmanifest
*.user
installer/AdvancedSettings-Installer.exe
*.user*
+6 -3
View File
@@ -2,10 +2,14 @@ image: Visual Studio 2017
environment:
matrix:
- QT: C:\Qt\5.10.1\msvc2017_64
PLATFORM: amd64
- QT_LOC: '"C:\Qt\5.11.2\msvc2017_64\bin\"'
VS_LOC: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"'
JOM_LOC: '"C:\Qt\Tools\QtCreator\bin\jom.exe"'
NSIS_LOC: '"C:\Program Files (x86)\NSIS\"'
ZIP_LOC: 7z
COMPILER: msvc
VSVER: 14
clone_depth: 1
@@ -14,7 +18,6 @@ init:
build_script:
- call "build_windows.cmd"
- call "package.cmd"
artifacts:
- path: bin\win64\AdvancedSettings.zip
+115
View File
@@ -0,0 +1,115 @@
@echo off
REM Echo off to avoid spam.
REM Non zero is failure, 0 is success.
SET exit_code_success=0
SET exit_code_failure_build_apps=1
SET exit_code_failure_build_locations=2
REM Used for echos.
SET current_activity=BUILD
REM If scripts are chain called the original dirs should not be overwritten.
IF NOT DEFINED original_dir (
SET original_dir=%CD%
)
IF NOT DEFINED project_dir (
REM Arg 0 (called %0) is the full path to the file.
REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters
REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only.
REM Project dir is up two dirs from the file.
SET project_dir=%~dp0\..\..\
)
REM Change dir to the project dir, otherwise qmake doesn't know where it is.
CD %project_dir%
REM QT_LOC is a directory, it can't be in the path, no reason to check using WHERE.
ECHO %current_activity%: Testing if all required build environment values are set:
IF NOT DEFINED QT_LOC (
ECHO %current_activity%: QT_LOC not defined. Using default value.
SET QT_LOC="C:\Qt\5.11.1\msvc2017_64\bin\"
)
ECHO %current_activity%: QT_LOC set to '%QT_LOC%'.
IF EXIST %QT_LOC% (
ECHO %current_activity%: QT_LOC exists.
) ELSE (
ECHO %current_activity%: QT_LOC directory does not exist. Exiting.
EXIT /B %exit_code_failure_build_locations%
)
IF NOT DEFINED VS_LOC (
ECHO %current_activity%: VS_LOC not defined. Using default value.
SET VS_LOC="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"
)
ECHO %current_activity%: VS_LOC set to '%VS_LOC%'.
REM EXIST won't find items in the PATH. WHERE will.
SET VS_VALID=0
IF EXIST %VS_LOC% SET VS_VALID=1
REM Prevents error message spam if it doesn't find it in PATH.
IF NOT %VS_VALID% EQU 1 (
WHERE /Q %VS_LOC%
IF NOT ERRORLEVEL 1 SET VS_VALID=1
)
IF %VS_VALID% EQU 1 (
ECHO %current_activity%: VS_LOC exists.
) ELSE (
ECHO %current_activity%: VS_LOC directory does not exist. Exiting.
EXIT /B %exit_code_failure_build_locations%
)
ECHO %current_activity%: All required build environment values are set.
IF DEFINED BUILD_DEBUG (
ECHO %current_activity%: BUILD_DEBUG var set. Compiling for debug.
SET compile_level=debug
) ELSE (
ECHO %current_activity%: BUILD_DEBUG var not set. Compiling for release.
SET compile_level=release
)
ECHO %current_activity%: Setting up environment with Visual Studio 'vcvarsall.bat'.
REM Currently only this platform is supported.
SET target_platform=AMD64
REM Set up environment for qmake.
CALL %VS_LOC% %target_platform%
IF DEFINED BUILD_VSPROJ (
ECHO %current_activity%: BUILD_VSPROJ defined. Building Visual Studio project files.
%QT_LOC%\qmake -tp vc
ECHO %current_activity%: Building Visual Studio project files done.
) ELSE (
ECHO %current_activity%: BUILD_VSPROJ not defined. Not building Visual Studio project files.
)
ECHO %current_activity%: Running qmake for %compile_level%:
%QT_LOC%\qmake -spec win32-msvc CONFIG+=x86_64 CONFIG+=%compile_level%
ECHO %current_activity%: qmake done.
IF NOT DEFINED JOM_LOC (
ECHO %current_activity%: JOM_LOC not defined. Using default value.
SET JOM_LOC="C:\Qt\Tools\QtCreator\bin\jom.exe"
)
ECHO %current_activity%: JOM_LOC set to '%JOM_LOC%'.
IF EXIST %JOM_LOC% (
ECHO %current_activity%: JOM_LOC exists.
ECHO %current_activity%: Running jom:
%JOM_LOC%
REM jom will not exit with an error code. Leading to a passing build even with errors.
IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps%
ECHO %current_activity%: jom done.
) ELSE (
ECHO JOM_LOC directory does not exist. Using nmake.
ECHO %current_activity%: Running nmake:
nmake
REM nmake will not exit with an error code. Leading to a passing build even with errors.
IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps%
ECHO %current_activity%: nmake done.
)
CD %original_dir%
ECHO %current_activity%: %current_activity% DONE.
+119
View File
@@ -0,0 +1,119 @@
@echo off
REM Echo off to avoid spam.
REM Non zero is failure, 0 is success.
SET exit_code_success=0
SET exit_code_failure_build_apps=1
SET exit_code_failure_build_locations=2
SET output_dir="\bin\win64\"
REM Used for echos.
SET current_activity=DEPLOY
REM If scripts are chain called the original dirs should not be overwritten.
IF NOT DEFINED original_dir (
SET original_dir=%CD%
)
IF NOT DEFINED project_dir (
REM Arg 0 (called %0) is the full path to the file.
REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters
REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only.
REM Project dir is up two dirs from the file.
SET project_dir=%~dp0\..\..\
)
ECHO %current_activity%: Testing if all required build environment values are set:
IF NOT DEFINED QT_LOC (
ECHO %current_activity%: QT_LOC not defined. Using default value.
SET QT_LOC="C:\Qt\5.11.1\msvc2017_64\bin\"
)
REM QT_LOC is a directory, it can't be in the path, no reason to check using WHERE.
ECHO %current_activity%: QT_LOC set to '%QT_LOC%'.
IF EXIST %QT_LOC% (
ECHO %current_activity%: QT_LOC exists.
) ELSE (
ECHO %current_activity%: QT_LOC directory does not exist. Exiting.
EXIT /B %exit_code_failure_build_locations%
)
ECHO %current_activity%: All required build environment values are set.
IF NOT EXIST %project_dir%\%output_dir% (
ECHO %current_activity%: Output dir '%output_dir%' does not exist. Creating.
mkdir %project_dir%\%output_dir%
ECHO %current_activity%: Output dir created.
)
cd %project_dir%\%output_dir%
IF DEFINED BUILD_DEBUG (
ECHO %current_activity%: BUILD_DEBUG var set. Compiling for debug.
SET compile_level=debug
) ELSE (
ECHO %current_activity%: BUILD_DEBUG var not set. Compiling for release.
SET compile_level=release
)
ECHO %current_activity%: Running windeployqt:
REM windeployqt requires the QT\bin location to be in the path.
REM Changing the PATH var is not ideal, but windeployqt does not work otherwise.
set original_path=%PATH%
set PATH=%QT_LOC%;%PATH%
REM Caret newline (^CFLR) splits a command over several lines.
REM This is done to avoid one ultra long line.
windeployqt --dir AdvancedSettings\qtdata ^
--libdir AdvancedSettings ^
--plugindir AdvancedSettings\qtdata\plugins ^
--no-system-d3d-compiler ^
--no-opengl-sw ^
--%compile_level% ^
--qmldir ..\..\src\res\qml\ ^
AdvancedSettings\AdvancedSettings.exe
REM windeployqt does not exit on error by itself.
IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps%
REM Return the PATH to original as quickly as possible.
set PATH=%original_path%
ECHO %current_activity%: windeployqt done.
REM Switches used for copy:
REM /V Verifies that files have been copied correctly.
REM /Q Suppresses xcopy spam.
REM /Y Skips the overwrite yes prompt.
REM /E Copies all subdirs, even if they are empty.
REM /I "If Source is a directory or contains wildcards and Destination does not exist,
REM xcopy assumes Destination specifies a directory name and creates a new directory.
REM Then, xcopy copies all specified files into the new directory. By default,
REM xcopy prompts you to specify whether Destination is a file or a directory."
ECHO %current_activity%: Copying necessary files.
copy /V /Y "%project_dir%\Readme.md" "%project_dir%\%output_dir%\AdvancedSettings\Readme.md"
ECHO %current_activity%: README copied.
REM All three licenses must be included in binary releases, as per the terms.
copy /V /Y "%project_dir%\LICENSE" "%project_dir%\%output_dir%\AdvancedSettings\LICENSE-GPL.txt"
copy /V /Y "%project_dir%\third-party\openvr\LICENSE" "%project_dir%\%output_dir%\AdvancedSettings\LICENSE-VALVE.txt"
copy /V /Y "%project_dir%\third-party\easylogging++\LICENSE" "%project_dir%\%output_dir%\AdvancedSettings\LICENSE-MIT.txt"
ECHO %current_activity%: LICENSE files copied.
xcopy /Q /Y /E /I /V "%project_dir%\src\res" "%project_dir%\%output_dir%\AdvancedSettings\res\"
ECHO %current_activity%: Resource files copied.
copy /V /Y "%project_dir%\src\restartvrserver.bat" "%project_dir%\%output_dir%\AdvancedSettings\restartvrserver.bat"
copy /V /Y "%project_dir%\src\startdesktopmode.bat" "%project_dir%\%output_dir%\AdvancedSettings\startdesktopmode.bat"
ECHO %current_activity%: Extra batch files copied.
copy /V /Y "%project_dir%\src\qt.conf" "%project_dir%\%output_dir%\AdvancedSettings\qt.conf"
copy /V /Y "%project_dir%\src\manifest.vrmanifest" "%project_dir%\%output_dir%\AdvancedSettings\manifest.vrmanifest"
ECHO %current_activity%: VR specific configuration files copied.
copy /V /Y "%project_dir%\third-party\openvr\bin\win64\openvr_api.dll" "%project_dir%\%output_dir%\AdvancedSettings\openvr_api.dll"
ECHO %current_activity%: OpenVR .dll copied.
cd %original_dir%
ECHO %current_activity%: %current_activity% DONE.
+96
View File
@@ -0,0 +1,96 @@
@echo off
REM Echo off to avoid spam.
REM Non zero is failure, 0 is success.
SET exit_code_success=0
SET exit_code_failure_build_apps=1
SET exit_code_failure_build_locations=2
SET output_dir="\bin\win64\"
REM Used for echos.
SET current_activity=PACKAGE
REM If scripts are chain called the original dirs should not be overwritten.
IF NOT DEFINED original_dir (
SET original_dir=%CD%
)
IF NOT DEFINED project_dir (
REM Arg 0 (called %0) is the full path to the file.
REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters
REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only.
REM Project dir is up two dirs from the file.
SET project_dir=%~dp0\..\..\
)
REM ZIP_LOC can't be called 7Z_LOC because of Windows limitations.
ECHO %current_activity%: Testing if all required build environment values are set:
IF NOT DEFINED ZIP_LOC (
ECHO %current_activity%: ZIP_LOC not defined. Using default value.
SET ZIP_LOC="C:\Program Files\7-Zip\7z.exe"
)
ECHO %current_activity%: ZIP_LOC set to '%ZIP_LOC%'.
REM EXIST won't find items in the PATH. WHERE will.
SET ZIP_VALID=0
IF EXIST %ZIP_LOC% SET ZIP_VALID=1
IF %ZIP_VALID% EQU 0 (
WHERE /Q %ZIP_LOC%
IF NOT ERRORLEVEL 1 SET ZIP_VALID=1
)
IF %ZIP_VALID% EQU 1 (
ECHO %current_activity%: ZIP_LOC exists.
) ELSE (
ECHO %current_activity%: ZIP_LOC directory does not exist. Exiting.
EXIT /B %exit_code_failure_build_locations%
)
IF NOT DEFINED NSIS_LOC (
ECHO %current_activity%: NSIS_LOC not defined. Using default value.
SET NSIS_LOC="C:\Program Files (x86)\NSIS\"
)
ECHO %current_activity%: NSIS_LOC set to '%NSIS_LOC%'.
REM EXIST won't find items in the PATH. WHERE will.
SET NSIS_VALID=0
IF EXIST %NSIS_LOC% SET NSIS_VALID=1
REM Prevents error message spam if it doesn't find it in PATH.
IF %NSIS_VALID% EQU 0 (
WHERE /Q %NSIS_LOC%
IF NOT ERRORLEVEL 1 SET NSIS_VALID=1
)
IF %NSIS_VALID% EQU 1 (
ECHO %current_activity%: NSIS_LOC exists.
) ELSE (
ECHO %current_activity%: NSIS_LOC directory does not exist. Exiting.
EXIT /B %exit_code_failure_build_locations%
)
ECHO %current_activity%: All required build environment values are set.
IF DEFINED BUILD_DEBUG (
ECHO %current_activity%: BUILD_DEBUG var set. NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS.
ECHO %current_activity%: NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS.
ECHO %current_activity%: NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS.
ECHO %current_activity%: NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS.
EXIT /B %exit_code_failure_build_apps%
)
ECHO %current_activity%: Running 7zip:
%ZIP_LOC% a %project_dir%\%output_dir%\AdvancedSettings.zip %project_dir%\%output_dir%\AdvancedSettings\*
ECHO %current_activity%: 7zip done.
ECHO %current_activity%: Running NSIS:
REM Trying to launch makensis without CD into the dir does not work for some reason.
CD %NSIS_LOC%
REM /V2 is show warnings and errors, /WX is treat warnings as errors.
makensis /V2 /WX %project_dir%\installer\installer.nsi
IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps%
ECHO %current_activity%: NSIS done.
CD %original_dir%
ECHO %current_activity%: %current_activity% DONE.
+28 -19
View File
@@ -1,25 +1,34 @@
echo on
@echo off
REM Echo off to avoid spam.
SET project_dir="%cd%"
REM Used for echos.
SET top_level_activity=MASTER
echo Set up environment...
set original_path=%PATH%
set PATH=%QT%\bin\;C:\Qt\Tools\QtCreator\bin\;C:\Qt\QtIFW2.0.1\bin\;C:\Program Files (x86)\NSIS\;%PATH%
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %PLATFORM%
REM If scripts are chain called the original dirs should not be overwritten.
cd "%project_dir%
echo Building AdvancedSettings...
qmake -spec win32-msvc CONFIG+=x86_64 CONFIG-=debug CONFIG+=release
nmake
SET original_dir=%CD%
echo Packaging...
mkdir %project_dir%\bin\win64\
cd %project_dir%\bin\win64\
windeployqt --dir AdvancedSettings\qtdata --libdir AdvancedSettings --plugindir AdvancedSettings\qtdata\plugins --no-system-d3d-compiler --no-opengl-sw --release --qmldir ..\..\src\res\qml\ AdvancedSettings\AdvancedSettings.exe
rd /s /q AdvancedSettings\moc\
rd /s /q AdvancedSettings\obj\
rd /s /q AdvancedSettings\qrc\
REM Arg 0 (called %0) is the full path to the file.
REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters
REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only.
SET folder_path=%~dp0
REM Project dir is up two dirs from the file.
SET project_dir=%folder_path%
set PATH=%original_path%
cd %project_dir%
ECHO %top_level_activity%: Calling build script.
CALL %project_dir%\build_scripts\win\build.cmd
IF ERRORLEVEL 1 EXIT /B 1
ECHO %top_level_activity%: Calling deployment script.
CALL %project_dir%\build_scripts\win\deploy.cmd
IF ERRORLEVEL 1 EXIT /B 1
ECHO %top_level_activity%: Calling packaging script.
CALL %project_dir%\build_scripts\win\package.cmd
IF ERRORLEVEL 1 EXIT /B 1
CD %original_dir%
ECHO %top_level_activity%: MASTER DONE.
+51 -6
View File
@@ -4,6 +4,8 @@
> * [Requirements](#requirements)
> * [Locations and Environment Variables](#locs_and_envs)
> * [Building](#features)
> * [Using with QtCreator](#qt_creator)
> * [Using with Visual Studio](#visual_studio)
<a name="requirements"></a>
## Requirements
@@ -14,21 +16,64 @@ For compiling:
2. Qt Framework (tested on 5.10 and 5.11)
Additionally, for fully building portable and installer release versions:
3. 7zip Command Line
3. 7zip
4. Nullsoft Scriptable Install System (NSIS)
<a name="locs_and_envs"></a>
## Locations and Environment Variables
Visual Studio must be installed in the default location of `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community`.
The following environmental variables are relevant for building the project.
The `QT` environment variable must be set to the location of your Qt installation (for example `C:\Qt\5.11.1\msvc2017_64`).
| Environment Variable | Purpose |
| -------------------- | ------------- |
| `QT_LOC` | Path to your Qt `\bin\` folder. |
| `VS_LOC` | Path to your Visual Studio `vcvarsall.bat` file. |
| `JOM_LOC` | Path to an `.exe` of `jom.exe`. Usually installed with Qt. `jom` is a wrapper around `nmake` allowing more threads to be used. It is not required, but using `nmake`is slower. If `JOM_LOC` isn't defined, or the `.exe` can't be found `nmake` will be used by default. |
| `ZIP_LOC` | Path to your 7zip `.exe`. Both portable and installer will work. |
| `NSIS_LOC` | Path to your installation of NSIS containing the `makensis` file. Both portable and installer will work. |
The `PLATFORM` environment variable must be set to `amd64`.
If an environment variable isn't set a default value will be provided. The default values are shown in the table below.
For building the portable and installer release versions, the locations of 7zip Command Line (`7z.exe`) and NSIS (`makensis.exe`) must be in the `PATH` environment variable.
| Environment Variable | Default Value |
| -------------------- | ------------- |
| `QT_LOC` | `"C:\Qt\5.11.1\msvc2017_64\bin\"` |
| `VS_LOC` | `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"` |
| `JOM_LOC` | `"C:\Qt\Tools\QtCreator\bin\jom.exe"`|
| `ZIP_LOC` | `"C:\Program Files\7-Zip\7z.exe"` |
| `NSIS_LOC` | `"C:\Program Files (x86)\NSIS\"` |
Additionally, these optional environment variables are supported.
| Environment Variable | Purpose |
| -------------------- | ------------- |
| `BUILD_DEBUG` | If set, a debug version will be built. The packaging script will not run with this var set. |
| `BUILD_VSPROJ` | If set, Visual Studio project files will be built. |
Remember that there's a difference between an unset variable and a variable set to an empty string. `SET BUILD_DEBUG=""` does not unset the variable. You need to write `SET BUILD_DEBUG=`.
The `.dll` files necessary for a release build differ from those needed by a debug build. Therefore you need to make sure you run all scripts with `BUILD_DEBUG` either defined or undefined, depending on your needs.
<a name="building"></a>
## Building
With the programs above installed and environment variables set, go into the root folder of the repository and first run `build_windows.cmd` and then `package.cmd`. Compiled binaries along with everything needed to run portable will output to `.\bin\win64\AdvancedSettings\`.
With the programs above installed and environment variables set, go into the root folder of the repository and run `build_windows.cmd`. Compiled binaries along with everything needed to run portable will output to `.\bin\win64\AdvancedSettings\`.
<a name="qt_creator"></a>
## Using with QtCreator
Run `build_windows.cmd` once and fully build (packaging not necessary) the application. Open the `.pro` file in Qt Creator. A build and toolchain option should be marked in Qt Creator, with all others unmarked. If it isn't, set the directory to be the root repo directory. You should now be able to compile and run in Qt Creator without issues.
Notice that you may need to redeploy library files if you make large changes (run `build_scripts\win\deploy.cmd`).
Additionally, you can set Qt Creator to run `build_scripts\win\deploy.cmd` on compilation in order to ensure that the correct libraries are present. Remember to set or unset `BUILD_DEBUG` depending on your needs.
<a name="visual_studio"></a>
## Using with Visual Studio
Run `build_windows.cmd` once and fully build (packaging not necessary) the application with the `BUILD_VSPROJ` environment variable set. Open the newly created project file. If you compiled a release build (`BUILD_DEBUG` not set) change the build type to release in Visual Studio. You should be able to compile and run with Visual Studio without issues.
Notice that any new files you add or compiler settings you change will not be backported to the `.pro` file. Hence it is necessary to manually change the `.pro` file.
Notice that you may need to redeploy library files if you make large changes (run `build_scripts\win\deploy.cmd`).
Additionally, you can set Visual Studio to run `build_scripts\win\deploy.cmd` on compilation in order to ensure that the correct libraries are present. Remember to set or unset `BUILD_DEBUG` depending on your needs.
-22
View File
@@ -1,22 +0,0 @@
echo on
SET project_dir="%cd%"
cd %project_dir%\bin\win64\
echo Copying project files for archival...
copy "%project_dir%\Readme.md" "AdvancedSettings\Readme.md"
copy "%project_dir%\LICENSE" "AdvancedSettings\LICENSE.txt"
xcopy /Y /E /I "%project_dir%\src\res" "AdvancedSettings\res\"
copy "%project_dir%\src\restartvrserver.bat" "AdvancedSettings\restartvrserver.bat"
copy "%project_dir%\src\startdesktopmode.bat" "AdvancedSettings\startdesktopmode.bat"
copy "%project_dir%\src\qt.conf" "AdvancedSettings\qt.conf"
copy "%project_dir%\src\manifest.vrmanifest" "AdvancedSettings\manifest.vrmanifest"
copy "%project_dir%\third-party\openvr\bin\win64\openvr_api.dll" "AdvancedSettings\openvr_api.dll"
echo Packaging portable archive...
7z a AdvancedSettings.zip AdvancedSettings
echo Creating installer...
cd %project_dir%/installer
makensis installer.nsi