Skip to content

Commit c3683fa

Browse files
committed
CI: Update to use vcpkg
1 parent fe8516d commit c3683fa

File tree

6 files changed

+132
-32
lines changed

6 files changed

+132
-32
lines changed

.github/workflows/main.yml

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,25 @@ on:
1414

1515
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1616
jobs:
17-
# This workflow contains a single job called "build"
1817
build:
1918
strategy:
2019
matrix:
21-
runs-on: [windows-2019, ubuntu-20.04]
20+
os:
21+
- runs-on: windows-2019
22+
vcpkg-triplet: x86-windows-static
23+
preset: ci-windows
24+
- runs-on: ubuntu-20.04
25+
vcpkg-triplet: x86-linux
26+
preset: ci-linux
2227
target: [client, server]
2328

2429
# The type of runner that the job will run on
25-
runs-on: ${{ matrix.runs-on }}
30+
runs-on: ${{ matrix.os.runs-on }}
31+
32+
env:
33+
VCPKG_ROOT: '${{github.workspace}}/vcpkg'
34+
VCPKG_DEFAULT_TRIPLET: '${{ matrix.os.vcpkg-triplet }}'
35+
VCPKG_DEFAULT_HOST_TRIPLET: '${{ matrix.os.vcpkg-triplet }}'
2636

2737
# Steps represent a sequence of tasks that will be executed as part of the job
2838
steps:
@@ -32,30 +42,46 @@ jobs:
3242
submodules: recursive
3343
fetch-depth: 0 # Required for automatic versioning
3444

35-
- name: Set up Python
36-
uses: actions/setup-python@v5
37-
with:
38-
python-version: 3.8
39-
4045
- name: Install Ubuntu packages
41-
if: matrix.runs-on == 'ubuntu-20.04'
46+
if: matrix.os.runs-on == 'ubuntu-20.04'
4247
run: |
4348
sudo dpkg --add-architecture i386
4449
sudo apt update || true
4550
sudo apt install -y libc6:i386 ninja-build gcc-9-multilib g++-9-multilib libssl1.1:i386 libssl-dev:i386 zlib1g-dev:i386
4651
47-
- name: Build release
48-
id: build
49-
run: |
50-
python ./scripts/BuildRelease.py --target ${{ matrix.target }} --build-type release --vs 2019 --toolset v141_xp --linux-compiler gcc-9 --out-dir ./_build_out --cmake-args="-DWARNINGS_ARE_ERRORS=ON" --github-actions
52+
# Restore artifacts, or setup vcpkg for building artifacts
53+
- name: Set up vcpkg
54+
uses: lukka/run-vcpkg@v11
55+
id: runvcpkg
56+
with:
57+
vcpkgJsonGlob: 'vcpkg.json'
58+
vcpkgDirectory: '${{env.VCPKG_ROOT}}'
59+
vcpkgGitCommitId: 'ef7dbf94b9198bc58f45951adcf1f041fcbc5ea0'
60+
runVcpkgInstall: false
61+
62+
# Run CMake+vcpkg+Ninja+CTest to generate/build/test.
63+
- name: Build and Test with CMake
64+
uses: lukka/run-cmake@v10
65+
id: runcmake
66+
with:
67+
configurePreset: '${{ matrix.os.preset }}'
68+
buildPreset: '${{ matrix.os.preset }}'
69+
buildPresetAdditionalArgs: "['--target', '${{ matrix.target }}', 'test_${{ matrix.target }}']"
70+
testPreset: '${{ matrix.os.preset }}'
71+
testPresetAdditionalArgs: "['-R', '${{ matrix.target }}']"
72+
env:
73+
VCPKG_FORCE_SYSTEM_BINARIES: 1
5174

52-
- name: Run tests
75+
# Install
76+
- name: Install with CMake
5377
run: |
54-
cd ./_build_out/build
55-
ctest -R ${{ matrix.target }} --build-config RelWithDebInfo --output-on-failure
78+
cd ${{github.workspace}}/_build/${{ matrix.os.preset }}
79+
cmake --install . --prefix ${{github.workspace}}/_build/ci-install --component ${{ matrix.target }}
5680
81+
# Upload result
5782
- name: Upload build result
5883
uses: actions/upload-artifact@v4
5984
with:
60-
name: ${{ steps.build.outputs.artifact_name }}
61-
path: ./_build_out/BugfixedHL-*.zip
85+
name: bhl-cmake-install
86+
path: ${{github.workspace}}/_build/ci-install
87+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ CMakeUserPresets.json
1111
# Ignore .vscode but allow examples
1212
.vscode/*
1313
!.vscode/**/*.example.*
14+
15+
# CI stuff
16+
/vcpkg

CMakeLists.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,17 @@ endif()
333333
# Libraries
334334
#-----------------------------------------------------------------
335335
set( THREADS_PREFER_PTHREAD_FLAG ON )
336-
find_package( Threads REQUIRED )
337336
find_package( nlohmann_json CONFIG REQUIRED )
338-
find_package( unofficial-pcre CONFIG REQUIRED )
339337
find_package( Python 3.8...<4.0 COMPONENTS Interpreter )
338+
find_package( Threads REQUIRED )
339+
find_package( unofficial-pcre CONFIG REQUIRED )
340340

341341
include( cmake/lib/SDL2.cmake )
342342

343343
add_subdirectory( external )
344344

345345
if( WIN32 )
346+
find_package( stackwalker CONFIG REQUIRED )
346347
include( cmake/lib/DInput.cmake )
347348
endif()
348349

@@ -387,13 +388,6 @@ set( GAME_COMMON_INCLUDE_PATHS
387388
${CMAKE_CURRENT_SOURCE_DIR}/src/pm_shared
388389
)
389390

390-
# Disable PCH for common sources because includes are a mess there
391-
set_source_files_properties(
392-
${GAME_COMMON_SRCS}
393-
PROPERTIES
394-
SKIP_PRECOMPILE_HEADERS ON
395-
)
396-
397391
#-----------------------------------------------------------------
398392
# Source SDK
399393
#-----------------------------------------------------------------
@@ -442,3 +436,14 @@ add_subdirectory( src/game/client )
442436
add_subdirectory( src/game/server )
443437
add_subdirectory( src/tests )
444438
add_subdirectory( gamedir )
439+
440+
# Disable PCH for common sources because includes are a mess there
441+
set_source_files_properties(
442+
${GAME_COMMON_SRCS}
443+
TARGET_DIRECTORY
444+
client
445+
server
446+
bugfixedapi_amxx
447+
PROPERTIES
448+
SKIP_PRECOMPILE_HEADERS ON
449+
)

CMakePresets.json

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"configurePresets": [
44
{
55
"name": "default",
6-
"binaryDir": "${sourceDir}/_build",
6+
"binaryDir": "${sourceDir}/_build/${presetName}",
77
"hidden": true,
88
"cacheVariables": {
99
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
@@ -13,17 +13,83 @@
1313
"GNU_FORCE_COLORED_OUTPUT": true
1414
}
1515
},
16+
{
17+
"name": "vcpkg-windows",
18+
"inherits": ["default"],
19+
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
20+
"generator": "Ninja",
21+
"cacheVariables": {
22+
"CMAKE_BUILD_TYPE": "Debug",
23+
"VCPKG_HOST_TRIPLET": "x86-windows-static",
24+
"VCPKG_TARGET_TRIPLET": "x86-windows-static"
25+
}
26+
},
1627
{
1728
"name": "vcpkg-linux",
1829
"inherits": ["default"],
19-
"toolchainFile": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
30+
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
2031
"generator": "Ninja",
2132
"cacheVariables": {
2233
"CMAKE_BUILD_TYPE": "Debug",
2334
"VCPKG_HOST_TRIPLET": "x86-linux",
2435
"VCPKG_TARGET_TRIPLET": "x86-linux",
2536
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/cmake/toolchains/linux-gcc.cmake"
2637
}
38+
},
39+
{
40+
"name": "ci-base",
41+
"hidden": true,
42+
"cacheVariables": {
43+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
44+
"BUILD_TESTING": true,
45+
"GNU_FORCE_COLORED_OUTPUT": false,
46+
"USE_UPDATER": true,
47+
"WARNINGS_ARE_ERRORS": true
48+
}
49+
},
50+
{
51+
"name": "ci-windows",
52+
"inherits": ["vcpkg-windows", "ci-base"]
53+
},
54+
{
55+
"name": "ci-linux",
56+
"inherits": ["vcpkg-linux", "ci-base"]
57+
}
58+
],
59+
"buildPresets": [
60+
{
61+
"name": "ci-base",
62+
"hidden": true,
63+
"inheritConfigureEnvironment": true
64+
},
65+
{
66+
"name": "ci-windows",
67+
"inherits": ["ci-base"],
68+
"configurePreset": "ci-windows"
69+
},
70+
{
71+
"name": "ci-linux",
72+
"inherits": ["ci-base"],
73+
"configurePreset": "ci-linux"
74+
}
75+
],
76+
"testPresets": [
77+
{
78+
"name": "ci-base",
79+
"hidden": true,
80+
"output": {
81+
"outputOnFailure": true
82+
}
83+
},
84+
{
85+
"name": "ci-windows",
86+
"inherits": ["ci-base"],
87+
"configurePreset": "ci-windows"
88+
},
89+
{
90+
"name": "ci-linux",
91+
"inherits": ["ci-base"],
92+
"configurePreset": "ci-linux"
2793
}
2894
]
2995
}

cmake/lib/DInput.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ block()
1313

1414
# DXGUID
1515
add_library( DXGUID SHARED IMPORTED GLOBAL )
16-
set_property( TARGET DInput PROPERTY IMPORTED_IMPLIB ${lib_dir}/lib/dxguid.lib )
16+
set_property( TARGET DXGUID PROPERTY IMPORTED_IMPLIB ${lib_dir}/lib/dxguid.lib )
1717
endblock()

src/game/client/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@ if( WIN32 )
324324
DInput
325325
DXGUID
326326
Dbghelp
327-
StackWalker::StackWalker
327+
unofficial::stackwalker::StackWalker
328328
)
329329

330330
target_include_directories( client PRIVATE
331-
${CMAKE_CURRENT_SOURCE_DIR}/external/SDL2/include
331+
${CMAKE_SOURCE_DIR}/external/SDL2/include
332332
)
333333
else()
334334
# Only link with SDL2 on Linux. Windows will conditionally link in runtime.

0 commit comments

Comments
 (0)