-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
103 lines (83 loc) · 3.52 KB
/
Copy pathbuild.zig
File metadata and controls
103 lines (83 loc) · 3.52 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
const std = @import("std");
const ModInf = struct {
path: []const u8,
deps: []const []const u8,
};
const MODS = std.StaticStringMap(ModInf).initComptime(.{
.{ "common", ModInf { .path = "src/common/mod.zig", .deps = &.{ "diagnostics"} } },
.{ "lex", ModInf { .path = "src/lex/mod.zig", .deps = &.{"common"} } },
.{ "parse", ModInf { .path = "src/parse/mod.zig", .deps = &.{"common", "lex", "diagnostics"} } },
.{ "diagnostics", ModInf { .path = "src/diagnostics/mod.zig", .deps = &.{"common"} } },
.{ "hir", ModInf { .path = "src/hir/mod.zig", .deps = &.{"common", "diagnostics", "lex", "parse"} } },
.{ "tir", ModInf { .path = "src/tir/mod.zig", .deps = &.{ "common", "diagnostics", "hir", "types"}}},
.{ "backend", ModInf { .path = "src/backend/mod.zig", .deps = &.{"common", "diagnostics"} } },
.{ "bindings", ModInf { .path = "src/bindings/mod.zig", .deps = &.{} }},
.{ "driver", ModInf { .path = "src/driver/mod.zig", .deps = &.{"common", "diagnostics"} } },
.{ "types", ModInf { .path = "src/types/mod.zig", .deps = &.{ "common", "hir", "diagnostics" } } },
});
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{ });
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "conical",
.use_llvm = false, //FIXME: Once zig adds SFrame support this should be disabled, currently false since backend has not yet been made
.use_lld = false, //FIXME: Same here
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
var modules = std.StringHashMap(*std.Build.Module).init(b.allocator);
const kvs = MODS.kvs;
// Create overall modules
for (0..kvs.len) |i| {
const name = kvs.keys[i];
const info = kvs.values[i];
const mod = b.addModule(name, .{
.root_source_file = b.path(info.path),
.target = target,
.optimize = optimize,
});
modules.put(name, mod) catch @panic("Ran out of memory");
exe.root_module.addImport(name, mod);
}
// Wire dependencies between modules
for (0..kvs.len) |i| {
const name = kvs.keys[i];
const info = kvs.values[i];
const mod = modules.get(name).?;
for (info.deps) |dep_name| {
const dep_mod = modules.get(dep_name)
orelse @panic("unkown module dependency");
mod.addImport(dep_name, dep_mod);
}
}
//modules.getPtr("bindings").?.*.link_libc = true;
// Add tests
const test_step = b.step("test", "Run unit tests");
var mod_it = modules.iterator();
while (mod_it.next()) |entry| {
const tst = b.addTest(.{
.use_lld = false, //FIXME: Remove with SFrame support
.use_llvm = false,
.root_module = entry.value_ptr.*,
});
const test_run = b.addRunArtifact(tst);
test_step.dependOn(&test_run.step);
}
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// const lib_unit_tests = b.addTest(.{
// .root_source_file = b.path("src/root.zig"),
// .target = target,
// .optimize = optimize,
// });
// const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
}