-
Notifications
You must be signed in to change notification settings - Fork 54
207 lines (182 loc) · 6.75 KB
/
build-rd-cpp.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
name: build-rd-cpp
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
NINJA_VERSION: 1.9.0
BUILD_TYPE: Release
jobs:
build:
env:
working-dir: ${{ github.workspace}}${{ matrix.config.SEP }}rd-cpp
artifact: ${{ matrix.config.artifact }}${{ github.run_number }}.zip
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "RD CPP Windows VS 2019", artifact: "RD-CPP-Windows-MSVC-2019-",
os: windows-2019,
cc: "cl", cxx: "cl",
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
SEP: \,
suffix: win-vs19
}
- {
name: "RD CPP Ubuntu Latest Clang", artifact: "RD-CPP-Linux-Clang-",
os: ubuntu-latest,
cc: "clang", cxx: "clang++",
SEP: /,
suffix: linux-clang
}
- {
name: "RD CPP macOS Latest Clang", artifact: "RD-CPP-macOS-Clang-",
os: macos-latest,
cc: "clang", cxx: "clang++",
SEP: /,
suffix: mac-clang
}
steps:
- uses: actions/checkout@v3
- name: Cache submodules
uses: actions/cache@v3
id: cache-submodules
with:
path: |
rd-cpp/thirdparty/spdlog
rd-cpp/thirdparty/googletest
key: ${{ matrix.config.os }}-submodules-${{ hashFiles('.gitmodules') }}
- name: Get submodules
if: steps.cache-submodules.outputs.cache-hit != 'true'
run: git submodule update --init --recursive
- name: Get nuget
if: steps.cache-nuget.outputs.cache-hit != 'true'
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.x'
- name: Cache Ninja
uses: actions/cache@v3
id: cache-ninja
with:
path: |
rd-cpp/ninja
rd-cpp/ninja.exe
key: ${{ matrix.config.os }}-Ninja-${{ env.NINJA_VERSION }}
- name: Download Ninja
if: steps.cache-ninja.outputs.cache-hit != 'true'
id: download_ninja
working-directory: ${{ env.working-dir }}
shell: cmake -P {0}
run: |
set(ninja_version $ENV{NINJA_VERSION})
message(STATUS "Using host CMake version: ${CMAKE_VERSION}")
if ("${{ runner.os }}" STREQUAL "Windows")
set(ninja_suffix "win.zip")
elseif ("${{ runner.os }}" STREQUAL "Linux")
set(ninja_suffix "linux.zip")
elseif ("${{ runner.os }}" STREQUAL "macOS")
set(ninja_suffix "mac.zip")
endif()
set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}")
file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS)
execute_process(COMMAND
${CMAKE_COMMAND} -E tar xvf ./ninja.zip
RESULT_VARIABLE download_ninja_result)
if (NOT download_ninja_result EQUAL 0)
message(FATAL_ERROR "Bad exit status. Fail downloading Ninja")
endif()
if (NOT "${{ runner.os }}" STREQUAL "Windows")
execute_process(COMMAND chmod +x ninja)
endif()
- name: Configure
working-directory: ${{ env.working-dir }}
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
file(GLOB all_files "*")
message(${all_files})
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
execute_process(
COMMAND "${{ matrix.config.environment_script }}" && set
OUTPUT_FILE environment_script_output.txt
RESULT_VARIABLE execute_vcvars_result
)
if (NOT execute_vcvars_result EQUAL 0)
message(FATAL_ERROR "Bad exit status ${execute_vcvars_result}. Fail running ${{ matrix.config.environment_script }}")
endif()
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
file(MAKE_DIRECTORY build)
execute_process(
COMMAND ${CMAKE_COMMAND}
-S .
-B build
-DENABLE_TESTS_OPTION:BOOL=OFF
-DCMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-G Ninja
-DCMAKE_MAKE_PROGRAM=${CMAKE_CURRENT_SOURCE_DIR}/ninja
RESULT_VARIABLE build_result
)
if (NOT build_result EQUAL 0)
message(FATAL_ERROR "Bad exit status. Fail building RD CPP")
endif()
- name: Upload environment script log
uses: actions/upload-artifact@v3
if: always()
with:
name: build-log-${{ matrix.config.os }}
path: environment_script_output.txt
- name: Build
working-directory: ${{ env.working-dir }}
shell: cmake -P {0}
run: |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
file(GLOB all_files "*")
message(${all_files})
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
execute_process(
COMMAND ${CMAKE_COMMAND} --build build --config ${{ env.BUILD_TYPE }}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Install Strip
working-directory: ${{ env.working-dir }}
run: cd build && cmake --config ${{ env.BUILD_TYPE }} -P cmake_install.cmake
- name: Pack
working-directory: ${{ env.working-dir }}
run: cd export && cmake -E tar "cfv" ../${{ env.artifact }} --format=zip include libs
- name: Upload
uses: actions/upload-artifact@v3
with:
path: |
${{ env.working-dir }}${{ matrix.config.SEP }}export${{ matrix.config.SEP }}**
name: ${{ env.artifact }}