Skip to content

Commit 96ae967

Browse files
gHashTagona-agent
andcommitted
Restore build.zig for Zig 0.13.0 compatibility
Gitpod uses Zig 0.13.0, local dev may use 0.15.x. For Zig 0.15.x: cp build_zig15.zig build.zig Co-authored-by: Ona <no-reply@ona.com>
1 parent 6ca03ee commit 96ae967

1 file changed

Lines changed: 50 additions & 82 deletions

File tree

build.zig

Lines changed: 50 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
11
const std = @import("std");
22

3-
// Build file for Zig 0.15.x
4-
// For Zig 0.13.x use build.zig
5-
63
pub fn build(b: *std.Build) void {
74
const target = b.standardTargetOptions(.{});
85
const optimize = b.standardOptimizeOption(.{});
96

10-
// Library module for imports
11-
const trinity_mod = b.createModule(.{
7+
// Library module
8+
const trinity_mod = b.addModule("trinity", .{
129
.root_source_file = b.path("src/trinity.zig"),
1310
.target = target,
1411
.optimize = optimize,
1512
});
1613

1714
// Library artifact
18-
const lib = b.addLibrary(.{
15+
const lib = b.addStaticLibrary(.{
1916
.name = "trinity",
20-
.linkage = .static,
21-
.root_module = b.createModule(.{
22-
.root_source_file = b.path("src/trinity.zig"),
23-
.target = target,
24-
.optimize = optimize,
25-
}),
17+
.root_source_file = b.path("src/trinity.zig"),
18+
.target = target,
19+
.optimize = optimize,
2620
});
2721
b.installArtifact(lib);
2822

2923
// Tests
3024
const main_tests = b.addTest(.{
31-
.root_module = b.createModule(.{
32-
.root_source_file = b.path("src/trinity.zig"),
33-
.target = target,
34-
.optimize = optimize,
35-
}),
25+
.root_source_file = b.path("src/trinity.zig"),
26+
.target = target,
27+
.optimize = optimize,
3628
});
3729

3830
const run_main_tests = b.addRunArtifact(main_tests);
@@ -41,34 +33,28 @@ pub fn build(b: *std.Build) void {
4133

4234
// VSA tests
4335
const vsa_tests = b.addTest(.{
44-
.root_module = b.createModule(.{
45-
.root_source_file = b.path("src/vsa.zig"),
46-
.target = target,
47-
.optimize = optimize,
48-
}),
36+
.root_source_file = b.path("src/vsa.zig"),
37+
.target = target,
38+
.optimize = optimize,
4939
});
5040
const run_vsa_tests = b.addRunArtifact(vsa_tests);
5141
test_step.dependOn(&run_vsa_tests.step);
5242

5343
// VM tests
5444
const vm_tests = b.addTest(.{
55-
.root_module = b.createModule(.{
56-
.root_source_file = b.path("src/vm.zig"),
57-
.target = target,
58-
.optimize = optimize,
59-
}),
45+
.root_source_file = b.path("src/vm.zig"),
46+
.target = target,
47+
.optimize = optimize,
6048
});
6149
const run_vm_tests = b.addRunArtifact(vm_tests);
6250
test_step.dependOn(&run_vm_tests.step);
6351

6452
// Benchmark executable
6553
const bench = b.addExecutable(.{
6654
.name = "trinity-bench",
67-
.root_module = b.createModule(.{
68-
.root_source_file = b.path("src/vsa.zig"),
69-
.target = target,
70-
.optimize = .ReleaseFast,
71-
}),
55+
.root_source_file = b.path("src/vsa.zig"),
56+
.target = target,
57+
.optimize = .ReleaseFast,
7258
});
7359
b.installArtifact(bench);
7460

@@ -79,35 +65,29 @@ pub fn build(b: *std.Build) void {
7965
// Examples
8066
const example_memory = b.addExecutable(.{
8167
.name = "example-memory",
82-
.root_module = b.createModule(.{
83-
.root_source_file = b.path("examples/memory.zig"),
84-
.target = target,
85-
.optimize = optimize,
86-
.imports = &.{.{ .name = "trinity", .module = trinity_mod }},
87-
}),
68+
.root_source_file = b.path("examples/memory.zig"),
69+
.target = target,
70+
.optimize = optimize,
8871
});
72+
example_memory.root_module.addImport("trinity", trinity_mod);
8973
b.installArtifact(example_memory);
9074

9175
const example_sequence = b.addExecutable(.{
9276
.name = "example-sequence",
93-
.root_module = b.createModule(.{
94-
.root_source_file = b.path("examples/sequence.zig"),
95-
.target = target,
96-
.optimize = optimize,
97-
.imports = &.{.{ .name = "trinity", .module = trinity_mod }},
98-
}),
77+
.root_source_file = b.path("examples/sequence.zig"),
78+
.target = target,
79+
.optimize = optimize,
9980
});
81+
example_sequence.root_module.addImport("trinity", trinity_mod);
10082
b.installArtifact(example_sequence);
10183

10284
const example_vm = b.addExecutable(.{
10385
.name = "example-vm",
104-
.root_module = b.createModule(.{
105-
.root_source_file = b.path("examples/vm.zig"),
106-
.target = target,
107-
.optimize = optimize,
108-
.imports = &.{.{ .name = "trinity", .module = trinity_mod }},
109-
}),
86+
.root_source_file = b.path("examples/vm.zig"),
87+
.target = target,
88+
.optimize = optimize,
11089
});
90+
example_vm.root_module.addImport("trinity", trinity_mod);
11191
b.installArtifact(example_vm);
11292

11393
// Run examples step
@@ -123,11 +103,9 @@ pub fn build(b: *std.Build) void {
123103
// Firebird CLI
124104
const firebird = b.addExecutable(.{
125105
.name = "firebird",
126-
.root_module = b.createModule(.{
127-
.root_source_file = b.path("src/firebird/cli.zig"),
128-
.target = target,
129-
.optimize = .ReleaseFast,
130-
}),
106+
.root_source_file = b.path("src/firebird/cli.zig"),
107+
.target = target,
108+
.optimize = .ReleaseFast,
131109
});
132110
b.installArtifact(firebird);
133111

@@ -140,45 +118,39 @@ pub fn build(b: *std.Build) void {
140118

141119
// Firebird tests
142120
const firebird_tests = b.addTest(.{
143-
.root_module = b.createModule(.{
144-
.root_source_file = b.path("src/firebird/b2t_integration.zig"),
145-
.target = target,
146-
.optimize = optimize,
147-
}),
121+
.root_source_file = b.path("src/firebird/b2t_integration.zig"),
122+
.target = target,
123+
.optimize = optimize,
148124
});
149125
const run_firebird_tests = b.addRunArtifact(firebird_tests);
150126
test_step.dependOn(&run_firebird_tests.step);
151127

152128
// WASM parser tests
153129
const wasm_tests = b.addTest(.{
154-
.root_module = b.createModule(.{
155-
.root_source_file = b.path("src/firebird/wasm_parser.zig"),
156-
.target = target,
157-
.optimize = optimize,
158-
}),
130+
.root_source_file = b.path("src/firebird/wasm_parser.zig"),
131+
.target = target,
132+
.optimize = optimize,
159133
});
160134
const run_wasm_tests = b.addRunArtifact(wasm_tests);
161135
test_step.dependOn(&run_wasm_tests.step);
162136

163137
// Cross-platform release builds
164138
const release_step = b.step("release", "Build release binaries for all platforms");
165139

166-
const targets_list: []const std.Target.Query = &.{
140+
const targets: []const std.Target.Query = &.{
167141
.{ .cpu_arch = .x86_64, .os_tag = .linux },
168142
.{ .cpu_arch = .x86_64, .os_tag = .macos },
169143
.{ .cpu_arch = .aarch64, .os_tag = .macos },
170144
.{ .cpu_arch = .x86_64, .os_tag = .windows },
171145
};
172146

173-
for (targets_list) |t| {
147+
for (targets) |t| {
174148
const release_target = b.resolveTargetQuery(t);
175149
const release_exe = b.addExecutable(.{
176150
.name = "firebird",
177-
.root_module = b.createModule(.{
178-
.root_source_file = b.path("src/firebird/cli.zig"),
179-
.target = release_target,
180-
.optimize = .ReleaseFast,
181-
}),
151+
.root_source_file = b.path("src/firebird/cli.zig"),
152+
.target = release_target,
153+
.optimize = .ReleaseFast,
182154
});
183155

184156
const target_output = b.addInstallArtifact(release_exe, .{
@@ -197,22 +169,18 @@ pub fn build(b: *std.Build) void {
197169

198170
// Extension WASM tests
199171
const extension_tests = b.addTest(.{
200-
.root_module = b.createModule(.{
201-
.root_source_file = b.path("src/firebird/extension_wasm.zig"),
202-
.target = target,
203-
.optimize = optimize,
204-
}),
172+
.root_source_file = b.path("src/firebird/extension_wasm.zig"),
173+
.target = target,
174+
.optimize = optimize,
205175
});
206176
const run_extension_tests = b.addRunArtifact(extension_tests);
207177
test_step.dependOn(&run_extension_tests.step);
208178

209179
// DePIN tests
210180
const depin_tests = b.addTest(.{
211-
.root_module = b.createModule(.{
212-
.root_source_file = b.path("src/firebird/depin.zig"),
213-
.target = target,
214-
.optimize = optimize,
215-
}),
181+
.root_source_file = b.path("src/firebird/depin.zig"),
182+
.target = target,
183+
.optimize = optimize,
216184
});
217185
const run_depin_tests = b.addRunArtifact(depin_tests);
218186
test_step.dependOn(&run_depin_tests.step);

0 commit comments

Comments
 (0)