Skip to content

build: fix CMake from always enabling address sanitizer on macos #29

build: fix CMake from always enabling address sanitizer on macos

build: fix CMake from always enabling address sanitizer on macos #29

Workflow file for this run

name: libpupdmd
on:
push:
pull_request:
permissions:
contents: write
defaults:
run:
shell: bash
jobs:
version:
name: Detect version
runs-on: ubuntu-24.04
outputs:
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- id: version
run: |
VERSION_MAJOR=$(grep -Eo "PUPDMD_VERSION_MAJOR\s+[0-9]+" src/pupdmd.h | grep -Eo "[0-9]+")
VERSION_MINOR=$(grep -Eo "PUPDMD_VERSION_MINOR\s+[0-9]+" src/pupdmd.h | grep -Eo "[0-9]+")
VERSION_PATCH=$(grep -Eo "PUPDMD_VERSION_PATCH\s+[0-9]+" src/pupdmd.h | grep -Eo "[0-9]+")
TAG="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
echo "${TAG}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
build:
name: Build libpupdmd-${{ matrix.platform }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
needs: [ version ]
strategy:
fail-fast: false
matrix:
include:
- { os: windows-2025, platform: win, arch: x64 }
- { os: windows-2025, platform: win, arch: x86 }
- { os: windows-2025, platform: win-mingw, arch: x64 }
- { os: macos-15, platform: macos, arch: arm64 }
- { os: macos-15, platform: macos, arch: x64 }
- { os: ubuntu-24.04, platform: linux, arch: x64 }
- { os: ubuntu-24.04-arm, platform: linux, arch: aarch64 }
- { os: ubuntu-24.04, platform: android, arch: arm64-v8a }
- { os: macos-15, platform: ios, arch: arm64 }
- { os: macos-15, platform: ios-simulator, arch: arm64 }
- { os: macos-15, platform: tvos, arch: arm64 }
steps:
- uses: actions/checkout@v6
#
# install dependencies
#
- if: (matrix.platform == 'win')
uses: microsoft/setup-msbuild@v2
- if: (matrix.platform == 'win-mingw')
run: |
/c/msys64/usr/bin/bash.exe -l -c "pacman -S --noconfirm \
mingw-w64-ucrt-x86_64-gcc \
mingw-w64-ucrt-x86_64-cmake"
#
# build (win)
#
- if: (matrix.platform == 'win')
name: Build (win)
run: |
if [[ "${{ matrix.arch }}" == "x64" ]]; then
cmake \
-G "Visual Studio 17 2022" \
-DPLATFORM=${{ matrix.platform }} \
-DARCH=${{ matrix.arch }} \
-B build
else
cmake \
-G "Visual Studio 17 2022" \
-A Win32 \
-DPLATFORM=${{ matrix.platform }} \
-DARCH=${{ matrix.arch }} \
-B build
fi
cmake --build build --config Release
#
# build (win-mingw)
#
- if: (matrix.platform == 'win-mingw')
name: Build (win-mingw)
run: |
CURRENT_DIR="$(pwd)"
MSYSTEM=UCRT64 /c/msys64/usr/bin/bash.exe -l -c "
cd \"${CURRENT_DIR}\" &&
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DPLATFORM=${{ matrix.platform }} \
-DARCH=${{ matrix.arch }} \
-B build &&
cmake --build build -- -j\$(nproc)
"
#
# build (macos)
#
- if: (matrix.platform == 'macos')
name: Build (macos)
run: |
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DPLATFORM=${{ matrix.platform }} \
-DARCH=${{ matrix.arch }} \
-B build
cmake --build build -- -j$(sysctl -n hw.ncpu)
#
# build (linux)
#
- if: (matrix.platform == 'linux')
name: Build (linux)
run: |
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DPLATFORM=${{ matrix.platform }} \
-DARCH=${{ matrix.arch }} \
-B build
cmake --build build -- -j$(nproc)
#
# build (ios/tvos)
#
- if: (matrix.platform == 'ios' || matrix.platform == 'ios-simulator' || matrix.platform == 'tvos')
name: Build (ios/tvos)
run: |
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DPLATFORM=${{ matrix.platform }} \
-DARCH=${{ matrix.arch }} \
-B build
cmake --build build -- -j$(sysctl -n hw.ncpu)
#
# build (android)
#
- if: (matrix.platform == 'android')
name: Build (android)
run: |
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DPLATFORM=${{ matrix.platform }} \
-DARCH=${{ matrix.arch }} \
-B build
cmake --build build -- -j$(nproc)
#
# test
#
- if: (!(matrix.arch == 'arm64' || matrix.arch == 'arm64-v8a' || matrix.arch == 'aarch64' || matrix.platform == 'win' || matrix.platform == 'win-mingw'))
name: pupdmd_test
run: build/pupdmd_test
#
# prepare artifacts
#
- if: (matrix.platform == 'win')
name: Prepare artifacts (win)
run: |
mkdir tmp
cp build/Release/*.lib tmp/
cp build/Release/*.dll tmp/
cp build/Release/*.exe tmp/
cp -r test tmp/
cd tmp && 7z a -r ../libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.zip *
- if: (matrix.platform == 'win-mingw')
name: Prepare artifacts (win-mingw)
run: |
mkdir tmp
cp build/*.dll tmp/
cp build/*.dll.a tmp/
cp build/pupdmd_static.a tmp/
cp build/*.exe tmp/
cp -r test tmp/
UCRT64_BIN="/c/msys64/ucrt64/bin"
cp "${UCRT64_BIN}/libgcc_s_seh-1.dll" tmp/
cp "${UCRT64_BIN}/libstdc++-6.dll" tmp/
cd tmp && 7z a -r ../libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.zip *
- if: (matrix.platform == 'macos')
name: Prepare artifacts (macos)
run: |
mkdir tmp
cp build/libpupdmd.a tmp/
cp -a build/*.dylib tmp/
cp build/pupdmd_test_s tmp/
cp build/pupdmd_test tmp/
cp -r test tmp/
cd tmp && tar -czvf ../libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz *
- if: (matrix.platform == 'linux')
name: Prepare artifacts (linux)
run: |
mkdir tmp
cp build/libpupdmd.a tmp/
cp -a build/*.so tmp/
cp -a build/*.so.* tmp/
cp build/pupdmd_test_s tmp/
cp build/pupdmd_test tmp/
cp -r test tmp/
cd tmp && tar -czvf ../libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz *
- if: (matrix.platform == 'ios' || matrix.platform == 'ios-simulator' || matrix.platform == 'tvos')
name: Prepare artifacts (ios/tvos)
run: |
mkdir tmp
cp build/libpupdmd.a tmp/
cp -a build/*.dylib tmp/
cd tmp && tar -czvf ../libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz *
- if: (matrix.platform == 'android')
name: Prepare artifacts (android)
run: |
mkdir tmp
cp build/libpupdmd.a tmp/
cp build/libpupdmd.so tmp/
cd tmp && tar -czvf ../libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz *
#
# upload artifacts
#
- if: (matrix.platform == 'win' || matrix.platform == 'win-mingw')
uses: actions/upload-artifact@v7
with:
name: libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.zip
path: libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.zip
archive: false
- if: (matrix.platform != 'win' && matrix.platform != 'win-mingw')
uses: actions/upload-artifact@v7
with:
name: libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz
path: libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz
archive: false
post-build:
runs-on: macos-15
needs: [ version, build ]
name: Build libpupdmd-macos
steps:
- uses: actions/download-artifact@v8
with:
name: libpupdmd-${{ needs.version.outputs.tag }}-macos-x64.tar.gz
skip-decompress: true
- uses: actions/download-artifact@v8
with:
name: libpupdmd-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz
skip-decompress: true
- name: Combine macos architectures
run: |
mkdir macos-x64 macos-arm64
tar -xzvf libpupdmd-${{ needs.version.outputs.tag }}-macos-x64.tar.gz -C macos-x64
tar -xzvf libpupdmd-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz -C macos-arm64
mkdir tmp
find macos-arm64 -name "*.dylib" | while read -r file; do
if [ -L "$file" ]; then
cp -a "$file" "tmp/"
elif [ -f "$file" ]; then
filename=$(basename "$file")
lipo -create -output "tmp/$filename" \
"macos-arm64/$filename" \
"macos-x64/$filename"
fi
done
lipo -create -output tmp/pupdmd_test \
macos-arm64/pupdmd_test \
macos-x64/pupdmd_test
lipo -create -output tmp/pupdmd_test_s \
macos-arm64/pupdmd_test_s \
macos-x64/pupdmd_test_s
cp -r macos-arm64/test tmp
cd tmp && tar -czvf ../libpupdmd-${{ needs.version.outputs.tag }}-macos.tar.gz * && cd ..
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: libpupdmd-${{ needs.version.outputs.tag }}-macos.tar.gz
path: libpupdmd-${{ needs.version.outputs.tag }}-macos.tar.gz
archive: false
- if: startsWith(github.ref, 'refs/tags/')
uses: actions/download-artifact@v8
with:
path: release
skip-decompress: true
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: release/**/*