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
|
const std = @import("std");
const Program = struct {
name: []const u8,
qemu: bool,
};
const programs = [_]Program {
.{ .name = "shell", .qemu = false },
.{ .name = "screen", .qemu = false },
};
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const estd = b.createModule(.{
.root_source_file = b.path("src/estd/root.zig"),
});
const init_exe = b.addExecutable(.{
.name = "init",
.root_source_file = b.path("src/init/main.zig"),
.target = target,
.optimize = optimize,
});
init_exe.root_module.addImport("estd", estd);
const test_step = b.step("test", "Run tests");
inline for (programs) |program| {
const path = b.path("src/" ++ program.name ++ "/main.zig");
const exe = b.addExecutable(.{
.name = program.name,
.root_source_file = path,
.target = target,
.optimize = optimize
});
exe.root_module.addImport("estd", estd);
b.installArtifact(exe);
const run = b.step("run-" ++ program.name, "Run " ++ program.name);
if (program.qemu) {
const run_qemu = b.addSystemCommand(&.{ "./build/run-qemu" });
run_qemu.addFileArg(init_exe.getEmittedBin());
run_qemu.addFileArg(exe.getEmittedBin());
run_qemu.step.dependOn(&exe.step);
run_qemu.step.dependOn(&init_exe.step);
run.dependOn(&run_qemu.step);
} else {
const run_artifact = b.addRunArtifact(exe);
run.dependOn(&run_artifact.step);
}
const tests = b.addTest(.{
.name = program.name,
.root_source_file = path,
});
tests.root_module.addImport("estd", estd);
const run_tests = b.addRunArtifact(tests);
test_step.dependOn(&run_tests.step);
}
const tests = b.addTest(.{
.name = "estd",
.root_source_file = b.path("src/estd/root.zig"),
});
const run_tests = b.addRunArtifact(tests);
test_step.dependOn(&run_tests.step);
}
|