This repository was archived by the owner on Apr 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxmake.lua
More file actions
761 lines (652 loc) · 20 KB
/
xmake.lua
File metadata and controls
761 lines (652 loc) · 20 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
set_xmakever("2.8.2")
set_project("UWVM")
set_version("1.0.0")
add_defines("UWVM_VERSION_X=1")
add_defines("UWVM_VERSION_Y=0")
add_defines("UWVM_VERSION_Z=0")
add_defines("UWVM_VERSION_S=1")
set_allowedplats("windows", "mingw", "linux", "sun", "msdosdjgpp", "unix", "bsd", "freebsd", "dragonflybsd", "netbsd", "openbsd", "macosx", "iphoneos", "watchos", "wasm-wasi", "wasm-wasip1", "wasm-wasip2", "wasm-wasi-threads", "wasm-wasip1-threads", "wasm-wasip2-threads", "cross")
add_rules("mode.debug", "mode.release", "mode.releasedbg")
set_defaultmode("releasedbg")
set_allowedmodes("release", "debug", "releasedbg")
set_encodings("utf-8")
set_defaultarchs("msdosdjgpp|i386")
set_defaultarchs("wasm-wasi|wasm32", "wasm-wasip1|wasm32", "wasm-wasip2|wasm32")
if is_plat("msdosdjgpp") then
set_allowedarchs("i386") -- x86 ms-dos not support (out of memory)
elseif is_plat("wasm-wasi", "wasm-wasip1", "wasm-wasip2") then
set_allowedarchs("wasm32", "wasm64")
end
option("native")
set_default(false)
set_showmenu(true)
add_defines("UWVM_NATIVE")
if is_plat("windows") then
add_vectorexts("all")
else
add_cxflags("-march=native")
end
option_end()
option("min-win32-sys")
set_description("Minimum system required Minimum value for _WIN32_WINNT, _WIN32_WINDOWS and WINVER")
set_default("default")
set_showmenu(true)
set_values("default", "WIN10", "WINBLUE", "WIN8", "WIN7", "WS08", "VISTA", "WS03", "WINXP", "WIN2K", "WINME", "WIN98", "WIN95")
option_end()
option("cppstdlib")
set_default("default")
set_showmenu(true)
set_values("default", "libstdc++", "libc++")
option_end()
option("use-llvm")
set_default(false)
set_showmenu(true)
option_end()
option("static")
set_default(true)
set_description("Static Linking")
set_showmenu(true)
option_end()
option("sysroot")
set_default("default")
set_showmenu(true)
option_end()
option("llvm-target")
set_default("default")
set_showmenu(true)
option_end()
option("timer")
set_default(false)
set_showmenu(true)
add_defines("UWVM_TIMER")
option_end()
option("use-mimalloc")
set_default(false)
set_showmenu(true)
option_end()
-- for dev --
option("uwvm-test")
set_default(false)
set_showmenu(true)
add_defines("UWVM_TEST")
option_end()
option("uwvm-default-mvp")
set_default(false)
set_showmenu(true)
add_defines("UWVM_DEFAULT_MVP")
option_end()
option("fno-exceptions")
set_default(false)
set_showmenu(true)
option_end()
option("uwvm-enable-ucint")
set_default(false)
set_showmenu(true)
add_defines("UWVM_ENABLE_UNCHECKED_INTERPRETER")
option_end()
option("uwvm-trace-wasi-syscall")
set_default(false)
set_showmenu(true)
add_defines("UWVM_TRACE_WASI_SYSCALL")
option_end()
function defopt()
set_languages("c11", "cxx23")
--native
add_options("native")
--timer
add_options("timer")
--uwvm-test
add_options("uwvm-test")
--uwvm-default-mvp
add_options("uwvm-default-mvp")
--ucint
add_options("uwvm-enable-ucint")
--trace-syscall
add_options("uwvm-trace-wasi-syscall")
-- fno-exceptions
local disable_cpp_exceptions = get_config("fno-exceptions")
local enable_ucint = get_config("uwvm-enable-ucint")
if disable_cpp_exceptions or enable_ucint then
set_exceptions("no-cxx")
end
if enable_ucint then
add_cxflags("-foptimize-sibling-calls") -- tail call
end
-- use llvm
local use_llvm_toolchain = get_config("use-llvm")
add_cxflags("-Wno-braced-scalar-init")
if is_plat("windows") then
if use_llvm_toolchain then
set_toolchains("clang-cl")
add_cxflags("-std:c++latest") -- argument unused during compilation: '-std:c++23'
else
print("[uwvm] warning: MSVC is not recommended. Some functions may not work!")
end
elseif not is_plat("wasm-wasi", "wasm-wasip1", "wasm-wasip2") then
if use_llvm_toolchain then
set_toolchains("clang")
add_ldflags("-fuse-ld=lld", {force = true})
end
end
-- sysroot
if not is_plat("windows") then
local sysroot_para = get_config("sysroot")
if sysroot_para ~= "default" and sysroot_para then
local sysroot_cvt = "--sysroot=" .. sysroot_para
add_cxflags(sysroot_cvt, {force = true})
add_ldflags(sysroot_cvt, {force = true})
end
end
if not is_plat("wasm-wasi", "wasm-wasip1", "wasm-wasip2") then
if use_llvm_toolchain then
local sysroot_para = get_config("llvm-target")
if sysroot_para ~= "default" and sysroot_para then
local sysroot_cvt = "--target=" .. sysroot_para
add_cxflags(sysroot_cvt, {force = true})
add_ldflags(sysroot_cvt, {force = true})
end
end
end
if is_mode("release", "releasedbg") then
local opt_name = get_config("min-win32-sys")
set_optimize("aggressive")
set_strip("all")
if is_kind("binary") then
set_policy("build.optimization.lto", true)
end
elseif is_mode("debug") then
set_optimize("none")
set_symbols("debug")
add_defines("_DEBUG")
if is_plat("windows") then
add_cxflags("/guard:cf")
end
end
if is_plat("windows") then -- MSVC update is too slow. In 2024, it does not support CPP23. Currently, it is not supported.
if is_kind("binary") then
set_extension(".exe")
end
add_cxflags("-GR-")
if is_mode("debug") then
add_cxflags("-GS")
local static_link = get_config("static")
if static_link then
set_runtimes("MTd")
else
set_runtimes("MDd")
end
else
set_fpmodels("fast")
add_cxflags("-GS-")
add_cxflags("-GL")
add_ldflags("-LTCG")
local static_link = get_config("static")
if static_link then
set_runtimes("MT")
else
set_runtimes("MD")
end
end
local opt_name = get_config("min-win32-sys")
if opt_name == "default" then
elseif opt_name == "WIN10" then
add_defines("_WIN32_WINNT=0x0A00")
elseif opt_name == "WINBLUE" then
add_defines("_WIN32_WINNT=0x0603")
elseif opt_name == "WIN8" then
add_defines("_WIN32_WINNT=0x0602")
elseif opt_name == "WIN7" then
add_defines("_WIN32_WINNT=0x0601")
elseif opt_name == "WS08" then
add_defines("_WIN32_WINNT=0x0600")
elseif opt_name == "VISTA" then
add_defines("_WIN32_WINNT=0x0600")
elseif opt_name == "WS03" then
add_defines("_WIN32_WINNT=0x0502")
elseif opt_name == "WINXP" then
add_defines("_WIN32_WINNT=0x0501")
elseif opt_name == "WIN2K" then
add_defines("_WIN32_WINNT=0x0500")
elseif opt_name == "WINME" then
add_defines("_WIN32_WINDOWS=0x0490")
elseif opt_name == "WIN98" then
add_defines("_WIN32_WINDOWS=0x0410")
elseif opt_name == "WIN95" then
add_defines("_WIN32_WINDOWS=0x0400")
else
error("invalid value")
end
elseif is_plat("mingw") then
if is_kind("binary") then
set_extension(".exe")
end
add_cxxflags("-fno-rtti")
add_cxxflags("-fno-unwind-tables")
if disable_cpp_exceptions then
add_cxflags("-fno-asynchronous-unwind-tables")
end
if is_mode("release", "releasedbg") then
add_cxflags("-fno-ident")
end
local csl_name = get_config("cppstdlib")
if csl_name == "libstdc++" then
add_cxflags("-stdlib=libstdc++")
elseif csl_name == "libc++" then
add_cxflags("-stdlib=libc++")
elseif csl_name == "default" then
else
error("invalid name")
end
--add_ldflags("-static-libstdc++")
--add_ldflags("-static-libgcc")
local static_link = get_config("static")
if static_link then
add_ldflags("-static", {force = true})
end
add_syslinks("ntdll")
local opt_name = get_config("min-win32-sys")
if opt_name == "default" then
elseif opt_name == "WIN10" then
add_defines("_WIN32_WINNT=0x0A00")
elseif opt_name == "WINBLUE" then
add_defines("_WIN32_WINNT=0x0603")
elseif opt_name == "WIN8" then
add_defines("_WIN32_WINNT=0x0602")
elseif opt_name == "WIN7" then
add_defines("_WIN32_WINNT=0x0601")
elseif opt_name == "WS08" then
add_defines("_WIN32_WINNT=0x0600")
elseif opt_name == "VISTA" then
add_defines("_WIN32_WINNT=0x0600")
elseif opt_name == "WS03" then
add_defines("_WIN32_WINNT=0x0502")
elseif opt_name == "WINXP" then
add_defines("_WIN32_WINNT=0x0501")
elseif opt_name == "WIN2K" then
add_defines("_WIN32_WINNT=0x0500")
elseif opt_name == "WINME" then
add_defines("_WIN32_WINDOWS=0x0490")
add_cxflags("-march=i386")
elseif opt_name == "WIN98" then
add_defines("_WIN32_WINDOWS=0x0410")
add_cxflags("-march=i386")
elseif opt_name == "WIN95" then
add_defines("_WIN32_WINDOWS=0x0400")
add_cxflags("-march=i386")
else
error("invalid value")
end
elseif is_plat("linux") then
add_cxxflags("-fno-rtti")
add_cxxflags("-fno-unwind-tables")
if disable_cpp_exceptions then
add_cxflags("-fno-asynchronous-unwind-tables")
end
if is_mode("release", "releasedbg") then
add_cxflags("-fno-ident")
end
if is_mode("debug") then
--set_policy("build.sanitizer.address", true)
--set_policy("build.sanitizer.leak", true)
end
local csl_name = get_config("cppstdlib")
if csl_name == "libstdc++" then
add_cxflags("-stdlib=libstdc++")
elseif csl_name == "libc++" then
add_cxflags("-stdlib=libc++")
elseif csl_name == "default" then
else
error("invalid name")
end
--add_ldflags("-static-libstdc++")
--add_ldflags("-static-libgcc")
local static_link = get_config("static")
if static_link then
add_ldflags("-static", {force = true})
end
if is_arch("x86_64") then
-- none
elseif is_arch("i386") then
-- none
elseif is_arch("loongarch64") then
-- none
end
if use_llvm_toolchain then
add_syslinks("c++abi")
end
add_syslinks("dl")
--add_syslinks("unwind")
add_cxflags("-pthread",{force = true})
add_ldflags("-pthread",{force = true})
elseif is_plat("msdosdjgpp") then
add_cxxflags("-fno-rtti")
add_cxxflags("-fno-unwind-tables")
if disable_cpp_exceptions then
add_cxflags("-fno-asynchronous-unwind-tables")
end
if is_mode("release", "releasedbg") then
add_cxflags("-fno-ident")
end
local csl_name = get_config("cppstdlib")
if csl_name == "libstdc++" then
add_cxflags("-stdlib=libstdc++")
elseif csl_name == "libc++" then
add_cxflags("-stdlib=libc++")
elseif csl_name == "default" then
else
error("invalid name")
end
--add_ldflags("-static-libstdc++")
--add_ldflags("-static-libgcc")
local static_link = get_config("static")
if static_link then
add_ldflags("-static", {force = true})
end
elseif is_plat("unix", "bsd", "freebsd", "dragonflybsd", "netbsd", "openbsd", "sun") then
add_cxxflags("-fno-rtti")
add_cxxflags("-fno-unwind-tables")
if disable_cpp_exceptions then
add_cxflags("-fno-asynchronous-unwind-tables")
end
if is_mode("release", "releasedbg") then
add_cxflags("-fno-ident")
end
local csl_name = get_config("cppstdlib")
if csl_name == "libstdc++" then
add_cxflags("-stdlib=libstdc++")
elseif csl_name == "libc++" then
add_cxflags("-stdlib=libc++")
elseif csl_name == "default" then
else
error("invalid name")
end
--add_ldflags("-static-libstdc++")
--add_ldflags("-static-libgcc")
local static_link = get_config("static")
if static_link then
add_ldflags("-static", {force = true})
end
add_cxflags("-pthread",{force = true})
add_ldflags("-pthread",{force = true})
if use_llvm_toolchain then
add_syslinks("c++abi")
end
elseif is_plat("macosx", "iphoneos", "watchos") then -- unknown-apple-darwin
add_cxxflags("-fno-rtti")
add_cxxflags("-fno-unwind-tables")
if disable_cpp_exceptions then
add_cxflags("-fno-asynchronous-unwind-tables")
end
if is_mode("release", "releasedbg") then
add_cxflags("-fno-ident")
end
local csl_name = get_config("cppstdlib")
if csl_name == "libstdc++" then
add_cxflags("-stdlib=libstdc++")
elseif csl_name == "libc++" then
add_cxflags("-stdlib=libc++")
elseif csl_name == "default" then
else
error("invalid name")
end
--add_ldflags("-static-libstdc++")
--add_ldflags("-static-libgcc")
local static_link = get_config("static")
if static_link then
add_ldflags("-static", {force = true})
end
if use_llvm_toolchain then
add_syslinks("c++abi")
end
--add_syslinks("unwind")
add_cxflags("-pthread",{force = true})
add_ldflags("-pthread",{force = true})
elseif is_plat("wasm-wasi", "wasm-wasip1", "wasm-wasip2", "wasm-wasi-threads", "wasm-wasip1-threads", "wasm-wasip2-threads") then -- wasm-wasi is equivalent to wasm-wasip1
set_extension(".wasm")
add_cxxflags("-fno-rtti")
add_cxxflags("-fno-unwind-tables")
if disable_cpp_exceptions then
add_cxflags("-fno-asynchronous-unwind-tables")
end
if is_mode("release", "releasedbg") then
add_cxflags("-fno-ident")
end
local csl_name = get_config("cppstdlib")
if csl_name == "libstdc++" then
add_cxflags("-stdlib=libstdc++")
elseif csl_name == "libc++" then
add_cxflags("-stdlib=libc++")
elseif csl_name == "default" then
else
error("invalid name")
end
--add_ldflags("-static-libstdc++")
--add_ldflags("-static-libgcc")
local static_link = get_config("static")
if static_link then
add_ldflags("-static", {force = true})
end
set_toolchains("clang")
add_ldflags("-fuse-ld=lld", {force = true})
if is_arch("wasm32") then
if is_plat("wasm-wasi") then
add_cxflags("--target=wasm32-wasi", {force = true})
add_ldflags("--target=wasm32-wasi", {force = true})
elseif is_plat("wasm-wasip1") then
add_cxflags("--target=wasm32-wasip1", {force = true})
add_ldflags("--target=wasm32-wasip1", {force = true})
elseif is_plat("wasm-wasip2") then
add_cxflags("--target=wasm32-wasip2", {force = true})
add_ldflags("--target=wasm32-wasip2", {force = true})
elseif is_plat("wasm-wasi-threads") then
add_cxflags("--target=wasm32-wasi-threads", {force = true})
add_ldflags("--target=wasm32-wasi-threads", {force = true})
add_defines("UWVM_ENABLE_WASI_THREADS")
elseif is_plat("wasm-wasip1-threads") then
add_cxflags("--target=wasm32-wasip1-threads", {force = true})
add_ldflags("--target=wasm32-wasip1-threads", {force = true})
add_defines("UWVM_ENABLE_WASI_THREADS")
elseif is_plat("wasm-wasip2-threads") then
add_cxflags("--target=wasm32-wasip2-threads", {force = true})
add_ldflags("--target=wasm32-wasip2-threads", {force = true})
add_defines("UWVM_ENABLE_WASI_THREADS")
end
elseif is_arch("wasm64") then
if is_plat("wasm-wasi") then
add_cxflags("--target=wasm64-wasi", {force = true})
add_ldflags("--target=wasm64-wasi", {force = true})
elseif is_plat("wasm-wasip1") then
add_cxflags("--target=wasm64-wasip1", {force = true})
add_ldflags("--target=wasm64-wasip1", {force = true})
elseif is_plat("wasm-wasip2") then
add_cxflags("--target=wasm64-wasip2", {force = true})
add_ldflags("--target=wasm64-wasip2", {force = true})
elseif is_plat("wasm-wasi-threads") then
add_cxflags("--target=wasm64-wasi-threads", {force = true})
add_ldflags("--target=wasm64-wasi-threads", {force = true})
add_defines("UWVM_ENABLE_WASI_THREADS")
elseif is_plat("wasm-wasip1-threads") then
add_cxflags("--target=wasm64-wasip1-threads", {force = true})
add_ldflags("--target=wasm64-wasip1-threads", {force = true})
add_defines("UWVM_ENABLE_WASI_THREADS")
elseif is_plat("wasm-wasip2-threads") then
add_cxflags("--target=wasm64-wasip2-threads", {force = true})
add_ldflags("--target=wasm64-wasip2-threads", {force = true})
add_defines("UWVM_ENABLE_WASI_THREADS")
end
end
add_syslinks("c++abi")
if not disable_cpp_exceptions then
add_syslinks("unwind")
end
elseif is_plat("cross") then
add_cxxflags("-fno-rtti")
add_cxxflags("-fno-unwind-tables")
if disable_cpp_exceptions then
add_cxflags("-fno-asynchronous-unwind-tables")
end
if is_mode("release", "releasedbg") then
add_cxflags("-fno-ident")
end
local csl_name = get_config("cppstdlib")
if csl_name == "libstdc++" then
add_cxflags("-stdlib=libstdc++")
elseif csl_name == "libc++" then
add_cxflags("-stdlib=libc++")
elseif csl_name == "default" then
else
error("invalid name")
end
--add_ldflags("-static-libstdc++")
--add_ldflags("-static-libgcc")
local static_link = get_config("static")
if static_link then
add_ldflags("-static", {force = true})
end
if use_llvm_toolchain then
add_syslinks("c++abi")
end
end
before_build(
function (target)
io.open(".git\\FETCH_HEAD", "a+")
local git_head_file = io.open(".git\\FETCH_HEAD", "r")
if not git_head_file then
return
end
local hfr = git_head_file:read()
git_head_file:close()
if not hfr then
local git_header_h_1 = io.open(".tmp\\git_commit_hash.h", "w")
if not git_header_h_1 then
return
end
git_header_h_1:write("u8\"No FETCH_HEAD information\"")
git_header_h_1:close()
return
end
local git_head = "u8\"" .. hfr .. "\""
local git_header_h = io.open(".tmp\\git_commit_hash.h", "w")
if not git_header_h then
return
end
local substr = string.gsub(git_head, "\t", " ")
git_header_h:write(substr)
git_header_h:close()
end
)
end
target("uwvm")
set_kind("binary")
defopt()
-- mimalloc
local use_mimalloc = get_config("use-mimalloc")
if use_mimalloc then
if not (is_plat("msdosdjgpp")) then
add_defines("FAST_IO_USE_MIMALLOC")
add_includedirs("third-parties/mimalloc/include/")
add_files("third-parties/mimalloc/src/static.c")
add_files("src/utils/new-delete/override.cpp")
end
end
-- fast_io
add_includedirs("third-parties/fast_io/include/")
-- uwvm *.h
add_includedirs("src/utils/")
-- win32
if is_plat("windows", "mingw") then
add_files("src/utils/consolecp/set_native_console_cp.cpp")
end
-- uwvm *.cpp
add_files("src/program/uwvm.cpp")
add_files("src/clpara/parameters/**.cpp")
add_files("src/vm/interpreter/func/**.cpp")
add_files("src/vm/interpreter/int_bt.cpp")
--add_files("src/vm/interpreter/tls.cpp") -- duplicate symbol: thread-local initialization routine
add_files("src/vm/unchecked_interpreter/func/**.cpp")
local opt_name = get_config("min-win32-sys")
if (is_plat("windows") or (is_plat("mingw") and opt_name ~= "WINME" and opt_name ~= "WIN98" and opt_name ~= "WIN95")) then
add_files("src/program/uwvm.rc")
end
target_end()
if disable_cpp_exceptions then
if not (is_plat("windows") or is_plat("msdosdjgpp") or is_plat("wasm-wasi", "wasm-wasip1", "wasm-wasip2"))then
target("unwind")
set_kind("static")
defopt()
add_defines("_LIBUNWIND_IS_NATIVE_ONLY")
add_includedirs("third-parties/libunwind/include/")
add_files("third-parties/libunwind/src/**.cpp")
add_files("third-parties/libunwind/src/**.c")
add_files("third-parties/libunwind/src/**.S")
target_end()
end
end
--
-- If you want to known more usage about xmake, please see https://xmake.io
--
-- ## FAQ
--
-- You can enter the project directory firstly before building project.
--
-- $ cd projectdir
--
-- 1. How to build project?
--
-- $ xmake
--
-- 2. How to configure project?
--
-- $ xmake f -p [windows|mingw|macosx|linux|iphoneos ..] -a [x86_64|i386|arm|arm64|loongarch ..] -m [debug|release]
--
-- 3. Where is the build output directory?
--
-- The default output directory is `./build` and you can configure the output directory.
--
-- $ xmake f -o outputdir
-- $ xmake
--
-- 4. How to run and debug target after building project?
--
-- $ xmake run [targetname]
-- $ xmake run -d [targetname]
--
-- 5. How to install target to the system directory or other output directory?
--
-- $ xmake install
-- $ xmake install -o installdir
--
-- 6. Add some frequently-used compilation flags in xmake.lua
--
-- @code
-- -- add debug and release modes
-- add_rules("mode.debug", "mode.release")
--
-- -- add macro definition
-- add_defines("NDEBUG", "_GNU_SOURCE=1")
--
-- -- set warning all as error
-- set_warnings("all", "error")
--
-- -- set language: c99, c++11
-- set_languages("c99", "c++11")
--
-- -- set optimization: none, faster, fastest, smallest
-- set_optimize("fastest")
--
-- -- add include search directories
-- add_includedirs("/usr/include", "/usr/local/include")
--
-- -- add link libraries and search directories
-- add_links("tbox")
-- add_linkdirs("/usr/local/lib", "/usr/lib")
--
-- -- add system link libraries
-- add_syslinks("z", "pthread")
--
-- -- add compilation and link flags
-- add_cxflags("-stdnolib", "-fno-strict-aliasing")
-- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true})
--
-- @endcode
--