Skip to content

Commit ea21b68

Browse files
committed
CI: Merge AMXX offsets
1 parent 14b895a commit ea21b68

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

.github/workflows/main.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ jobs:
106106
target: [client, server]
107107
runs-on: ubuntu-latest
108108

109+
env:
110+
# Must also be updated in src/game/server/CMakeLists.txt
111+
AMXX_OFFSET_GENERATOR_VERSION: "1.0.0"
112+
109113
steps:
110114
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
111115
- uses: actions/checkout@v4
@@ -119,6 +123,26 @@ jobs:
119123
pattern: "*-${{ matrix.target }}-ci-*"
120124
merge-multiple: true
121125

126+
# Download amxx-offset-generator
127+
- name: Download amxx-offset-generator
128+
run: |
129+
mkdir -p ${{github.workspace}}/_build/_amxx
130+
cd ${{github.workspace}}/_build/_amxx
131+
curl -L --output amxx-offset-generator.zip https://github.com/tmp64/amxx-offset-generator/releases/download/v${AMXX_OFFSET_GENERATOR_VERSION}/amxx-offset-generator-v${AMXX_OFFSET_GENERATOR_VERSION}.zip
132+
unzip amxx-offset-generator.zip -d .
133+
134+
# Generate new AMXX offsets
135+
- name: Generate AMXX offsets
136+
if: matrix.target == 'server'
137+
run: >
138+
python
139+
${{github.workspace}}/_build/_amxx/amxx-offset-generator-v${AMXX_OFFSET_GENERATOR_VERSION}/create_amxx_files.py
140+
--windows $(find ${{github.workspace}}/_build/ci-artifacts -name "bhl-amxx-offsets-windows.json" -print -quit)
141+
--linux $(find ${{github.workspace}}/_build/ci-artifacts -name "bhl-amxx-offsets-linux.json" -print -quit)
142+
--out $${{github.workspace}}/_build/ci-artifacts/bhl-${{ matrix.target }}-allow-missing-amxx-offsets/valve_addon/addons/amxmodx/data/gamedata/common.games/custom
143+
--banner "BugfixedHL-Rebased offset file. Generated using amxx-offset-generator."
144+
--file-prefix "bhl"
145+
122146
# Merge them
123147
- name: Merge artifacts
124148
id: merge_artifacts
@@ -127,6 +151,7 @@ jobs:
127151
--artifact-dir ${{github.workspace}}/_build/ci-artifacts
128152
--out-dir ${{github.workspace}}/_build/ci-out-artifact
129153
--target ${{ matrix.target }}
154+
allow-missing-amxx-offsets
130155
ci-linux
131156
ci-windows
132157

CMakePresets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
},
5252
{
5353
"name": "ci-windows",
54-
"inherits": ["vcpkg-windows", "ci-base"]
54+
"inherits": ["ci-base", "vcpkg-windows"]
5555
},
5656
{
5757
"name": "ci-linux",
58-
"inherits": ["vcpkg-linux", "ci-base"]
58+
"inherits": ["ci-base", "vcpkg-linux"]
5959
}
6060
],
6161
"buildPresets": [

scripts/merge_artifacts.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ def main():
3333
artifacts_with_suffix = list(artifact_dir.glob(f'*{name_suffix}', case_sensitive=True))
3434

3535
if len(artifacts_with_suffix) == 0:
36-
raise Exception(f'No artifacts found for suffix = {suffix}')
36+
if suffix.startswith('allow-missing'):
37+
continue
38+
else:
39+
raise Exception(f'No artifacts found for suffix = {suffix}')
3740

3841
if len(artifacts_with_suffix) > 1:
3942
print('Found too many artifacts:')

src/game/server/CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ set_target_properties( ${TARGET_NAME} PROPERTIES PREFIX "" )
219219
set_target_properties( ${TARGET_NAME} PROPERTIES OUTPUT_NAME "hl" )
220220

221221
if( GENERATE_AMXX_OFFSETS )
222+
# Must also be updated in .github/workflows/main.yml
222223
set( AMXX_OFFSET_GENERATOR_VERSION "1.0.0" )
224+
223225
set( AMXX_OFFSET_GENERATOR_DIR "${CMAKE_BINARY_DIR}/amxx-offset-generator" )
224226
set( AMXX_OFFSETS_SCRIPT "${AMXX_OFFSET_GENERATOR_DIR}/create_amxx_files.py" )
225227
set( AMXX_OFFSETS_CLASS_LIST "${CMAKE_CURRENT_SOURCE_DIR}/AmxxOffsetClassList.txt" )
@@ -238,15 +240,6 @@ if( GENERATE_AMXX_OFFSETS )
238240
set( AMXX_OFFSETS_DBG_FILE_ARG --so )
239241
set( AMXX_OFFSETS_JSON "${CMAKE_BINARY_DIR}/bhl-amxx-offsets-linux.json" )
240242
set( AMXX_OFFSETS_SCRIPT_ARG "--linux=${AMXX_OFFSETS_JSON}" )
241-
242-
# File doesn't have +x set in the ZIP. Fix that.
243-
file(
244-
CHMOD ${AMXX_OFFSETS_EXEC}
245-
PERMISSIONS
246-
OWNER_READ OWNER_WRITE OWNER_EXECUTE
247-
GROUP_WRITE GROUP_EXECUTE
248-
WORLD_READ WORLD_EXECUTE
249-
)
250243
else()
251244
message( FATAL_ERROR "GENERATE_AMXX_OFFSETS is not supported on this platform" )
252245
endif()
@@ -261,6 +254,17 @@ if( GENERATE_AMXX_OFFSETS )
261254

262255
FetchContent_MakeAvailable( amxx-offset-generator )
263256

257+
if( PLATFORM_LINUX )
258+
# File doesn't have +x set in the ZIP. Fix that.
259+
file(
260+
CHMOD ${AMXX_OFFSETS_EXEC}
261+
PERMISSIONS
262+
OWNER_READ OWNER_WRITE OWNER_EXECUTE
263+
GROUP_WRITE GROUP_EXECUTE
264+
WORLD_READ WORLD_EXECUTE
265+
)
266+
endif()
267+
264268
# Add command to generate the JSON file and the offset files
265269
add_custom_command(
266270
TARGET server POST_BUILD

0 commit comments

Comments
 (0)