-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
80 lines (71 loc) · 3.52 KB
/
Copy pathbuild.zig
File metadata and controls
80 lines (71 loc) · 3.52 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Version from build.zig.zon, overridable via -Dversion (used by CI release)
const version: []const u8 = b.option([]const u8, "version", "Override version string (e.g. from git tag)") orelse @import("build.zig.zon").version;
// Library versions from versions.zon — the tested compatible set for this CLI release
const versions = @import("versions.zon");
// ── Build options ────────────────────────────────────────────────
// Issue #217: the CLI is a thin driver over the standalone
// labelle-assembler binary and no longer links the assembler's
// `generator` module. The `project.labelle` schema the CLI reads
// (src/cli/project_config.zig) pins default framework versions and
// the CLI version — those come from this `build_options` module
// instead of the assembler package's build options.
const options = b.addOptions();
options.addOption([]const u8, "cli_version", version);
options.addOption([]const u8, "core_version", versions.core);
options.addOption([]const u8, "engine_version", versions.engine);
options.addOption([]const u8, "gfx_version", versions.gfx);
const build_options_mod = options.createModule();
const gen_exe = b.addExecutable(.{
.name = "labelle",
.root_module = b.createModule(.{
.root_source_file = b.path("src/cli.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "build_options", .module = build_options_mod },
},
}),
});
wireStb(b, gen_exe.root_module);
b.installArtifact(gen_exe);
const gen_run = b.addRunArtifact(gen_exe);
if (b.args) |args| {
gen_run.addArgs(args);
}
const gen_step = b.step("generate", "Generate assembler from project.labelle");
gen_step.dependOn(&gen_run.step);
// ── Tests ────────────────────────────────────────────────────────
const zspec_dep = b.dependency("zspec", .{ .target = target, .optimize = optimize });
const cli_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/cli.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "build_options", .module = build_options_mod },
.{ .name = "zspec", .module = zspec_dep.module("zspec") },
},
}),
});
wireStb(b, cli_tests.root_module);
const run_cli_tests = b.addRunArtifact(cli_tests);
const test_step = b.step("test", "Run CLI unit tests");
test_step.dependOn(&run_cli_tests.step);
}
/// Compile the vendored stb implementation (PNG decode + encode) and
/// put its headers on the include path. Two consumers `@cImport` those
/// headers: `src/cli/bake.zig` (decode, for the PNG→LRGBA prebake) and
/// `src/texpack/` (decode + encode, for `labelle pack`). A single `.c`
/// provides one definition of the symbols for both.
fn wireStb(b: *std.Build, mod: *std.Build.Module) void {
mod.addCSourceFile(.{
.file = b.path("src/cli/stb_image_impl.c"),
.flags = &.{"-std=c99"},
});
mod.addIncludePath(b.path("src/cli"));
mod.link_libc = true;
}