-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
108 lines (90 loc) · 3.25 KB
/
Copy pathbuild.zig
File metadata and controls
108 lines (90 loc) · 3.25 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const strip = b.option(bool, "strip", "Strip symbols from installed binaries") orelse false;
const terence_css = b.addModule("terence_css", .{
.root_source_file = b.path("src/terence_css.zig"),
});
const exe_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.strip = strip,
});
exe_module.addImport("terence_css", terence_css);
const exe = b.addExecutable(.{
.name = "terence-css",
.root_module = exe_module,
});
b.installArtifact(exe);
const run_step = b.step("run", "Run the app");
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const test_module = b.createModule(.{
.root_source_file = b.path("src/test.zig"),
.target = target,
.optimize = optimize,
});
test_module.addImport("corpus", b.createModule(.{
.root_source_file = b.path("test/corpus.zig"),
}));
const tests = b.addTest(.{ .root_module = test_module });
const run_tests = b.addRunArtifact(tests);
const public_api_test_module = b.createModule(.{
.root_source_file = b.path("test/terence_css_test.zig"),
.target = target,
.optimize = optimize,
});
public_api_test_module.addImport("terence_css", terence_css);
const public_api_tests = b.addTest(.{
.root_module = public_api_test_module,
});
const run_public_api_tests = b.addRunArtifact(public_api_tests);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_tests.step);
test_step.dependOn(&run_public_api_tests.step);
const wasm_target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
});
const wasm_module = b.createModule(.{
.root_source_file = b.path("src/wasm.zig"),
.target = wasm_target,
.optimize = .ReleaseSmall,
.single_threaded = true,
.strip = true,
});
wasm_module.addImport("terence_css", terence_css);
wasm_module.export_symbol_names = &.{
"terence_abi_version",
"terence_alloc",
"terence_free",
"terence_format",
"terence_result_ptr",
"terence_result_len",
"terence_result_error",
"terence_result_free",
};
const wasm = b.addExecutable(.{
.name = "terence_css",
.root_module = wasm_module,
});
wasm.entry = .disabled;
wasm.export_memory = true;
const install_wasm = b.addInstallFile(
wasm.getEmittedBin(),
"terence_css.wasm",
);
const wasm_step = b.step("wasm", "Build the WebAssembly library");
wasm_step.dependOn(&install_wasm.step);
const run_wasm_tests = b.addSystemCommand(&.{"node"});
run_wasm_tests.addFileArg(b.path("npm/wasm/test.mjs"));
run_wasm_tests.addFileArg(wasm.getEmittedBin());
const wasm_test_step = b.step("wasm-test", "Test the WebAssembly npm package");
wasm_test_step.dependOn(&run_wasm_tests.step);
}