-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.c
More file actions
770 lines (694 loc) · 24.1 KB
/
build.c
File metadata and controls
770 lines (694 loc) · 24.1 KB
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
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
#if !defined(_WIN32) && !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200112L
#endif
#include <stdlib.h>
#include "config.h"
#define AVEN_IMPLEMENTATION
#include "deps/libavengl/deps/libaven/include/aven.h"
#include "deps/libavengl/deps/libaven/include/aven/arena.h"
#include "deps/libavengl/deps/libaven/include/aven/arg.h"
#include "deps/libavengl/deps/libaven/include/aven/build.h"
#include "deps/libavengl/deps/libaven/include/aven/build/common.h"
#include "deps/libavengl/deps/libaven/include/aven/io.h"
#include "deps/libavengl/deps/libaven/include/aven/path.h"
#include "deps/libavengl/deps/libaven/include/aven/str.h"
#include "deps/libavengl/deps/libaven/include/aven/watch.h"
#include "deps/libavengl/deps/libaven/build.h"
#include "deps/libavengl/build.h"
#include "build.h"
typedef enum {
REBUILD_STATE_NONE = 0,
REBUILD_STATE_EXE,
REBUILD_STATE_GAME,
} RebuildState;
#define ARENA_SIZE (4096 * 2000)
int main(int argc, char **argv) {
void *mem = malloc(ARENA_SIZE);
if (mem == NULL) {
aven_panic("malloc failed");
}
AvenArena arena = aven_arena_init(mem, ARENA_SIZE);
// Construct and parse build arguments
AvenArgSlice common_args = aven_build_common_args();
AvenArgSlice libaven_args = libaven_build_args();
AvenArgSlice libavengl_args = libavengl_build_args();
List(AvenArg) arg_list = aven_arena_create_list(
AvenArg,
&arena,
3 + common_args.len + libavengl_args.len + libaven_args.len
);
list_push(arg_list) = (AvenArg){
.name = aven_str("watch"),
.description = aven_str(
"Build and run visualization and hot-reload src changes"
),
.type = AVEN_ARG_TYPE_BOOL,
};
list_push(arg_list) = (AvenArg){
.name = aven_str("bench"),
.description = aven_str("Build and run benchmarks"),
.type = AVEN_ARG_TYPE_BOOL,
};
list_push(arg_list) = (AvenArg){
.name = aven_str("tikz"),
.description = aven_str("Build tikz drawing example generators"),
.type = AVEN_ARG_TYPE_BOOL,
};
for (size_t i = 0; i < common_args.len; i += 1) {
list_push(arg_list) = get(common_args, i);
}
for (size_t i = 0; i < libaven_args.len; i += 1) {
list_push(arg_list) = get(libaven_args, i);
}
for (size_t i = 0; i < libavengl_args.len; i += 1) {
list_push(arg_list) = get(libavengl_args, i);
}
AvenArgSlice args = slice_list(arg_list);
AvenArgError parse_error = aven_arg_parse(
args,
argv,
argc,
aven_build_common_overview(),
aven_build_common_usage()
);
if (parse_error != 0) {
if (parse_error != AVEN_ARG_ERROR_HELP) {
return 1;
}
return 0;
}
bool opt_bench = aven_arg_get_bool(args, "bench");
bool opt_watch = aven_arg_get_bool(args, "watch");
bool opt_tikz = aven_arg_get_bool(args, "tikz");
AvenBuildCommonOpts opts = aven_build_common_opts(args, &arena);
LibAvenBuildOpts libaven_opts = libaven_build_opts(args, &arena);
LibAvenGlBuildOpts libavengl_opts = libavengl_build_opts(args, &arena);
// Build setup
AvenStr root_path = aven_str(".");
AvenStr libavengl_path = aven_path(
&arena,
aven_str("deps"),
aven_str("libavengl")
);
AvenStr libaven_path = aven_path(
&arena,
libavengl_path,
aven_str("deps"),
aven_str("libaven")
);
AvenStr libaven_include_path = libaven_build_include_path(
libaven_path,
&arena
);
AvenStr include_data[3];
List(AvenStr) include_list = list_array(include_data);
list_push(include_list) = libaven_include_path;
list_push(include_list) = libavengraph_build_include_path(root_path, &arena);
if (libaven_opts.winpthreads.local) {
list_push(include_list) = libaven_build_include_winpthreads(
libaven_path,
&arena
);
}
AvenStrSlice includes = slice_list(include_list);
AvenStrSlice macros = { 0 };
AvenStr work_dir = aven_str("build_work");
AvenBuildStep work_dir_step = aven_build_step_mkdir(work_dir);
AvenStr out_dir = aven_str("build_out");
AvenBuildStep out_dir_step = aven_build_step_mkdir(out_dir);
Optional(AvenBuildStep) winutf8_obj_step = { 0 };
if (libaven_opts.winutf8) {
winutf8_obj_step.value = libaven_build_step_windres_manifest(
&opts,
libaven_path,
&work_dir_step,
&arena
);
winutf8_obj_step.valid = true;
}
Optional(AvenBuildStep) winpthreads_obj_step = { 0 };
if (libaven_opts.winpthreads.local) {
winpthreads_obj_step.value = libaven_build_step_winpthreads(
&opts,
&libaven_opts,
libaven_path,
&work_dir_step,
false,
&arena
);
winpthreads_obj_step.valid = true;
}
// Build steps nd includes for libavengl
AvenStr graphics_include_data[countof(include_data) + 3];
List(AvenStr) graphics_include_list = list_array(graphics_include_data);
for (size_t i = 0; i < includes.len; i += 1) {
list_push(graphics_include_list) = get(includes, i);
}
list_push(graphics_include_list) = libavengl_build_include_path(
libavengl_path,
&arena
);
list_push(graphics_include_list) = libavengl_build_include_glfw(
libavengl_path,
&arena
);
list_push(graphics_include_list) = libavengl_build_include_gles3(
libavengl_path,
&arena
);
AvenStrSlice graphics_includes = slice_list(graphics_include_list);
// Build steps for visualizaiton
AvenStr visualization_hot_macro_data[3];
List(AvenStr) visualization_hot_macro_list = list_array(
visualization_hot_macro_data
);
list_push(visualization_hot_macro_list) = aven_str("HOT_RELOAD");
AvenStrSlice visualization_dll_hot_macros = slice_list(
visualization_hot_macro_list
);
AvenBuildStep visualization_hot_game_dir_step =
aven_build_common_step_subdir(&out_dir_step, aven_str("game"), &arena);
AvenBuildStep visualization_hot_watch_dir_step =
aven_build_common_step_subdir(&out_dir_step, aven_str("watch"), &arena);
AvenBuildStep visualization_hot_dll_step =
aven_build_common_step_cc_ld_so_ex(
&opts,
graphics_includes,
visualization_dll_hot_macros,
(AvenStrSlice){ 0 },
(AvenBuildStepPtrSlice){ 0 },
aven_path(
&arena,
root_path,
aven_str("visualization"),
aven_str("game"),
aven_str("game.c")
),
&visualization_hot_game_dir_step,
&arena
);
AvenBuildStep hot_dll_signal_step = aven_build_step_trunc(
aven_path(
&arena,
visualization_hot_watch_dir_step.out_path.value,
aven_str("lock")
)
);
aven_build_step_add_dep(
&hot_dll_signal_step,
&visualization_hot_watch_dir_step,
&arena
);
aven_build_step_add_dep(
&hot_dll_signal_step,
&visualization_hot_dll_step,
&arena
);
#ifdef _WIN32
list_push(visualization_hot_macro_list) = aven_str_escape(
aven_str_concat(
aven_str_concat(
aven_str("HOT_DLL_PATH=\""),
aven_path_rel_diff(
visualization_hot_dll_step.out_path.value,
out_dir_step.out_path.value,
&arena
),
&arena
),
aven_str("\""),
&arena
),
&arena
);
#else
list_push(visualization_hot_macro_list) = aven_str_concat(
aven_str_concat(
aven_str("HOT_DLL_PATH=\""),
aven_path_rel_diff(
visualization_hot_dll_step.out_path.value,
out_dir_step.out_path.value,
&arena
),
&arena
),
aven_str("\""),
&arena
);
#endif
#ifdef _WIN32
list_push(visualization_hot_macro_list) = aven_str_escape(
aven_str_concat(
aven_str_concat(
aven_str("HOT_WATCH_PATH=\""),
aven_path_rel_diff(
visualization_hot_watch_dir_step.out_path.value,
out_dir_step.out_path.value,
&arena
),
&arena
),
aven_str("\""),
&arena
),
&arena
);
#else
list_push(visualization_hot_macro_list) = aven_str_concat(
aven_str_concat(
aven_str("HOT_WATCH_PATH=\""),
aven_path_rel_diff(
visualization_hot_watch_dir_step.out_path.value,
out_dir_step.out_path.value,
&arena
),
&arena
),
aven_str("\""),
&arena
);
#endif
AvenStrSlice visualization_hot_macros = slice_list(
visualization_hot_macro_list
);
AvenBuildStep hot_dll_root_step = aven_build_step_root();
aven_build_step_add_dep(&hot_dll_root_step, &hot_dll_signal_step, &arena);
AvenBuildStep visualization_hot_obj_step = aven_build_common_step_cc_ex(
&opts,
graphics_includes,
visualization_hot_macros,
aven_path(
&arena,
root_path,
aven_str("visualization"),
aven_str("main.c")
),
&work_dir_step,
libavengl_opts.android.enabled,
&arena
);
AvenBuildStep *visualization_hot_obj_data[4];
List(AvenBuildStep *) visualization_hot_obj_list = list_array(
visualization_hot_obj_data
);
list_push(visualization_hot_obj_list) = &visualization_hot_obj_step;
if (winutf8_obj_step.valid) {
list_push(visualization_hot_obj_list) = &winutf8_obj_step.value;
}
if (winpthreads_obj_step.valid) {
list_push(visualization_hot_obj_list) = &winpthreads_obj_step.value;
}
AvenBuildStepPtrSlice visualization_hot_objs = slice_list(
visualization_hot_obj_list
);
AvenBuildStep visualization_hot_exe_step = libavengl_build_step_ld(
&opts,
&libavengl_opts,
libavengl_path,
visualization_hot_objs,
&work_dir_step,
&out_dir_step,
aven_str("visualization_hot"),
&arena
);
AvenBuildStep hot_root_step = aven_build_step_root();
aven_build_step_add_dep(&hot_root_step, &hot_dll_root_step, &arena);
aven_build_step_add_dep(
&hot_root_step,
&visualization_hot_watch_dir_step,
&arena
);
aven_build_step_add_dep(&hot_root_step, &visualization_hot_exe_step, &arena);
AvenBuildStep visualization_obj_step = aven_build_common_step_cc_ex(
&opts,
graphics_includes,
macros,
aven_path(
&arena,
root_path,
aven_str("visualization"),
aven_str("main.c")
),
&work_dir_step,
libavengl_opts.android.enabled,
&arena
);
AvenBuildStep *visualization_obj_data[4];
List(AvenBuildStep *) visualization_obj_list = list_array(
visualization_obj_data
);
list_push(visualization_obj_list) = &visualization_obj_step;
if (winutf8_obj_step.valid) {
list_push(visualization_obj_list) = &winutf8_obj_step.value;
}
if (winpthreads_obj_step.valid) {
list_push(visualization_obj_list) = &winpthreads_obj_step.value;
}
AvenBuildStepPtrSlice visualization_objs = slice_list(
visualization_obj_list
);
AvenBuildStep visualization_exe_step = libavengl_build_step_ld(
&opts,
&libavengl_opts,
libavengl_path,
visualization_objs,
&work_dir_step,
&out_dir_step,
aven_str("visualization"),
&arena
);
AvenBuildStep root_step = aven_build_step_root();
aven_build_step_add_dep(&root_step, &visualization_exe_step, &arena);
// Build steps for tikz drawing generators
AvenBuildStep p3color_tikz_obj_step = aven_build_common_step_cc_ex(
&opts,
includes,
macros,
aven_path(
&arena,
root_path,
aven_str("tikz"),
aven_str("p3color_tikz.c")
),
&work_dir_step,
false,
&arena
);
AvenBuildStep *p3color_tikz_obj_data[2];
List(AvenBuildStep *) p3color_tikz_obj_list = list_array(
p3color_tikz_obj_data
);
list_push(p3color_tikz_obj_list) = &p3color_tikz_obj_step;
if (winutf8_obj_step.valid) {
list_push(p3color_tikz_obj_list) = &winutf8_obj_step.value;
}
AvenBuildStepPtrSlice p3color_tikz_objs = slice_list(p3color_tikz_obj_list);
AvenBuildStep p3color_tikz_exe_step = aven_build_common_step_ld_exe_ex(
&opts,
libavengl_opts.syslibs,
p3color_tikz_objs,
&out_dir_step,
aven_str("p3color_tikz"),
false,
&arena
);
AvenBuildStep p3choose_tikz_obj_step = aven_build_common_step_cc_ex(
&opts,
includes,
macros,
aven_path(
&arena,
root_path,
aven_str("tikz"),
aven_str("p3choose_tikz.c")
),
&work_dir_step,
false,
&arena
);
AvenBuildStep *p3choose_tikz_obj_data[2];
List(AvenBuildStep *) p3choose_tikz_obj_list = list_array(
p3choose_tikz_obj_data
);
list_push(p3choose_tikz_obj_list) = &p3choose_tikz_obj_step;
if (winutf8_obj_step.valid) {
list_push(p3choose_tikz_obj_list) = &winutf8_obj_step.value;
}
AvenBuildStepPtrSlice p3choose_tikz_objs = slice_list(
p3choose_tikz_obj_list
);
AvenBuildStep p3choose_tikz_exe_step = aven_build_common_step_ld_exe_ex(
&opts,
libavengl_opts.syslibs,
p3choose_tikz_objs,
&out_dir_step,
aven_str("p3choose_tikz"),
false,
&arena
);
// Tikz build_out artifact build steps
AvenBuildStep tikz_root_step = aven_build_step_root();
aven_build_step_add_dep(&tikz_root_step, &p3color_tikz_exe_step, &arena);
aven_build_step_add_dep(&tikz_root_step, &p3choose_tikz_exe_step, &arena);
// Build steps for tests
AvenStr test_dir = aven_str("build_test");
AvenBuildStep test_dir_step = aven_build_step_mkdir(test_dir);
AvenBuildStep *test_obj_data[1];
List(AvenBuildStep *) test_obj_list = list_array(test_obj_data);
if (winutf8_obj_step.valid) {
list_push(test_obj_list) = &winutf8_obj_step.value;
}
AvenBuildStepPtrSlice test_objs = slice_list(test_obj_list);
AvenStrSlice test_args = { 0 };
AvenBuildStep test_step = aven_build_common_step_cc_ld_run_exe_ex(
&opts,
includes,
macros,
libavengl_opts.syslibs,
test_objs,
aven_path(&arena, root_path, aven_str("test.c")),
&test_dir_step,
false,
test_args,
&arena
);
AvenBuildStep test_root_step = aven_build_step_root();
aven_build_step_add_dep(&test_root_step, &test_step, &arena);
// Build steps for benchmarks
AvenStr bench_dir = aven_str("build_bench");
AvenBuildStep bench_dir_step = aven_build_step_mkdir(bench_dir);
AvenBuildStep *bench_obj_data[2];
List(AvenBuildStep *) bench_obj_list = list_array(bench_obj_data);
if (winutf8_obj_step.valid) {
list_push(bench_obj_list) = &winutf8_obj_step.value;
}
if (winpthreads_obj_step.valid) {
list_push(bench_obj_list) = &winpthreads_obj_step.value;
}
AvenBuildStepPtrSlice bench_objs = slice_list(bench_obj_list);
AvenStrSlice bench_args = { 0 };
AvenBuildStep bench_all_step = aven_build_common_step_cc_ld_run_exe_ex(
&opts,
includes,
macros,
libavengl_opts.syslibs,
bench_objs,
aven_path(&arena, root_path, aven_str("benchmarks"), aven_str("all.c")),
&bench_dir_step,
false,
bench_args,
&arena
);
AvenBuildStep all_root_step = aven_build_step_root();
aven_build_step_add_dep(&all_root_step, &bench_all_step, &arena);
AvenBuildStep bench_pyramid_step = aven_build_common_step_cc_ld_run_exe_ex(
&opts,
includes,
macros,
libavengl_opts.syslibs,
bench_objs,
aven_path(
&arena,
root_path,
aven_str("benchmarks"),
aven_str("pyramid.c")
),
&bench_dir_step,
false,
bench_args,
&arena
);
AvenBuildStep pyramid_root_step = aven_build_step_root();
aven_build_step_add_dep(&pyramid_root_step, &bench_pyramid_step, &arena);
AvenBuildStep bench_root_step = aven_build_step_root();
aven_build_step_add_dep(&bench_root_step, &pyramid_root_step, &arena);
aven_build_step_add_dep(&bench_root_step, &all_root_step, &arena);
// Run build steps according to args
if (opts.clean) {
aven_build_step_clean(&root_step, arena);
aven_build_step_clean(&hot_root_step, arena);
aven_build_step_clean(&tikz_root_step, arena);
aven_build_step_clean(&test_root_step, arena);
aven_build_step_clean(&bench_root_step, arena);
} else if (opts.dry_run) {
if (opts.test) {
aven_build_step_dry_run(&test_root_step, arena);
} else if (opt_bench) {
aven_build_step_dry_run(&bench_root_step, arena);
} else if (opt_tikz) {
aven_build_step_dry_run(&tikz_root_step, arena);
} else if (opt_watch) {
aven_build_step_dry_run(&hot_root_step, arena);
} else {
aven_build_step_dry_run(&root_step, arena);
}
} else {
if (opts.test) {
AvenBuildStepRunError run_error = aven_build_step_run(
&test_root_step,
arena
);
if (run_error != 0) {
aven_io_perrf("TESTS FAILED: {}\n", aven_fmt_int(run_error));
return 1;
}
} else if (opt_bench) {
AvenBuildStepRunError run_error = aven_build_step_run(
&bench_root_step,
arena
);
if (run_error != 0) {
aven_io_perrf(
"BENCHMARKS FAILED: {}\n",
aven_fmt_int(run_error)
);
return 1;
}
} else if (opt_tikz) {
AvenBuildStepRunError run_error = aven_build_step_run(
&tikz_root_step,
arena
);
if (run_error != 0) {
aven_io_perrf(
"TIKZ BUILD FAILED: {}\n",
aven_fmt_int(run_error)
);
return 1;
}
} else if (opt_watch) {
AvenWatchHandle src_handle = aven_watch_init(
aven_path(&arena, root_path, aven_str("visualization")),
arena
);
AvenWatchHandle game_handle = aven_watch_init(
aven_path(
&arena,
root_path,
aven_str("visualization"),
aven_str("game")
),
arena
);
AvenWatchHandle handle_data[] = { src_handle, game_handle };
AvenWatchHandleSlice handles = slice_array(handle_data);
Optional(AvenProcId) exe_pid = { .valid = false };
RebuildState rebuild_state = REBUILD_STATE_EXE;
for (;;) {
switch (rebuild_state) {
case REBUILD_STATE_EXE: {
if (exe_pid.valid) {
aven_proc_kill(exe_pid.value);
exe_pid.valid = false;
}
aven_build_step_reset(&hot_root_step, arena);
AvenBuildStepRunError run_error = aven_build_step_run(
&hot_root_step,
arena
);
if (run_error != 0) {
aven_io_perrf(
"BUILD FAILED: {}\n",
aven_fmt_int(run_error)
);
}
break;
}
case REBUILD_STATE_GAME: {
aven_build_step_reset(&hot_dll_root_step, arena);
AvenBuildStepRunError run_error = aven_build_step_run(
&hot_dll_root_step,
arena
);
if (run_error != 0) {
aven_io_perrf(
"BUILD FAILED: {}\n",
aven_fmt_int(run_error)
);
}
break;
}
default: {
break;
}
}
rebuild_state = REBUILD_STATE_NONE;
if (exe_pid.valid) {
AvenProcWaitResult result = aven_proc_check(exe_pid.value);
if (result.error == 0) {
if (result.payload == 0) {
aven_io_perr("APPLICATION EXITED CLEANLY\n");
} else {
aven_io_perrf(
"APPLICATION FAILED: {}\n",
aven_fmt_int(result.payload)
);
}
exe_pid.valid = false;
} else if (result.error != AVEN_PROC_WAIT_ERROR_TIMEOUT) {
aven_proc_kill(exe_pid.value);
exe_pid.valid = false;
}
}
if (!exe_pid.valid) {
aven_io_perr("RUNNING:\n");
AvenStr cmd_parts[] = {
visualization_hot_exe_step.out_path.value,
};
AvenStrSlice cmd = slice_array(cmd_parts);
AvenProcCmdResult result = aven_proc_cmd(cmd, arena);
if (result.error != 0) {
aven_io_perrf(
"RUN FAILED: {}\n",
aven_fmt_int(result.error)
);
} else {
exe_pid.valid = true;
exe_pid.value = result.payload;
}
}
AvenWatchResult result = aven_watch_check_multiple(handles, -1);
if (result.error != 0) {
aven_io_perrf(
"WATCH CHECK FAILED: {}\n",
aven_fmt_int(result.error)
);
return 1;
}
for (size_t i = 0; i < handles.len; i += 1) {
if ((result.payload & (((uint32_t)1) << i)) == 0) {
continue;
}
if (get(handles, i) == src_handle) {
rebuild_state = REBUILD_STATE_EXE;
break;
}
if (get(handles, i) == game_handle) {
rebuild_state = REBUILD_STATE_GAME;
}
}
// Ignore extraneous source modifications some editors produce
while (result.payload != 0) {
result = aven_watch_check_multiple(handles, 100);
if (result.error != 0) {
aven_io_perrf(
"WATCH CHECK FAILED: {}\n",
aven_fmt_int(result.error)
);
return 1;
}
}
}
} else {
AvenBuildStepRunError run_error = aven_build_step_run(
&root_step,
arena
);
if (run_error != 0) {
aven_io_perrf("BUILD FAILED: {}\n", aven_fmt_int(run_error));
return 1;
}
}
}
return 0;
}