-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
89 lines (79 loc) · 3.09 KB
/
Copy pathbuild.zig
File metadata and controls
89 lines (79 loc) · 3.09 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const use_llvm = b.option(bool, "use-llvm", "Compile library and tests with LLVM backend") orelse true;
const tracy_enable = b.option(bool, "tracy_enable", "Enable profiling") orelse true;
const tracy = b.dependency("tracy", .{
.target = target,
.optimize = optimize,
.tracy_enable = tracy_enable,
});
const tables_exe = b.addExecutable(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/tables.zig"),
.target = b.graph.host,
.optimize = .Debug,
}),
.use_llvm = use_llvm,
.name = "tables",
});
const run_tables = b.addRunArtifact(tables_exe);
const tables_mod = b.createModule(.{ .root_source_file = run_tables.captureStdOut() });
run_tables.captured_stdout.?.basename = "table.zig"; // work around before zig 0.16
const reedsol = b.addModule("reedsol", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "tables", .module = tables_mod }},
});
reedsol.addImport("tracy", tracy.module("tracy"));
reedsol.linkLibrary(tracy.artifact("tracy"));
const benchmark_step = b.step("benchmark", "Runs the benchmarks");
const benchmark_exe = b.addExecutable(.{
.name = "benchmarks",
.root_module = b.createModule(.{
.root_source_file = b.path("src/benchmarks.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "reedsol", .module = reedsol }},
}),
.use_llvm = use_llvm,
});
benchmark_step.dependOn(&b.addRunArtifact(benchmark_exe).step);
const example_step = b.step("example", "Runs the example");
const example_exe = b.addExecutable(.{
.name = "example",
.root_module = b.createModule(.{
.root_source_file = b.path("example/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "reedsol", .module = reedsol }},
}),
.use_llvm = use_llvm,
});
example_step.dependOn(&b.addRunArtifact(example_exe).step);
const test_step = b.step("test", "Run tests");
inline for (.{
.{ "encode", "tests/tests.zig" },
.{ "engine", "src/root.zig" },
}) |entry| {
const name, const path = entry;
const tests = b.addTest(.{
.name = name,
.use_llvm = use_llvm,
.root_module = b.createModule(.{
.root_source_file = b.path(path),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "reedsol", .module = reedsol },
.{ .name = "tables", .module = tables_mod },
},
}),
});
b.installArtifact(tests);
const run_tests = b.addRunArtifact(tests);
test_step.dependOn(&run_tests.step);
}
}