Compare commits

...

2 Commits

Author SHA1 Message Date
Alibek Omarov
9cd456e414 ci: add wafcache to all targets that use Waf, except Android which uses generated CMakeLists instead 2025-01-13 20:24:45 +03:00
Alibek Omarov
4a7a5f0b8c wscript: add option to use wafcache 2025-01-13 20:02:59 +03:00
9 changed files with 48 additions and 12 deletions

View File

@@ -6,8 +6,21 @@ jobs:
# steps: # steps:
# - name: Cleanup # - name: Cleanup
# run: rm -rf .* || true # run: rm -rf .* || true
get_prev_runid:
runs-on: ubuntu-latest
outputs:
value: ${{ steps.do.outputs.value }}
steps:
- id: do
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
value=$(gh run -R ${{ github.repository }} list -b${{ github.ref_name }} -ssuccess -L1 --json databaseId -q'.[0].databaseId')
echo "Last run ID is $value"
echo "value=$value" >> "$GITHUB_OUTPUT"
build: build:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
needs: get_prev_runid
continue-on-error: true continue-on-error: true
strategy: strategy:
fail-fast: false fail-fast: false
@@ -69,11 +82,19 @@ jobs:
SDL_VERSION: 2.30.11 SDL_VERSION: 2.30.11
GH_CPU_ARCH: ${{ matrix.targetarch }} GH_CPU_ARCH: ${{ matrix.targetarch }}
GH_CROSSCOMPILING: ${{ matrix.cross }} GH_CROSSCOMPILING: ${{ matrix.cross }}
WAFCACHE: ${{ github.workspace }}/wafcache/
WAFCACHE_EVICT_MAX_BYTES: 1000000 # github only gives 10gb for the whole repository
WAFCACHE_STATS: 1 # enable statistics in build log
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Restore cache
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-${{ matrix.targetos }}-${{ matrix.targetarch }}-${{ needs.get_prev_runid.outputs.value }}
path: ${{ github.workspace }}/wafcache/
- name: Install dependencies - name: Install dependencies
run: bash scripts/gha/deps_${{ matrix.targetos }}.sh run: bash scripts/gha/deps_${{ matrix.targetos }}.sh
- name: Build engine - name: Build engine
@@ -85,6 +106,12 @@ jobs:
with: with:
name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }} name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }}
path: artifacts/* path: artifacts/*
- name: Save cache
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/wafcache/
key: ${{ runner.os }}-${{ matrix.targetos }}-${{ matrix.targetarch }}-${{ github.run_id }}
flatpak: flatpak:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:

View File

@@ -8,7 +8,7 @@ pushd hlsdk || die
./waf configure build install --destdir=../bin || die ./waf configure build install --destdir=../bin || die
popd popd
./waf configure --enable-utils --enable-tests --enable-lto build install --destdir=bin || die_configure ./waf configure --enable-utils --enable-tests --enable-lto --enable-wafcache build --zones=wafcache install --destdir=bin || die_configure
cp -vr /Library/Frameworks/SDL2.framework bin cp -vr /Library/Frameworks/SDL2.framework bin

View File

@@ -61,14 +61,14 @@ build_engine()
fi fi
if [ "$1" = "dedicated" ]; then if [ "$1" = "dedicated" ]; then
./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -d || die_configure ./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -d --enable-wafcache || die_configure
elif [ "$1" = "full" ]; then elif [ "$1" = "full" ]; then
./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -s SDL2_linux --enable-stb --enable-utils || die_configure ./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -s SDL2_linux --enable-stb --enable-utils --enable-wafcache || die_configure
else else
die die
fi fi
./waf build || die_configure ./waf build --zones=wafcache || die_configure
} }
deploy_engine() deploy_engine()

View File

@@ -12,7 +12,7 @@ pushd hlsdk || die
./waf configure -T fast --enable-magx --enable-simple-mod-hacks build install --destdir=../Xash || die ./waf configure -T fast --enable-magx --enable-simple-mod-hacks build install --destdir=../Xash || die
popd popd
./waf configure -T fast --enable-magx build install --destdir=Xash/ || die ./waf configure -T fast --enable-magx --enable-wafcache build install --destdir=Xash/ || die
cat > Xash/run.sh << 'EOF' cat > Xash/run.sh << 'EOF'
mypath=${0%/*} mypath=${0%/*}

View File

@@ -11,7 +11,7 @@ mkdir -p artifacts/ || die
echo "Running build script in Docker container..." echo "Running build script in Docker container..."
docker run --name xash-build --rm -v `pwd`:`pwd` -w `pwd` devkitpro/devkita64:latest bash ./scripts/gha/build_nswitch_docker.sh || die docker run --name xash-build --rm -v `pwd`:`pwd` -v $HOME/.cache:$HOME/.cache -w `pwd` devkitpro/devkita64:latest bash ./scripts/gha/build_nswitch_docker.sh || die
echo "Packaging artifacts..." echo "Packaging artifacts..."

View File

@@ -42,7 +42,7 @@ make -C libsolder install || die
echo "Building engine..." echo "Building engine..."
./waf configure -T release --nswitch || die_configure ./waf configure -T release --nswitch --enable-wafcache || die_configure
./waf build install --destdir=pkgtemp/xash3d -v || die ./waf build install --destdir=pkgtemp/xash3d -v || die
echo "Building HLSDK..." echo "Building HLSDK..."

View File

@@ -44,8 +44,8 @@ popd
echo "Building engine..." echo "Building engine..."
./waf configure -T release --psvita || die_configure ./waf configure -T release --psvita --enable-wafcache || die_configure
./waf build install --destdir=pkgtemp/data/xash3d -v || die ./waf build install --destdir=pkgtemp/data/xash3d || die
cp build/engine/xash.vpk pkgtemp/ cp build/engine/xash.vpk pkgtemp/
echo "Building HLSDK..." echo "Building HLSDK..."

View File

@@ -12,8 +12,8 @@ fi
# NOTE: to build with other version use --msvc_version during configuration # NOTE: to build with other version use --msvc_version during configuration
# NOTE: sometimes you may need to add WinSDK to %PATH% # NOTE: sometimes you may need to add WinSDK to %PATH%
# NOTE: --enable-msvcdeps only used for CI builds, enabling it non-English versions of MSVC causes useless console spam # NOTE: --enable-msvcdeps only used for CI builds, enabling it non-English versions of MSVC causes useless console spam
./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto --enable-msvcdeps $AMD64 || die_configure ./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto --enable-msvcdeps --enable-wafcache $AMD64 || die_configure
./waf.bat build || die ./waf.bat build --zones=wafcache || die
./waf.bat install --destdir=. || die ./waf.bat install --destdir=. || die
if [ "$ARCH" = "i386" ]; then if [ "$ARCH" = "i386" ]; then

11
wscript
View File

@@ -128,6 +128,9 @@ REFDLLS = [
def options(opt): def options(opt):
opt.load('reconfigure compiler_optimizations xshlib xcompile compiler_cxx compiler_c sdl2 clang_compilation_database strip_on_install waf_unit_test msdev msvs subproject cmake') opt.load('reconfigure compiler_optimizations xshlib xcompile compiler_cxx compiler_c sdl2 clang_compilation_database strip_on_install waf_unit_test msdev msvs subproject cmake')
opt.add_option('--enable-wafcache', action = 'store_false', dest = 'enable_gccdeps', default = True,
help = 'enable usage of wafcache tool, disables gccdeps')
grp = opt.add_option_group('Common options') grp = opt.add_option_group('Common options')
grp.add_option('-d', '--dedicated', action = 'store_true', dest = 'DEDICATED', default = False, grp.add_option('-d', '--dedicated', action = 'store_true', dest = 'DEDICATED', default = False,
@@ -204,6 +207,9 @@ def configure(conf):
if conf.options.MSVCDEPS: if conf.options.MSVCDEPS:
conf.load('msvcdeps') conf.load('msvcdeps')
if not conf.options.enable_gccdeps:
conf.env.ENABLE_WAFCACHE = True
if conf.options.NSWITCH: if conf.options.NSWITCH:
conf.load('nswitch') conf.load('nswitch')
@@ -217,7 +223,7 @@ def configure(conf):
if conf.env.COMPILER_CC == 'msvc': if conf.env.COMPILER_CC == 'msvc':
conf.load('msvc_pdb') conf.load('msvc_pdb')
conf.load('msvs msdev subproject clang_compilation_database strip_on_install waf_unit_test enforce_pic cmake force_32bit') conf.load('msvs msdev subproject clang_compilation_database strip_on_install waf_unit_test enforce_pic force_32bit')
if conf.env.MSVC_TARGETS[0] == 'amd64_x86' or conf.env.MSVC_TARGETS[0] == 'x86': if conf.env.MSVC_TARGETS[0] == 'amd64_x86' or conf.env.MSVC_TARGETS[0] == 'x86':
conf.env.MSVC_SUBSYSTEM = 'WINDOWS,5.01' conf.env.MSVC_SUBSYSTEM = 'WINDOWS,5.01'
@@ -503,6 +509,9 @@ int main(void) { return (int)BZ2_bzlibVersion(); }'''
conf.add_subproject(i.name) conf.add_subproject(i.name)
def build(bld): def build(bld):
if bld.env.ENABLE_WAFCACHE:
bld.load('wafcache')
# guard rails to not let install to root # guard rails to not let install to root
if bld.is_install and not bld.options.PACKAGING and not bld.options.destdir: if bld.is_install and not bld.options.PACKAGING and not bld.options.destdir:
bld.fatal('Set the install destination directory using --destdir option') bld.fatal('Set the install destination directory using --destdir option')