-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbuild.zig
More file actions
152 lines (129 loc) · 4.96 KB
/
build.zig
File metadata and controls
152 lines (129 loc) · 4.96 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// .'\ /`.
// .'.-.`-'.-.`.
// ..._: .-. .-. :_...
// .' '-.(o ) (o ).-' `.
// : _ _ _`~(_)~`_ _ _ :
// : /: ' .-=_ _=-. ` ;\ :
// : :|-.._ ' ` _..-|: :
// : `:| |`:-:-.-:-:'| |:' :
// `. `.| | | | | | |.' .'
// `. `-:_| | |_:-' .'
// `-._ ```` _.-'
// ``-------''
//
// Created by ab, 14.11.2024
const std = @import("std");
pub const ProtoGenStep = @import("step.zig");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
_ = b.addModule("gremlin_parser", .{
.root_source_file = b.path("src/parser/main.zig"),
});
const gremlin = b.addModule("gremlin", .{
.root_source_file = b.path("src/gremlin/main.zig"),
});
const test_step = b.step("test", "Run tests");
{
const parser_test = b.addTest(.{
.name = "parser",
.root_module = b.createModule(.{
.root_source_file = b.path("src/parser/main.zig"),
.target = target,
.optimize = optimize,
}),
});
const run_parser_tests = b.addRunArtifact(parser_test);
test_step.dependOn(&run_parser_tests.step);
}
{
const gremlin_test = b.addTest(.{
.name = "wire",
.root_module = b.createModule(.{
.root_source_file = b.path("src/gremlin/main.zig"),
.target = target,
.optimize = optimize,
}),
});
const run_gremiln_tests = b.addRunArtifact(gremlin_test);
test_step.dependOn(&run_gremiln_tests.step);
}
{
const codegen_test = b.addTest(.{
.name = "codegen",
.root_module = b.createModule(.{
.root_source_file = b.path("step.zig"),
.target = target,
.optimize = optimize,
}),
});
const run_codegen_tests = b.addRunArtifact(codegen_test);
test_step.dependOn(&run_codegen_tests.step);
}
{
const proto_gen_step = b.step("proto-gen", "Generate protobuf files");
const google_protobuf = ProtoGenStep.create(
b,
.{
.name = "test_data/google protobuf",
.proto_sources = b.path("test_data/google"),
.target = b.path("integration-test/gen/google"),
},
);
proto_gen_step.dependOn(&google_protobuf.step);
const gogofast_protobuf = ProtoGenStep.create(
b,
.{
.name = "test_data/gogofast protobuf",
.proto_sources = b.path("test_data/gogofast"),
.target = b.path("integration-test/gen/gogofast"),
},
);
proto_gen_step.dependOn(&gogofast_protobuf.step);
const ambg_ref_protobuf = ProtoGenStep.create(
b,
.{
.name = "test_data/ambg_ref protobuf",
.proto_sources = b.path("test_data/ambg_ref"),
.target = b.path("integration-test/gen/ambg_ref"),
},
);
proto_gen_step.dependOn(&ambg_ref_protobuf.step);
const integration_test = b.addTest(.{
.name = "integration",
.root_module = b.createModule(.{
.root_source_file = b.path("integration-test/main.zig"),
.target = target,
.optimize = optimize,
}),
});
integration_test.step.dependOn(proto_gen_step);
integration_test.root_module.addImport("gremlin", gremlin);
const run_integration = b.addRunArtifact(integration_test);
test_step.dependOn(&run_integration.step);
// Add benchmark binary
const benchmark_step = b.step("benchmark", "Build serialization benchmark");
const benchmark_exe = b.addExecutable(.{
.name = "serialization-benchmark",
.root_module = b.createModule(.{
.root_source_file = b.path("integration-test/benchmark.zig"),
.target = target,
.optimize = .ReleaseFast, // Use ReleaseFast for benchmarks
}),
});
benchmark_exe.step.dependOn(proto_gen_step);
benchmark_exe.root_module.addImport("gremlin", gremlin);
const install_benchmark = b.addInstallArtifact(benchmark_exe, .{});
benchmark_step.dependOn(&install_benchmark.step);
// Add a run step for the benchmark
const run_benchmark = b.addRunArtifact(benchmark_exe);
run_benchmark.step.dependOn(&install_benchmark.step);
if (b.args) |args| {
run_benchmark.addArgs(args);
} else {
run_benchmark.addArg("1000"); // Default to 1000 iterations
}
const run_benchmark_step = b.step("run-benchmark", "Run serialization benchmark");
run_benchmark_step.dependOn(&run_benchmark.step);
}
}