-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
118 lines (106 loc) · 3.77 KB
/
build.zig
File metadata and controls
118 lines (106 loc) · 3.77 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
const std = @import("std");
const IntegrationSuite = struct {
step_name: []const u8,
description: []const u8,
path: []const u8,
};
fn addIntegrationSuite(
b: *std.Build,
mod: *std.Build.Module,
optimize: std.builtin.OptimizeMode,
suite: IntegrationSuite,
) *std.Build.Step.Run {
const tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path(suite.path),
.target = b.graph.host,
.optimize = optimize,
.imports = &.{
.{ .name = "zrwrite", .module = mod },
},
}),
});
return b.addRunArtifact(tests);
}
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mod = b.addModule("zrwrite", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
});
const zrstd_mod = b.addModule("zrstd", .{
.root_source_file = b.path("src/zrstd/root.zig"),
.target = target,
});
const exe = b.addExecutable(.{
.name = "zrwrite",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zrwrite", .module = mod },
},
}),
});
b.installArtifact(exe);
const run_step = b.step("run", "Run the zrwrite CLI");
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 mod_tests = b.addTest(.{
.root_module = mod,
});
const run_mod_tests = b.addRunArtifact(mod_tests);
const zrstd_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/zrstd/root.zig"),
.target = b.graph.host,
.optimize = optimize,
.imports = &.{
.{ .name = "zrstd", .module = zrstd_mod },
},
}),
});
const run_zrstd_tests = b.addRunArtifact(zrstd_tests);
const integration_suites = [_]IntegrationSuite{
.{
.step_name = "test-integration-elf-workflow",
.description = "Run ELF workflow integration tests",
.path = "tests/integration/elf_workflow.zig",
},
.{
.step_name = "test-integration-elf-replay",
.description = "Run AArch64 replay integration tests",
.path = "tests/integration/elf_replay.zig",
},
.{
.step_name = "test-integration-payload-linker",
.description = "Run payload linker integration tests",
.path = "tests/integration/payload_linker.zig",
},
.{
.step_name = "test-integration-macho-layout",
.description = "Run Mach-O layout integration tests",
.path = "tests/integration/macho_layout.zig",
},
.{
.step_name = "test-integration-macho-runtime",
.description = "Run Mach-O runtime integration tests",
.path = "tests/integration/macho_runtime.zig",
},
};
const integration_step = b.step("test-integration", "Run integration test suites");
inline for (integration_suites) |suite| {
const run_suite = addIntegrationSuite(b, mod, optimize, suite);
integration_step.dependOn(&run_suite.step);
const suite_step = b.step(suite.step_name, suite.description);
suite_step.dependOn(&run_suite.step);
}
const test_step = b.step("test", "Run unit and integration tests");
test_step.dependOn(&run_mod_tests.step);
test_step.dependOn(&run_zrstd_tests.step);
test_step.dependOn(integration_step);
}