From 1f9d4eb9f458eb3653957e5873b384ec83090c74 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 14 Feb 2023 21:18:17 -0800 Subject: [PATCH] update to latest build API, rebase --- build.zig | 18 ++++++++++++------ src/build/LibtoolStep.zig | 11 ++++++----- src/build/LipoStep.zig | 7 ++++--- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/build.zig b/build.zig index 3c6e8818f..34f65af2c 100644 --- a/build.zig +++ b/build.zig @@ -138,10 +138,13 @@ pub fn build(b: *std.build.Builder) !void { const macapp = b.step("macapp", "Build macOS app using XCode."); if (builtin.target.isDarwin()) { const static_lib_aarch64 = lib: { - const lib = b.addStaticLibrary("ghostty", "src/main_c.zig"); + const lib = b.addStaticLibrary(.{ + .name = "ghostty", + .root_source_file = .{ .path = "src/main_c.zig" }, + .target = try std.zig.CrossTarget.parse(.{ .arch_os_abi = "aarch64-macos" }), + .optimize = optimize, + }); lib.bundle_compiler_rt = true; - lib.setBuildMode(mode); - lib.setTarget(try std.zig.CrossTarget.parse(.{ .arch_os_abi = "aarch64-macos" })); lib.linkLibC(); lib.addOptions("build_options", exe_options); b.default_step.dependOn(&lib.step); @@ -160,10 +163,13 @@ pub fn build(b: *std.build.Builder) !void { }; const static_lib_x86_64 = lib: { - const lib = b.addStaticLibrary("ghostty", "src/main_c.zig"); + const lib = b.addStaticLibrary(.{ + .name = "ghostty", + .root_source_file = .{ .path = "src/main_c.zig" }, + .target = try std.zig.CrossTarget.parse(.{ .arch_os_abi = "x86_64-macos" }), + .optimize = optimize, + }); lib.bundle_compiler_rt = true; - lib.setBuildMode(mode); - lib.setTarget(try std.zig.CrossTarget.parse(.{ .arch_os_abi = "x86_64-macos" })); lib.linkLibC(); lib.addOptions("build_options", exe_options); b.default_step.dependOn(&lib.step); diff --git a/src/build/LibtoolStep.zig b/src/build/LibtoolStep.zig index e3395c880..98d03017b 100644 --- a/src/build/LibtoolStep.zig +++ b/src/build/LibtoolStep.zig @@ -20,7 +20,7 @@ pub const Options = struct { }; step: Step, -builder: *std.build.Builder, +builder: *std.Build, /// Resulting binary out_path: GeneratedFile, @@ -30,7 +30,7 @@ name: []const u8, out_name: []const u8, sources: []FileSource, -pub fn create(builder: *std.build.Builder, opts: Options) *LibtoolStep { +pub fn create(builder: *std.Build, opts: Options) *LibtoolStep { const self = builder.allocator.create(LibtoolStep) catch @panic("OOM"); self.* = .{ .step = Step.init(.custom, builder.fmt("lipo {s}", .{opts.name}), builder.allocator, make), @@ -48,9 +48,10 @@ fn make(step: *Step) !void { // TODO: use the zig cache system when it is in the stdlib // https://github.com/ziglang/zig/pull/14571 - const output_path = self.builder.pathJoin(&.{ - self.builder.cache_root, self.out_name, - }); + const output_path = try self.builder.cache_root.join( + self.builder.allocator, + &.{self.out_name}, + ); // We use a RunStep here to ease our configuration. { diff --git a/src/build/LipoStep.zig b/src/build/LipoStep.zig index cc6f187ce..9570a54c6 100644 --- a/src/build/LipoStep.zig +++ b/src/build/LipoStep.zig @@ -50,9 +50,10 @@ fn make(step: *Step) !void { // TODO: use the zig cache system when it is in the stdlib // https://github.com/ziglang/zig/pull/14571 - const output_path = self.builder.pathJoin(&.{ - self.builder.cache_root, self.out_name, - }); + const output_path = try self.builder.cache_root.join( + self.builder.allocator, + &.{self.out_name}, + ); // We use a RunStep here to ease our configuration. {