-
Notifications
You must be signed in to change notification settings - Fork 244
145 lines (141 loc) · 5.21 KB
/
build.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
name: Build
on: [push, pull_request]
env:
BUILD_TYPE: Release
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: "Windows Latest MSVC"
os: windows-latest
cc: "cl"
cxx: "cl"
environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
- name: "Ubuntu Latest GCC"
os: ubuntu-latest
cc: "gcc-11"
cxx: "g++-11"
- name: "macOS Latest Clang"
os: macos-latest
cc: "clang"
cxx: "clang++"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Cache vcpkg installed libraries
uses: actions/cache@v2
with:
path: |
!c:/vcpkg/packages
c:/vcpkg/installed
c:/vcpkg/vcpkg
key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/vcpkg.json') }}
restore-keys: |
${{ runner.os }}-vcpkg-
- name: Install Windows dependencies
if: runner.os == 'Windows'
shell: cmd
run: |
vcpkg install pkgconf
vcpkg install cairo
vcpkg install libwebp
- name: Install package dependencies
id: cmake_and_ninja
shell: cmake -P {0}
run: |
if ("${{ runner.os }}" STREQUAL "Windows")
execute_process(COMMAND choco install ninja)
elseif ("${{ runner.os }}" STREQUAL "Linux")
execute_process(COMMAND sudo apt-get update)
execute_process(COMMAND sudo apt-get install libcairo2-dev)
execute_process(COMMAND sudo apt-get install libgtk-3-dev)
execute_process(COMMAND sudo apt-get install libwebp-dev)
execute_process(COMMAND sudo apt-get install ninja-build)
elseif ("${{ runner.os }}" STREQUAL "macOS")
execute_process(COMMAND brew install pkg-config)
execute_process(COMMAND brew install cairo)
execute_process(COMMAND brew install fontconfig)
execute_process(COMMAND brew install bzip2)
execute_process(COMMAND brew install expat)
execute_process(COMMAND brew install zlib)
execute_process(COMMAND brew install libpng)
execute_process(COMMAND brew install webp)
execute_process(COMMAND brew install ninja)
endif()
- name: Configure
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
# If we are on windows, run the environment script, parse it with cmake
# and set environment variables with it (required for Visual Studio)
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
)
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()
if ("${{ runner.os }}" STREQUAL "Windows")
execute_process(
COMMAND ${CMAKE_COMMAND}
-S .
-B build
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-G Ninja
-D CMAKE_MAKE_PROGRAM=ninja
-D CMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake
RESULT_VARIABLE result
ERROR_VARIABLE error_message
)
else()
execute_process(
COMMAND ${CMAKE_COMMAND}
-S .
-B build
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-G Ninja
-D CMAKE_MAKE_PROGRAM=ninja
RESULT_VARIABLE result
ERROR_VARIABLE error_message
)
endif()
if (NOT result EQUAL 0)
message(FATAL_ERROR "Could not run with ${CMAKE_COMMAND}: Got ${error_message} - ${result}")
endif()
- name: Build
shell: cmake -P {0}
run: |
# If we are on windows, run the environment script, parse it with cmake
# and set environment variables with it (required for Visual Studio)
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
)
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()
execute_process(
COMMAND ${CMAKE_COMMAND} --build build
RESULT_VARIABLE result
ERROR_VARIABLE error_message
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Could not run with ${CMAKE_COMMAND}: Got ${error_message} - ${result}")
endif()