Skip to content

Commit e544949

Browse files
committed
Update cmake.yml
1 parent 7abfff0 commit e544949

File tree

1 file changed

+27
-88
lines changed

1 file changed

+27
-88
lines changed

.github/workflows/cmake.yml

Lines changed: 27 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,70 @@
1-
# This workflow is for a CMake project running on multiple platforms.
2-
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
3-
name: CMake Build and Test
1+
name: CMake Build and Test
42

53
on:
64
workflow_call:
75
inputs:
86
build_type:
9-
description: 'Build type (e.g., "Debug", "Release", "RelWithDebInfo", "MinSizeRel")'
10-
default: '"Debug"'
7+
description: 'Build type (e.g., "Debug", "Release")'
8+
default: '"Release"'
119
required: true
1210
type: string
1311
upload_artifacts:
1412
description: 'Whether to upload artifacts (true/false)'
15-
default: false
13+
default: true
1614
required: true
1715
type: boolean
1816

1917
jobs:
2018
cmake_build:
21-
runs-on: ${{ matrix.os }}
22-
23-
strategy:
24-
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
25-
fail-fast: false
26-
27-
# Set up a matrix to run the following 3 configurations:
28-
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
29-
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
30-
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
31-
#
32-
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
33-
matrix:
34-
os: [ubuntu-latest, windows-latest, macOS-latest]
35-
build_type: ${{ fromJSON(format('[{0}]', inputs.build_type || '"Debug","Release"')) }}
36-
c_compiler: [gcc, clang, cl]
37-
include:
38-
- os: windows-latest
39-
c_compiler: cl
40-
cpp_compiler: cl
41-
- os: ubuntu-latest
42-
c_compiler: gcc
43-
cpp_compiler: g++
44-
- os: ubuntu-latest
45-
c_compiler: clang
46-
cpp_compiler: clang++
47-
- os: macOS-latest
48-
c_compiler: clang
49-
cpp_compiler: clang++
50-
exclude:
51-
- os: windows-latest
52-
c_compiler: gcc
53-
- os: windows-latest
54-
c_compiler: clang
55-
- os: ubuntu-latest
56-
c_compiler: cl
57-
- os: macOS-latest
58-
c_compiler: cl
59-
- os: macOS-latest
60-
c_compiler: gcc
19+
runs-on: ubuntu-22.04
20+
container:
21+
image: quay.io/centos/centos:7
6122

6223
steps:
6324
- uses: actions/checkout@v4
6425
with:
6526
submodules: true
6627

6728
- name: Set reusable strings
68-
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
6929
id: strings
7030
shell: bash
71-
run: |
72-
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
73-
74-
- name: Install Clang and Libraries
75-
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang'
76-
run: |
77-
sudo apt-get update
78-
sudo apt-get install -y clang libc++-dev libc++abi-dev
79-
80-
- name: Set Clang 16 as Default
81-
if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang'
82-
run: |
83-
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 100
84-
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100
85-
sudo update-alternatives --set clang /usr/bin/clang-16
86-
sudo update-alternatives --set clang++ /usr/bin/clang++-16
31+
run: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
8732

88-
- name: Check Clang Settings
89-
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang'
33+
- name: Install Dependencies on CentOS 7
9034
run: |
91-
clang --version
92-
clang++ --version
93-
echo "Checking clang headers..."
94-
clang++ -v -E -x c++ /dev/null
95-
echo "check lld..."
96-
ldd --version
35+
yum install -y epel-release
36+
yum install -y wget tar xz cmake3 ninja-build git which pkgconfig
37+
# Install clang16 for RHEL7
38+
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.6/clang+llvm-16.0.6-x86_64-linux-gnu-rhel7.tar.xz
39+
tar -xf clang+llvm-16.0.6-x86_64-linux-gnu-rhel7.tar.xz -C /opt
40+
ln -s /opt/clang+llvm-16.0.6-x86_64-linux-gnu-rhel7 /opt/clang16
41+
echo "/opt/clang16/bin" >> $GITHUB_PATH
9742
9843
- name: Configure CMake
99-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
100-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
10144
run: >
102-
cmake -B ${{ steps.strings.outputs.build-output-dir }}
103-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
104-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
105-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
45+
cmake3 -B ${{ steps.strings.outputs.build-output-dir }}
46+
-DCMAKE_C_COMPILER=clang
47+
-DCMAKE_CXX_COMPILER=clang++
48+
-DCMAKE_BUILD_TYPE=${{ inputs.build_type }}
49+
-DCMAKE_CXX_FLAGS="-fPIC -D_FILE_OFFSET_BITS=64"
10650
-S ${{ github.workspace }}
10751
10852
- name: Build
109-
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
110-
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --verbose
53+
run: cmake3 --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ inputs.build_type }} --verbose
11154

11255
- name: Test
11356
working-directory: ${{ steps.strings.outputs.build-output-dir }}
114-
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
115-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
116-
run: ctest --build-config ${{ matrix.build_type }} --verbose --output-on-failure
57+
run: ctest --build-config ${{ inputs.build_type }} --verbose --output-on-failure
11758

11859
- name: Package Build Artifacts
11960
run: |
12061
mkdir -p ${{ steps.strings.outputs.build-output-dir }}/package
121-
# Adjust the path to your built library files
122-
cp ${{ steps.strings.outputs.build-output-dir }}/${{ matrix.build_type }}/*GameAnalytics.* ${{ steps.strings.outputs.build-output-dir }}/package/
62+
cp ${{ steps.strings.outputs.build-output-dir }}/${{ inputs.build_type }}/*GameAnalytics.* ${{ steps.strings.outputs.build-output-dir }}/package/ || true
12363
cp -r ${{ github.workspace }}/include ${{ steps.strings.outputs.build-output-dir }}/package/
124-
64+
12565
- name: Upload Build Artifact
12666
uses: actions/upload-artifact@v4
12767
with:
128-
name: ga-cpp-sdk-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}
68+
name: ga-cpp-sdk-linux-clang16-${{ inputs.build_type }}
12969
path: ${{ steps.strings.outputs.build-output-dir }}/package/
130-
retention-days: 3
131-
70+
retention-days: 3

0 commit comments

Comments
 (0)