fix: unbreak use_llvm and pie options on macos

This commit is contained in:
CJ van den Berg 2024-11-14 17:46:51 +01:00
parent 29c7fbebc4
commit 25eabfa4ca
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -4,19 +4,17 @@ const builtin = @import("builtin");
pub fn build(b: *std.Build) void { pub fn build(b: *std.Build) void {
const tracy_enabled = b.option(bool, "enable_tracy", "Enable tracy client library (default: no)") orelse false; const tracy_enabled = b.option(bool, "enable_tracy", "Enable tracy client library (default: no)") orelse false;
const optimize_deps = b.option(bool, "optimize_deps", "Enable optimization for dependecies (default: yes)") orelse true; const optimize_deps = b.option(bool, "optimize_deps", "Enable optimization for dependecies (default: yes)") orelse true;
const use_llvm = b.option(bool, "use_llvm", "Enable llvm backend (default: yes)") orelse true;
const use_tree_sitter = b.option(bool, "use_tree_sitter", "Enable tree-sitter (default: yes)") orelse true; const use_tree_sitter = b.option(bool, "use_tree_sitter", "Enable tree-sitter (default: yes)") orelse true;
const strip = b.option(bool, "strip", "Disable debug information (default: no)") orelse false; const strip = b.option(bool, "strip", "Disable debug information (default: no)") orelse false;
const pie = b.option(bool, "pie", "Produce an executable with position independent code (default: no)") orelse false;
const dynamic_keybind = b.option(bool, "dynamic_keybind", "Build with dynamic keybinding support (default: no) (EXPERIMENTAL)") orelse false; const dynamic_keybind = b.option(bool, "dynamic_keybind", "Build with dynamic keybinding support (default: no) (EXPERIMENTAL)") orelse false;
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 options = b.addOptions(); const options = b.addOptions();
options.addOption(bool, "enable_tracy", tracy_enabled); options.addOption(bool, "enable_tracy", tracy_enabled);
options.addOption(bool, "optimize_deps", optimize_deps); options.addOption(bool, "optimize_deps", optimize_deps);
options.addOption(bool, "use_llvm", use_llvm);
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, "pie", pie);
options.addOption(bool, "dynamic_keybind", dynamic_keybind); options.addOption(bool, "dynamic_keybind", dynamic_keybind);
const options_mod = options.createModule(); const options_mod = options.createModule();
@ -197,7 +195,6 @@ pub fn build(b: *std.Build) void {
// b.installArtifact(tests); // b.installArtifact(tests);
break :blk b.addRunArtifact(tests); break :blk b.addRunArtifact(tests);
}; };
const ripgrep_mod = b.createModule(.{ const ripgrep_mod = b.createModule(.{
.root_source_file = b.path("src/ripgrep.zig"), .root_source_file = b.path("src/ripgrep.zig"),
@ -281,12 +278,14 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/main.zig"), .root_source_file = b.path("src/main.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.use_llvm = use_llvm,
.use_lld = use_llvm,
.strip = strip, .strip = strip,
}); });
exe.pie = pie; if (use_llvm) |value| {
exe.use_llvm = value;
exe.use_lld = value;
}
if (pie) |value| exe.pie = value;
exe.root_module.addImport("build_options", options_mod); exe.root_module.addImport("build_options", options_mod);
exe.root_module.addImport("flags", flags_dep.module("flags")); exe.root_module.addImport("flags", flags_dep.module("flags"));
exe.root_module.addImport("cbor", cbor_mod); exe.root_module.addImport("cbor", cbor_mod);