Skip to content

Commit 8f82989

Browse files
authored
Merge pull request #1234 from openmultiplayer/amir/macos-fix
macos fix, add macos ci, fix conan cache for conan 2
2 parents 7a07256 + fc57257 commit 8f82989

5 files changed

Lines changed: 179 additions & 64 deletions

File tree

.github/workflows/build.yml

Lines changed: 169 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- name: Setup Python
5959
uses: actions/setup-python@v4
6060
with:
61-
python-version: '3.10'
61+
python-version: "3.10"
6262

6363
- name: Install CMake
6464
uses: lukka/get-cmake@latest
@@ -76,7 +76,7 @@ jobs:
7676
env:
7777
cache-name: cache-conan-modules
7878
with:
79-
path: ~/.conan/data
79+
path: ~/.conan2/p
8080
key: conan-windows-${{ matrix.arch }}-${{ hashFiles('CMakeLists.txt', 'lib/CMakeLists.txt', 'SDK/CMakeLists.txt', 'SDK/lib/cmake-conan/conan.cmake', 'SDK/lib/cmake-conan/conan-omp.cmake') }}
8181

8282
- name: Generate build files
@@ -93,7 +93,7 @@ jobs:
9393
env:
9494
cache-name: cache-conan-modules
9595
with:
96-
path: ~/.conan/data
96+
path: ~/.conan2/p
9797
key: ${{ steps.conan-cache-restore.outputs.cache-primary-key }}
9898

9999
- name: Build
@@ -161,7 +161,7 @@ jobs:
161161
env:
162162
cache-name: cache-conan-modules
163163
with:
164-
path: docker/conan/data
164+
path: docker/conan2/p
165165
key: conan-linux-${{ matrix.arch }}-${{ matrix.ssl }}-${{ hashFiles('CMakeLists.txt', 'lib/CMakeLists.txt', 'SDK/CMakeLists.txt', 'SDK/lib/cmake-conan/conan.cmake', 'SDK/lib/cmake-conan/conan-omp.cmake') }}
166166

167167
- name: Build
@@ -175,7 +175,7 @@ jobs:
175175
env:
176176
cache-name: cache-conan-modules
177177
with:
178-
path: docker/conan/data
178+
path: docker/conan2/p
179179
key: ${{ steps.conan-cache-restore.outputs.cache-primary-key }}
180180

181181
- name: Create a build archive
@@ -241,64 +241,176 @@ jobs:
241241
ssl: [dynamic, static]
242242

243243
steps:
244-
- uses: actions/checkout@v4
245-
with:
246-
clean: true
247-
submodules: recursive
248-
fetch-depth: 0
249-
250-
- name: Declare build output variables
251-
id: vars
252-
shell: bash
253-
env:
254-
HEAD_REF: ${{ github.head_ref || github.ref_name }}
255-
run: |
256-
echo "build_version=$(git describe --always --tags "refs/remotes/origin/${HEAD_REF}")" >> $GITHUB_OUTPUT
257-
echo "build_config=RelWithDebInfo" >> $GITHUB_OUTPUT
258-
259-
- name: Try to restore conan cache
260-
id: conan-cache-restore
261-
uses: actions/cache/restore@v3
262-
env:
263-
cache-name: cache-conan-modules
264-
with:
265-
path: docker/conan/data
266-
key: conan-linux-${{ matrix.arch }}-${{ matrix.ssl }}-${{ hashFiles('CMakeLists.txt', 'lib/CMakeLists.txt', 'SDK/CMakeLists.txt', 'SDK/lib/cmake-conan/conan.cmake', 'SDK/lib/cmake-conan/conan-omp.cmake') }}
267-
268-
- name: Run ARM build
269-
uses: pguyot/arm-runner-action@v2.5.2
270-
with:
271-
base_image: ${{ matrix.arch == 'arm32' && 'raspios_lite' || 'raspios_lite_arm64' }}:2022-04-04
272-
image_additional_mb: 10000
273-
bind_mount_repository: true
274-
cpu: cortex-a7
275-
commands: |
244+
- uses: actions/checkout@v4
245+
with:
246+
clean: true
247+
submodules: recursive
248+
fetch-depth: 0
249+
250+
- name: Declare build output variables
251+
id: vars
252+
shell: bash
253+
env:
254+
HEAD_REF: ${{ github.head_ref || github.ref_name }}
255+
run: |
256+
echo "build_version=$(git describe --always --tags "refs/remotes/origin/${HEAD_REF}")" >> $GITHUB_OUTPUT
257+
echo "build_config=RelWithDebInfo" >> $GITHUB_OUTPUT
258+
259+
- name: Try to restore conan cache
260+
id: conan-cache-restore
261+
uses: actions/cache/restore@v3
262+
env:
263+
cache-name: cache-conan-modules
264+
with:
265+
path: docker/conan2/p
266+
key: conan-linux-${{ matrix.arch }}-${{ matrix.ssl }}-${{ hashFiles('CMakeLists.txt', 'lib/CMakeLists.txt', 'SDK/CMakeLists.txt', 'SDK/lib/cmake-conan/conan.cmake', 'SDK/lib/cmake-conan/conan-omp.cmake') }}
267+
268+
- name: Run ARM build
269+
uses: pguyot/arm-runner-action@v2.5.2
270+
with:
271+
base_image: ${{ matrix.arch == 'arm32' && 'raspios_lite' || 'raspios_lite_arm64' }}:2022-04-04
272+
image_additional_mb: 10000
273+
bind_mount_repository: true
274+
cpu: cortex-a7
275+
commands: |
276276
apt update && apt install -y ninja-build clang-11 python3-pip libstdc++6 libc6
277277
pip install --upgrade pip setuptools wheel
278278
pip3 install --user conan
279279
pip3 install --user -v "cmake==3.23.3"
280280
export CC=/usr/bin/clang-11
281281
export CXX=/usr/bin/clang++-11
282282
export PATH=~/.local/bin:${PATH}
283-
mkdir -p docker/conan/data
284-
mkdir ~/.conan
285-
mv docker/conan/data ~/.conan
283+
mkdir -p docker/conan2/p
284+
mkdir -p ~/.conan2
285+
mv docker/conan2/p ~/.conan2
286286
cmake -S . -B build -G Ninja -DTARGET_BUILD_ARCH=${{ matrix.arch == 'arm32' && 'armv7' || 'armv8' }} -DCMAKE_BUILD_TYPE=${{ steps.vars.outputs.build_config }} -DSHARED_OPENSSL=${{ matrix.ssl == 'dynamic' }} -DSTATIC_STDCXX=true -DBUILD_SERVER=1 -DBUILD_ABI_CHECK_TOOL=0
287287
cmake --build build --config ${{ steps.vars.outputs.build_config }} --parallel $(nproc)
288-
mv ~/.conan/data docker/conan
289-
290-
- name: Upload build artifacts
291-
uses: actions/upload-artifact@v4
292-
with:
293-
name: open.mp-linux-${{ matrix.arch }}${{ matrix.ssl == 'dynamic' && '-dynssl' || '' }}-${{ steps.vars.outputs.build_version }}
294-
path: build/Output/${{ steps.vars.outputs.build_config }}/Server
295-
if-no-files-found: error
296-
297-
- name: Try to save conan cache
298-
if: steps.conan-cache-restore.outputs.cache-hit != 'true'
299-
uses: actions/cache/save@v3
300-
env:
301-
cache-name: cache-conan-modules
302-
with:
303-
path: docker/conan/data
304-
key: ${{ steps.conan-cache-restore.outputs.cache-primary-key }}
288+
mv ~/.conan2/p docker/conan2
289+
290+
- name: Upload build artifacts
291+
uses: actions/upload-artifact@v4
292+
with:
293+
name: open.mp-linux-${{ matrix.arch }}${{ matrix.ssl == 'dynamic' && '-dynssl' || '' }}-${{ steps.vars.outputs.build_version }}
294+
path: build/Output/${{ steps.vars.outputs.build_config }}/Server
295+
if-no-files-found: error
296+
297+
- name: Try to save conan cache
298+
if: steps.conan-cache-restore.outputs.cache-hit != 'true'
299+
uses: actions/cache/save@v3
300+
env:
301+
cache-name: cache-conan-modules
302+
with:
303+
path: docker/conan2/p
304+
key: ${{ steps.conan-cache-restore.outputs.cache-primary-key }}
305+
306+
build-macos-arm:
307+
name: macOS ARM build
308+
runs-on: macos-latest
309+
310+
strategy:
311+
matrix:
312+
ssl: [dynamic, static]
313+
314+
steps:
315+
- uses: actions/checkout@v4
316+
with:
317+
clean: true
318+
submodules: recursive
319+
fetch-depth: 0
320+
321+
- name: Declare build output variables
322+
id: vars
323+
shell: bash
324+
env:
325+
HEAD_REF: ${{ github.head_ref || github.ref_name }}
326+
run: |
327+
echo "build_version=$(git describe --always --tags "refs/remotes/origin/${HEAD_REF}")" >> "$GITHUB_OUTPUT"
328+
echo "build_config=RelWithDebInfo" >> "$GITHUB_OUTPUT"
329+
echo "build_shared=${{ matrix.ssl == 'dynamic' }}" >> $GITHUB_OUTPUT
330+
echo "build_server=1" >> "$GITHUB_OUTPUT"
331+
echo "build_tools=0" >> "$GITHUB_OUTPUT"
332+
echo "build_target_arch=arm64" >> "$GITHUB_OUTPUT"
333+
334+
- name: Install CMake
335+
uses: lukka/get-cmake@latest
336+
with:
337+
cmakeVersion: "3.31.8"
338+
339+
- name: Install build dependencies
340+
shell: bash
341+
run: |
342+
brew update
343+
brew install ninja
344+
345+
python3 -m venv "$RUNNER_TEMP/conan-venv"
346+
source "$RUNNER_TEMP/conan-venv/bin/activate"
347+
348+
python -m pip install --upgrade pip
349+
python -m pip install conan
350+
351+
echo "$RUNNER_TEMP/conan-venv/bin" >> "$GITHUB_PATH"
352+
353+
conan --version
354+
cmake --version
355+
ninja --version
356+
clang --version
357+
358+
- name: Restore Conan cache
359+
id: conan-cache-restore
360+
uses: actions/cache/restore@v4
361+
with:
362+
path: ~/.conan2/p
363+
key: conan-macos-arm64-${{ hashFiles('CMakeLists.txt', 'lib/CMakeLists.txt', 'SDK/CMakeLists.txt', 'SDK/lib/cmake-conan/conan.cmake', 'SDK/lib/cmake-conan/conan-omp.cmake') }}
364+
365+
- name: Configure
366+
shell: bash
367+
run: |
368+
export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
369+
export MACOSX_DEPLOYMENT_TARGET="11.0"
370+
export CFLAGS="-isysroot ${SDKROOT}"
371+
export CXXFLAGS="-isysroot ${SDKROOT}"
372+
export LDFLAGS="-isysroot ${SDKROOT}"
373+
374+
cmake -S . -B build \
375+
-G Ninja \
376+
-DCMAKE_OSX_SYSROOT="${SDKROOT}" \
377+
-DCMAKE_OSX_DEPLOYMENT_TARGET="${MACOSX_DEPLOYMENT_TARGET}" \
378+
-DTARGET_BUILD_ARCH=${{ steps.vars.outputs.build_target_arch }} \
379+
-DCMAKE_BUILD_TYPE=${{ steps.vars.outputs.build_config }} \
380+
-DSHARED_OPENSSL=${{ steps.vars.outputs.build_shared }} \
381+
-DSTATIC_STDCXX=false \
382+
-DBUILD_SERVER=${{ steps.vars.outputs.build_server }} \
383+
-DBUILD_ABI_CHECK_TOOL=${{ steps.vars.outputs.build_tools }}
384+
385+
- name: Build
386+
shell: bash
387+
run: |
388+
cmake --build build \
389+
--config ${{ steps.vars.outputs.build_config }} \
390+
--parallel "$(sysctl -n hw.logicalcpu)"
391+
392+
- name: Save Conan cache
393+
if: steps.conan-cache-restore.outputs.cache-hit != 'true'
394+
uses: actions/cache/save@v4
395+
with:
396+
path: ~/.conan2/p
397+
key: ${{ steps.conan-cache-restore.outputs.cache-primary-key }}
398+
399+
- name: Create build archive
400+
id: build
401+
shell: bash
402+
run: |
403+
version="${{ steps.vars.outputs.build_version }}"
404+
artifact_name="open.mp-macos-arm${{ matrix.ssl == 'dynamic' && '-dynssl' || '' }}-${version}"
405+
406+
echo "artifact_name=${artifact_name}" >> "$GITHUB_OUTPUT"
407+
408+
cd "build/Output/${{ steps.vars.outputs.build_config }}"
409+
tar -cJvf "${artifact_name}.tar.xz" "Server"
410+
411+
- name: Upload build artifacts
412+
uses: actions/upload-artifact@v4
413+
with:
414+
name: ${{ steps.build.outputs.artifact_name }}
415+
path: build/Output/${{ steps.vars.outputs.build_config }}/${{ steps.build.outputs.artifact_name }}.tar.xz
416+
if-no-files-found: error

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ __pycache__/
296296
*.i
297297
.vscode/
298298
/docker/conan/
299+
/docker/conan2/
299300
/docker/data/
300301
/buildlinux/*
301302
**/CMakeFiles/*

Server/Source/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ if(MSVC)
3535
winmm
3636
)
3737
else()
38-
target_link_libraries(Server PRIVATE dl atomic)
38+
if(UNIX AND NOT APPLE)
39+
target_link_libraries(Server PRIVATE dl atomic)
40+
endif()
3941

4042
if(SHARED_STDCXXFS)
4143
target_link_libraries(Server PRIVATE stdc++fs)

docker/abicheck.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ docker build \
3333
abicheck_ubuntu-${ubuntu_version}/ \
3434
|| exit 1
3535

36-
folders=('build' 'conan')
36+
folders=('build' 'conan2')
3737
for folder in "${folders[@]}"; do
3838
if [[ ! -d "./${folder}" ]]; then
39-
mkdir ${folder} &&
40-
sudo chown 1000:1000 ${folder} || exit 1
39+
mkdir ${folder}
4140
fi
41+
sudo chown -R 1000:1000 ${folder} || exit 1
4242
done
4343

4444
docker run \
@@ -47,7 +47,7 @@ docker run \
4747
-w /code \
4848
-v $PWD/..:/code \
4949
-v $PWD/build:/code/build \
50-
-v $PWD/conan:/home/user/.conan \
50+
-v $PWD/conan2:/home/user/.conan2 \
5151
-v $PWD/ref:/ref \
5252
-e CONFIG=${config} \
5353
-e NIGHTLY_REPO=${nightly_repo} \

docker/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ docker build \
3030
build_ubuntu-${ubuntu_version}/ \
3131
|| exit 1
3232

33-
folders=('build' 'conan')
33+
folders=('build' 'conan2')
3434
for folder in "${folders[@]}"; do
3535
if [[ ! -d "./${folder}" ]]; then
3636
mkdir ${folder}
@@ -44,7 +44,7 @@ docker run \
4444
-w /code \
4545
-v $PWD/..:/code \
4646
-v $PWD/build:/code/build \
47-
-v $PWD/conan:/home/user/.conan \
47+
-v $PWD/conan2:/home/user/.conan2 \
4848
-e CONFIG=${config} \
4949
-e TARGET_BUILD_ARCH=${target_build_arch} \
5050
-e BUILD_SHARED=${build_shared} \

0 commit comments

Comments
 (0)