-
Notifications
You must be signed in to change notification settings - Fork 48
198 lines (169 loc) · 5.47 KB
/
ci-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
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
name: ci-build
on:
pull_request:
branches:
- master
- develop
- feature/**
push:
branches:
- master
- develop
- feature/**
tags:
- 'v*'
workflow_dispatch:
release:
types: published
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}
cancel-in-progress: true
env:
NINJA_BASE_URL: https://github.com/ninja-build/ninja/releases/download/
jobs:
posix:
strategy:
fail-fast: true
matrix:
include:
- slug: linux-i386
cc: gcc
cxx: g++
cflags: "-m32"
ldflags: "-m32"
libflags: "-m32"
os: ubuntu-20.04
# https://github.com/actions/runner-images/issues/2324#issuecomment-749985726
install: "libc6-dev:i386 libx11-dev:i386 libxext-dev:i386 lib32gcc-7-dev gcc-multilib"
ninja_release_name: v1.11.1/ninja-linux.zip
- slug: linux-amd64
cc: gcc
cxx: g++
cflags: "-m64"
ldflags: "-m64"
libflags: "-m64"
os: ubuntu-20.04
ninja_release_name: v1.11.1/ninja-linux.zip
- slug: macos-amd64
gen_args: "--use-lto --use-icf"
cc: clang
cxx: clang++
cflags: "-m64"
ldflags: "-m64"
libflags: "-m64"
os: macos-12
ninja_release_name: v1.11.1/ninja-mac.zip
runs-on: ${{ matrix.os }}
steps:
- name: Install packages
if: matrix.install
run: sudo apt install ${{ matrix.install }}
- uses: actions/checkout@v4
with:
# we need all everything for `git describe` to work correctly
fetch-depth: 0
- name: Make dependencies directory
run: |
DEPS_DIR=$(cd ~; pwd)/deps
mkdir -p ${DEPS_DIR}
echo "export DEPS_DIR=$DEPS_DIR" >> "${GITHUB_WORKSPACE}/.env"
- name: Install recent Ninja
run: |
source .env
cd ${DEPS_DIR}
wget --no-check-certificate --quiet -O ninja.zip "${NINJA_BASE_URL}${{ matrix.ninja_release_name }}"
python -c 'import sys,zipfile;zipfile.ZipFile(sys.argv[1]).extractall()' ninja.zip
chmod +x ninja
- name: Setup compiler environment
run: |
echo 'export CC="${{ matrix.cc }}"' >> "${GITHUB_WORKSPACE}/.env"
echo 'export CXX="${{ matrix.cxx }}"' >> "${GITHUB_WORKSPACE}/.env"
echo 'export CFLAGS="${{ matrix.cflags }}"' >> "${GITHUB_WORKSPACE}/.env"
echo 'export LDFLAGS="${{ matrix.ldflags }}"' >> "${GITHUB_WORKSPACE}/.env"
echo 'export LIBFLAGS="${{ matrix.libflags }}"' >> "${GITHUB_WORKSPACE}/.env"
- name: Cache libc++ and libc++abi if needed
if: "${{ matrix.cc == 'clang' }}"
uses: actions/cache@v3
with:
path: ~/deps/llvm
key: ${{ runner.os }}-llvm-${{ matrix.slug }}
- name: Show final environment
run: |
cat .env
- name: Compile
run: |
source .env
build/gen.py ${{ matrix.gen_args }}
${DEPS_DIR}/ninja -C out
- name: Run tests
run: |
source .env
out/gn_unittests
- name: Archive binaries
run: |
tar -C out -czf "out/gn-${{ matrix.slug }}.tar.gz" gn
- name: Upload archives
uses: actions/upload-artifact@v3
with:
name: binaries
path: |
out/gn-${{ matrix.slug }}.tar.gz
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
out/gn-${{ matrix.slug }}.tar.gz
windows:
strategy:
fail-fast: true
matrix:
include:
- slug: windows-i386
arch: x86
gen_args: "--use-lto --use-icf"
ninja_release_name: v1.11.1/ninja-linux.zip
- slug: windows-amd64
arch: x64
gen_args: "--use-lto --use-icf"
ninja_release_name: v1.11.1/ninja-linux.zip
runs-on: windows-2022
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v4
with:
# we need all everything for `git describe` to work correctly
fetch-depth: 0
- name: Download Ninja
run: |
Invoke-WebRequest -Uri https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip -OutFile ninja.zip
7z x ninja.zip > nul
./ninja --version
- name: Set up Visual Studio shell
uses: egor-tensin/vs-shell@v2
with:
arch: ${{ matrix.arch }}
- name: Build
run: |
python build/gen.py ${{ matrix.gen_args }}
./ninja -C out
- name: Run tests
run: |
out/gn_unittests
- name: Make zip
run: |
7z a -tzip out\gn-${{ matrix.slug }}.zip out\gn.exe
- name: Upload archives
uses: actions/upload-artifact@v3
with:
name: binaries
path: |
out/gn-${{ matrix.slug }}.zip
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
out/gn-${{ matrix.slug }}.zip