diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-05-31 06:34:48 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-05-31 06:34:48 +1000 |
commit | d9481850f365b4fe0424d299480d3cb114b1c446 (patch) | |
tree | 826680e32713b6c21c6589b780ac7b7138e7e133 | |
parent | c8aea48d84a1da84759a6a15b95212ca43082581 (diff) |
default to GCC on Linux for now, move to optional Clang build action
-rw-r--r-- | .github/workflows/build.yml | 88 | ||||
-rw-r--r-- | source/CMakePresets.json | 18 | ||||
-rw-r--r-- | source/core/StarColor.cpp | 4 | ||||
-rw-r--r-- | triplets/x64-linux-mixed-clang.cmake | 26 | ||||
-rw-r--r-- | triplets/x64-linux-mixed.cmake | 1 |
5 files changed, 130 insertions, 7 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6474e7e..42e506c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,8 +5,12 @@ on: inputs: linux: type: boolean - description: Linux + description: Linux (GCC) default: true + linux_clang: + type: boolean + description: Linux (Clang) + default: false windows: type: boolean description: Windows @@ -162,7 +166,83 @@ jobs: - name: Upload Artifacts uses: actions/upload-artifact@v4 with: - name: OpenStarbound-Linux + name: OpenStarbound-Linux-GCC + path: dist.tar + + - name: Run Tests + uses: lukka/run-cmake@v10 + with: + cmakeListsTxtPath: '${{ github.workspace }}/source/CMakeLists.txt' + testPreset: 'linux-release' + + - name: Assemble Files + working-directory: ${{ github.workspace }} + run: scripts/ci/linux/assemble.sh + + - name: Upload Client Files + uses: actions/upload-artifact@v4 + with: + name: OpenStarbound-Linux-GCC-Client + path: client.tar + + - name: Upload Server Files + uses: actions/upload-artifact@v4 + with: + name: OpenStarbound-Linux-GCC-Server + path: server.tar + + build_linux_Clang: + name: Build OpenStarbound Linux Clang x86_64 + runs-on: ubuntu-22.04 + if: ${{ inputs.linux_clang == true }} + env: + CC: clang + CXX: clang++ + + steps: + - name: Install Packages + run: | + sudo apt-get update + sudo apt-get install -y pkg-config libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libsdl2-dev + + - name: Install CMake & Ninja + uses: lukka/get-cmake@latest + with: + cmakeVersion: 3.29.2 + + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: sccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + variant: sccache + key: ${{ github.job }}-${{ runner.os }} + max-size: 250M + + - name: vcpkg + uses: lukka/run-vcpkg@v11 + id: runvcpkg + with: + vcpkgJsonGlob: '**/source/vcpkg.json' + vcpkgConfigurationJsonGlob: '**/source/vcpkg-configuration.json' + + - name: Run CMake + uses: lukka/run-cmake@v10 + with: + cmakeListsTxtPath: '${{ github.workspace }}/source/CMakeLists.txt' + configurePreset: 'linux-release-clang' + buildPreset: 'linux-release-clang' + + - name: Prepare Artifacts + working-directory: ${{ github.workspace }} + run: tar -cvf dist.tar dist + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: OpenStarbound-Linux-Clang path: dist.tar - name: Run Tests @@ -178,13 +258,13 @@ jobs: - name: Upload Client Files uses: actions/upload-artifact@v4 with: - name: OpenStarbound-Linux-Client + name: OpenStarbound-Linux-Clang-Client path: client.tar - name: Upload Server Files uses: actions/upload-artifact@v4 with: - name: OpenStarbound-Linux-Server + name: OpenStarbound-Linux-Clang-Server path: server.tar build-mac-intel: diff --git a/source/CMakePresets.json b/source/CMakePresets.json index defd840..d8ec968 100644 --- a/source/CMakePresets.json +++ b/source/CMakePresets.json @@ -53,8 +53,6 @@ "binaryDir": "${sourceParentDir}/build/linux-release", "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_C_COMPILER": "clang", - "CMAKE_CXX_COMPILER": "clang++", "VCPKG_TARGET_TRIPLET": "x64-linux-mixed", "CMAKE_INCLUDE_PATH": "${sourceParentDir}/lib/linux/include", "CMAKE_LIBRARY_PATH": "${sourceParentDir}/lib/linux", @@ -68,6 +66,18 @@ } }, { + "inherits": "linux-release", + "name": "linux-release-clang", + "displayName": "Linux Clang x64", + "binaryDir": "${sourceParentDir}/build/linux-release-clang", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "VCPKG_TARGET_TRIPLET": "x64-linux-mixed-clang", + "STAR_USE_JEMALLOC": true + } + }, + { "inherits": "base", "name": "macos-release", "displayName": "macOS x64", @@ -122,6 +132,10 @@ "configurePreset": "linux-release" }, { + "name": "linux-release-clang", + "configurePreset": "linux-release-clang" + }, + { "name": "macos-release", "configurePreset": "macos-release" }, diff --git a/source/core/StarColor.cpp b/source/core/StarColor.cpp index 4eb726c..cab4b4f 100644 --- a/source/core/StarColor.cpp +++ b/source/core/StarColor.cpp @@ -322,8 +322,10 @@ Vec3F Color::toRgbF() const { return Vec3F(redF(), greenF(), blueF()); } +#ifdef __GNUC__ #pragma GCC push_options #pragma GCC optimize("-fno-fast-math") +#endif Vec4F Color::toHsva() const { float h, s, v; @@ -367,7 +369,9 @@ Vec4F Color::toHsva() const { return Vec4F(h, s, v, alphaF()); } +#ifdef __GNUC__ #pragma GCC pop_options +#endif String Color::toHex() const { auto rgba = toRgba(); diff --git a/triplets/x64-linux-mixed-clang.cmake b/triplets/x64-linux-mixed-clang.cmake new file mode 100644 index 0000000..9a95aff --- /dev/null +++ b/triplets/x64-linux-mixed-clang.cmake @@ -0,0 +1,26 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../toolchains/linux-clang.cmake) + +if(PORT MATCHES "discord-") + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() + +if(PORT MATCHES "opus") + string(CONCAT VCPKG_CMAKE_CONFIGURE_OPTIONS + "-DOPUS_INSTALL_PKG_CONFIG_MODULE=OFF" + "-DOPUS_INSTALL_CMAKE_CONFIG_MODULE=OFF" + "-DOPUS_X86_MAY_HAVE_SSE=ON" + "-DOPUS_X86_MAY_HAVE_AVX=ON" + "-DOPUS_X86_MAY_HAVE_SSE4_1=ON" + "-DOPUS_ENABLE_FLOAT_API=ON" + "-DOPUS_FLOAT_APPROX=ON" + "-DOPUS_STACK_PROTECTOR=OFF" + "-DOPUS_NONTHREADSAFE_PSEUDOSTACK=OFF" + "-DOPUS_USE_ALLOCA=ON" + "-DBUILD_TESTING=OFF" + ) +endif()
\ No newline at end of file diff --git a/triplets/x64-linux-mixed.cmake b/triplets/x64-linux-mixed.cmake index 9a95aff..be80364 100644 --- a/triplets/x64-linux-mixed.cmake +++ b/triplets/x64-linux-mixed.cmake @@ -3,7 +3,6 @@ set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Linux) -set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../toolchains/linux-clang.cmake) if(PORT MATCHES "discord-") set(VCPKG_LIBRARY_LINKAGE dynamic) |