| 1 |
/* Copyright (C) 2025 Wildfire Games. |
| 2 |
* This file is part of 0 A.D. |
| 3 |
* |
| 4 |
* 0 A.D. is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation, either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* 0 A.D. is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
// This pipeline builds the game on Windows (with the Visual Studio 2022 / 17.x compiler) and runs tests. |
| 19 |
|
| 20 |
def visualStudioPath = 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe' |
| 21 |
def buildOptions = '/p:PlatformToolset=v143 /t:pyrogenesis /t:AtlasUI /t:test /nologo -clp:NoSummary' |
| 22 |
|
| 23 |
def getHOSTTYPE(String arch) { |
| 24 |
return arch == 'win64' ? 'amd64' : 'x86' |
| 25 |
} |
| 26 |
|
| 27 |
def getParserConfig(String arch, String buildType) { |
| 28 |
def config |
| 29 |
if (arch.startsWith('win32')) { |
| 30 |
config = [ 'name': 'Win32', 'id': 'win32' + buildType] |
| 31 |
} else { |
| 32 |
config = [ 'name': 'Win64', 'id': 'win64' + buildType ] |
| 33 |
} |
| 34 |
if (buildType.matches('Debug')) { |
| 35 |
config['name'] += ' Debug Build' |
| 36 |
} else { |
| 37 |
config['name'] += ' Release Build' |
| 38 |
} |
| 39 |
return config |
| 40 |
} |
| 41 |
|
| 42 |
pipeline { |
| 43 |
// Stop previous build in pull requests, but not in branches |
| 44 |
options { disableConcurrentBuilds(abortPrevious: env.CHANGE_ID != null) } |
| 45 |
|
| 46 |
parameters { |
| 47 |
booleanParam description: 'Non-incremental build', name: 'CLEANBUILD' |
| 48 |
} |
| 49 |
|
| 50 |
agent none |
| 51 |
|
| 52 |
stages { |
| 53 |
stage('Windows Build') { |
| 54 |
matrix { |
| 55 |
axes { |
| 56 |
axis { |
| 57 |
name 'ARCH' |
| 58 |
values 'win32', 'win64' |
| 59 |
} |
| 60 |
axis { |
| 61 |
name 'BUILD_TYPE' |
| 62 |
values 'Debug', 'Release' |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
environment { |
| 67 |
HOSTTYPE = getHOSTTYPE(env.ARCH) |
| 68 |
} |
| 69 |
|
| 70 |
stages { |
| 71 |
stage('Matrix run') { |
| 72 |
agent { |
| 73 |
node { |
| 74 |
label 'WindowsAgent' |
| 75 |
// Share workspace for different build types as the precompiled libs |
| 76 |
// are only seperated by arch. |
| 77 |
customWorkspace "workspace/${ARCH}-pch" |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
stages { |
| 82 |
stage('Pre-build') { |
| 83 |
steps { |
| 84 |
bat 'git lfs pull -I binaries/data/tests' |
| 85 |
bat 'git lfs pull -I "binaries/data/mods/_test.*"' |
| 86 |
|
| 87 |
script { |
| 88 |
if (env.ARCH.startsWith('win64')) { |
| 89 |
bat 'cd libraries && get-windows-libs.bat --amd64' |
| 90 |
} else { |
| 91 |
bat 'cd libraries && get-windows-libs.bat' |
| 92 |
} |
| 93 |
} |
| 94 |
bat "(robocopy /MIR /NDL /NJH /NJS /NP /NS /NC E:\\wxWidgets-3.2.8\\lib libraries\\${ARCH}\\wxwidgets\\lib) ^& IF %ERRORLEVEL% LEQ 1 exit 0" |
| 95 |
bat "(robocopy /MIR /NDL /NJH /NJS /NP /NS /NC E:\\wxWidgets-3.2.8\\include libraries\\${ARCH}\\wxwidgets\\include) ^& IF %ERRORLEVEL% LEQ 1 exit 0" |
| 96 |
bat 'cd build\\workspaces && update-workspaces.bat' |
| 97 |
|
| 98 |
script { |
| 99 |
if (params.CLEANBUILD) { |
| 100 |
bat "cd build\\workspaces\\vs2022 && \"${visualStudioPath}\" pyrogenesis.sln /p:Configuration=Debug /t:Clean" |
| 101 |
bat "cd build\\workspaces\\vs2022 && \"${visualStudioPath}\" pyrogenesis.sln /p:Configuration=Release /t:Clean" |
| 102 |
} |
| 103 |
} |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
stage('Build') { |
| 108 |
steps { |
| 109 |
powershell """ |
| 110 |
cd build\\workspaces\\vs2022 |
| 111 |
& \"${visualStudioPath}\" pyrogenesis.sln /p:Configuration=${BUILD_TYPE} ${buildOptions} \$env:JOBS 2>&1 | Tee-Object -FilePath ${BUILD_TYPE}-build.log |
| 112 |
""" |
| 113 |
} |
| 114 |
post { |
| 115 |
failure { |
| 116 |
script { |
| 117 |
if (!params.CLEANBUILD) { |
| 118 |
build wait: false, job: "$JOB_NAME", parameters: [booleanParam(name: 'CLEANBUILD', value: true)] |
| 119 |
} |
| 120 |
} |
| 121 |
} |
| 122 |
always { |
| 123 |
script { |
| 124 |
def config = getParserConfig(env.ARCH, env.BUILD_TYPE) |
| 125 |
recordIssues( |
| 126 |
tool: analysisParser( |
| 127 |
analysisModelId: 'msbuild', |
| 128 |
name: config['name'], |
| 129 |
id : config['id'], |
| 130 |
pattern: "build\\workspaces\\vs2022\\${BUILD_TYPE}-build.log" |
| 131 |
), |
| 132 |
skipPublishingChecks: true, |
| 133 |
enabledForFailure: true, |
| 134 |
qualityGates: [[threshold: 1, type: 'TOTAL', criticality: 'FAILURE']] |
| 135 |
) |
| 136 |
} |
| 137 |
} |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
stage('Test') { |
| 142 |
steps { |
| 143 |
timeout(time: 15) { |
| 144 |
script { |
| 145 |
def bin = env.BUILD_TYPE == 'Debug' ? 'test_dbg' : 'test' |
| 146 |
bat "cd binaries\\system && ${bin}.exe --format junit --output cxxtest.xml" |
| 147 |
} |
| 148 |
} |
| 149 |
} |
| 150 |
post { |
| 151 |
always { |
| 152 |
junit(skipPublishingChecks: true, testResults: 'binaries/system/cxxtest.xml') |
| 153 |
} |
| 154 |
} |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
} |
| 159 |
} |
| 160 |
} |
| 161 |
} |
| 162 |
} |