-
Notifications
You must be signed in to change notification settings - Fork 1
/
write_workflows.js
449 lines (403 loc) · 12.8 KB
/
write_workflows.js
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
const fs = require('fs');
const path = require('path');
const samples = [
'Shader',
'Texture',
'MultiWindow',
'ComputeShader',
'TextureArray',
'ShaderG5',
'RuntimeShaderCompilation',
'00_empty',
'01_triangle',
'02_matrix',
'03_colored_cube',
'04_textured_cube',
'05_camera_controls',
'06_render_targets',
'07_multiple_render_targets',
'08_float_render_targets',
'09_depth_render_targets',
'10_cubemap',
'11_instanced_rendering',
'12_set_render_target_depth',
'13_generate_mipmaps',
'14_set_mipmap',
'15_deinterleaved_buffers'
];
const workflowsDir = path.join('.github', 'workflows');
function writeFreeBSDWorkflow(workflow) {
const steps = workflow.steps ?? '';
const postfixSteps = workflow.postfixSteps ?? '';
const workflowName = workflow.gfx ? (workflow.sys + ' (' + workflow.gfx + ')') : workflow.sys;
let workflowText = `name: ${workflowName}
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ${workflow.runsOn}
steps:
- uses: actions/checkout@v3
${steps}
- name: Get Submodules
run: ./get_dlc
- name: Get the FreeBSD-submodule
run: git -C Kinc submodule update --init Tools/freebsd_x64
- name: Compile in FreeBSD VM
id: build
uses: vmactions/freebsd-vm@v0
with:
usesh: true
copyback: false
mem: 2048
prepare: pkg install -y bash alsa-lib libXinerama mesa-libs libXi xorg-vfbserver libXrandr libXi libXcursor evdev-proto libinotify ImageMagick7-nox11 libxkbcommon
run: |
`;
for (const sample of samples) {
if (sample === 'RuntimeShaderCompilation') {
if (!workflow.RuntimeShaderCompilation) {
continue;
}
}
if (workflow.noCompute && sample === 'ComputeShader') {
continue;
}
if (workflow.noTexArray && sample === 'TextureArray') {
continue;
}
const prefix = workflow.compilePrefix ?? '';
const postfix = workflow.compilePostfix ?? '';
const gfx = workflow.gfx ? ((workflow.gfx === 'WebGL') ? ' -g opengl' : ' -g ' + workflow.gfx.toLowerCase().replace(/ /g, '')) : '';
const options = workflow.options ? ' ' + workflow.options : '';
const sys = workflow.sys === 'macOS' ? 'osx' : (workflow.sys === 'UWP' ? 'windowsapp' : workflow.sys.toLowerCase());
const vs = workflow.vs ? ' -v ' + workflow.vs : '';
workflowText +=
` echo " * Compile ${sample}"
cd ${sample}
../Kinc/make ${sys}${vs}${gfx}${options} --compile${postfix}
cd ..
`;
if (workflow.env) {
workflowText += workflow.env;
}
}
const name = workflow.gfx ? (workflow.sys.toLowerCase() + '-' + workflow.gfx.toLowerCase().replace(/ /g, '')) : workflow.sys.toLowerCase();
fs.writeFileSync(path.join(workflowsDir, name + '.yml'), workflowText, {encoding: 'utf8'});
}
function writeLinuxArmWorkflow(workflow) {
const steps = workflow.steps ?? '';
const postfixSteps = workflow.postfixSteps ?? '';
const workflowName = workflow.gfx ? (workflow.sys + ' (' + workflow.gfx + ')') : workflow.sys;
let workflowText = `name: Linux on ARM (OpenGL)
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
name: Build on \${{ matrix.distro }} \${{ matrix.arch }}
# Run steps for both armv6 and aarch64
strategy:
matrix:
include:
- arch: aarch64
distro: ubuntu20.04
- arch: armv7
distro: ubuntu20.04
steps:
- uses: actions/checkout@v3
- uses: uraimo/[email protected]
name: Run Tests in \${{ matrix.distro }} \${{ matrix.arch }}
id: build
with:
arch: \${{ matrix.arch }}
distro: \${{ matrix.distro }}
# Not required, but speeds up builds
githubToken: \${{ github.token }}
# The shell to run commands with in the container
shell: /bin/bash
# Install some dependencies in the container. This speeds up builds if
# you are also using githubToken. Any dependencies installed here will
# be part of the container image that gets cached, so subsequent
# builds don't have to re-install them. The image layer is cached
# publicly in your project's package repository, so it is vital that
# no secrets are present in the container state or logs.
install: |
apt-get update -y -q
apt-get upgrade -y -q
apt-get install -y -q libasound2-dev libxinerama-dev libxrandr-dev libgl1-mesa-dev libxi-dev libxcursor-dev libudev-dev git build-essential imagemagick xvfb libwayland-dev wayland-protocols libxkbcommon-dev ninja-build
# Produce a binary artifact and place it in the mounted volume
run: |
echo " * Make Git happy"
git config --global --add safe.directory /home/runner/work/Kinc-Samples/Kinc-Samples
git config --global --add safe.directory /home/runner/work/Kinc-Samples/Kinc-Samples/Kinc
git config --global --add safe.directory /home/runner/work/Kinc-Samples/Kinc-Samples/Kinc/Tools/linux_arm
git config --global --add safe.directory /home/runner/work/Kinc-Samples/Kinc-Samples/Kinc/Tools/linux_arm64
echo " * Get Submodules"
./get_dlc
`;
for (const sample of samples) {
if (sample === 'RuntimeShaderCompilation') {
if (!workflow.RuntimeShaderCompilation) {
continue;
}
}
if (workflow.noCompute && sample === 'ComputeShader') {
continue;
}
if (workflow.noTexArray && sample === 'TextureArray') {
continue;
}
const prefix = workflow.compilePrefix ?? '';
const postfix = workflow.compilePostfix ?? '';
const gfx = workflow.gfx ? ((workflow.gfx === 'WebGL') ? ' -g opengl' : ' -g ' + workflow.gfx.toLowerCase().replace(/ /g, '')) : '';
const options = workflow.options ? ' ' + workflow.options : '';
const sys = workflow.sys === 'macOS' ? 'osx' : (workflow.sys === 'UWP' ? 'windowsapp' : workflow.sys.toLowerCase());
const vs = workflow.vs ? ' -v ' + workflow.vs : '';
workflowText +=
` echo " * Compile ${sample}"
cd ${sample}
../Kinc/make -g opengl --compile
cd ..
`;
if (workflow.env) {
workflowText += workflow.env;
}
}
fs.writeFileSync(path.join(workflowsDir, 'linux-arm-opengl.yml'), workflowText, {encoding: 'utf8'});
}
function writeWorkflow(workflow) {
if (workflow.sys === 'FreeBSD') {
writeFreeBSDWorkflow(workflow);
return;
}
if (workflow.sys === 'Linux' && workflow.cpu === 'ARM') {
writeLinuxArmWorkflow(workflow);
return;
}
const java = workflow.java
?
`
- uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: '17'
`
:
'';
const steps = workflow.steps ?? '';
const postfixSteps = workflow.postfixSteps ?? '';
const workflowName = workflow.gfx ? (workflow.sys + ' (' + workflow.gfx + ')') : workflow.sys;
let workflowText = `name: ${workflowName}
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ${workflow.runsOn}
steps:
- uses: actions/checkout@v3
${java}
${steps}
- name: Get Submodules
run: ./get_dlc
${postfixSteps}
`;
for (const sample of samples) {
if (sample === 'RuntimeShaderCompilation') {
if (!workflow.RuntimeShaderCompilation) {
continue;
}
}
if (workflow.noCompute && sample === 'ComputeShader') {
continue;
}
if (workflow.noTexArray && sample === 'TextureArray') {
continue;
}
const prefix = workflow.compilePrefix ?? '';
const postfix = workflow.compilePostfix ?? '';
const gfx = workflow.gfx ? ((workflow.gfx === 'WebGL') ? ' -g opengl' : ' -g ' + workflow.gfx.toLowerCase().replace(/ /g, '')) : '';
const options = workflow.options ? ' ' + workflow.options : '';
const sys = workflow.sys === 'macOS' ? 'osx' : (workflow.sys === 'UWP' ? 'windowsapp' : workflow.sys.toLowerCase());
const vs = workflow.vs ? ' -v ' + workflow.vs : '';
workflowText +=
` - name: Compile ${sample}
working-directory: ${sample}
run: ${prefix}../Kinc/make ${sys}${vs}${gfx}${options} --compile${postfix}
`;
if (workflow.env) {
workflowText += workflow.env;
}
}
const name = workflow.gfx ? (workflow.sys.toLowerCase() + '-' + workflow.gfx.toLowerCase().replace(/ /g, '')) : workflow.sys.toLowerCase();
fs.writeFileSync(path.join(workflowsDir, name + '.yml'), workflowText, {encoding: 'utf8'});
}
const workflows = [
{
sys: 'Android',
gfx: 'OpenGL',
runsOn: 'ubuntu-latest',
java: true
},
{
sys: 'Android',
gfx: 'Vulkan',
runsOn: 'ubuntu-latest',
java: true
},
{
sys: 'Emscripten',
gfx: 'WebGL',
runsOn: 'ubuntu-latest',
steps: '',
compilePrefix: '../emsdk/emsdk activate latest && source ../emsdk/emsdk_env.sh && ',
compilePostfix: ' && cd build/Release && make',
postfixSteps:
` - name: Setup emscripten
run: git clone https://github.com/emscripten-core/emsdk.git && cd emsdk && ./emsdk install latest
`,
noCompute: true,
noTexArray: true
},
{
sys: 'Emscripten',
gfx: 'WebGPU',
runsOn: 'ubuntu-latest',
steps: '',
compilePrefix: '../emsdk/emsdk activate latest && source ../emsdk/emsdk_env.sh && ',
compilePostfix: ' && cd build/Release && make',
postfixSteps:
` - name: Setup emscripten
run: git clone https://github.com/emscripten-core/emsdk.git && cd emsdk && ./emsdk install latest
`
},
/*{
sys: 'FreeBSD',
gfx: 'OpenGL',
runsOn: 'macos-12'
},*/
{
sys: 'iOS',
gfx: 'Metal',
runsOn: 'macOS-latest',
options: '--nosigning'
},
{
sys: 'iOS',
gfx: 'OpenGL',
runsOn: 'macOS-latest',
options: '--nosigning',
noCompute: true
},
{
sys: 'Linux',
gfx: 'OpenGL',
cpu: 'ARM'
},
{
sys: 'Linux',
gfx: 'OpenGL',
runsOn: 'ubuntu-latest',
steps:
` - name: Apt Update
run: sudo apt update
- name: Apt Install
run: sudo apt-get install libasound2-dev libxinerama-dev libxrandr-dev libgl1-mesa-dev libxi-dev libxcursor-dev libudev-dev libwayland-dev wayland-protocols libxkbcommon-dev ninja-build --yes --quiet
`,
RuntimeShaderCompilation: true
},
{
sys: 'Linux',
gfx: 'Vulkan',
runsOn: 'ubuntu-latest',
steps:
` - name: Get LunarG key
run: wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
- name: Get LunarG apt sources
run: sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.3.275-jammy.list https://packages.lunarg.com/vulkan/1.3.275/lunarg-vulkan-1.3.275-jammy.list
- name: Apt Update
run: sudo apt update
- name: Apt Install
run: sudo apt install libasound2-dev libxinerama-dev libxrandr-dev libgl1-mesa-dev libxi-dev libxcursor-dev libudev-dev vulkan-sdk libwayland-dev wayland-protocols libxkbcommon-dev ninja-build --yes --quiet
`
},
{
sys: 'macOS',
gfx: 'Metal',
runsOn: 'macOS-latest',
RuntimeShaderCompilation: true
},
{
sys: 'macOS',
gfx: 'OpenGL',
runsOn: 'macOS-latest'
},
{
sys: 'UWP',
runsOn: 'windows-latest',
vs: 'vs2022'
},
{
sys: 'Windows',
gfx: 'Direct3D 9',
runsOn: 'windows-latest',
noCompute: true,
noTexArray: true,
vs: 'vs2022',
postfixSteps:
` - name: Install DirectX
run: choco install -y directx --no-progress`
},
{
sys: 'Windows',
gfx: 'Direct3D 11',
runsOn: 'windows-latest',
RuntimeShaderCompilation: true,
vs: 'vs2022'
},
{
sys: 'Windows',
gfx: 'Direct3D 12',
runsOn: 'windows-latest',
vs: 'vs2022'
},
{
sys: 'Windows',
gfx: 'OpenGL',
runsOn: 'windows-latest',
vs: 'vs2022'
},
{
sys: 'Windows',
gfx: 'Vulkan',
runsOn: 'windows-latest',
vs: 'vs2022',
env:
` env:
VULKAN_SDK: C:\\VulkanSDK\\1.3.275.0
`,
steps:
` - name: Setup Vulkan
run: |
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.3.275.0/windows/VulkanSDK-1.3.275.0-Installer.exe" -OutFile VulkanSDK.exe
$installer = Start-Process -FilePath VulkanSDK.exe -Wait -PassThru -ArgumentList @("--da", "--al", "-c", "in");
$installer.WaitForExit();`
}
];
for (const workflow of workflows) {
writeWorkflow(workflow);
}