forked from ange-yaghi/engine-sim
-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (132 loc) · 5.19 KB
/
Copy pathcmake.yml
File metadata and controls
156 lines (132 loc) · 5.19 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
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
name: CMake
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build-windows:
name: Build and Test (windows-latest)
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: windows-latest
env:
# Set your boost version
BOOST_VERSION: 1.78.0
# Set your boost path to the default one (I don't know if you can use variables here)
BOOST_PATH: ${{github.workspace}}/boost
SCCACHE_DIR: ${{github.workspace}}/.sccache
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
submodules: recursive
- name: Cache winflexbison3
id: cache-wfb
uses: actions/cache@v5
with:
path: C:\ProgramData\chocolatey\lib\winflexbison3\tools
key: winflexbison3-2.5.24
- name: Install winflexbison3
if: steps.cache-wfb.outputs.cache-hit != 'true'
run: choco install -y winflexbison3
- name: Configure winflexbison3 PATH
shell: pwsh
run: |
$tools = "C:\ProgramData\chocolatey\lib\winflexbison3\tools"
if (Test-Path "$tools\win_bison.exe") { Copy-Item "$tools\win_bison.exe" "$tools\bison.exe" -Force }
if (Test-Path "$tools\win_flex.exe") { Copy-Item "$tools\win_flex.exe" "$tools\flex.exe" -Force }
Add-Content -Path $env:GITHUB_PATH -Value $tools
& "$tools\bison.exe" --version
& "$tools\flex.exe" --version
- name: Cache boost
uses: actions/cache@v5
id: cache-boost
with:
# Set the path to cache
path: ${{env.BOOST_PATH}}
# Use the version as the key to only cache the correct version
key: boost-${{env.BOOST_VERSION}}
- name: Prepare boost install directory
shell: pwsh
run: |
$path = "${{ github.workspace }}\boost"
if (-not (Test-Path $path)) { New-Item -ItemType Directory -Path $path -Force | Out-Null }
# Actual install step (only runs if the cache is empty)
- name: Install boost
if: steps.cache-boost.outputs.cache-hit != 'true'
uses: MarkusJx/install-boost@v2.6.0
with:
# Set the boost version (required)
boost_version: ${{env.BOOST_VERSION}}
# Set the install directory parent path
boost_install_dir: ${{env.BOOST_PATH}}
# Set your platform version
platform_version: 2022
# Set the toolset
toolset: msvc
- name: Prepare sccache directory
shell: pwsh
run: New-Item -ItemType Directory -Force -Path "${{ env.SCCACHE_DIR }}" | Out-Null
- name: Restore sccache
uses: actions/cache@v5
with:
path: ${{env.SCCACHE_DIR}}
key: sccache-windows-${{ github.sha }}
restore-keys: |
sccache-windows-
- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build `
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} `
-DBOOST_ROOT="${{ env.BOOST_PATH }}/boost" `
-DCMAKE_PREFIX_PATH="${{ env.BOOST_PATH }}/boost" `
-DCMAKE_C_COMPILER_LAUNCHER=sccache `
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache `
-DCMAKE_CXX_FLAGS="/MP"
env:
BOOST_ROOT: ${{ env.BOOST_PATH }}/boost
- name: Build
# Build only the library and tests — skip engine-sim-app which requires delta-studio
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target engine-sim engine-sim-test
- name: Test
run: ctest --test-dir ${{github.workspace}}/build --output-on-failure -C ${{env.BUILD_TYPE}}
build-macos:
name: Build and Test (macos-latest)
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Cache Homebrew packages
uses: actions/cache@v5
with:
path: |
~/Library/Caches/Homebrew
key: ${{ runner.os }}-${{ runner.arch }}-brew-${{ hashFiles('Brewfile') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-brew-
- name: Install dependencies
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
HOMEBREW_NO_INSTALL_CLEANUP: "1"
run: |
brew bundle --file Brewfile
echo "/opt/homebrew/opt/bison/bin" >> $GITHUB_PATH
echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH
- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DBOOST_ROOT="/opt/homebrew/opt/boost" \
-DCMAKE_PREFIX_PATH="/opt/homebrew/opt/boost" \
-DDISCORD_ENABLED=OFF \
-DCMAKE_CXX_FLAGS="-Wno-error=unused-variable -Wno-error=unused-parameter"
- name: Build
run: cmake --build ${{github.workspace}}/build --target engine-sim-test -- -j$(sysctl -n hw.logicalcpu)
- name: Test
run: ctest --test-dir ${{github.workspace}}/build --output-on-failure -j$(sysctl -n hw.logicalcpu)