-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathxmake.lua
More file actions
710 lines (614 loc) · 25.2 KB
/
Copy pathxmake.lua
File metadata and controls
710 lines (614 loc) · 25.2 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
set_version("0.1.0")
set_project("catter")
add_rules("mode.debug", "mode.release", "mode.releasedbg")
set_allowedplats("windows", "linux", "macosx")
set_languages("c++23")
option("dev", {default = true})
option("test", {default = false})
local prefix_includedirs = {}
local function collect_prefix_includedirs(prefix)
local include_candidates = {
path.join(prefix, "include"),
path.join(prefix, "Library", "include"),
}
for _, includedir in ipairs(include_candidates) do
if os.isdir(includedir) then
table.insert(prefix_includedirs, includedir)
end
end
end
local function add_local_prefix_includedirs()
for _, includedir in ipairs(prefix_includedirs) do
add_includedirs(includedir)
end
end
local conda_prefix = os.getenv("CONDA_PREFIX")
if conda_prefix then
collect_prefix_includedirs(conda_prefix)
else
local pixi_dev_prefix = path.join(os.projectdir(), ".pixi", "envs", "dev")
local pixi_default_prefix = path.join(os.projectdir(), ".pixi", "envs", "default")
if os.isdir(pixi_dev_prefix) then
collect_prefix_includedirs(pixi_dev_prefix)
elseif os.isdir(pixi_default_prefix) then
collect_prefix_includedirs(pixi_default_prefix)
end
end
if has_config("dev") then
-- Don't fetch system package
set_policy("package.install_only", true)
set_policy("build.ccache", true)
add_rules("plugin.compile_commands.autoupdate", {outputdir = "build", lsp = "clangd"})
local toolchain = get_config("toolchain")
if is_mode("debug") then
if is_plat("windows") then
if toolchain == "msvc" then
set_policy("build.sanitizer.address", true)
end
else
set_policy("build.sanitizer.address", true)
end
end
if is_plat("windows") then
set_runtimes("MD")
if toolchain == "clang" then
add_ldflags("-fuse-ld=lld-link")
add_shflags("-fuse-ld=lld-link")
elseif toolchain == "clang-cl" then
set_toolset("ld", "lld-link")
set_toolset("sh", "lld-link")
end
end
end
if is_plat("macosx") then
-- https://conda-forge.org/docs/maintainer/knowledge_base/#newer-c-features-with-old-sdk
set_toolchains("clang")
set_config("ranlib", "/usr/bin/ranlib")
add_defines("_LIBCPP_DISABLE_AVAILABILITY=1")
add_ldflags("-fuse-ld=lld")
add_shflags("-fuse-ld=lld")
add_requireconfs("**|cmake", {configs = {
ldflags = "-fuse-ld=lld",
shflags = "-fuse-ld=lld",
cxflags = "-D_LIBCPP_DISABLE_AVAILABILITY=1",
}})
end
if is_mode("debug") then
add_defines("DEBUG")
end
if is_mode("debug") and is_plat("linux", "macosx") then
-- hook.so will use a static lib to log in debug mode
add_cxxflags("-fPIC")
end
if is_plat("linux") then
add_defines("CATTER_LINUX")
elseif is_plat("macosx") then
add_defines("CATTER_MAC")
elseif is_plat("windows") then
add_defines("CATTER_WINDOWS")
add_defines("WIN32_LEAN_AND_MEAN", "NOMINMAX")
add_requires("minhook", {version = "v1.3.4"})
end
-- do
-- local toolchain = get_config("toolchain")
-- if toolchain == "msvc" or toolchain == "clang-cl" then
-- add_cxxflags("/W3", "/WX", {force = true})
-- else
-- add_cxxflags("-Wall", "-Werror", {force = true})
-- end
-- end
add_requires("quickjs-ng", {version = "v0.15.0"})
add_requires("spdlog", {version = "1.15.3", configs = {header_only = false, std_format = true, noexcept = true}})
add_requires("kotatsu")
target("common")
set_kind("static")
add_local_prefix_includedirs()
add_includedirs("src/common", {public = true})
add_files("src/common/**.cc")
add_packages("spdlog", {public = true})
add_packages("kotatsu", {public = true})
target("catter-js-types")
set_kind("phony")
set_default(false)
-- Regenerates the public TypeScript declarations (build:types). Phony
add_rules("build.js", {
js_script = "build:types",
js_inputs = {
"api/src/**.ts",
"api/dev/modules.json",
"api/native/**.d.ts",
"api/dev/package.json",
"api/dev/tsconfig.app.json",
"api/dev/scripts/check-modules.mjs",
"tsconfig.base.json"
},
js_outputs = {
"api/types/**.d.ts",
"api/types/**.d.ts.map",
}
})
target("catter-js-runtime")
set_kind("object")
set_default(false)
-- One target hosts the whole builtin JS pipeline:
-- 1. build.js (before_build) runs rollup to emit per-module bundles + manifest.json
-- 2. pack.js (before_build, ordered after build.js) packs them into jslib.bin
-- 3. utils.bin2obj (default build) embeds the blob into one object file
-- The before_build scripts run before the target's default build, so the
-- blob always exists when the file-level bin2obj rule processes it.
add_rules("build.js", {
js_script = "build:runtime",
js_inputs = {
"api/src/**.ts",
"api/dev/modules.json",
"api/native/**.d.ts",
"api/dev/package.json",
"api/dev/rollup.config.js",
"api/dev/scripts/check-modules.mjs",
"api/dev/tsconfig.app.json",
"tsconfig.base.json"
},
js_outputs = {
"api/dist/manifest.json",
"api/dist/**.js",
"api/package.json"
}
})
add_rules("pack.js", {
pack_manifest = "api/dist/manifest.json",
pack_output = "api/dist/jslib.bin"
})
-- Embed the packed blob into an object file consumed by catter-core.
add_files("api/dist/jslib.bin",
{rule = "utils.bin2obj", zeroend = true, always_added = true})
target("catter-js-tests")
set_kind("phony")
set_default(false)
add_deps("catter-js-types")
-- Compiles the TS API tests into api/build/test (build:tests). Phony
-- target; depends on the declarations generated by catter-js-types.
add_rules("build.js", {
js_script = "build:tests",
js_inputs = {
"api/test/**.ts",
"api/dev/package.json",
"api/dev/tsconfig.test.json",
"tsconfig.base.json"
},
js_outputs = {"api/build/test/**.js"}
})
target("catter-js-scripts")
set_kind("object")
set_default(false)
-- Builds the builtin service scripts (scripts/) and embeds them as one
add_deps("catter-js-runtime")
add_rules("build.js", {
js_dir = "scripts",
js_script = "build",
js_inputs = {
"scripts/src/**.ts",
"scripts/manifest.json",
"scripts/package.json",
"scripts/rollup.config.js",
"scripts/tsconfig.json",
"api/native/**.d.ts",
"tsconfig.base.json"
},
js_outputs = {
"scripts/dist/manifest.json",
"scripts/dist/**.js"
}
})
add_rules("pack.js", {
pack_manifest = "scripts/dist/manifest.json",
pack_output = "scripts/dist/scripts.bin"
})
add_files("scripts/dist/scripts.bin",
{rule = "utils.bin2obj", zeroend = true, always_added = true})
target("catter-core")
-- use object, avoid register invalid
set_kind("object")
add_local_prefix_includedirs()
add_includedirs("src/catter/core", {public = true})
add_packages("quickjs-ng", {public = true})
add_deps("common", "catter-js-runtime", "catter-js-scripts")
add_files("src/catter/core/**.cc")
target("catter")
set_kind("binary")
add_local_prefix_includedirs()
add_deps("catter-core")
add_files("src/catter/main.cc")
target("hook-resolver")
set_kind("static")
add_local_prefix_includedirs()
add_includedirs("src/catter-hook/", {public = true})
if is_plat("windows") then
add_syslinks("user32", "advapi32")
add_files("src/catter-hook/shared/resolver_win.cc")
else
add_files("src/catter-hook/shared/resolver_unix.cc")
end
target("catter-hook-win64")
set_default(is_plat("windows"))
set_kind("shared")
add_local_prefix_includedirs()
add_includedirs("src/catter-hook/")
add_files("src/catter-hook/win/payload/*.cc")
add_packages("minhook")
add_deps("hook-resolver")
local toolchain = get_config("toolchain")
if toolchain == "msvc" or toolchain == "clang-cl" then
add_cxxflags("/GR-")
add_shflags("/DEF:src/catter-hook/win/payload/exports.def")
else
add_cxxflags("-fno-exceptions", "-fno-rtti")
add_shflags("-Wl,/DEF:src/catter-hook/win/payload/exports.def")
end
target("catter-hook-unix")
set_default(is_plat("linux", "macosx"))
set_kind("shared")
add_local_prefix_includedirs()
add_deps("hook-resolver")
if is_mode("debug") then
add_deps("common")
end
add_cxxflags("-fvisibility=hidden")
add_cxxflags("-fvisibility-inlines-hidden")
add_cxflags("-ffunction-sections", "-fdata-sections")
add_includedirs("src/catter-hook/")
add_includedirs("src/catter-hook/unix/payload/")
add_files("src/catter-hook/unix/payload/**.cc")
if is_plat("linux") then
add_shflags("-static-libstdc++", {force = true})
add_shflags("-static-libgcc", {force = true})
add_shflags("-Wl,--version-script=src/catter-hook/unix/payload/inject/exports.map")
add_syslinks("dl")
add_shflags("-Wl,--gc-sections", {force = true})
elseif is_plat("macosx") then
-- set_policy("check.auto_ignore_flags", false)
add_shflags("-nostdlib++", {force = true})
add_syslinks("System")
add_syslinks("c++abi")
add_shflags("-fuse-ld=lld")
add_shflags("-Wl,-exported_symbols_list,/dev/null", {public = true, force = true})
add_shflags("-Wl,-dead_strip", {force = true})
end
on_load(function (target)
if is_plat("macosx") then
local libcxx_lib = os.iorun("clang++ -print-file-name=libc++.a"):trim()
target:add("shflags", "-Wl,-force_load," .. libcxx_lib, {force = true})
end
end
)
target("catter-hook")
set_kind("object")
add_local_prefix_includedirs()
add_includedirs("src/catter-hook/", {public = true})
add_deps("common")
if is_plat("windows") then
add_files("src/catter-hook/win/*.cc")
elseif is_plat("linux", "macosx") then
add_files("src/catter-hook/unix/impl.cc")
end
target("catter-proxy")
set_kind("binary")
add_local_prefix_includedirs()
add_deps("common", "catter-hook", "hook-resolver")
add_includedirs("src/catter-proxy/")
add_files("src/catter-proxy/**.cc")
rule("ut-base")
on_load(function (target)
target:add("includedirs", "tests/unit/base/")
target:add("files", "tests/unit/base/**.cc")
target:add("packages", "kotatsu")
end)
target("ut-common")
set_default(has_config("test"))
set_kind("binary")
add_local_prefix_includedirs()
add_rules("ut-base")
add_files("tests/unit/common/**.cc")
add_deps("common")
add_tests("default")
target("ut-catter")
set_default(has_config("test"))
set_kind("binary")
add_local_prefix_includedirs()
add_rules("ut-base")
add_files("tests/unit/catter/**.cc")
add_deps("catter-core", "catter-js-tests", "common")
add_defines(format([[JS_TEST_PATH="%s"]], path.unix(path.join(os.projectdir(), "api/build/test/"))))
add_defines(format([[JS_TEST_RES_PATH="%s"]], path.unix(path.join(os.projectdir(), "api/build/test/res"))))
add_tests("default")
target("ut-catter-hook-unix")
set_default(has_config("test") and (is_plat("linux", "macosx")))
set_kind("binary")
add_rules("ut-base")
if is_plat("linux") then
add_syslinks("dl")
end
add_includedirs("src/catter-hook/", { public = true })
add_includedirs("src/catter-hook/unix/payload/", { public = true })
add_files("src/catter-hook/unix/payload/*.cc")
add_files("tests/unit/catter-hook/unix/**.cc")
add_files("tests/unit/catter-hook/shared/**.cc")
add_deps("common", "hook-resolver")
if is_plat("linux", "macosx") then
add_tests("default")
end
target("ut-catter-hook-win64")
set_default(has_config("test") and is_plat("windows"))
set_kind("binary")
add_rules("ut-base")
add_includedirs("src/catter-hook/")
add_files("src/catter-hook/win/payload/util.cc")
add_files("tests/unit/catter-hook/win/**.cc")
add_files("tests/unit/catter-hook/shared/**.cc")
add_deps("common", "hook-resolver")
if is_plat("windows") then
add_tests("default")
end
target("it-catter-hook")
set_default(has_config("test"))
set_kind("binary")
add_files("tests/integration/test/catter-hook.cc")
add_deps("catter-hook", "common")
target("it-catter-proxy")
set_default(has_config("test"))
set_kind("binary")
add_files("tests/integration/test/catter-proxy.cc")
add_deps("common", "catter-core", "catter-proxy")
target("it-catter-replay")
set_default(has_config("test"))
set_kind("binary")
add_local_prefix_includedirs()
add_files("tests/integration/replay/catter-replay.cc")
add_deps("common", "catter-core")
-- rule("build.js"): runs a JS toolchain build (pnpm script in api/dev/) and
-- tracks the inputs/outputs for change detection. It hooks into before_build,
-- so the produced artifacts are ready before the target's default build (e.g.
-- file-level rules like utils.bin2obj) runs. It only *builds* JS artifacts;
-- embedding them is not its job.
--
-- Parameters (set via add_rules("build.js", { ... })):
-- js_dir directory of the JS package, defaults to "api/dev".
-- js_script pnpm script to run in api/, e.g. "build:runtime".
-- js_inputs glob patterns of the source files that trigger a rebuild.
-- js_outputs glob patterns of the output files to track.
--
-- Change detection: a stamp file records the last successful build; the build
-- runs only when an input file changed, the script/input/output config
-- changed, or the output is missing.
rule("build.js")
before_build(function (target, opt)
import("lib.detect.find_tool")
import("core.project.depend")
import("utils.progress")
local js_dir = target:extraconf("rules", "build.js", "js_dir") or "api/dev"
local js_script = target:extraconf("rules", "build.js", "js_script")
local js_inputs = target:extraconf("rules", "build.js", "js_inputs")
local js_outputs = target:extraconf("rules", "build.js", "js_outputs")
assert(js_script, "build.js rule requires js_script")
local pnpm = assert(find_tool("pnpm") or find_tool("pnpm.cmd") or find_tool("pnpm.bat"), "pnpm not found!")
local stampfile = target:autogenfile(path.join("rules", "build.js", target:name() .. ".stamp"))
os.mkdir(path.directory(stampfile))
-- Expand the input globs into concrete files used for change detection.
local changefiles = {}
-- The script/input/output config is tracked as values too, so
-- changing them in xmake.lua also forces a rebuild.
local dependvalues = {js_script}
table.insert(dependvalues, "dir:" .. js_dir)
if js_outputs then
for _, pattern in ipairs(js_outputs) do
table.join2(changefiles, os.files(pattern))
table.insert(dependvalues, "output:" .. pattern)
end
end
if js_inputs then
for _, pattern in ipairs(js_inputs) do
table.join2(changefiles, os.files(pattern))
table.insert(dependvalues, "input:" .. pattern)
end
end
table.sort(changefiles)
depend.on_changed(function()
progress.show(opt.progress or 0, "${color.build.object}Running js script %s", js_script)
os.vrunv(pnpm.program, {"--dir", js_dir, "run", js_script})
io.writefile(stampfile, os.date("%Y-%m-%dT%H:%M:%S"))
end, {
files = changefiles,
values = dependvalues,
dependfile = target:dependfile(stampfile),
changed = target:is_rebuilt()
or not os.isfile(stampfile)
})
end)
-- rule("pack.js"): packs every module file listed in a manifest into a single
-- binary blob, so the whole builtin JS library can be embedded as one object.
-- It is ordered after build.js (add_orders, the modern spelling of the old
-- add_deps("build.js", {order = true})), so its before_build script runs after
-- the JS bundles are produced; utils.bin2obj then embeds the blob during the
-- target's default build.
--
-- Blob layout (little-endian): u32 count, then per module:
-- u32 name_len, name, u32 content_len, content, NUL.
-- The trailing NUL keeps each content view NUL-terminated in memory, which
-- QuickJS's tokenizer relies on to detect end of input. This is the
-- (mod_name, mod_content) array consumed by EsmModuleLoader.
--
-- Parameters (set via add_rules("pack.js", { ... })):
-- pack_manifest manifest JSON (specifier -> file) listing the module files.
-- pack_output the packed blob file to produce (e.g. api/output/lib/jslib.bin).
--
-- Change detection: repack only when the manifest or any listed module file
-- changed, or when the blob file is missing.
rule("pack.js")
add_orders("build.js", "pack.js")
before_build(function (target, opt)
import("core.project.depend")
import("core.base.json")
import("utils.progress")
local pack_manifest = target:extraconf("rules", "pack.js", "pack_manifest")
local pack_output = target:extraconf("rules", "pack.js", "pack_output")
local stampfile = target:autogenfile(path.join("rules", "pack.js", target:name() .. ".stamp"))
os.mkdir(path.directory(stampfile))
-- build.js (an ordered dependency) regenerates the manifest before
-- this script runs; if it is missing, defer until the next build.
if not os.isfile(pack_manifest) then
return
end
local function read_all(filepath)
local f = assert(io.open(filepath, "rb"), "cannot open " .. filepath)
local data = f:read("*a")
f:close()
return data
end
local function pack_modules(manifest_path, output_path)
local manifest = json.decode(read_all(manifest_path))
local modules = manifest.modules
local names = {}
for name, _ in pairs(modules) do
table.insert(names, name)
end
table.sort(names)
local out = assert(io.open(output_path, "wb"), "cannot open " .. output_path)
out:write(string.pack("<I4", #names))
for _, name in ipairs(names) do
local content = read_all(path.join(path.directory(manifest_path), modules[name]))
out:write(string.pack("<I4", #name))
out:write(name)
out:write(string.pack("<I4", #content))
out:write(content)
out:write(string.char(0))
end
out:close()
end
-- Inputs are the manifest itself plus every module file it lists.
local inputfiles = {pack_manifest}
local manifest = json.decode(read_all(pack_manifest))
for _, file in pairs(manifest.modules) do
table.insert(inputfiles, path.join(path.directory(pack_manifest), file))
end
table.sort(inputfiles)
depend.on_changed(function()
progress.show(opt.progress or 0, "${color.build.object}packing.js-modules %s", pack_output)
pack_modules(pack_manifest, pack_output)
io.writefile(stampfile, os.date("%Y-%m-%dT%H:%M:%S"))
end, {
files = inputfiles,
values = {pack_manifest, pack_output},
dependfile = target:dependfile(stampfile),
changed = target:is_rebuilt()
or not os.isfile(stampfile)
or not os.exists(pack_output),
})
end)
package("kotatsu")
set_homepage("https://clice.io")
set_license("Apache-2.0")
set_urls("https://github.com/clice-io/kotatsu.git")
-- version from `git rev-list --count HEAD`
add_versions("170", "c516e3ae0ca3c7d7fb35fdcfdc7c6a111adef764")
add_deps("libuv v1.52.0")
add_deps("cpptrace v1.0.4")
add_deps("libcurl 8.11.0")
on_install(function (package)
if package:has_tool("cxx", "cl", "clang_cl") then
package:add("cxxflags", "/Zc:__cplusplus", "/Zc:preprocessor")
end
local configs = {}
-- Build the dependency with a plain consumer config so we do not pull
-- in kotatsu's repo-local dev toolchain tweaks during package install.
configs.dev = false
configs.test = false
-- Pin the kotatsu submodules catter actually consumes so upstream
-- default flips do not silently drop features we depend on.
configs.async = true
configs.deco = true
configs.ztest = true
configs.http = true
if package:is_plat("macosx") then
local conda_prefix = os.getenv("CONDA_PREFIX")
if conda_prefix then
local bindir = path.join(conda_prefix, "bin")
local libdir = path.join(conda_prefix, "lib")
local mode = package:is_debug() and "debug" or "release"
local builddir = package:builddir()
-- Pixi's clang cfg injects `.pixi/.../include`; disable that default
-- config just for kotatsu's package install and keep the rest explicit.
local argv = {
"f", "-y", "-c",
"--plat=" .. package:plat(),
"--arch=" .. package:arch(),
"--mode=" .. mode,
"--kind=" .. (package:config("shared") and "shared" or "static"),
"--builddir=" .. builddir,
"--cc=" .. path.join(bindir, "clang"),
"--cxx=" .. path.join(bindir, "clang++"),
"--ld=" .. path.join(bindir, "clang++"),
"--sh=" .. path.join(bindir, "clang++"),
"--ar=" .. path.join(bindir, "llvm-ar"),
"--ranlib=" .. path.join(bindir, "llvm-ranlib"),
"--cflags=--no-default-config",
"--cxflags=--no-default-config -D_LIBCPP_DISABLE_AVAILABILITY=1",
"--ldflags=--no-default-config -L" .. libdir .. " -Wl,-rpath," .. libdir,
"--shflags=--no-default-config -L" .. libdir .. " -Wl,-rpath," .. libdir,
"--dev=false",
"--test=false",
"--async=true",
"--deco=true",
"--ztest=true",
"--http=true"
}
if package:config("asan") then
table.insert(argv, "--policies=build.sanitizer.address")
end
os.vrunv("xmake", argv, {curdir = package:sourcedir()})
os.mkdir(path.join(builddir, ".deps", "kotatsu", package:plat(), package:arch(), mode))
os.vrunv("xmake", {"build", "kotatsu"}, {curdir = package:sourcedir()})
os.vrunv("xmake", {"install", "-y", "--packages=n", "-o", package:installdir(), "kotatsu"}, {curdir = package:sourcedir()})
return
end
import("package.tools.xmake").install(package, configs, {target = "kotatsu"})
elseif is_plat("linux") then
import("package.tools.xmake").install(package, configs, {target = "kotatsu"})
else
import("package.tools.xmake").install(package, configs, {target = "kotatsu"})
end
end)
includes("@builtin/xpack")
xpack("catter")
set_basename("catter-$(version)-$(plat)-$(arch)")
set_title("Catter")
set_description("A tool for intercepting and analyzing build processes")
set_licensefile("LICENSE")
set_homepage("https://clice.io")
-- set_iconfile()
set_formats("nsis", "zip", "targz")
-- The packaged runtime layout matches the built api/ package root:
-- native/, src/, types/, dist/ and the generated package.json. types/
-- and dist/ carry only declarations / bundles plus their source maps.
add_installfiles("api/native/**.d.ts",
{prefixdir = "native", rootdir = "api/native"})
add_installfiles("api/src/**",
{prefixdir = "src", rootdir = "api/src"})
add_installfiles("api/types/**.d.ts",
{prefixdir = "types", rootdir = "api/types"})
add_installfiles("api/types/**.d.ts.map",
{prefixdir = "types", rootdir = "api/types"})
add_installfiles("api/dist/**.js",
{prefixdir = "dist", rootdir = "api/dist"})
add_installfiles("api/dist/**.js.map",
{prefixdir = "dist", rootdir = "api/dist"})
add_installfiles("api/package.json", {prefixdir = "."})
before_package(function ()
assert(os.isfile("api/package.json"),
"Package metadata is missing; run `pixi run -e dev build-js` before packaging.")
end)
add_targets("catter", "catter-proxy")
if is_plat("windows") then
add_targets("catter-hook-win64")
elseif is_plat("linux", "macosx") then
add_targets("catter-hook-unix")
end
set_libdir("bin") -- put hook dlls in bin for easier loading