-
Notifications
You must be signed in to change notification settings - Fork 29
/
compile.v
739 lines (636 loc) · 19 KB
/
compile.v
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
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
// Copyright(C) 2019-2022 Lars Pontoppidan. All rights reserved.
// Use of this source code is governed by an MIT license file distributed with this software package
module android
import os
import vab.vxt
import vab.util as job_util
import vab.android.ndk
import vab.android.util
import crypto.md5
pub const (
supported_target_archs = ndk.supported_archs
default_archs = ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
supported_gles_versions = [2, 3]
default_gles_version = 2
)
pub struct CompileOptions {
pub:
verbosity int // level of verbosity
cache bool
cache_key string
parallel bool = true // Run, what can be run, in parallel
no_so_build bool // Do not build the .so file, can be used if you're only interested in the object files
// env
work_dir string // temporary work directory
input string
//
is_prod bool
gles_version int = android.default_gles_version
no_printf_hijack bool // Do not let V redefine printf for log output aka. V_ANDROID_LOG_PRINT
archs []string // compile for these CPU architectures
v_flags []string // flags to pass to the v compiler
c_flags []string // flags to pass to the C compiler(s)
ndk_version string // version of the Android NDK to compile against
lib_name string // filename of the resulting .so ('${lib_name}.so')
api_level string // Android API level to use when compiling
min_sdk_version int = default_min_sdk_version
}
// uses_gc returns true if a `-gc` flag is found among the passed v flags.
pub fn (opt CompileOptions) uses_gc() bool {
mut uses_gc := true // V default
for v_flag in opt.v_flags {
if v_flag.starts_with('-gc') {
if v_flag.ends_with('none') {
uses_gc = false
}
break
}
}
return uses_gc
}
// is_debug_build returns true if either `-cg` or `-g` flags is found among the passed v flags.
pub fn (opt CompileOptions) is_debug_build() bool {
return '-cg' in opt.v_flags || '-g' in opt.v_flags
}
// archs returns an array of target architectures.
pub fn (opt CompileOptions) archs() ![]string {
mut archs := []string{}
if opt.archs.len > 0 {
for arch in opt.archs.map(it.trim_space()) {
if arch in android.default_archs {
archs << arch
} else {
return error(@MOD + '.' + @FN +
': Architechture "$arch" not one of $android.default_archs')
}
}
}
return archs
}
// build_directory returns the compile build directory.
pub fn (opt CompileOptions) build_directory() !string {
dir := os.join_path(opt.work_dir, 'build')
return dir
}
pub enum CompileType {
v_to_c
c_to_o
o_to_so
}
pub struct CompileError {
Error
pub:
kind CompileType
err string
}
fn (err CompileError) msg() string {
enum_to_text := match err.kind {
.v_to_c {
'.v to .c'
}
.c_to_o {
'.c to .o'
}
.o_to_so {
'.o to .so'
}
}
return 'failed to compile $enum_to_text:\n$err.err'
}
// compile_v_to_c compiles V into sources to their C counterpart.
pub fn compile_v_to_c(opt CompileOptions) !VMetaInfo {
err_sig := @MOD + '.' + @FN
os.mkdir_all(opt.work_dir) or {
return error('$err_sig: failed making directory "$opt.work_dir". $err')
}
if opt.verbosity > 0 {
println('Compiling V to C')
if opt.v_flags.len > 0 {
println('V flags: `$opt.v_flags`')
}
}
v_compile_opt := VCompileOptions{
verbosity: opt.verbosity
cache: opt.cache
flags: opt.v_flags
work_dir: os.join_path(opt.work_dir, 'v')
input: opt.input
}
v_meta_dump := v_dump_meta(v_compile_opt)!
imported_modules := v_meta_dump.imports
if imported_modules.len == 0 {
return error('$err_sig: empty module dump.')
}
v_output_file := os.join_path(opt.work_dir, 'v_android.c')
// Boehm-Demers-Weiser Garbage Collector (bdwgc / libgc)
uses_gc := opt.uses_gc()
if opt.verbosity > 1 {
println('Garbage collecting is $uses_gc')
}
vexe := vxt.vexe()
// Compile to Android compatible C file
mut v_cmd := [
vexe,
'-os android',
]
if !uses_gc {
v_cmd << '-gc none'
}
if 'sokol.sapp' in imported_modules {
v_cmd << '-apk'
} else {
v_cmd << '-d no_sokol_app'
}
if !opt.cache {
v_cmd << '-nocache'
}
v_cmd << opt.v_flags
v_cmd << [
'-o "$v_output_file"',
]
v_cmd << opt.input
util.verbosity_print_cmd(v_cmd, opt.verbosity)
v_dump_res := util.run_or_error(v_cmd)!
if opt.verbosity > 2 {
println(v_dump_res)
}
return v_meta_dump
}
pub fn compile(opt CompileOptions) ! {
err_sig := @MOD + '.' + @FN
os.mkdir_all(opt.work_dir) or {
return error('$err_sig: failed making directory "$opt.work_dir". $err')
}
build_dir := opt.build_directory()!
v_meta_dump := compile_v_to_c(opt) or {
return IError(CompileError{
kind: .v_to_c
err: err.msg()
})
}
v_cflags := v_meta_dump.c_flags
imported_modules := v_meta_dump.imports
v_output_file := os.join_path(opt.work_dir, 'v_android.c')
v_thirdparty_dir := os.join_path(vxt.home(), 'thirdparty')
uses_gc := opt.uses_gc()
// Poor man's cache check
mut hash := ''
hash_file := os.join_path(opt.work_dir, 'v_android.hash')
if opt.cache && os.exists(build_dir) && os.exists(v_output_file) {
mut bytes := os.read_bytes(v_output_file) or {
return error('$err_sig: failed reading "$v_output_file".\n$err')
}
bytes << '$opt.str()-$opt.cache_key'.bytes()
hash = md5.sum(bytes).hex()
if os.exists(hash_file) {
prev_hash := os.read_file(hash_file) or { '' }
if hash == prev_hash {
if opt.verbosity > 1 {
println('Skipping compile. Hashes match $hash')
}
return
}
}
}
if hash != '' && os.exists(v_output_file) {
if opt.verbosity > 2 {
println('Writing new hash $hash')
}
os.rm(hash_file) or {}
mut hash_fh := os.open_file(hash_file, 'w+', 0o700) or {
return error('$err_sig: failed opening "$hash_file". $err')
}
hash_fh.write(hash.bytes()) or {
return error('$err_sig: failed writing to "$hash_file".\n$err')
}
hash_fh.close()
}
// Remove any previous builds
if os.is_dir(build_dir) {
os.rmdir_all(build_dir) or { return error('$err_sig: failed removing "$build_dir": $err') }
}
os.mkdir(build_dir) or { return error('$err_sig: failed making directory "$build_dir".\n$err') }
archs := opt.archs()!
if opt.verbosity > 0 {
println('Compiling V import C dependencies (.c to .o for $archs)' +
if opt.parallel { ' in parallel' } else { '' })
}
vicd := compile_v_imports_c_dependencies(opt, imported_modules) or {
return IError(CompileError{
kind: .c_to_o
err: err.msg()
})
}
mut o_files := vicd.o_files.clone()
mut a_files := vicd.a_files.clone()
// For all compilers
mut cflags := opt.c_flags.clone()
mut includes := []string{}
mut defines := []string{}
mut ldflags := []string{}
// Grab any external C flags
for line in v_cflags {
if line.contains('.tmp.c') || line.ends_with('.o"') {
continue
}
if line.starts_with('-D') {
defines << line
}
if line.starts_with('-I') {
if line.contains('/usr/') {
continue
}
includes << line
}
if line.starts_with('-l') {
if line.contains('-lgc') {
// compiled in
continue
}
if line.contains('-lpthread') {
// pthread is built into bionic
continue
}
ldflags << line
}
}
// ... still a bit of a mess
if opt.is_prod {
cflags << ['-Os']
} else {
cflags << ['-O0']
}
cflags << ['-fPIC', '-fvisibility=hidden', '-ffunction-sections', '-fdata-sections',
'-ferror-limit=1']
cflags << ['-Wall', '-Wextra']
cflags << ['-Wno-unused-parameter'] // sokol_app.h
// TODO V compile warnings - here to make the compiler(s) shut up :/
cflags << ['-Wno-unused-variable', '-Wno-unused-result', '-Wno-unused-function',
'-Wno-unused-label']
cflags << ['-Wno-missing-braces', '-Werror=implicit-function-declaration']
cflags << ['-Wno-enum-conversion', '-Wno-unused-value', '-Wno-pointer-sign',
'-Wno-incompatible-pointer-types']
// NOTE This define allows V to redefine C's printf() - to let logging via println() etc. go
// through Android device's system log (that adb logcat reads).
if !opt.no_printf_hijack {
if opt.verbosity > 1 {
println('Define V_ANDROID_LOG_PRINT - (f)printf will be redefined...')
}
defines << '-DV_ANDROID_LOG_PRINT'
}
defines << '-DAPPNAME="$opt.lib_name"'
defines << ['-DANDROID', '-D__ANDROID__', '-DANDROIDVERSION=$opt.api_level']
// Include NDK headers
mut android_includes := []string{}
ndk_sysroot := ndk.sysroot_path(opt.ndk_version) or {
return error('$err_sig: getting NDK sysroot path.\n$err')
}
android_includes << '-I"' + os.join_path(ndk_sysroot, 'usr', 'include') + '"'
android_includes << '-I"' + os.join_path(ndk_sysroot, 'usr', 'include', 'android') + '"'
is_debug_build := opt.is_debug_build()
// Sokol sapp
if 'sokol.sapp' in imported_modules {
if opt.verbosity > 1 {
println('Including sokol_sapp support via sokol.sapp module')
}
if is_debug_build {
if opt.verbosity > 1 {
println('Define SOKOL_DEBUG')
}
defines << '-DSOKOL_DEBUG'
}
if opt.verbosity > 1 {
println('Using GLES $opt.gles_version')
}
ldflags << '-lEGL'
if opt.gles_version == 3 {
defines << ['-DSOKOL_GLES3']
ldflags << '-lGLESv3'
} else {
defines << ['-DSOKOL_GLES2']
ldflags << '-lGLESv2'
}
ldflags << ['-uANativeActivity_onCreate', '-usokol_main']
}
if uses_gc {
includes << '-I"' + os.join_path(v_thirdparty_dir, 'libgc', 'include') + '"'
}
// misc
ldflags << ['-llog', '-landroid', '-lm']
ldflags << ['-shared'] // <- Android loads native code via a library in NativeActivity
mut cflags_arm64 := ['-m64']
mut cflags_arm32 := ['-mfloat-abi=softfp', '-m32']
mut cflags_x86 := ['-march=i686', '-mssse3', '-mfpmath=sse', '-m32']
mut cflags_x86_64 := ['-march=x86-64', '-msse4.2', '-mpopcnt', '-m64']
mut arch_cc := map[string]string{}
mut arch_libs := map[string]string{}
for arch in archs {
compiler := ndk.compiler(.c, opt.ndk_version, arch, opt.api_level) or {
return error('$err_sig: failed getting NDK compiler.\n$err')
}
arch_cc[arch] = compiler
arch_lib := ndk.libs_path(opt.ndk_version, arch, opt.api_level) or {
return error('$err_sig: failed getting NDK libs path.\n$err')
}
arch_libs[arch] = arch_lib
}
mut arch_cflags := map[string][]string{}
arch_cflags['arm64-v8a'] = cflags_arm64
arch_cflags['armeabi-v7a'] = cflags_arm32
arch_cflags['x86'] = cflags_x86
arch_cflags['x86_64'] = cflags_x86_64
if opt.verbosity > 0 {
println('Compiling C output for $archs' + if opt.parallel { ' in parallel' } else { '' })
}
mut jobs := []job_util.ShellJob{}
for arch in archs {
arch_cflags[arch] << [
'-target ' + ndk.compiler_triplet(arch) + opt.min_sdk_version.str(),
]
if arch == 'armeabi-v7a' {
arch_cflags[arch] << ['-march=armv7-a']
}
}
// Cross compile v.c to v.o lib files
for arch in archs {
arch_o_dir := os.join_path(build_dir, 'o', arch)
if !os.is_dir(arch_o_dir) {
os.mkdir_all(arch_o_dir) or {
return error('$err_sig: failed making directory "$arch_o_dir". $err')
}
}
arch_o_file := os.join_path(arch_o_dir, '${opt.lib_name}.o')
// Compile .o
build_cmd := [
arch_cc[arch],
cflags.join(' '),
android_includes.join(' '),
includes.join(' '),
defines.join(' '),
arch_cflags[arch].join(' '),
'-c "$v_output_file"',
'-o "$arch_o_file"',
]
o_files[arch] << arch_o_file
jobs << job_util.ShellJob{
cmd: build_cmd
}
}
job_util.run_jobs(jobs, opt.parallel, opt.verbosity) or {
return IError(CompileError{
kind: .c_to_o
err: err.msg()
})
}
jobs.clear()
if opt.no_so_build && opt.verbosity > 1 {
println('Skipping .so build since .no_so_build == true')
}
// Cross compile .o files to .so lib file
if !opt.no_so_build {
for arch in archs {
arch_lib_dir := os.join_path(build_dir, 'lib', arch)
os.mkdir_all(arch_lib_dir) or {
return error('$err_sig: failed making directory "$arch_lib_dir".\n$err')
}
arch_o_files := o_files[arch].map('"$it"')
arch_a_files := a_files[arch].map('"$it"')
build_cmd := [
arch_cc[arch],
arch_o_files.join(' '),
'-o "$arch_lib_dir/lib${opt.lib_name}.so"',
arch_a_files.join(' '),
'-L"' + arch_libs[arch] + '"',
ldflags.join(' '),
]
jobs << job_util.ShellJob{
cmd: build_cmd
}
}
job_util.run_jobs(jobs, opt.parallel, opt.verbosity) or {
return IError(CompileError{
kind: .o_to_so
err: err.msg()
})
}
if 'armeabi-v7a' in archs {
// TODO fix DT_NAME crash instead of including a copy of the armeabi-v7a lib
armeabi_lib_dir := os.join_path(build_dir, 'lib', 'armeabi')
os.mkdir_all(armeabi_lib_dir) or {
return error('$err_sig: failed making directory "$armeabi_lib_dir".\n$err')
}
armeabi_lib_src := os.join_path(build_dir, 'lib', 'armeabi-v7a', 'lib${opt.lib_name}.so')
armeabi_lib_dst := os.join_path(armeabi_lib_dir, 'lib${opt.lib_name}.so')
os.cp(armeabi_lib_src, armeabi_lib_dst) or {
return error('$err_sig: failed copying "$armeabi_lib_src" to "$armeabi_lib_dst".\n$err')
}
}
}
// !opt.no_so_build
}
pub struct VCompileOptions {
pub:
verbosity int // level of verbosity
cache bool
work_dir string // temporary work directory
input string
flags []string // flags to pass to the v compiler
}
// uses_gc returns true if a `-gc` flag is found among the passed v flags.
pub fn (opt VCompileOptions) uses_gc() bool {
mut uses_gc := true // V default
for v_flag in opt.flags {
if v_flag.starts_with('-gc') {
if v_flag.ends_with('none') {
uses_gc = false
}
break
}
}
return uses_gc
}
pub struct VMetaInfo {
pub:
imports []string
c_flags []string
}
// v_dump_meta returns the information dumped by
// -dump-modules and -dump-c-flags.
pub fn v_dump_meta(opt VCompileOptions) !VMetaInfo {
err_sig := @MOD + '.' + @FN
os.mkdir_all(opt.work_dir) or {
return error('$err_sig: failed making directory "$opt.work_dir". $err')
}
vexe := vxt.vexe()
uses_gc := opt.uses_gc()
// Dump modules and C flags to files
v_cflags_file := os.join_path(opt.work_dir, 'v.cflags')
os.rm(v_cflags_file) or {}
v_dump_modules_file := os.join_path(opt.work_dir, 'v.modules')
os.rm(v_dump_modules_file) or {}
mut v_cmd := [
vexe,
'-os android',
]
if !uses_gc {
v_cmd << '-gc none'
}
if !opt.cache {
v_cmd << '-nocache'
}
v_cmd << opt.flags
v_cmd << [
'-cc clang',
'-dump-modules "$v_dump_modules_file"',
'-dump-c-flags "$v_cflags_file"',
]
v_cmd << opt.input
// NOTE this command fails with a C compile error but the output we need is still
// present... Yes - not exactly pretty.
// VCROSS_COMPILER_NAME is needed (on at least Windows) - just get whatever compiler is available
os.setenv('VCROSS_COMPILER_NAME', ndk.compiler_min_api(.c, ndk.default_version(),
'arm64-v8a') or { '' }, true)
util.verbosity_print_cmd(v_cmd, opt.verbosity)
v_dump_res := util.run(v_cmd)
if opt.verbosity > 3 {
println(v_dump_res)
}
// Read in the dumped cflags
cflags := os.read_file(v_cflags_file) or {
flat_cmd := v_cmd.join(' ')
return error('$err_sig: failed reading C flags to "$v_cflags_file". $err\nCompile output of `$flat_cmd`:\n$v_dump_res')
}
// Parse imported modules from dump
mut imported_modules := os.read_file(v_dump_modules_file) or {
flat_cmd := v_cmd.join(' ')
return error('$err_sig: failed reading module dump file "$v_dump_modules_file". $err\nCompile output of `$flat_cmd`:\n$v_dump_res')
}.split('\n').filter(it != '')
imported_modules.sort()
if opt.verbosity > 2 {
println('Imported modules: $imported_modules')
}
return VMetaInfo{
imports: imported_modules
c_flags: cflags.split('\n')
}
}
struct VImportCDeps {
pub:
o_files map[string][]string
a_files map[string][]string
}
// compile_v_imports_c_dependencies compiles the C dependencies of V's module imports.
pub fn compile_v_imports_c_dependencies(opt CompileOptions, imported_modules []string) !VImportCDeps {
err_sig := @MOD + '.' + @FN
mut o_files := map[string][]string{}
mut a_files := map[string][]string{}
uses_gc := opt.uses_gc()
build_dir := opt.build_directory()!
is_debug_build := opt.is_debug_build()
// For all compilers
mut cflags := opt.c_flags.clone()
if opt.is_prod {
cflags << ['-Os']
} else {
cflags << ['-O0']
}
cflags << ['-fPIC']
cflags << ['-Wall', '-Wextra']
mut android_includes := []string{}
// Include NDK headers
ndk_sysroot := ndk.sysroot_path(opt.ndk_version) or {
return error('$err_sig: getting NDK sysroot path.\n$err')
}
android_includes << '-I"' + os.join_path(ndk_sysroot, 'usr', 'include') + '"'
android_includes << '-I"' + os.join_path(ndk_sysroot, 'usr', 'include', 'android') + '"'
v_thirdparty_dir := os.join_path(vxt.home(), 'thirdparty')
archs := opt.archs()!
mut jobs := []job_util.ShellJob{}
for arch in archs {
arch_o_dir := os.join_path(build_dir, 'o', arch)
if !os.is_dir(arch_o_dir) {
os.mkdir_all(arch_o_dir) or {
return error('$err_sig: failed making directory "$arch_o_dir".\n$err')
}
}
compiler := ndk.compiler(.c, opt.ndk_version, arch, opt.api_level) or {
return error('$err_sig: failed getting NDK compiler.\n$err')
}
if uses_gc {
if opt.verbosity > 1 {
println('Compiling libgc ($arch) via -gc flag')
}
mut defines := []string{}
if is_debug_build {
defines << '-DGC_ASSERTIONS'
defines << '-DGC_ANDROID_LOG'
}
defines << '-DGC_THREADS=1'
defines << '-DGC_BUILTIN_ATOMIC=1'
defines << '-D_REENTRANT'
// NOTE it's currently a little unclear why this is needed.
// V UI can crash and with when the gc is built into the exe and started *without* GC_INIT() the error would occur:
defines << '-DUSE_MMAP' // Will otherwise crash with a message with a path to the lib in GC_unix_mmap_get_mem+528
o_file := os.join_path(arch_o_dir, 'gc.o')
build_cmd := [
compiler,
cflags.join(' '),
'-I"' + os.join_path(v_thirdparty_dir, 'libgc', 'include') + '"',
defines.join(' '),
'-c "' + os.join_path(v_thirdparty_dir, 'libgc', 'gc.c') + '"',
'-o "$o_file"',
]
util.verbosity_print_cmd(build_cmd, opt.verbosity)
o_res := util.run_or_error(build_cmd)!
if opt.verbosity > 2 {
eprintln(o_res)
}
o_files[arch] << o_file
jobs << job_util.ShellJob{
cmd: build_cmd
}
}
// stb_image via `stbi` module
if 'stbi' in imported_modules {
if opt.verbosity > 1 {
println('Compiling stb_image ($arch) via stbi module')
}
o_file := os.join_path(arch_o_dir, 'stbi.o')
build_cmd := [
compiler,
cflags.join(' '),
'-Wno-sign-compare',
'-I"' + os.join_path(v_thirdparty_dir, 'stb_image') + '"',
'-c "' + os.join_path(v_thirdparty_dir, 'stb_image', 'stbi.c') + '"',
'-o "$o_file"',
]
o_files[arch] << o_file
jobs << job_util.ShellJob{
cmd: build_cmd
}
}
// cJson via `json` module
if 'json' in imported_modules {
if opt.verbosity > 1 {
println('Compiling cJSON ($arch) via json module')
}
o_file := os.join_path(arch_o_dir, 'cJSON.o')
build_cmd := [
compiler,
cflags.join(' '),
'-I"' + os.join_path(v_thirdparty_dir, 'cJSON') + '"',
'-c "' + os.join_path(v_thirdparty_dir, 'cJSON', 'cJSON.c') + '"',
'-o "$o_file"',
]
o_files[arch] << o_file
jobs << job_util.ShellJob{
cmd: build_cmd
}
}
}
job_util.run_jobs(jobs, opt.parallel, opt.verbosity)!
return VImportCDeps{
o_files: o_files
a_files: a_files
}
}