-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrite_workflows.js
274 lines (256 loc) · 7.05 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
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 writeWorkflow(workflow) {
if (workflow.sys === 'FreeBSD') {
writeFreeBSDWorkflow(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 ?? '';
let workflowName = workflow.sys;
if (workflow.cpu) workflowName += ' on ' + workflow.cpu;
if (workflow.gfx) workflowName += ' (' + workflow.gfx + ')';
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}../Kore/make ${sys}${vs}${gfx}${options} --compile${postfix}
`;
if (workflow.env) {
workflowText += workflow.env;
}
}
let name = workflow.sys.toLowerCase();
if (workflow.cpu) name += '-' + workflow.cpu.toLowerCase().replace(/ /g, '');
if (workflow.gfx) name += '-' + workflow.gfx.toLowerCase().replace(/ /g, '');
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: 'iOS',
gfx: 'Metal',
runsOn: 'macOS-latest',
options: '--nosigning'
},
{
sys: 'iOS',
gfx: 'OpenGL',
runsOn: 'macOS-latest',
options: '--nosigning',
noCompute: true
},
{
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: 'OpenGL',
cpu: 'ARM',
runsOn: 'ubuntu-22.04-arm',
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
`
},
{
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-noble.list http://packages.lunarg.com/vulkan/lunarg-vulkan-noble.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);
}