-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.zig
More file actions
140 lines (117 loc) · 4.32 KB
/
Copy pathbuild.zig
File metadata and controls
140 lines (117 loc) · 4.32 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
const flatbuffers = b.addModule("flatbuffers", .{
.root_source_file = b.path("src/flatbuffers.zig"),
.target = target,
.optimize = optimize,
});
const reflection = b.addModule("reflection", .{
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/reflection.zig"),
.imports = &.{
.{ .name = "flatbuffers", .module = flatbuffers },
},
});
const parse = b.addModule("parse", .{
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/parse.zig"),
.imports = &.{
.{ .name = "flatbuffers", .module = flatbuffers },
},
});
{
const exe = b.addExecutable(.{
.name = "zfbs-parse",
.root_module = parse,
});
b.installArtifact(exe);
const run = b.addRunArtifact(exe);
if (b.args) |args|
run.addArgs(args);
b.installArtifact(exe);
b.step("parse", "Parse a .bfbs schema into ZON IR").dependOn(&run.step);
}
const generate = b.addModule("generate", .{
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/generate.zig"),
.imports = &.{
.{ .name = "flatbuffers", .module = flatbuffers },
},
});
{
const exe = b.addExecutable(.{
.name = "zfbs-generate",
.root_module = generate,
});
b.installArtifact(exe);
const run = b.addRunArtifact(exe);
if (b.args) |args|
run.addArgs(args);
b.installArtifact(exe);
b.step("generate", "Generate a decoder library for the ZON schema").dependOn(&run.step);
}
const tests = b.addTest(.{
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("test/test.zig"),
.imports = &.{
.{ .name = "flatbuffers", .module = flatbuffers },
.{ .name = "reflection", .module = reflection },
},
}),
});
const run_tests = b.addRunArtifact(tests);
b.step("test", "run the tests").dependOn(&run_tests.step);
// Integration tests with flatcc
const integration_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("test/test_integration.zig"),
.imports = &.{
.{ .name = "flatbuffers", .module = flatbuffers },
.{ .name = "reflection", .module = reflection },
},
});
// Add flatcc runtime C sources
integration_module.addCSourceFile(.{
.file = b.path("flatcc/src/runtime/builder.c"),
.flags = &.{"-std=c11"},
});
integration_module.addCSourceFile(.{
.file = b.path("flatcc/src/runtime/verifier.c"),
.flags = &.{"-std=c11"},
});
integration_module.addCSourceFile(.{
.file = b.path("flatcc/src/runtime/emitter.c"),
.flags = &.{"-std=c11"},
});
integration_module.addCSourceFile(.{
.file = b.path("flatcc/src/runtime/refmap.c"),
.flags = &.{"-std=c11"},
});
// Add our C helper wrappers for each schema
integration_module.addCSourceFile(.{
.file = b.path("test/simple/flatcc_helpers.c"),
.flags = &.{"-std=c11"},
});
integration_module.addCSourceFile(.{
.file = b.path("test/monster/flatcc_helpers.c"),
.flags = &.{"-std=c11"},
});
integration_module.link_libc = true;
integration_module.addIncludePath(b.path("flatcc/include"));
integration_module.addIncludePath(b.path("flatcc/include/flatcc/reflection"));
integration_module.addIncludePath(b.path("test"));
integration_module.addIncludePath(b.path("test/simple/flatcc"));
integration_module.addIncludePath(b.path("test/monster/flatcc"));
integration_module.addIncludePath(b.path("test/arrow/flatcc"));
const integration_tests = b.addTest(.{ .root_module = integration_module });
const run_integration_tests = b.addRunArtifact(integration_tests);
b.step("test-integration", "run the integration tests").dependOn(&run_integration_tests.step);
}