-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
57 lines (52 loc) · 2.04 KB
/
Copy pathbuild.zig
File metadata and controls
57 lines (52 loc) · 2.04 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
const std = @import("std");
const SourceFile = struct {
name: []const u8,
path: []const u8,
};
const files = [_]SourceFile{
.{ .path = "src/ast.zig", .name = "ast" },
.{ .path = "src/lexer.zig", .name = "lexer" },
.{ .path = "src/parser.zig", .name = "parser" },
.{ .path = "src/sema.zig", .name = "sema" },
.{ .path = "src/utils.zig", .name = "utils" },
.{ .path = "src/ir/ir.zig", .name = "stack-ir" },
.{ .path = "src/ir/stack.zig", .name = "stack-ir-gen" },
.{ .path = "src/ir/phi.zig", .name = "phi-ir-gen" },
.{ .path = "src/ir/ir_phi.zig", .name = "phi-ir" },
.{ .path = "src/ir/opt.zig", .name = "opt" },
.{ .path = "src/ir/sccp.zig", .name = "sccp" },
.{ .path = "src/ir/cmp-info-prop.zig", .name = "cmp-prop" },
};
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const build_mode = b.standardOptimizeOption(.{});
// TODO: uncommment for when there is actually a main.zig file
const exe = b.addExecutable(.{
.name = "minipp",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = build_mode,
});
b.installArtifact(exe);
const run_exe = b.addRunArtifact(exe);
const run_step = b.step("run", "Run minipp");
run_step.dependOn(&run_exe.step);
// create tests for all files and a test step that runs them all
const test_step = b.step("test", "Run Tests");
const build_test_step = b.step("test-exe", "Build Tests");
for (files) |file| {
const file_tests = b.addTest(.{
.name = file.name,
.root_source_file = .{ .path = file.path },
.target = target,
.optimize = build_mode,
.main_pkg_path = .{ .path = "./" },
});
const run_test = b.addRunArtifact(file_tests);
test_step.dependOn(&run_test.step);
const build_test = b.addInstallArtifact(file_tests, .{
.dest_dir = .{ .override = .{ .custom = "tests" } },
});
build_test_step.dependOn(&build_test.step);
}
}