-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
180 lines (156 loc) · 8.02 KB
/
build.zig
File metadata and controls
180 lines (156 loc) · 8.02 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//! GoldenFloat — φ-Optimized Zig Kernel Build System
//! Zig 0.15 package system — module-only library
//!
//! **Build Targets:**
//! - `zig build` — Build module only
//! - `zig build test` — Run all tests
//! - `zig build shared` — Build libgoldenfloat.{so,dylib,dll}
//! - `zig build c-abi-test` — Test C-ABI layer
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// ─────────────────────────────────────────────────────────────────
// Library module (what users import via @import("golden-float"))
// ─────────────────────────────────────────────────────────────────
_ = b.addModule("golden-float", .{
.root_source_file = b.path("src/root.zig"),
});
// ─────────────────────────────────────────────────────────────────
// tri_gen executable — code generator from .tri specs
// ─────────────────────────────────────────────────────────────────
const tri_gen_module = b.createModule(.{
.root_source_file = b.path("tools/gen/tri_gen.zig"),
.target = target,
.optimize = optimize,
});
const tri_gen = b.addExecutable(.{
.name = "tri_gen",
.root_module = tri_gen_module,
});
b.installArtifact(tri_gen);
const run_tri_gen = b.addRunArtifact(tri_gen);
const gen_step = b.step("gen", "Generate code from .tri specs");
gen_step.dependOn(&run_tri_gen.step);
// ─────────────────────────────────────────────────────────────────
// C-ABI Shared Library — libgoldenfloat.{so,dylib,dll}
// ─────────────────────────────────────────────────────────────────
const c_abi_module = b.createModule(.{
.root_source_file = b.path("src/c_abi.zig"),
.target = target,
.optimize = optimize,
});
const c_abi_lib = b.addLibrary(.{
.name = "goldenfloat",
.root_module = c_abi_module,
.linkage = .dynamic,
.version = .{ .major = 2, .minor = 1, .patch = 0 },
});
b.installArtifact(c_abi_lib);
// Install C header alongside library
const header_install = b.addInstallHeaderFile(b.path("src/c/gf16.h"), "gf16.h");
const shared_step = b.step("shared", "Build C-ABI shared library (libgoldenfloat)");
shared_step.dependOn(&b.addInstallArtifact(c_abi_lib, .{}).step);
shared_step.dependOn(&header_install.step);
// ─────────────────────────────────────────────────────────────────
// C-ABI Tests
// ─────────────────────────────────────────────────────────────────
const c_abi_test_module = b.createModule(.{
.root_source_file = b.path("src/c_abi.zig"),
.target = target,
.optimize = optimize,
});
const c_abi_tests = b.addTest(.{
.name = "c-abi-tests",
.root_module = c_abi_test_module,
});
const run_c_abi_tests = b.addRunArtifact(c_abi_tests);
const c_abi_test_step = b.step("c-abi-test", "Run C-ABI tests");
c_abi_test_step.dependOn(&run_c_abi_tests.step);
// ─────────────────────────────────────────────────────────────────
// Tests — formats (GF16/TF3)
// ─────────────────────────────────────────────────────────────────
const formats_tests_root = b.createModule(.{
.root_source_file = b.path("src/formats/golden_float16.zig"),
.target = target,
.optimize = optimize,
});
const formats_tests = b.addTest(.{
.name = "formats-tests",
.root_module = formats_tests_root,
});
// ─────────────────────────────────────────────────────────────────
// Tests — transcendental functions (Wave 4B)
// ─────────────────────────────────────────────────────────────────
const transcendent_tests_root = b.createModule(.{
.root_source_file = b.path("src/math/transcendental.zig"),
.target = target,
.optimize = optimize,
});
const transcendent_tests = b.addTest(.{
.name = "transcendent-tests",
.root_module = transcendent_tests_root,
});
const run_tests = b.addRunArtifact(formats_tests);
const run_transcendent_tests = b.addRunArtifact(transcendent_tests);
const trinity_tests_root = b.createModule(.{
.root_source_file = b.path("src/trinity_constants.zig"),
.target = target,
.optimize = optimize,
});
const trinity_tests = b.addTest(.{
.name = "trinity-constants-tests",
.root_module = trinity_tests_root,
});
const run_trinity_tests = b.addRunArtifact(trinity_tests);
const phi_attention_tests_root = b.createModule(.{
.root_source_file = b.path("src/phi_attention.zig"),
.target = target,
.optimize = optimize,
});
const phi_attention_tests = b.addTest(.{
.name = "phi-attention-tests",
.root_module = phi_attention_tests_root,
});
const run_phi_attention_tests = b.addRunArtifact(phi_attention_tests);
const trinity_init_tests_root = b.createModule(.{
.root_source_file = b.path("src/trinity_init.zig"),
.target = target,
.optimize = optimize,
});
const trinity_init_tests = b.addTest(.{
.name = "trinity-init-tests",
.root_module = trinity_init_tests_root,
});
const run_trinity_init_tests = b.addRunArtifact(trinity_init_tests);
const jepa_t_tests_root = b.createModule(.{
.root_source_file = b.path("src/jepa_t.zig"),
.target = target,
.optimize = optimize,
});
const jepa_t_tests = b.addTest(.{
.name = "jepa-t-tests",
.root_module = jepa_t_tests_root,
});
const run_jepa_t_tests = b.addRunArtifact(jepa_t_tests);
const test_step = b.step("test", "Run all tests");
test_step.dependOn(&run_tests.step);
test_step.dependOn(&run_transcendent_tests.step);
test_step.dependOn(&run_c_abi_tests.step);
test_step.dependOn(&run_trinity_tests.step);
test_step.dependOn(&run_phi_attention_tests.step);
test_step.dependOn(&run_trinity_init_tests.step);
test_step.dependOn(&run_jepa_t_tests.step);
const igla_bench_module = b.createModule(.{
.root_source_file = b.path("benches/igla_gf16_bench.zig"),
.target = target,
.optimize = optimize,
});
const igla_bench = b.addExecutable(.{
.name = "igla_gf16_bench",
.root_module = igla_bench_module,
});
const run_igla_bench = b.addRunArtifact(igla_bench);
const igla_bench_step = b.step("bench-igla", "Run IGLA-GF16 architecture verification (Module 7)");
igla_bench_step.dependOn(&run_igla_bench.step);
}