-
Notifications
You must be signed in to change notification settings - Fork 7
123 lines (110 loc) · 4.2 KB
/
cmake.yml
File metadata and controls
123 lines (110 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# This workflow is for a CMake project running on multiple platforms.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: CMake Build and Test
on:
workflow_call:
inputs:
build_type:
description: 'Build type (e.g., "Debug", "Release", "RelWithDebInfo", "MinSizeRel")'
default: '"Debug"'
required: true
type: string
upload_artifacts:
description: 'Whether to upload artifacts (true/false)'
default: false
required: true
type: boolean
jobs:
cmake_build:
runs-on: ${{ matrix.os }}
strategy:
# 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.
fail-fast: false
# Set up a matrix to run the following configurations:
# - Multiple platforms (Windows, Linux, macOS)
# - Multiple compilers (cl, gcc, clang)
# - Multiple library types (static, shared)
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
build_type: ${{ fromJSON(format('[{0}]', inputs.build_type || '"Debug","Release"')) }}
c_compiler: [gcc, clang, cl]
lib_type: [static, shared]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: macOS-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: macOS-latest
c_compiler: cl
- os: macOS-latest
c_compiler: gcc
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
# Map OS to platform
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
echo "platform=linux_x64" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.os }}" == "windows-latest" ]; then
echo "platform=win64" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.os }}" == "macOS-latest" ]; then
echo "platform=osx" >> "$GITHUB_OUTPUT"
fi
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install libc++ on Ubuntu
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang'
run: |
sudo apt-get update
sudo apt-get install -y libc++-dev libc++abi-dev
- name: Display Clang Info
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang'
run: |
clang --version
clang++ --version
echo "Checking clang headers..."
clang++ -v -E -x c++ /dev/null
echo "check lld..."
ldd --version
- name: Build, Test, and Package with setup.py
shell: bash
run: |
SHARED_FLAG=""
if [ "${{ matrix.lib_type }}" == "shared" ]; then
SHARED_FLAG="--shared"
fi
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
python setup.py --platform ${{ steps.strings.outputs.platform }} --compiler ${{ matrix.c_compiler }} --cfg ${{ matrix.build_type }} $SHARED_FLAG --build --test
else
python setup.py --platform ${{ steps.strings.outputs.platform }} --cfg ${{ matrix.build_type }} $SHARED_FLAG --build --test
fi
- name: Upload Build Artifact
if: ${{ inputs.upload_artifacts && success() }}
uses: actions/upload-artifact@v4
with:
name: ga-cpp-sdk-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}-${{ matrix.lib_type }}
path: ${{ steps.strings.outputs.build-output-dir }}/package/
retention-days: 3