Repository navigation
Expand file tree
/
Copy pathbuild.zig
More file actions
72 lines (64 loc) · 2.63 KB
/
Copy pathbuild.zig
File metadata and controls
72 lines (64 loc) · 2.63 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
const std = @import("std");
const Build = std.Build;
const rlptest_json = "ethereum-tests/RLPTests/rlptest.json";
const invalid_rlptest_json = "ethereum-tests/RLPTests/invalidRLPTest.json";
pub fn build(b: *Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
_ = b.addModule("zig-rlp", Build.Module.CreateOptions{
.root_source_file = b.path("src/rlp.zig"),
.target = target,
.optimize = optimize,
});
const lib = b.addLibrary(.{
.name = "zig-rlp",
.root_module = b.createModule(.{
.root_source_file = b.path("src/serialize.zig"),
.target = target,
.optimize = optimize,
}),
.linkage = .static,
});
b.installArtifact(lib);
var main_tests = b.addRunArtifact(b.addTest(.{
.root_module = b.createModule(.{ .root_source_file = b.path("src/serialize.zig"), .target = target, .optimize = optimize }),
}));
var deser_tests = b.addRunArtifact(b.addTest(.{
.root_module = b.createModule(.{ .root_source_file = b.path("src/deserialize.zig"), .target = target, .optimize = optimize }),
}));
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&main_tests.step);
test_step.dependOn(&deser_tests.step);
const have_vectors = blk: {
const io = b.graph.io;
b.root.access(io, rlptest_json, .{}) catch break :blk false;
b.root.access(io, invalid_rlptest_json, .{}) catch break :blk false;
break :blk true;
};
if (have_vectors) {
const vectors_module = b.createModule(.{
.root_source_file = b.path("src/vectors.zig"),
.target = target,
.optimize = optimize,
});
vectors_module.addAnonymousImport("rlptest.json", .{
.root_source_file = b.path(rlptest_json),
});
vectors_module.addAnonymousImport("invalidRLPTest.json", .{
.root_source_file = b.path(invalid_rlptest_json),
});
const vector_tests = b.addRunArtifact(b.addTest(.{ .root_module = vectors_module }));
test_step.dependOn(&vector_tests.step);
}
const bench_exe = b.addExecutable(.{
.name = "rlp-bench",
.root_module = b.createModule(.{
.root_source_file = b.path("src/bench.zig"),
.target = target,
.optimize = if (optimize == .debug) .fast else optimize,
.link_libc = true,
}),
});
const bench_step = b.step("bench", "Build zig-out/bin/rlp-bench, a benchmark workload for poop");
bench_step.dependOn(&b.addInstallArtifact(bench_exe, .{}).step);
}