fix(build): don't declare d2d mutiple times in package_release builds

This commit is contained in:
CJ van den Berg 2025-01-14 16:11:17 +01:00
parent 9cc5c9711b
commit d58f1964bf
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -9,6 +9,7 @@ pub fn build(b: *std.Build) void {
const use_llvm = b.option(bool, "use_llvm", "Enable llvm backend (default: none)"); const use_llvm = b.option(bool, "use_llvm", "Enable llvm backend (default: none)");
const pie = b.option(bool, "pie", "Produce an executable with position independent code (default: none)"); const pie = b.option(bool, "pie", "Produce an executable with position independent code (default: none)");
const gui = b.option(bool, "gui", "Standalone GUI mode") orelse false; const gui = b.option(bool, "gui", "Standalone GUI mode") orelse false;
const d2d = if (gui) b.option(bool, "d2d", "use the Direct2D backend (instead of Direct3D11)") orelse false else false;
const run_step = b.step("run", "Run the app"); const run_step = b.step("run", "Run the app");
const check_step = b.step("check", "Check the app"); const check_step = b.step("check", "Check the app");
@ -27,6 +28,7 @@ pub fn build(b: *std.Build) void {
use_llvm, use_llvm,
pie, pie,
gui, gui,
d2d,
); );
} }
@ -42,6 +44,7 @@ fn build_development(
use_llvm: ?bool, use_llvm: ?bool,
pie: ?bool, pie: ?bool,
gui: bool, gui: bool,
d2d: bool,
) void { ) void {
const target = b.standardTargetOptions(.{ .default_target = .{ .abi = if (builtin.os.tag == .linux and !tracy_enabled) .musl else null } }); const target = b.standardTargetOptions(.{ .default_target = .{ .abi = if (builtin.os.tag == .linux and !tracy_enabled) .musl else null } });
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
@ -61,6 +64,7 @@ fn build_development(
use_llvm, use_llvm,
pie, pie,
gui, gui,
d2d,
); );
} }
@ -76,6 +80,7 @@ fn build_release(
use_llvm: ?bool, use_llvm: ?bool,
pie: ?bool, pie: ?bool,
_: bool, //gui _: bool, //gui
d2d: bool,
) void { ) void {
const targets: []const std.Target.Query = &.{ const targets: []const std.Target.Query = &.{
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl }, .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl },
@ -118,6 +123,7 @@ fn build_release(
use_llvm, use_llvm,
pie, pie,
false, //gui false, //gui
false, //d2d
); );
if (t.os_tag == .windows) if (t.os_tag == .windows)
@ -136,6 +142,7 @@ fn build_release(
use_llvm, use_llvm,
pie, pie,
true, //gui true, //gui
d2d,
); );
} }
} }
@ -155,19 +162,14 @@ pub fn build_exe(
use_llvm: ?bool, use_llvm: ?bool,
pie: ?bool, pie: ?bool,
gui: bool, gui: bool,
d2d: bool,
) void { ) void {
const options = b.addOptions(); const options = b.addOptions();
options.addOption(bool, "enable_tracy", tracy_enabled); options.addOption(bool, "enable_tracy", tracy_enabled);
options.addOption(bool, "use_tree_sitter", use_tree_sitter); options.addOption(bool, "use_tree_sitter", use_tree_sitter);
options.addOption(bool, "strip", strip); options.addOption(bool, "strip", strip);
options.addOption(bool, "gui", gui); options.addOption(bool, "gui", gui);
if (gui) { options.addOption(bool, "d2d", d2d);
options.addOption(bool, "d2d", b.option(
bool,
"d2d",
"use the Direct2D backend (instead of Direct3D11)",
) orelse false);
}
const options_mod = options.createModule(); const options_mod = options.createModule();