Skip to content

Commit 4ef907c

Browse files
gHashTagona-agent
andcommitted
Replace build.zig with Zig 0.15.x version, keep 0.13.x as build_zig13.zig
Co-authored-by: Ona <no-reply@ona.com>
1 parent a430b98 commit 4ef907c

2 files changed

Lines changed: 269 additions & 50 deletions

File tree

build.zig

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

3+
// Build file for Zig 0.15.x
4+
// For Zig 0.13.x use build.zig
5+
36
pub fn build(b: *std.Build) void {
47
const target = b.standardTargetOptions(.{});
58
const optimize = b.standardOptimizeOption(.{});
69

7-
// Library module
8-
const trinity_mod = b.addModule("trinity", .{
10+
// Library module for imports
11+
const trinity_mod = b.createModule(.{
912
.root_source_file = b.path("src/trinity.zig"),
1013
.target = target,
1114
.optimize = optimize,
1215
});
1316

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

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

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

3442
// VSA tests
3543
const vsa_tests = b.addTest(.{
36-
.root_source_file = b.path("src/vsa.zig"),
37-
.target = target,
38-
.optimize = optimize,
44+
.root_module = b.createModule(.{
45+
.root_source_file = b.path("src/vsa.zig"),
46+
.target = target,
47+
.optimize = optimize,
48+
}),
3949
});
4050
const run_vsa_tests = b.addRunArtifact(vsa_tests);
4151
test_step.dependOn(&run_vsa_tests.step);
4252

4353
// VM tests
4454
const vm_tests = b.addTest(.{
45-
.root_source_file = b.path("src/vm.zig"),
46-
.target = target,
47-
.optimize = optimize,
55+
.root_module = b.createModule(.{
56+
.root_source_file = b.path("src/vm.zig"),
57+
.target = target,
58+
.optimize = optimize,
59+
}),
4860
});
4961
const run_vm_tests = b.addRunArtifact(vm_tests);
5062
test_step.dependOn(&run_vm_tests.step);
5163

5264
// Benchmark executable
5365
const bench = b.addExecutable(.{
5466
.name = "trinity-bench",
55-
.root_source_file = b.path("src/vsa.zig"),
56-
.target = target,
57-
.optimize = .ReleaseFast,
67+
.root_module = b.createModule(.{
68+
.root_source_file = b.path("src/vsa.zig"),
69+
.target = target,
70+
.optimize = .ReleaseFast,
71+
}),
5872
});
5973
b.installArtifact(bench);
6074

@@ -65,29 +79,35 @@ pub fn build(b: *std.Build) void {
6579
// Examples
6680
const example_memory = b.addExecutable(.{
6781
.name = "example-memory",
68-
.root_source_file = b.path("examples/memory.zig"),
69-
.target = target,
70-
.optimize = optimize,
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+
}),
7188
});
72-
example_memory.root_module.addImport("trinity", trinity_mod);
7389
b.installArtifact(example_memory);
7490

7591
const example_sequence = b.addExecutable(.{
7692
.name = "example-sequence",
77-
.root_source_file = b.path("examples/sequence.zig"),
78-
.target = target,
79-
.optimize = optimize,
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+
}),
8099
});
81-
example_sequence.root_module.addImport("trinity", trinity_mod);
82100
b.installArtifact(example_sequence);
83101

84102
const example_vm = b.addExecutable(.{
85103
.name = "example-vm",
86-
.root_source_file = b.path("examples/vm.zig"),
87-
.target = target,
88-
.optimize = optimize,
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+
}),
89110
});
90-
example_vm.root_module.addImport("trinity", trinity_mod);
91111
b.installArtifact(example_vm);
92112

93113
// Run examples step
@@ -103,9 +123,11 @@ pub fn build(b: *std.Build) void {
103123
// Firebird CLI
104124
const firebird = b.addExecutable(.{
105125
.name = "firebird",
106-
.root_source_file = b.path("src/firebird/cli.zig"),
107-
.target = target,
108-
.optimize = .ReleaseFast,
126+
.root_module = b.createModule(.{
127+
.root_source_file = b.path("src/firebird/cli.zig"),
128+
.target = target,
129+
.optimize = .ReleaseFast,
130+
}),
109131
});
110132
b.installArtifact(firebird);
111133

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

119141
// Firebird tests
120142
const firebird_tests = b.addTest(.{
121-
.root_source_file = b.path("src/firebird/b2t_integration.zig"),
122-
.target = target,
123-
.optimize = optimize,
143+
.root_module = b.createModule(.{
144+
.root_source_file = b.path("src/firebird/b2t_integration.zig"),
145+
.target = target,
146+
.optimize = optimize,
147+
}),
124148
});
125149
const run_firebird_tests = b.addRunArtifact(firebird_tests);
126150
test_step.dependOn(&run_firebird_tests.step);
127151

128152
// WASM parser tests
129153
const wasm_tests = b.addTest(.{
130-
.root_source_file = b.path("src/firebird/wasm_parser.zig"),
131-
.target = target,
132-
.optimize = optimize,
154+
.root_module = b.createModule(.{
155+
.root_source_file = b.path("src/firebird/wasm_parser.zig"),
156+
.target = target,
157+
.optimize = optimize,
158+
}),
133159
});
134160
const run_wasm_tests = b.addRunArtifact(wasm_tests);
135161
test_step.dependOn(&run_wasm_tests.step);
136162

137163
// Cross-platform release builds
138164
const release_step = b.step("release", "Build release binaries for all platforms");
139165

140-
const targets: []const std.Target.Query = &.{
166+
const targets_list: []const std.Target.Query = &.{
141167
.{ .cpu_arch = .x86_64, .os_tag = .linux },
142168
.{ .cpu_arch = .x86_64, .os_tag = .macos },
143169
.{ .cpu_arch = .aarch64, .os_tag = .macos },
144170
.{ .cpu_arch = .x86_64, .os_tag = .windows },
145171
};
146172

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

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

170198
// Extension WASM tests
171199
const extension_tests = b.addTest(.{
172-
.root_source_file = b.path("src/firebird/extension_wasm.zig"),
173-
.target = target,
174-
.optimize = optimize,
200+
.root_module = b.createModule(.{
201+
.root_source_file = b.path("src/firebird/extension_wasm.zig"),
202+
.target = target,
203+
.optimize = optimize,
204+
}),
175205
});
176206
const run_extension_tests = b.addRunArtifact(extension_tests);
177207
test_step.dependOn(&run_extension_tests.step);
178208

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

0 commit comments

Comments
 (0)