Add a script to build spir-v shaders for the bundle.

Fixes: #6636
Refs: #6718
Discussed with: @vladislavbelov

Differential Revision: https://code.wildfiregames.com/D4988
This was SVN commit r27633.
This commit is contained in:
Stan 2023-05-08 14:25:23 +00:00
parent 7cd980f2e1
commit d8b1935493
2 changed files with 62 additions and 24 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2023 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -24,12 +24,13 @@ pipeline {
}
parameters {
string(name: 'BUNDLE_VERSION', defaultValue: '0.0.26dev', description: 'Bundle Version')
string(name: 'SVN_REV', defaultValue: 'HEAD', description: 'For instance 21000')
string(name: 'BUNDLE_VERSION', defaultValue: '0.0.27dev', description: 'Bundle Version')
string(name: 'ENGINE_VERSION', defaultValue: '0.0.27', description: 'Engine Version')
booleanParam(name: 'ONLY_MOD', defaultValue: true, description: 'Only archive the mod mod.')
booleanParam(name: 'DO_GZIP', defaultValue: true, description: 'Create .gz unix tarballs as well as .xz')
booleanParam(name: 'FULL_REBUILD', defaultValue: true, description: 'Do a full rebuild (safer for release, slower).')
booleanParam(name: 'WINDOWS_UNIX', defaultValue: true, description: 'Build windows and unix bundles.')
booleanParam(name: 'BUILD_SHADERS', defaultValue: true, description: 'Build the spir-v shaders (very slow).')
}
stages {
@ -65,7 +66,7 @@ pipeline {
}
stage("Create archive data") {
steps {
sh "JOBS=\"-j\$(sysctl -n hw.ncpu)\" ONLY_MOD=${params.ONLY_MOD} source/tools/dist/build-archives.sh"
sh "JOBS=\"-j\$(sysctl -n hw.ncpu)\" ONLY_MOD=${params.ONLY_MOD} BUILD_SHADERS=${params.BUILD_SHADERS} ENGINE_VERSION=${params.ENGINE_VERSION} source/tools/dist/build-archives.sh"
}
}
stage("Create Mac Bundle") {

View File

@ -38,9 +38,46 @@ else
fi
popd > /dev/null
BUILD_SHADERS="${BUILD_SHADERS:=true}"
if [ "${BUILD_SHADERS}" = true ]; then
PYTHON=${PYTHON:=$(command -v python3 || command -v python)}
GLSLC=${GLSLC:=$(command -v glslc)}
SPIRV_REFLECT=${SPIRV_REFLECT:=$(command -v spirv-reflect)}
[ -n "${PYTHON}" ] || die "Error: python is not available. Install it before proceeding."
[ -n "${GLSLC}" ] || die "Error: glslc is not available. Install it with the Vulkan SDK before proceeding."
[ -n "${SPIRV_REFLECT}" ] || die "Error: spirv-reflect is not available. Install it with the Vulkan SDK before proceeding."
pushd "source/tools/spirv" > /dev/null
ENGINE_VERSION=${ENGINE_VERSION:="0.0.xx"}
rulesFile="rules.${ENGINE_VERSION}.json"
if [ ! -e "$rulesFile" ]
then
# The rules.json file should be present in release tarballs, for
# some Linux CIs don't have access to the internet.
download="$(command -v wget || echo "curl -sLo ""${rulesFile}""")"
$download "https://releases.wildfiregames.com/spir-v/$rulesFile"
fi
for modname in $archives
do
modLocation="../../../binaries/data/mods/${modname}"
if [ -e "${modLocation}/shaders/spirv/" ]
then
echo "Removing existing spirv shaders for '${modname}'..."
rm -rf "${modLocation}/shaders/spirv"
fi
echo "Building shader for '${modname}'..."
$PYTHON compile.py "$modLocation" "$rulesFile" "$modLocation" --dependency "../../../binaries/data/mods/mod/"
done
popd > /dev/null
fi
for modname in $archives
do
echo "\nBuilding archive for '${modname}'\n"
echo "Building archive for '${modname}'..."
ARCHIVEBUILD_INPUT="binaries/data/mods/${modname}"
ARCHIVEBUILD_OUTPUT="archives/${modname}"