From b7c5fd49087fee7cb4495edb61ea8a80a7670855 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 6 Feb 2024 16:42:38 -0800 Subject: [PATCH] build: if emit-bench is on, do not emit exes This isn't the cleanest approach yet. But this gets things going quickly. Ideally longer term I want to be able to specify a list of artifacts that you want to build or something like that. --- build.zig | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/build.zig b/build.zig index 406fc1942..3b109ee4e 100644 --- a/build.zig +++ b/build.zig @@ -105,18 +105,6 @@ pub fn build(b: *std.Build) !void { "Name of the conformance app to run with 'run' option.", ); - const emit_docs = b.option( - bool, - "emit-docs", - "Build and install auto-generated documentation (requires pandoc)", - ) orelse emit_docs: { - // We only default to true if we can find pandoc. - const path = Command.expandPath(b.allocator, "pandoc") catch - break :emit_docs false; - defer if (path) |p| b.allocator.free(p); - break :emit_docs path != null; - }; - const emit_test_exe = b.option( bool, "emit-test-exe", @@ -135,6 +123,30 @@ pub fn build(b: *std.Build) !void { "Build and install the helpgen executable.", ) orelse false; + const emit_docs = b.option( + bool, + "emit-docs", + "Build and install auto-generated documentation (requires pandoc)", + ) orelse emit_docs: { + // If we are emitting any other artifacts then we default to false. + if (emit_bench or emit_test_exe or emit_helpgen) break :emit_docs false; + + // We only default to true if we can find pandoc. + const path = Command.expandPath(b.allocator, "pandoc") catch + break :emit_docs false; + defer if (path) |p| b.allocator.free(p); + break :emit_docs path != null; + }; + + const emit_xcframework = b.option( + bool, + "emit-xcframework", + "Build and install the xcframework for the macOS library.", + ) orelse builtin.target.isDarwin() and + target.result.os.tag == .macos and + config.app_runtime == .none and + (!emit_bench and !emit_test_exe and !emit_helpgen); + // On NixOS, the built binary from `zig build` needs to patch the rpath // into the built binary for it to be portable across the NixOS system // it was built for. We default this to true if we can detect we're in @@ -502,10 +514,7 @@ pub fn build(b: *std.Build) !void { } // On Mac we can build the embedding library. This only handles the macOS lib. - if (builtin.target.isDarwin() and - target.result.os.tag == .macos and - config.app_runtime == .none) - { + if (emit_xcframework) { // Create the universal macOS lib. const macos_lib_step, const macos_lib_path = try createMacOSLib( b,