-
Notifications
You must be signed in to change notification settings - Fork 52
/
Makefile.toml
550 lines (486 loc) · 11.8 KB
/
Makefile.toml
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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
[config]
default_to_workspace = false
# If adding a new backend, be sure to update:
# - test-native (if necessary)
# - test-example
# - test-feature
# - gen-example
# - gen-feature
#
# You will likely also want to add {gen, test}-{feature, example}-[backend] and
# {gen, test}-[backend]
# Metatasks invoked by CI
[tasks.test-native]
description = "Test only the native"
category = "Tests"
dependencies = [
"test-cpp",
"test-c",
]
[tasks.gen]
category = "Code generation"
dependencies = [
"gen-feature",
"gen-example",
]
# Tests
[tasks.test-all]
category = "Tests"
dependencies = [
"test-example",
"test-feature",
]
[tasks.test-cpp]
category = "Tests"
dependencies = [
"test-cpp-example",
"test-cpp-feature",
]
[tasks.test-c]
category = "Tests"
dependencies = [
"test-c-example",
]
[tasks.test-js]
category = "Tests"
dependencies = [
"test-js-feature",
]
[tasks.test-demo]
category = "Tests"
dependencies = [
"test-demo-feature",
"test-demo-example"
]
[tasks.test-dart]
category = "Tests"
dependencies = [
"test-dart-example",
"test-dart-feature",
]
[tasks.test-kotlin]
category = "Tests"
dependencies = [
"test-kotlin-example",
"test-kotlin-feature",
]
[tasks.test-example]
category = "Tests"
dependencies = [
"test-cpp-example",
"test-c-example",
"test-demo-example",
"test-dart-example",
"test-kotlin-example",
]
[tasks.test-feature]
category = "Tests"
dependencies = [
"test-cpp-feature",
"test-js-feature",
"test-demo-feature",
"test-dart-feature",
"test-kotlin-feature",
]
[tasks.test-cpp-example]
category = "Tests"
dependencies = ["build-example"]
script_runner = "@duckscript"
script = '''
exit_on_error true
cd example/cpp
rm tests/*.out
exec --fail-on-error make
'''
[tasks.test-cpp-feature]
category = "Tests"
dependencies = ["build-feature"]
script_runner = "@duckscript"
script = '''
exit_on_error true
cd feature_tests/cpp
rm tests/*.out
exec --fail-on-error make
'''
[tasks.test-c-example]
category = "Tests"
dependencies = ["build-example"]
script_runner = "@duckscript"
script = '''
exit_on_error true
cd example/c
rm *.out
exec --fail-on-error make
'''
[tasks.test-js-feature]
category = "Tests"
dependencies = ["build-feature-wasm"]
script_runner = "@shell"
script = '''
cd feature_tests/js/
cp ../../target/wasm32-unknown-unknown/debug/diplomat_feature_tests.wasm api/diplomat_feature_tests.wasm
npm install && npm run test
'''
[tasks.test-demo-feature]
category = "Tests"
dependencies = ["build-feature-wasm"]
script_runner = "@shell"
script = '''
cd feature_tests/demo_gen
cp ../../target/wasm32-unknown-unknown/debug/diplomat_feature_tests.wasm ../js/api/diplomat_feature_tests.wasm
npm install && npm run test
'''
[tasks.test-demo-example]
category = "Tests"
dependencies = ["build-example-wasm"]
script_runner = "@shell"
script = '''
cd example/demo_gen
cp ../../target/wasm32-unknown-unknown/debug/diplomat_example.wasm ../js/lib/api/diplomat_example.wasm
npm install && npm run test
'''
[tasks.test-dart-example]
category = "Tests"
script_runner = "@duckscript"
dependencies = ["build-example"]
script = '''
exit_on_error true
cd example/dart/
exec --fail-on-error dart --enable-experiment=native-assets pub get
exec --fail-on-error dart --enable-experiment=native-assets test
'''
[tasks.test-dart-feature]
category = "Tests"
script_runner = "@duckscript"
dependencies = ["build-feature"]
script = '''
exit_on_error true
cd feature_tests/dart/
exec --fail-on-error dart --enable-experiment=native-assets pub get
exec --fail-on-error dart --enable-experiment=native-assets test
'''
[tasks.test-kotlin-example.mac]
env = {"OUT_FILE" = "dylib"}
[tasks.test-kotlin-example.linux]
env = {"OUT_FILE" = "so", "LD_LIBRARY_PATH" = "./"}
[tasks.test-kotlin-example]
category = "Tests"
script_runner = "@duckscript"
dependencies = ["build-example-jvm"]
script = '''
exit_on_error true
cp target/debug/libdiplomat_example.${OUT_FILE} example/kotlin/somelib/libsomelib.${OUT_FILE}
cd example/kotlin/somelib
exec --fail-on-error gradle test --warning-mode all
'''
[tasks.test-kotlin-feature.mac]
env = {"OUT_FILE" = "dylib"}
[tasks.test-kotlin-feature.linux]
env = {"OUT_FILE" = "so", "LD_LIBRARY_PATH" = "./"}
[tasks.test-kotlin-feature]
category = "Tests"
script_runner = "@duckscript"
dependencies = ["build-feature-jvm"]
script = '''
exit_on_error true
cp target/debug/libdiplomat_feature_tests.${OUT_FILE} feature_tests/kotlin/somelib/libsomelib.${OUT_FILE}
cd feature_tests/kotlin/somelib
exec --fail-on-error gradle test --warning-mode all
'''
[tasks.check-c-example]
category = "Tests"
script_runner = "@duckscript"
script = '''
exit_on_error true
cc = get_env CC
if is_empty ${cc}
cc = set "gcc"
end
c_std = get_env C_STD
if is_empty ${c_std}
c_std = set "c11"
end
cd example/c/include
files_list = glob_array "./*.h"
exit_code = set 0
for file in ${files_list}
echo "Checking ${file}"
output = exec --get-exit-code ${cc} -std=${c_std} -pedantic-errors -Wall ${file}
exit_code = set ${exit_code} or ${output}
end
exit ${exit_code}
'''
[tasks.check-c-feature]
category = "Tests"
script_runner = "@duckscript"
script = '''
exit_on_error true
cc = get_env CC
if is_empty ${cc}
cc = set "gcc"
end
c_std = get_env C_STD
if is_empty ${c_std}
c_std = set "c11"
end
cd feature_tests/c/include
files_list = glob_array "./*.h"
exit_code = set 0
for file in ${files_list}
echo "Checking ${file}"
output = exec --get-exit-code ${cc} -std=${c_std} -pedantic-errors -Wall ${file}
exit_code = set ${exit_code} or ${output}
end
exit ${exit_code}
'''
[tasks.check-c]
category = "Tests"
dependencies = [
"check-c-feature",
"check-c-example",
]
[tasks.check-cpp-example]
category = "Tests"
script_runner = "@duckscript"
script = '''
exit_on_error true
cxx = get_env CXX
if is_empty ${cxx}
cxx = set "g++"
end
cxx_std = get_env CXX_STD
if is_empty ${cxx_std}
cxx_std = set "c++17"
end
cd example/cpp/include
files_list = glob_array "./*.hpp"
exit_code = set 0
for file in ${files_list}
echo "Checking ${file}"
output = exec --get-exit-code ${cxx} -std=${cxx_std} -pedantic-errors -Wall ${file}
exit_code = set ${exit_code} or ${output}
end
exit ${exit_code}
'''
[tasks.check-cpp-feature]
category = "Tests"
script_runner = "@duckscript"
script = '''
exit_on_error true
cxx = get_env CXX
if is_empty ${cxx}
cxx = set "g++"
end
cxx_std = get_env CXX_STD
if is_empty ${cxx_std}
cxx_std = set "c++17"
end
cd feature_tests/cpp/include
files_list = glob_array "./*.hpp"
exit_code = set 0
for file in ${files_list}
echo "Checking ${file}"
output = exec --get-exit-code ${cxx} -std=${cxx_std} -pedantic-errors -Wall ${file}
exit_code = set ${exit_code} or ${output}
end
exit ${exit_code}
'''
[tasks.check-cpp]
category = "Tests"
dependencies = [
"check-cpp-feature",
"check-cpp-example",
]
# Generation
[tasks.gen-feature]
category = "Code generation"
dependencies = [
"gen-cpp-feature",
"gen-c-feature",
"gen-js-feature",
"gen-demo-feature",
"gen-dart-feature",
"gen-kotlin-feature",
]
[tasks.gen-example]
category = "Code generation"
dependencies = [
"gen-cpp-example",
"gen-c-example",
"gen-js-example",
"gen-demo-example",
"gen-dart-example",
"gen-kotlin-example",
]
[tasks.gen-c]
category = "Code generation"
dependencies = [
"gen-c-feature",
"gen-c-example"
]
[tasks.gen-cpp]
category = "Code generation"
dependencies = [
"gen-cpp-feature",
"gen-cpp-example"
]
[tasks.gen-dart]
category = "Code generation"
dependencies = [
"gen-dart-feature",
"gen-dart-example",
]
[tasks.gen-kotlin]
category = "Code generation"
dependencies = [
"gen-kotlin-feature",
"gen-kotlin-example",
]
[tasks.gen-c-feature]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic feature_tests c include
'''
[tasks.gen-c-example]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic example c include
'''
[tasks.gen-cpp-feature]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic feature_tests cpp include
'''
[tasks.gen-cpp-example]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic example cpp include
'''
[tasks.gen-js-feature]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic feature_tests js api
'''
[tasks.gen-js-example]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic example js lib/api
'''
[tasks.gen-demo-feature]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic feature_tests demo_gen demo "-l diplomat-demo-conf.toml"
'''
[tasks.gen-demo-example]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic example demo_gen demo "-l diplomat-demo-conf.toml"
'''
[tasks.gen-dart-feature]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic feature_tests dart lib/src
'''
[tasks.gen-dart-example]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic example dart lib/src
'''
# this task generates all of the kotlin code but does not copy generated project files over
# we only copy the generated main src files to preserve the tests
[tasks.gen-kotlin-feature]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic feature_tests kotlin somelib "-l diplomat-kt-conf.toml" /src/main/kotlin
'''
[tasks.gen-kotlin-example]
category = "Code generation"
script_runner = "@duckscript"
script = '''
exit_on_error true
!include_files ./support/functions.ds
generate_generic example kotlin somelib "-l diplomat-kt-conf.toml" /src/main/kotlin
'''
# Build deps
[tasks.build-tool]
description = "Build diplomat-tool"
category = "Plumbing"
command = "cargo"
args = ["build", "-p", "diplomat-tool"]
[tasks.build-example]
description = "Build example"
category = "Plumbing"
command = "cargo"
args = ["build", "-p", "diplomat-example"]
[tasks.build-feature]
description = "Build feature_tests"
category = "Plumbing"
command = "cargo"
args = ["build", "-p", "diplomat-feature-tests"]
[tasks.build-example-wasm]
description = "Build feature_tests for wasm"
category = "Plumbing"
command = "cargo"
args = ["build", "-p", "diplomat-example", "--target", "wasm32-unknown-unknown"]
[tasks.build-feature-wasm]
description = "Build feature_tests for wasm"
category = "Plumbing"
command = "cargo"
args = ["build", "-p", "diplomat-feature-tests", "--target", "wasm32-unknown-unknown"]
[tasks.build-example-jvm]
description = "Build feature_tests for wasm"
category = "Plumbing"
command = "cargo"
args = ["build", "-p", "diplomat-example", "--features", "diplomat-runtime/jvm-callback-support"]
[tasks.build-feature-jvm]
description = "Build feature_tests for wasm"
category = "Plumbing"
command = "cargo"
args = ["build", "-p", "diplomat-feature-tests", "--features", "diplomat-runtime/jvm-callback-support"]
[tasks.bench-rust-example]
description = "Benchmark rust example"
category = "Benchmark"
script = '''
cargo bench --package diplomat-example
'''
[tasks.bench-kotlin-example]
description = "Benchmark kotlin example"
category = "Benchmark"
dependencies = ["gen-kotlin-example", "test-kotlin-example"]
script = '''
cd example/kotlin/somelib
gradle jmh --warning-mode all
'''