Skip to content

Commit

Permalink
ci: build universal dylib (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr authored Jan 12, 2025
1 parent b021890 commit 7fac813
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- { name: Windows (mingw64), os: windows-latest, build-spirv-cross: false, vendored: false, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, artifact: 'SDL3_shadercross-mingw64' }
- { name: Ubuntu 22.04, os: ubuntu-22.04, build-spirv-cross: true, vendored: false, shell: sh, artifact: 'SDL3_shadercross-linux-x64' }
- { name: Steam Linux Runtime (Sniper), os: ubuntu-latest, build-spirv-cross: false, vendored: true, shell: sh, artifact: 'SDL3_shadercross-slrsniper', container: 'registry.gitlab.steamos.cloud/steamrt/sniper/sdk:beta' }
- { name: macOS, os: macos-latest, build-spirv-cross: true, vendored: true, shell: sh, artifact: 'SDL3_shadercross-macos-arm64' }
- { name: macOS, os: macos-latest, build-spirv-cross: true, vendored: true, shell: sh, artifact: 'SDL3_shadercross-macos-arm64', cmake-arguments: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DCMAKE_C_FLAGS="-mmacosx-version-min=11.0" -DCMAKE_CXX_FLAGS="-mmacosx-version-min=11.0"' }

steps:
- uses: actions/checkout@v4
Expand All @@ -47,6 +47,7 @@ jobs:
id: sdl
uses: libsdl-org/setup-sdl@main
with:
cmake-arguments: ${{ matrix.platform.cmake-arguments }}
cmake-generator: Ninja
version: 3-head
sdl-test: true
Expand Down Expand Up @@ -81,7 +82,8 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DSPIRV_CROSS_SHARED=ON \
-DSPIRV_CROSS_STATIC=ON \
-DCMAKE_INSTALL_PREFIX=${PWD}/spirv_cross_prefix
-DCMAKE_INSTALL_PREFIX=${PWD}/spirv_cross_prefix \
${{ matrix.platform.cmake-arguments }}
cmake --build spirv_cross_build
cmake --install spirv_cross_build
Expand All @@ -103,7 +105,8 @@ jobs:
-DSDLSHADERCROSS_INSTALL=ON \
-DSDLSHADERCROSS_INSTALL_RUNTIME=ON \
-DSDLSHADERCROSS_INSTALL_CPACK=ON \
-DCMAKE_INSTALL_PREFIX="${PWD}/prefix"
-DCMAKE_INSTALL_PREFIX="${PWD}/prefix" \
${{ matrix.platform.cmake-arguments }}
- name: Build (CMake)
id: build
Expand All @@ -125,7 +128,8 @@ jobs:
if: ${{ always() && steps.install.outcome == 'success' }}
run: |
cmake -S cmake/test -B cmake_config_build -GNinja \
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=Release \
${{ matrix.platform.cmake-arguments }}
cmake --build cmake_config_build --verbose
- uses: actions/upload-artifact@v4
Expand Down
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,18 @@ if(SDLSHADERCROSS_INSTALL_RUNTIME)
include(ExternalProject)

if(NOT WIN32)
set(configure_CFLAGS "${CMAKE_C_FLAGS}")
if(APPLE)
foreach(osx_arch IN LISTS CMAKE_OSX_ARCHITECTURES)
string(APPEND configure_CFLAGS " -arch ${osx_arch}")
endforeach()
endif()
string(REPLACE ";" "$<SEMICOLON>" genex_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}")

ExternalProject_Add(spirv_headers
GIT_REPOSITORY "https://github.com/KhronosGroup/SPIRV-Headers.git"
GIT_TAG "main"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DCMAKE_OSX_ARCHITECTURES=${genex_CMAKE_OSX_ARCHITECTURES}" "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}"
BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "<BINARY_DIR>" --config "Release"
INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "<BINARY_DIR>" --config "Release"
)
Expand All @@ -450,7 +458,7 @@ if(SDLSHADERCROSS_INSTALL_RUNTIME)
ExternalProject_Add(vulkan_headers
GIT_REPOSITORY "https://github.com/KhronosGroup/Vulkan-Headers"
GIT_TAG "main"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DCMAKE_OSX_ARCHITECTURES=${genex_CMAKE_OSX_ARCHITECTURES}" "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}"
BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "<BINARY_DIR>" --config "Release"
INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "<BINARY_DIR>" --config "Release"
)
Expand All @@ -461,7 +469,7 @@ if(SDLSHADERCROSS_INSTALL_RUNTIME)
DEPENDS spirv_headers vulkan_headers
GIT_REPOSITORY "https://github.com/KhronosGroup/Vulkan-Loader.git"
GIT_TAG "main"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DCMAKE_PREFIX_PATH=${vulkan_headers_install_dir}"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DCMAKE_OSX_ARCHITECTURES=${genex_CMAKE_OSX_ARCHITECTURES}" "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}" "-DCMAKE_PREFIX_PATH=${vulkan_headers_install_dir}"
BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "<BINARY_DIR>" --config "Release"
INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "<BINARY_DIR>" --config "Release"
)
Expand All @@ -474,7 +482,7 @@ if(SDLSHADERCROSS_INSTALL_RUNTIME)
URL "https://dl.winehq.org/vkd3d/source/vkd3d-1.14.tar.xz"
URL_HASH "SHA256=c94015d59ebe8ae72c4d802af5ca1517d9744548842a4e776534612a8d905485"
DOWNLOAD_EXTRACT_TIMESTAMP "1"
CONFIGURE_COMMAND "sh" "<SOURCE_DIR>/configure" "--prefix=<INSTALL_DIR>" "--enable-tests=no" "--enable-demos=no" "--disable-doxygen-doc" "CFLAGS=-I${spirv_headers_install_dir}/include -I${vulkan_headers_install_dir}/include -I${vulkan_loader_install_dir}/include" "LDFLAGS=-L${vulkan_loader_install_dir}/lib" "BISON=${BISON_EXECUTABLE}"
CONFIGURE_COMMAND "sh" "<SOURCE_DIR>/configure" "--prefix=<INSTALL_DIR>" "--enable-tests=no" "--enable-demos=no" "--disable-doxygen-doc" "CFLAGS=-I${spirv_headers_install_dir}/include -I${vulkan_headers_install_dir}/include -I${vulkan_loader_install_dir}/include ${configure_CFLAGS}" "LDFLAGS=-L${vulkan_loader_install_dir}/lib" "BISON=${BISON_EXECUTABLE}"
BUILD_COMMAND "make"
INSTALL_COMMAND "make" "install"
)
Expand Down

0 comments on commit 7fac813

Please sign in to comment.