-
Notifications
You must be signed in to change notification settings - Fork 4
218 lines (194 loc) · 7.36 KB
/
cmake.yml
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: Build CMake Project
on:
workflow_call:
inputs:
project-path:
required: true
type: string
project-slug:
required: true
type: string
pull-sdk:
required: false
type: boolean
default: false
sdk-version:
required: false
type: string
default: nightly
need-flatc:
required: false
type: boolean
default: true
jobs:
build:
name: "[${{ matrix.build_type }}] ${{ matrix.config.name }}"
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
build_type: ["release", "debug"]
config:
- name: "Windows Latest MSVC"
key: msvc
os: windows-latest
cc: "cl"
cxx: "cl"
generator: "Visual Studio 17 2022"
target_triplet: x64-windows
- name: "Windows Latest MinGW"
key: mingw
os: windows-latest
cc: "gcc"
cxx: "g++"
generator: "Ninja"
target_triplet: x64-mingw-static
- name: "Ubuntu Latest GCC"
key: gcc
os: ubuntu-24.04
cc: "gcc"
cxx: "g++"
generator: "Ninja"
target_triplet: x64-linux
- name: "macOS x64 Latest Clang"
key: clang
os: macos-13
cc: "clang"
cxx: "clang++"
generator: "Ninja"
target_triplet: x64-osx
- name: "macOS arm64 Latest Clang"
key: clang
os: macos-14
cc: "clang"
cxx: "clang++"
generator: "Ninja"
target_triplet: arm64-osx
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Amplitude Audio SDK
uses: AmplitudeAudio/action-setup-sdk@main
if: inputs.pull-sdk
id: sdk_path
with:
platforms: |
${{ matrix.config.target_triplet }}
version: ${{ inputs.sdk-version }}
install-dir: "${{ github.workspace }}/amplitude_audio"
config: ${{ matrix.build_type }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Setup vcpkg
uses: lukka/[email protected]
with:
vcpkgGitCommitId: 7adc2e4d49e8d0efc07a369079faa6bc3dbb90f3
doNotCache: false
- name: Find flatc version
if: startsWith(matrix.config.os, 'ubuntu') || startsWith(matrix.config.os, 'macos')
id: flatc_version
uses: tdemin/find-latest-tag@v1
with:
repo: https://github.com/google/flatbuffers.git
- name: Install dependencies on Windows
if: startsWith(matrix.config.os, 'windows')
run: |
choco install ninja cmake curl
ninja --version
cmake --version
$FLATC_VERSION = "$(curl "https://api.github.com/repos/google/flatbuffers/releases/latest" --ssl-no-revoke --silent | Select-String -Pattern '"tag_name":\s*"(.+)"')" -replace '.*"v(.+)".*','$1'
echo "flatc download latest v$FLATC_VERSION version"
iwr -Uri https://github.com/google/flatbuffers/releases/download/v$FLATC_VERSION/Windows.flatc.binary.zip -OutFile flatc.zip
mkdir bin
Expand-Archive -Force flatc.zip .\bin\
.\bin\flatc --version
- name: Install dependencies on Windows (MingW)
if: startsWith(matrix.config.os, 'windows') && startsWith(matrix.config.key, 'mingw')
run: choco upgrade mingw
- name: Install dependencies on Ubuntu
if: startsWith(matrix.config.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install cpanminus autoconf automake libtool pkg-config libltdl-dev ninja-build cmake
sudo cpanm open
ninja --version
cmake --version
gcc --version
wget https://github.com/google/flatbuffers/releases/download/${{ steps.flatc_version.outputs.tag }}/Linux.flatc.binary.g++-13.zip
mkdir bin
sudo unzip Linux.flatc.binary.g++-13.zip -d bin
./bin/flatc --version
- name: Install dependencies on MacOS
if: startsWith(matrix.config.os, 'macos')
run: |
brew install p7zip cmake ninja
ninja --version
cmake --version
wget https://github.com/google/flatbuffers/releases/download/${{ steps.flatc_version.outputs.tag }}/Mac.flatc.binary.zip
mkdir bin
sudo unzip Mac.flatc.binary.zip -d bin
./bin/flatc --version
- name: Setup Latest Xcode version
if: startsWith(matrix.config.os, 'macos')
uses: maxim-lobanov/[email protected]
with:
xcode-version: latest
- name: Restore SDK Cache
uses: actions/cache/restore@v4
with:
enableCrossOsArchive: true
path: sdk
key: "${{ matrix.build_type }}-${{ inputs.project-slug }}-${{ matrix.config.target_triplet }}-${{ hashFiles('**/sdk') }}"
restore-keys: |
${{ matrix.build_type }}-${{ inputs.project-slug }}-${{ matrix.config.target_triplet }}
- name: Configure
id: configure
shell: bash
working-directory: ${{ inputs.project-path }}
run: |
mkdir build
cmake \
-S . \
-B build \
-G "${{ matrix.config.generator }}" \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_TOOLCHAIN_FILE:STRING="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET:STRING="${{ matrix.config.target_triplet }}" \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
-DBUILD_SAMPLES:BOOL=TRUE
env:
AM_SDK_PATH: "${{ steps.sdk_path.outputs.path }}/sdk"
AM_SDK_PLATFORM: ${{ matrix.config.target_triplet }}
- name: Inspect vcpkg errors
if: failure() && steps.configure.outcome != 'success'
run: |
cat ${{ github.workspace }}/build/vcpkg_installed/vcpkg/issue_body.md
- name: Build
shell: bash
working-directory: ${{ inputs.project-path }}/build
run: cmake --build . --config ${{ matrix.build_type }}
- name: Install Strip
shell: bash
working-directory: ${{ inputs.project-path }}/build
run: cmake --install . --strip --config ${{ matrix.build_type }}
- name: Copy flatc to SDK folder (Windows)
if: inputs.need-flatc && startsWith(matrix.config.os, 'windows')
run: |
Copy-Item .\bin\flatc.exe -Destination .\sdk\bin\${{ matrix.config.target_triplet }}
- name: Copy flatc to SDK folder (Unix)
if: inputs.need-flatc && (startsWith(matrix.config.os, 'ubuntu') || startsWith(matrix.config.os, 'macos'))
run: |
cp ./bin/flatc ./sdk/bin/${{ matrix.config.target_triplet }}
- name: Save SDK Cache
uses: actions/cache/save@v4
id: cache
with:
enableCrossOsArchive: true
path: sdk
key: ${{ matrix.build_type }}-${{ inputs.project-slug }}-${{ matrix.config.target_triplet }}-${{ hashFiles('**/sdk') }}