Skip to content

Commit cb9083b

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

File tree

7 files changed

+75
-28
lines changed

7 files changed

+75
-28
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.1"
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": [

cmake/InstallAmxxOffsets.cmake

Lines changed: 0 additions & 13 deletions
This file was deleted.

cmake/InstallAmxxOffsets.cmake.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Set the binary dir path from configure_file
2+
set( ACTUAL_BINARY_DIR "@CMAKE_BINARY_DIR@" )
3+
4+
# Glob all offset files
5+
file(
6+
GLOB offset_files
7+
LIST_DIRECTORIES false
8+
"${ACTUAL_BINARY_DIR}/amxx-offsets/*.txt"
9+
"${ACTUAL_BINARY_DIR}/bhl-amxx-offsets-*.json"
10+
)
11+
12+
if( NOT offset_files )
13+
message( FATAL_ERROR "Offset files not found" )
14+
endif()
15+
16+
# Install them
17+
file(
18+
INSTALL ${offset_files}
19+
DESTINATION "${CMAKE_INSTALL_PREFIX}/addons/amxmodx/data/gamedata/common.games/custom"
20+
)

gamedir/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,16 @@ bhl_install_target( server server "dlls" )
162162
bhl_install_target( server bugfixedapi_amxx "addons/amxmodx/modules" )
163163

164164
if( GENERATE_AMXX_OFFSETS )
165+
# Generate the install script
166+
configure_file(
167+
${CMAKE_SOURCE_DIR}/cmake/InstallAmxxOffsets.cmake.in
168+
${CMAKE_CURRENT_BINARY_DIR}/InstallAmxxOffsets.cmake
169+
@ONLY
170+
)
171+
165172
# Install offset files
166173
install(
167-
SCRIPT ${CMAKE_SOURCE_DIR}/cmake/InstallAmxxOffsets.cmake
174+
SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/InstallAmxxOffsets.cmake
168175
COMPONENT server
169176
)
170177
endif()

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: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ set_target_properties( ${TARGET_NAME} PROPERTIES PREFIX "" )
219219
set_target_properties( ${TARGET_NAME} PROPERTIES OUTPUT_NAME "hl" )
220220

221221
if( GENERATE_AMXX_OFFSETS )
222-
set( AMXX_OFFSET_GENERATOR_VERSION "1.0.0" )
222+
# Must also be updated in .github/workflows/main.yml
223+
# Must also change URL_HASH
224+
set( AMXX_OFFSET_GENERATOR_VERSION "1.0.1" )
225+
223226
set( AMXX_OFFSET_GENERATOR_DIR "${CMAKE_BINARY_DIR}/amxx-offset-generator" )
224227
set( AMXX_OFFSETS_SCRIPT "${AMXX_OFFSET_GENERATOR_DIR}/create_amxx_files.py" )
225228
set( AMXX_OFFSETS_CLASS_LIST "${CMAKE_CURRENT_SOURCE_DIR}/AmxxOffsetClassList.txt" )
@@ -238,15 +241,6 @@ if( GENERATE_AMXX_OFFSETS )
238241
set( AMXX_OFFSETS_DBG_FILE_ARG --so )
239242
set( AMXX_OFFSETS_JSON "${CMAKE_BINARY_DIR}/bhl-amxx-offsets-linux.json" )
240243
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-
)
250244
else()
251245
message( FATAL_ERROR "GENERATE_AMXX_OFFSETS is not supported on this platform" )
252246
endif()
@@ -255,12 +249,23 @@ if( GENERATE_AMXX_OFFSETS )
255249
FetchContent_Declare(
256250
amxx-offset-generator
257251
URL https://github.com/tmp64/amxx-offset-generator/releases/download/v${AMXX_OFFSET_GENERATOR_VERSION}/amxx-offset-generator-v${AMXX_OFFSET_GENERATOR_VERSION}.zip
258-
URL_HASH SHA256=a2e26ea8b94162f505f430094b26eb114fa446f2955db3396394e6c3702e6d50
252+
URL_HASH SHA256=8fb1b0dd311cdbade408621bad66bf58c2e3472a8c68d3126a5b7b1b26c6da8e
259253
SOURCE_DIR ${AMXX_OFFSET_GENERATOR_DIR}
260254
)
261255

262256
FetchContent_MakeAvailable( amxx-offset-generator )
263257

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

0 commit comments

Comments
 (0)