From 2e5d7de877ded6a85718c58865153d51c37214f2 Mon Sep 17 00:00:00 2001 From: Nick Klingensmith Date: Sun, 17 Mar 2024 21:46:50 -0700 Subject: [PATCH] Github actions --- .github/workflows/build.yml | 152 ++++++++++++++++++++++++++++++++++++ CMakePresets.json | 91 +++++++++++++++++++++ 2 files changed, 243 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 CMakePresets.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6884566 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,152 @@ +name: Build Package +on: + workflow_dispatch: + inputs: + branch: + description: 'Branch to build' + type: string + required: true + workflow_call: + inputs: + branch: + description: 'Branch to build' + type: string + required: true + +permissions: + contents: write + actions: write + +jobs: + +########################################### + + build-windows: + runs-on: windows-latest + env: + CPM_SOURCE_CACHE: .deps_cache + + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch }} + - uses: lukka/get-cmake@v3.26.3 + + - name: Get Cache + uses: actions/cache@v3 + with: + key: DependencyCache + path: | + .deps_cache + + - name: Build Native Win32 x64 + run: | + cmake --preset Win32_x64_Release + cmake --build --preset Win32_x64_Release + + mkdir -p bin/distribute/win32_x64 + copy bin/intermediate/Win32_x64_Release/Release/skshaderc.exe bin/distribute/win32_x64/skshaderc.exe + + - name: Build Native Win32 Arm64 + run: | + cmake --preset Win32_Arm64_Release + cmake --build --preset Win32_Arm64_Release + + mkdir -p bin/distribute/win32_arm64 + copy bin/intermediate/Win32_Arm64_Release/Release/skshaderc.exe bin/distribute/win32_arm64/skshaderc.exe + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: binaries + path: bin/distribute/ + +########################################### + + build-linux: + runs-on: ubuntu-20.04 + env: + CPM_SOURCE_CACHE: .deps_cache + + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch }} + - uses: lukka/get-cmake@v3.26.3 + + - name: Get Cache + uses: actions/cache@v3 + with: + key: DependencyCache + path: | + .deps_cache + + + - name: Install Prerequisites + run: | + sudo apt-get update + sudo apt-get install ninja-build + + - name: Build Native Linux x64 + run: | + cmake --preset Linux_x64_Release + cmake --build --preset Linux_x64_Release + + mkdir -p bin/distribute/linux_x64 + copy bin/intermediate/Linux_x64_Release/skshaderc_exe bin/distribute/linux_x64/skshaderc + + - name: Install Arm64 Prerequisites + run: | + sudo cp ./tools/docker/arm-cross-compile-sources-focal.list /etc/apt/sources.list.d/ + sudo sed -i "s/deb mirror/deb [arch=amd64] mirror/g" /etc/apt/sources.list + sudo dpkg --add-architecture arm64 + sudo apt-get update + sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu lld:arm64 + + - name: Build Linux Arm64 + run: | + cmake --preset Linux_Arm64_Release + cmake --build --preset Linux_Arm64_Release + + mkdir -p bin/distribute/linux_arm64 + copy bin/intermediate/Linux_Arm64_Release/skshaderc_exe bin/distribute/linux_arm64/skshaderc + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: binaries + path: bin/distribute/ + + ########################################### + + build-mac: + runs-on: macos-latest + env: + CPM_SOURCE_CACHE: .deps_cache + + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch }} + - uses: lukka/get-cmake@v3.26.3 + + - name: Get Cache + uses: actions/cache@v3 + with: + key: DependencyCache + path: | + .deps_cache + + - name: Build Native Linux x64 + run: | + cmake --preset Linux_x64_Release + cmake --build --preset Linux_x64_Release + + mkdir -p bin/distribute/mac_arm64 + copy bin/intermediate/Linux_Arm64_Release/Release/skshaderc_exe bin/distribute/mac_arm64/skshaderc + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: binaries + path: bin/distribute/ \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..6c78107 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,91 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 21, + "patch": 0 + }, + "configurePresets": [ + { + "name": "Win32", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_CXX_FLAGS_RELEASE": "/O1 /GL /Gy", + "CMAKE_C_FLAGS_RELEASE": "/O1 /GL /Gy", + "CMAKE_EXE_LINKER_FLAGS": "/LTCG /INCREMENTAL:NO", + "CMAKE_SHARED_LINKER_FLAGS": "/LTCG /INCREMENTAL:NO", + "CMAKE_STATIC_LINKER_FLAGS": "/LTCG", + "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE" + } + }, + { + "name": "skshaderc_Win32_x64_Release", + "inherits": "Win32", + "description": "Release build for Win32 x64", + "hidden": false, + "binaryDir": "${sourceDir}/bin/intermediate/Win32_x64" + }, + { + "name": "skshaderc_Win32_Arm64_Release", + "inherits": "Win32", + "description": "Release build for Win32 Arm64", + "hidden": false, + "architecture": "ARM64", + "binaryDir": "${sourceDir}/bin/intermediate/Win32_Arm64" + }, + { + "name": "Linux", + "description": "Build for Linux", + "hidden": true, + "generator": "Ninja", + "cacheVariables": { + "CMAKE_SYSTEM_NAME": "Linux", + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_LINKER": "lld", + "CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=lld", + "CMAKE_SHARED_LINKER_FLAGS": "-fuse-ld=lld", + "CMAKE_MODULE_LINKER_FLAGS": "-fuse-ld=lld" + } + }, + { + "name": "skshaderc_Linux_x64_Release", + "description": "Release build for Linux x64", + "hidden": false, + "inherits": "Linux", + "binaryDir": "${sourceDir}/bin/intermediate/Linux_x64_Release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "skshaderc_Linux_Arm64_Release", + "description": "Release build for Linux Arm64", + "hidden": false, + "inherits": "Linux", + "binaryDir": "${sourceDir}/bin/intermediate/Linux_ARM64_Release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_AR": "/usr/bin/aarch64-linux-gnu-ar", + "CMAKE_LINKER": "/usr/bin/aarch64-linux-gnu-ld", + "CMAKE_OBJCOPY": "/usr/bin/aarch64-linux-gnu-objcopy", + "CMAKE_RANLIB": "/usr/bin/aarch64-linux-gnu-ranlib", + "CMAKE_SIZE": "/usr/bin/aarch64-linux-gnu-size", + "CMAKE_STRIP": "/usr/bin/aarch64-linux-gnu-strip", + "CMAKE_C_COMPILER": "aarch64-linux-gnu-gcc", + "CMAKE_CXX_COMPILER": "aarch64-linux-gnu-g++", + "CMAKE_SYSTEM_PROCESSOR": "arm64", + "CMAKE_EXE_LINKER_FLAGS": null, + "CMAKE_SHARED_LINKER_FLAGS": null, + "CMAKE_MODULE_LINKER_FLAGS": null + } + } + ], + "buildPresets": [ + { "name":"skshaderc_Win32_x64_Release", "targets": ["sk_gpu_header", "skshaderc"], "configuration":"Release", "configurePreset":"Win32_x64_Release", "jobs":24}, + { "name":"skshaderc_Win32_Arm64_Release", "targets": ["sk_gpu_header", "skshaderc"], "configuration":"Release", "configurePreset":"Win32_Arm64_Release", "jobs":24}, + { "name":"skshaderc_Linux_x64_Release", "targets": ["sk_gpu_header", "skshaderc"], "configuration":"MinSizeRelease", "configurePreset":"Linux_x64_Release", "jobs":24}, + { "name":"skshaderc_Linux_Arm64_Release", "targets": ["sk_gpu_header", "skshaderc"], "configuration":"MinSizeRelease", "configurePreset":"Linux_Arm64_Release", "jobs":24} + ] +} \ No newline at end of file