From 1913243c357a2ceb754756e3f7edde791f2150d9 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Wed, 3 Jan 2024 21:50:32 +0100 Subject: [PATCH 01/24] WIP: Update to new build module API after Zig PR #18160 Temporarily change dependency sources to forks until they update --- build.zig | 255 +++++++++++++++++++++--------------- build.zig.zon | 20 +-- pkg/apple-sdk/build.zig | 2 +- pkg/apple-sdk/build.zig.zon | 4 +- pkg/cimgui/build.zig | 10 +- pkg/fontconfig/build.zig | 16 +-- pkg/freetype/build.zig | 6 +- pkg/glslang/build.zig | 6 +- pkg/harfbuzz/build.zig | 10 +- pkg/libpng/build.zig | 2 +- pkg/libxml2/build.zig | 4 +- pkg/macos/build.zig | 8 +- pkg/oniguruma/build.zig | 6 +- pkg/opengl/build.zig | 2 +- pkg/pixman/build.zig | 10 +- pkg/spirv-cross/build.zig | 4 +- pkg/tracy/build.zig | 6 +- src/apprt.zig | 6 +- src/font/main.zig | 4 +- src/renderer.zig | 4 +- 20 files changed, 213 insertions(+), 172 deletions(-) diff --git a/build.zig b/build.zig index 8856eb766..ee043ee4f 100644 --- a/build.zig +++ b/build.zig @@ -1,8 +1,8 @@ const std = @import("std"); const builtin = @import("builtin"); const fs = std.fs; -const LibExeObjStep = std.build.LibExeObjStep; -const RunStep = std.build.RunStep; +const CompileStep = std.Build.Step.Compile; +const RunStep = std.Build.Step.Run; const apprt = @import("src/apprt.zig"); const font = @import("src/font/main.zig"); @@ -47,9 +47,9 @@ pub fn build(b: *std.Build) !void { const target = target: { var result = b.standardTargetOptions(.{}); - if (result.isDarwin()) { - if (result.os_version_min == null) { - result.os_version_min = .{ .semver = .{ .major = 12, .minor = 0, .patch = 0 } }; + if (result.result.isDarwin()) { + if (result.query.os_version_min == null) { + result.query.os_version_min = .{ .semver = .{ .major = 12, .minor = 0, .patch = 0 } }; } } @@ -81,13 +81,13 @@ pub fn build(b: *std.Build) !void { font.Backend, "font-backend", "The font backend to use for discovery and rasterization.", - ) orelse font.Backend.default(target, wasm_target); + ) orelse font.Backend.default(target.result, wasm_target); app_runtime = b.option( apprt.Runtime, "app-runtime", "The app runtime to use. Not all values supported on all platforms.", - ) orelse apprt.Runtime.default(target); + ) orelse apprt.Runtime.default(target.result); libadwaita = b.option( bool, @@ -99,7 +99,7 @@ pub fn build(b: *std.Build) !void { renderer.Impl, "renderer", "The app runtime to use. Not all values supported on all platforms.", - ) orelse renderer.Impl.default(target, wasm_target); + ) orelse renderer.Impl.default(target.result, wasm_target); const static = b.option( bool, @@ -136,7 +136,7 @@ pub fn build(b: *std.Build) !void { "This defaults to LD_LIBRARY_PATH if we're in a Nix shell environment on NixOS.", ) orelse patch_rpath: { // We only do the patching if we're targeting our own CPU and its Linux. - if (!target.isLinux() or !target.isNativeCpu()) break :patch_rpath null; + if (!(target.result.os.tag == .linux) or !target.query.isNativeCpu()) break :patch_rpath null; // If we're in a nix shell we default to doing this. // Note: we purposely never deinit envmap because we leak the strings @@ -215,7 +215,7 @@ pub fn build(b: *std.Build) !void { // Exe if (exe_) |exe| { - exe.addOptions("build_options", exe_options); + exe.root_module.addOptions("build_options", exe_options); // Add the shared dependencies _ = try addDeps(b, exe, static); @@ -223,9 +223,9 @@ pub fn build(b: *std.Build) !void { // If we're in NixOS but not in the shell environment then we issue // a warning because the rpath may not be setup properly. const is_nixos = is_nixos: { - if (!target.isLinux()) break :is_nixos false; - if (!target.isNativeCpu()) break :is_nixos false; - if (target.getOsTag() != builtin.os.tag) break :is_nixos false; + if (target.result.os.tag != .linux) break :is_nixos false; + if (!target.query.isNativeCpu()) break :is_nixos false; + if (!target.query.isNativeOs()) break :is_nixos false; break :is_nixos if (std.fs.accessAbsolute("/etc/NIXOS", .{})) true else |_| false; }; if (is_nixos and env.get("IN_NIX_SHELL") == null) { @@ -273,7 +273,7 @@ pub fn build(b: *std.Build) !void { } // App (Mac) - if (target.isDarwin()) { + if (target.result.isDarwin()) { const bin_install = b.addInstallFile( exe.getEmittedBin(), "Ghostty.app/Contents/MacOS/ghostty", @@ -294,7 +294,7 @@ pub fn build(b: *std.Build) !void { }); b.getInstallStep().dependOn(&install.step); - if (target.isDarwin() and exe_ != null) { + if (target.result.isDarwin() and exe_ != null) { const mac_install = b.addInstallDirectory(options: { var copy = install.options; copy.install_dir = .{ @@ -317,7 +317,7 @@ pub fn build(b: *std.Build) !void { }); b.getInstallStep().dependOn(&install.step); - if (target.isDarwin() and exe_ != null) { + if (target.result.isDarwin() and exe_ != null) { const mac_install = b.addInstallDirectory(options: { var copy = install.options; copy.install_dir = .{ @@ -341,7 +341,7 @@ pub fn build(b: *std.Build) !void { const src_source = wf.add("share/terminfo/ghostty.terminfo", str.items); const src_install = b.addInstallFile(src_source, "share/terminfo/ghostty.terminfo"); b.getInstallStep().dependOn(&src_install.step); - if (target.isDarwin() and exe_ != null) { + if (target.result.isDarwin() and exe_ != null) { const mac_src_install = b.addInstallFile( src_source, "Ghostty.app/Contents/Resources/terminfo/ghostty.terminfo", @@ -352,17 +352,17 @@ pub fn build(b: *std.Build) !void { // Convert to termcap source format if thats helpful to people and // install it. The resulting value here is the termcap source in case // that is used for other commands. - if (!target.isWindows()) { + if (target.result.os.tag != .windows) { const run_step = RunStep.create(b, "infotocap"); run_step.addArg("infotocap"); - run_step.addFileSourceArg(src_source); + run_step.addFileArg(src_source); const out_source = run_step.captureStdOut(); _ = run_step.captureStdErr(); // so we don't see stderr const cap_install = b.addInstallFile(out_source, "share/terminfo/ghostty.termcap"); b.getInstallStep().dependOn(&cap_install.step); - if (target.isDarwin() and exe_ != null) { + if (target.result.isDarwin() and exe_ != null) { const mac_cap_install = b.addInstallFile( out_source, "Ghostty.app/Contents/Resources/terminfo/ghostty.termcap", @@ -372,11 +372,11 @@ pub fn build(b: *std.Build) !void { } // Compile the terminfo source into a terminfo database - if (!target.isWindows()) { + if (target.result.os.tag != .windows) { const run_step = RunStep.create(b, "tic"); run_step.addArgs(&.{ "tic", "-x", "-o" }); const path = run_step.addOutputFileArg("terminfo"); - run_step.addFileSourceArg(src_source); + run_step.addFileArg(src_source); _ = run_step.captureStdErr(); // so we don't see stderr // Depend on the terminfo source install step so that Zig build @@ -386,15 +386,15 @@ pub fn build(b: *std.Build) !void { { const copy_step = RunStep.create(b, "copy terminfo db"); copy_step.addArgs(&.{ "cp", "-R" }); - copy_step.addFileSourceArg(path); + copy_step.addFileArg(path); copy_step.addArg(b.fmt("{s}/share", .{b.install_prefix})); b.getInstallStep().dependOn(©_step.step); } - if (target.isDarwin() and exe_ != null) { + if (target.result.isDarwin() and exe_ != null) { const copy_step = RunStep.create(b, "copy terminfo db"); copy_step.addArgs(&.{ "cp", "-R" }); - copy_step.addFileSourceArg(path); + copy_step.addFileArg(path); copy_step.addArg( b.fmt("{s}/Ghostty.app/Contents/Resources", .{b.install_prefix}), ); @@ -417,7 +417,7 @@ pub fn build(b: *std.Build) !void { } // App (Linux) - if (target.isLinux()) { + if (target.result.os.tag == .linux) { // https://developer.gnome.org/documentation/guidelines/maintainer/integrating.html // Desktop file so that we have an icon and other metadata @@ -538,19 +538,23 @@ pub fn build(b: *std.Build) !void { // wasm { // Build our Wasm target. - const wasm_crosstarget: std.zig.CrossTarget = .{ - .cpu_arch = .wasm32, - .os_tag = .freestanding, - .cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp }, - .cpu_features_add = std.Target.wasm.featureSet(&.{ - // We use this to explicitly request shared memory. - .atomics, + const wasm_crosstarget: std.Target = .{ + .os = .{ .tag = .freestanding, .version_range = .{ .none = {} } }, + .cpu = .{ + .arch = .wasm32, + .model = &std.Target.wasm.cpu.mvp, + .features = std.Target.wasm.featureSet(&.{ + // We use this to explicitly request shared memory. + .atomics, - // Not explicitly used but compiler could use them if they want. - .bulk_memory, - .reference_types, - .sign_ext, - }), + // Not explicitly used but compiler could use them if they want. + .bulk_memory, + .reference_types, + .sign_ext, + }), + }, + .abi = std.Target.Abi.default(.wasm32, .{ .tag = .freestanding, .version_range = .{ .none = {} } }), + .ofmt = std.Target.ObjectFormat.default(.freestanding, .wasm32), }; // Whether we're using wasm shared memory. Some behaviors change. @@ -566,10 +570,13 @@ pub fn build(b: *std.Build) !void { const wasm = b.addSharedLibrary(.{ .name = "ghostty-wasm", .root_source_file = .{ .path = "src/main_wasm.zig" }, - .target = wasm_crosstarget, + .target = .{ + .result = wasm_crosstarget, + .query = std.Target.Query.fromTarget(wasm_crosstarget), + }, .optimize = optimize, }); - wasm.addOptions("build_options", exe_options); + wasm.root_module.addOptions("build_options", exe_options); // So that we can use web workers with our wasm binary wasm.import_memory = true; @@ -578,7 +585,7 @@ pub fn build(b: *std.Build) !void { wasm.shared_memory = wasm_shared; // Stack protector adds extern requirements that we don't satisfy. - wasm.stack_protector = false; + wasm.root_module.stack_protector = false; // Wasm-specific deps _ = try addDeps(b, wasm, true); @@ -597,9 +604,12 @@ pub fn build(b: *std.Build) !void { const main_test = b.addTest(.{ .name = "wasm-test", .root_source_file = .{ .path = "src/main_wasm.zig" }, - .target = wasm_crosstarget, + .target = .{ + .result = wasm_crosstarget, + .query = std.Target.Query.fromTarget(wasm_crosstarget), + }, }); - main_test.addOptions("build_options", exe_options); + main_test.root_module.addOptions("build_options", exe_options); _ = try addDeps(b, main_test, true); test_step.dependOn(&main_test.step); } @@ -637,7 +647,7 @@ pub fn build(b: *std.Build) !void { { if (emit_test_exe) b.installArtifact(main_test); _ = try addDeps(b, main_test, true); - main_test.addOptions("build_options", exe_options); + main_test.root_module.addOptions("build_options", exe_options); const test_run = b.addRunArtifact(main_test); test_step.dependOn(&test_run.step); @@ -646,94 +656,125 @@ pub fn build(b: *std.Build) !void { } /// Used to keep track of a list of file sources. -const FileSourceList = std.ArrayList(std.build.FileSource); +const LazyPathList = std.ArrayList(std.Build.LazyPath); /// Adds and links all of the primary dependencies for the exe. fn addDeps( b: *std.Build, - step: *std.build.LibExeObjStep, + step: *std.Build.Step.Compile, static: bool, -) !FileSourceList { - var static_libs = FileSourceList.init(b.allocator); +) !LazyPathList { + var static_libs = LazyPathList.init(b.allocator); errdefer static_libs.deinit(); // For dynamic linking, we prefer dynamic linking and to search by // mode first. Mode first will search all paths for a dynamic library // before falling back to static. - const dynamic_link_opts: std.build.Step.Compile.LinkSystemLibraryOptions = .{ + const dynamic_link_opts: std.Build.Module.LinkSystemLibraryOptions = .{ .preferred_link_mode = .Dynamic, .search_strategy = .mode_first, }; + const target_triple: []const u8 = try step.rootModuleTarget().zigTriple(b.allocator); + const cpu_opts: []const u8 = try step.root_module.resolved_target.?.query.serializeCpuAlloc(b.allocator); + // Dependencies - const cimgui_dep = b.dependency("cimgui", .{ .target = step.target, .optimize = step.optimize }); - const js_dep = b.dependency("zig_js", .{ .target = step.target, .optimize = step.optimize }); - const libxev_dep = b.dependency("libxev", .{ .target = step.target, .optimize = step.optimize }); - const objc_dep = b.dependency("zig_objc", .{ .target = step.target, .optimize = step.optimize }); + const cimgui_dep = b.dependency("cimgui", .{ + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, + }); + const js_dep = b.dependency("zig_js", .{ + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, + }); + const libxev_dep = b.dependency("libxev", .{ + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, + }); + const objc_dep = b.dependency("zig_objc", .{ + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, + }); const fontconfig_dep = b.dependency("fontconfig", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, }); const freetype_dep = b.dependency("freetype", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, .@"enable-libpng" = true, }); const glslang_dep = b.dependency("glslang", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, }); const spirv_cross_dep = b.dependency("spirv_cross", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, }); const mach_glfw_dep = b.dependency("mach_glfw", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, }); const libpng_dep = b.dependency("libpng", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, }); const macos_dep = b.dependency("macos", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, }); const oniguruma_dep = b.dependency("oniguruma", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, }); const opengl_dep = b.dependency("opengl", .{}); const pixman_dep = b.dependency("pixman", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, }); const tracy_dep = b.dependency("tracy", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .optimize = step.root_module.optimize.?, }); const zlib_dep = b.dependency("zlib", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, }); const harfbuzz_dep = b.dependency("harfbuzz", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, .@"enable-freetype" = true, .@"enable-coretext" = font_backend.hasCoretext(), }); const ziglyph_dep = b.dependency("ziglyph", .{ - .target = step.target, - .optimize = step.optimize, + .target = target_triple, + .cpu = cpu_opts, + .optimize = step.root_module.optimize.?, }); // Wasm we do manually since it is such a different build. - if (step.target.getCpuArch() == .wasm32) { + if (step.rootModuleTarget().cpu.arch == .wasm32) { // We link this package but its a no-op since Tracy // never actually WORKS with wasm. - step.addModule("tracy", tracy_dep.module("tracy")); - step.addModule("zig-js", js_dep.module("zig-js")); + step.root_module.addImport("tracy", tracy_dep.module("tracy")); + step.root_module.addImport("zig-js", js_dep.module("zig-js")); return static_libs; } @@ -741,8 +782,8 @@ fn addDeps( // On Linux, we need to add a couple common library paths that aren't // on the standard search list. i.e. GTK is often in /usr/lib/x86_64-linux-gnu // on x86_64. - if (step.target.isLinux()) { - const triple = try step.target.linuxTriple(b.allocator); + if (step.rootModuleTarget().os.tag == .linux) { + const triple = try step.rootModuleTarget().linuxTriple(b.allocator); step.addLibraryPath(.{ .path = b.fmt("/usr/lib/{s}", .{triple}) }); } @@ -756,42 +797,42 @@ fn addDeps( // We always require the system SDK so that our system headers are available. // This makes things like `os/log.h` available for cross-compiling. - if (step.target.isDarwin()) { + if (step.rootModuleTarget().isDarwin()) { try @import("apple_sdk").addPaths(b, step); } // We always need the Zig packages // TODO: This can't be the right way to use the new Zig modules system, // so take a closer look at this again later. - if (font_backend.hasFontconfig()) step.addModule( + if (font_backend.hasFontconfig()) step.root_module.addImport( "fontconfig", fontconfig_dep.module("fontconfig"), ); - step.addModule("oniguruma", oniguruma_dep.module("oniguruma")); - step.addModule("freetype", freetype_dep.module("freetype")); - step.addModule("glslang", glslang_dep.module("glslang")); - step.addModule("spirv_cross", spirv_cross_dep.module("spirv_cross")); - step.addModule("harfbuzz", harfbuzz_dep.module("harfbuzz")); - step.addModule("xev", libxev_dep.module("xev")); - step.addModule("opengl", opengl_dep.module("opengl")); - step.addModule("pixman", pixman_dep.module("pixman")); - step.addModule("ziglyph", ziglyph_dep.module("ziglyph")); + step.root_module.addImport("oniguruma", oniguruma_dep.module("oniguruma")); + step.root_module.addImport("freetype", freetype_dep.module("freetype")); + step.root_module.addImport("glslang", glslang_dep.module("glslang")); + step.root_module.addImport("spirv_cross", spirv_cross_dep.module("spirv_cross")); + step.root_module.addImport("harfbuzz", harfbuzz_dep.module("harfbuzz")); + step.root_module.addImport("xev", libxev_dep.module("xev")); + step.root_module.addImport("opengl", opengl_dep.module("opengl")); + step.root_module.addImport("pixman", pixman_dep.module("pixman")); + step.root_module.addImport("ziglyph", ziglyph_dep.module("ziglyph")); // Mac Stuff - if (step.target.isDarwin()) { - step.addModule("objc", objc_dep.module("objc")); - step.addModule("macos", macos_dep.module("macos")); + if (step.rootModuleTarget().isDarwin()) { + step.root_module.addImport("objc", objc_dep.module("objc")); + step.root_module.addImport("macos", macos_dep.module("macos")); step.linkLibrary(macos_dep.artifact("macos")); try static_libs.append(macos_dep.artifact("macos").getEmittedBin()); } // cimgui - step.addModule("cimgui", cimgui_dep.module("cimgui")); + step.root_module.addImport("cimgui", cimgui_dep.module("cimgui")); step.linkLibrary(cimgui_dep.artifact("cimgui")); try static_libs.append(cimgui_dep.artifact("cimgui").getEmittedBin()); // Tracy - step.addModule("tracy", tracy_dep.module("tracy")); + step.root_module.addImport("tracy", tracy_dep.module("tracy")); if (tracy) { step.linkLibrary(tracy_dep.artifact("tracy")); try static_libs.append(tracy_dep.artifact("tracy").getEmittedBin()); @@ -867,7 +908,7 @@ fn addDeps( .none => {}, .glfw => { - step.addModule("glfw", mach_glfw_dep.module("mach-glfw")); + step.root_module.addImport("glfw", mach_glfw_dep.module("mach-glfw")); @import("mach_glfw").link(mach_glfw_dep.builder, step); }, @@ -883,8 +924,8 @@ fn addDeps( fn benchSteps( b: *std.Build, - target: std.zig.CrossTarget, - optimize: std.builtin.Mode, + target: std.Build.ResolvedTarget, + optimize: std.builtin.OptimizeMode, install: bool, ) !void { // Open the directory ./src/bench @@ -916,7 +957,7 @@ fn benchSteps( .root_source_file = .{ .path = path }, .target = target, .optimize = optimize, - .main_pkg_path = .{ .path = "./src" }, + // .main_pkg_path = .{ .path = "./src" }, }); if (install) b.installArtifact(c_exe); _ = try addDeps(b, c_exe, true); @@ -925,10 +966,10 @@ fn benchSteps( fn conformanceSteps( b: *std.Build, - target: std.zig.CrossTarget, + target: std.Build.ResolvedTarget, optimize: std.builtin.Mode, -) !std.StringHashMap(*LibExeObjStep) { - var map = std.StringHashMap(*LibExeObjStep).init(b.allocator); +) !std.StringHashMap(*CompileStep) { + var map = std.StringHashMap(*CompileStep).init(b.allocator); // Open the directory ./conformance const c_dir_path = (comptime root()) ++ "/conformance"; diff --git a/build.zig.zon b/build.zig.zon index a1f3c1497..d8dcb38eb 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,24 +5,24 @@ .dependencies = .{ // Zig libs .libxev = .{ - .url = "https://github.com/mitchellh/libxev/archive/7eada4333c36b3e16f4dc2abad707149ef7b6de5.tar.gz", - .hash = "1220be2c7b3f3a07b9150720140c7038f454a9ce0cbc5d303767c1e4a50856ec1b01", + .url = "https://github.com/der-teufel-programming/libxev/archive/2bef0a64276df5f4f4a7f54e5757566502951a27.tar.gz", + .hash = "1220bfba76eaadfbee75acdd18a44df896252b1945280f69229b5b37ac1984ccccf1", }, .mach_glfw = .{ - .url = "https://github.com/hexops/mach-glfw/archive/577220552e1b31c4496d2e0df2fb5fbc9287b966.tar.gz", - .hash = "12204779ba2f14b46f569110f774d5c3f48b7a105b6717e668bc410710bceae62072", + .url = "https://github.com/der-teufel-programming/mach-glfw/archive/cf3a3fdfcbcdabe3529fa3ad6815ff5af7b38538.tar.gz", + .hash = "12200ce85e5d72069d695fe4ac4f4dcc4686d89bb80e1d9a3308396dfac898255f0e", }, .zig_objc = .{ - .url = "https://github.com/mitchellh/zig-objc/archive/10e552bd37c2f61b9f570d5ceb145165c6f1854b.tar.gz", - .hash = "122045926c2a90c61ca2ce907cc83a91ede0d49c989209fff2e2db421a88caf88e91", + .url = "https://github.com/der-teufel-programming/zig-objc/archive/31298087bbb7b9346737a6dfd8c87e21db066152.tar.gz", + .hash = "122083bcd6341d2e7e2e34af42e86888a9f5e84516b28d2f61b1251c2fe054ee94d8", }, .zig_js = .{ - .url = "https://github.com/mitchellh/zig-js/archive/60ac42ab137461cdba2b38cc6c5e16376470aae6.tar.gz", - .hash = "1220319b42fbc0116f3f198343256018e9f1da9483cef259201afe4ebab0ce0d8f6a", + .url = "https://github.com/der-teufel-programming/zig-js/archive/bbb15f9ff39c5caaf64998d8c6d2483cd575787b.tar.gz", + .hash = "1220ddc4e61d7bff3eab90661f0849dedeabc9840648084c994416bdd8ac4697d85b", }, .ziglyph = .{ - .url = "https://codeberg.org/dude_the_builder/ziglyph/archive/ef6a97e3e6d31786e4c5152abb8393f32ce52279.tar.gz", - .hash = "1220847f934ea57e90ffb4d447a43e37ff4dce2aab23c84513dfff591376350ffd31", + .url = "https://codeberg.org/dude_the_builder/ziglyph/archive/0e17bd36a4e882b194a87c283bd78562ea215116.tar.gz", + .hash = "12208553f3f47e51494e187f4c0e6f6b3844e3993436cad4a0e8c4db4e99645967b5", }, // C libs diff --git a/pkg/apple-sdk/build.zig b/pkg/apple-sdk/build.zig index 1aae3088f..2d632a098 100644 --- a/pkg/apple-sdk/build.zig +++ b/pkg/apple-sdk/build.zig @@ -7,7 +7,7 @@ pub fn build(b: *std.Build) !void { _ = optimize; } -pub fn addPaths(b: *std.Build, step: *std.build.CompileStep) !void { +pub fn addPaths(b: *std.Build, step: *std.Build.Step.Compile) !void { _ = b; @import("macos_sdk").addPaths(step); } diff --git a/pkg/apple-sdk/build.zig.zon b/pkg/apple-sdk/build.zig.zon index bcc5f95cf..7c0202076 100644 --- a/pkg/apple-sdk/build.zig.zon +++ b/pkg/apple-sdk/build.zig.zon @@ -3,8 +3,8 @@ .version = "0.1.0", .dependencies = .{ .macos_sdk = .{ - .url = "https://github.com/mitchellh/zig-build-macos-sdk/archive/7a7cb3816617dbaf87ecbc3fd90ad56a6f828275.tar.gz", - .hash = "1220a1dd91457d0131b50db15fb1bc51208ecadf1a23ad5dfa2d3a6bb3d1de5230c1", + .url = "https://github.com/der-teufel-programming/zig-build-macos-sdk/archive/51dc3ff03b6f103043ed12f7d4508d270475b569.tar.gz", + .hash = "12201f1da86d5de762253305b89775ca70c4f1c818695a128649b88f358ca7a4f61f", }, }, } diff --git a/pkg/cimgui/build.zig b/pkg/cimgui/build.zig index d0e02ded8..7a7957752 100644 --- a/pkg/cimgui/build.zig +++ b/pkg/cimgui/build.zig @@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("cimgui", .{ .source_file = .{ .path = "main.zig" } }); + _ = b.addModule("cimgui", .{ .root_source_file = .{ .path = "main.zig" } }); const imgui = b.dependency("imgui", .{}); const freetype = b.dependency("freetype", .{ @@ -21,7 +21,7 @@ pub fn build(b: *std.Build) !void { lib.linkLibC(); lib.linkLibCpp(); lib.linkLibrary(freetype.artifact("freetype")); - if (target.isWindows()) { + if (target.result.os.tag == .windows) { lib.linkSystemLibrary("imm32"); } @@ -34,7 +34,7 @@ pub fn build(b: *std.Build) !void { "-DIMGUI_USE_WCHAR32=1", "-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1", }); - if (target.isWindows()) { + if (target.result.os.tag == .windows) { try flags.appendSlice(&.{ "-DIMGUI_IMPL_API=extern\t\"C\"\t__declspec(dllexport)", }); @@ -57,8 +57,8 @@ pub fn build(b: *std.Build) !void { .flags = flags.items, }); - if (target.isDarwin()) { - if (!target.isNative()) try @import("apple_sdk").addPaths(b, lib); + if (target.result.isDarwin()) { + if (!target.query.isNative()) try @import("apple_sdk").addPaths(b, lib); lib.addCSourceFile(.{ .file = imgui.path("backends/imgui_impl_metal.mm"), .flags = flags.items, diff --git a/pkg/fontconfig/build.zig b/pkg/fontconfig/build.zig index 0a927d66f..8009227e2 100644 --- a/pkg/fontconfig/build.zig +++ b/pkg/fontconfig/build.zig @@ -10,10 +10,10 @@ pub fn build(b: *std.Build) !void { bool, "enable-libxml2-iconv", "Build libxml2 with iconv", - ) orelse (target.getOsTag() != .windows); + ) orelse (target.result.os.tag != .windows); const freetype_enabled = b.option(bool, "enable-freetype", "Build freetype") orelse true; - _ = b.addModule("fontconfig", .{ .source_file = .{ .path = "main.zig" } }); + _ = b.addModule("fontconfig", .{ .root_source_file = .{ .path = "main.zig" } }); const upstream = b.dependency("fontconfig", .{}); const lib = b.addStaticLibrary(.{ @@ -22,7 +22,7 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }); lib.linkLibC(); - if (!target.isWindows()) { + if (target.result.os.tag != .windows) { lib.linkSystemLibrary("pthread"); } if (freetype_enabled) { @@ -86,8 +86,8 @@ pub fn build(b: *std.Build) !void { "-fno-sanitize=undefined", "-fno-sanitize-trap=undefined", }); - const target_info = try NativeTargetInfo.detect(target); - switch (target_info.target.ptrBitWidth()) { + // const target_info = try NativeTargetInfo.detect(target); + switch (target.result.ptrBitWidth()) { 32 => try flags.appendSlice(&.{ "-DSIZEOF_VOID_P=4", "-DALIGNOF_VOID_P=4", @@ -100,7 +100,7 @@ pub fn build(b: *std.Build) !void { else => @panic("unsupported arch"), } - if (target.isWindows()) { + if (target.result.os.tag == .windows) { try flags.appendSlice(&.{ "-DFC_CACHEDIR=\"LOCAL_APPDATA_FONTCONFIG_CACHE\"", "-DFC_TEMPLATEDIR=\"c:/share/fontconfig/conf.avail\"", @@ -133,7 +133,7 @@ pub fn build(b: *std.Build) !void { "-DCONFIGDIR=\"/usr/local/fontconfig/conf.d\"", "-DFC_DEFAULT_FONTS=\"/usr/share/fonts/usr/local/share/fonts\"", }); - if (target.isLinux()) { + if (target.result.os.tag == .linux) { try flags.appendSlice(&.{ "-DHAVE_SYS_STATFS_H", "-DHAVE_SYS_VFS_H", @@ -146,7 +146,7 @@ pub fn build(b: *std.Build) !void { "-DLIBXML_STATIC", "-DLIBXML_PUSH_ENABLED", }); - if (target.isWindows()) { + if (target.result.os.tag == .windows) { // NOTE: this should be defined on all targets try flags.appendSlice(&.{ "-Werror=implicit-function-declaration", diff --git a/pkg/freetype/build.zig b/pkg/freetype/build.zig index 24006e17f..24a2723d0 100644 --- a/pkg/freetype/build.zig +++ b/pkg/freetype/build.zig @@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void { const optimize = b.standardOptimizeOption(.{}); const libpng_enabled = b.option(bool, "enable-libpng", "Build libpng") orelse false; - _ = b.addModule("freetype", .{ .source_file = .{ .path = "main.zig" } }); + _ = b.addModule("freetype", .{ .root_source_file = .{ .path = "main.zig" } }); const upstream = b.dependency("freetype", .{}); const lib = b.addStaticLibrary(.{ @@ -45,7 +45,7 @@ pub fn build(b: *std.Build) !void { }); } - switch (target.getOsTag()) { + switch (target.result.os.tag) { .linux => lib.addCSourceFile(.{ .file = upstream.path("builds/unix/ftsystem.c"), .flags = flags.items, @@ -59,7 +59,7 @@ pub fn build(b: *std.Build) !void { .flags = flags.items, }), } - switch (target.getOsTag()) { + switch (target.result.os.tag) { .windows => { lib.addCSourceFile(.{ .file = upstream.path("builds/windows/ftdebug.c"), diff --git a/pkg/glslang/build.zig b/pkg/glslang/build.zig index 201c0743e..e699bd595 100644 --- a/pkg/glslang/build.zig +++ b/pkg/glslang/build.zig @@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("glslang", .{ .source_file = .{ .path = "main.zig" } }); + _ = b.addModule("glslang", .{ .root_source_file = .{ .path = "main.zig" } }); const upstream = b.dependency("glslang", .{}); const lib = try buildGlslang(b, upstream, target, optimize); @@ -30,7 +30,7 @@ pub fn build(b: *std.Build) !void { fn buildGlslang( b: *std.Build, upstream: *std.Build.Dependency, - target: std.zig.CrossTarget, + target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, ) !*std.Build.Step.Compile { const lib = b.addStaticLibrary(.{ @@ -108,7 +108,7 @@ fn buildGlslang( }, }); - if (!target.isWindows()) { + if (target.result.os.tag != .windows) { lib.addCSourceFiles(.{ .dependency = upstream, .flags = flags.items, diff --git a/pkg/harfbuzz/build.zig b/pkg/harfbuzz/build.zig index 5e315347c..d7a950414 100644 --- a/pkg/harfbuzz/build.zig +++ b/pkg/harfbuzz/build.zig @@ -17,8 +17,8 @@ pub fn build(b: *std.Build) !void { const upstream = b.dependency("harfbuzz", .{}); const module = b.addModule("harfbuzz", .{ - .source_file = .{ .path = "main.zig" }, - .dependencies = &.{ + .root_source_file = .{ .path = "main.zig" }, + .imports = &.{ .{ .name = "freetype", .module = freetype.module("freetype") }, .{ .name = "macos", .module = macos.module("macos") }, }, @@ -41,7 +41,7 @@ pub fn build(b: *std.Build) !void { try flags.appendSlice(&.{ "-DHAVE_STDBOOL_H", }); - if (!target.isWindows()) { + if (target.result.os.tag != .windows) { try flags.appendSlice(&.{ "-DHAVE_UNISTD_H", "-DHAVE_SYS_MMAN_H", @@ -85,8 +85,8 @@ pub fn build(b: *std.Build) !void { }); test_exe.linkLibrary(lib); - var it = module.dependencies.iterator(); - while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*); + var it = module.import_table.iterator(); + while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*); test_exe.linkLibrary(freetype_dep.artifact("freetype")); const tests_run = b.addRunArtifact(test_exe); const test_step = b.step("test", "Run tests"); diff --git a/pkg/libpng/build.zig b/pkg/libpng/build.zig index f54c06893..10785c07d 100644 --- a/pkg/libpng/build.zig +++ b/pkg/libpng/build.zig @@ -12,7 +12,7 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }); lib.linkLibC(); - if (target.isLinux()) { + if (target.result.os.tag == .linux) { lib.linkSystemLibrary("m"); } diff --git a/pkg/libxml2/build.zig b/pkg/libxml2/build.zig index 457a504bb..0d95a4895 100644 --- a/pkg/libxml2/build.zig +++ b/pkg/libxml2/build.zig @@ -15,7 +15,7 @@ pub fn build(b: *std.Build) !void { lib.addIncludePath(upstream.path("include")); lib.addIncludePath(.{ .path = "override/include" }); - if (target.isWindows()) { + if (target.result.os.tag == .windows) { lib.addIncludePath(.{ .path = "override/config/win32" }); lib.linkSystemLibrary("ws2_32"); } else { @@ -42,7 +42,7 @@ pub fn build(b: *std.Build) !void { "-DLIBXML_AUTOMATA_ENABLED=1", "-DWITHOUT_TRIO=1", }); - if (!target.isWindows()) { + if (target.result.os.tag != .windows) { try flags.appendSlice(&.{ "-DHAVE_ARPA_INET_H=1", "-DHAVE_ARPA_NAMESER_H=1", diff --git a/pkg/macos/build.zig b/pkg/macos/build.zig index cf8b4a541..964e188bf 100644 --- a/pkg/macos/build.zig +++ b/pkg/macos/build.zig @@ -6,7 +6,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const module = b.addModule("macos", .{ .source_file = .{ .path = "main.zig" } }); + const module = b.addModule("macos", .{ .root_source_file = .{ .path = "main.zig" } }); const lib = b.addStaticLibrary(.{ .name = "macos", @@ -29,7 +29,7 @@ pub fn build(b: *std.Build) !void { lib.linkFramework("CoreGraphics"); lib.linkFramework("CoreText"); lib.linkFramework("CoreVideo"); - if (!target.isNative()) try apple_sdk.addPaths(b, lib); + if (!target.query.isNative()) try apple_sdk.addPaths(b, lib); b.installArtifact(lib); @@ -41,8 +41,8 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }); test_exe.linkLibrary(lib); - var it = module.dependencies.iterator(); - while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*); + var it = module.import_table.iterator(); + while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*); const tests_run = b.addRunArtifact(test_exe); const test_step = b.step("test", "Run tests"); diff --git a/pkg/oniguruma/build.zig b/pkg/oniguruma/build.zig index 70a1e9312..9d51971d5 100644 --- a/pkg/oniguruma/build.zig +++ b/pkg/oniguruma/build.zig @@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("oniguruma", .{ .source_file = .{ .path = "main.zig" } }); + _ = b.addModule("oniguruma", .{ .root_source_file = .{ .path = "main.zig" } }); const upstream = b.dependency("oniguruma", .{}); const lib = try buildOniguruma(b, upstream, target, optimize); @@ -31,7 +31,7 @@ pub fn build(b: *std.Build) !void { fn buildOniguruma( b: *std.Build, upstream: *std.Build.Dependency, - target: std.zig.CrossTarget, + target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, ) !*std.Build.Step.Compile { const lib = b.addStaticLibrary(.{ @@ -39,7 +39,7 @@ fn buildOniguruma( .target = target, .optimize = optimize, }); - const t = lib.target_info.target; + const t = target.result; lib.linkLibC(); lib.addIncludePath(upstream.path("src")); diff --git a/pkg/opengl/build.zig b/pkg/opengl/build.zig index 34e5a8ab1..5d4cb16fa 100644 --- a/pkg/opengl/build.zig +++ b/pkg/opengl/build.zig @@ -1,5 +1,5 @@ const std = @import("std"); pub fn build(b: *std.Build) !void { - _ = b.addModule("opengl", .{ .source_file = .{ .path = "main.zig" } }); + _ = b.addModule("opengl", .{ .root_source_file = .{ .path = "main.zig" } }); } diff --git a/pkg/pixman/build.zig b/pkg/pixman/build.zig index ef2a91286..cee740abe 100644 --- a/pkg/pixman/build.zig +++ b/pkg/pixman/build.zig @@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const module = b.addModule("pixman", .{ .source_file = .{ .path = "main.zig" } }); + const module = b.addModule("pixman", .{ .root_source_file = .{ .path = "main.zig" } }); const upstream = b.dependency("pixman", .{}); const lib = b.addStaticLibrary(.{ @@ -13,7 +13,7 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }); lib.linkLibC(); - if (!target.isWindows()) { + if (!(target.result.os.tag == .windows)) { lib.linkSystemLibrary("pthread"); } @@ -42,7 +42,7 @@ pub fn build(b: *std.Build) !void { "-fno-sanitize=undefined", "-fno-sanitize-trap=undefined", }); - if (!target.isWindows()) { + if (!(target.result.os.tag == .windows)) { try flags.appendSlice(&.{ "-DHAVE_PTHREADS=1", @@ -75,8 +75,8 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }); test_exe.linkLibrary(lib); - var it = module.dependencies.iterator(); - while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*); + var it = module.import_table.iterator(); + while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*); const tests_run = b.addRunArtifact(test_exe); const test_step = b.step("test", "Run tests"); diff --git a/pkg/spirv-cross/build.zig b/pkg/spirv-cross/build.zig index 13ff7d827..9206deb83 100644 --- a/pkg/spirv-cross/build.zig +++ b/pkg/spirv-cross/build.zig @@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("spirv_cross", .{ .source_file = .{ .path = "main.zig" } }); + _ = b.addModule("spirv_cross", .{ .root_source_file = .{ .path = "main.zig" } }); const upstream = b.dependency("spirv_cross", .{}); const lib = try buildSpirvCross(b, upstream, target, optimize); @@ -30,7 +30,7 @@ pub fn build(b: *std.Build) !void { fn buildSpirvCross( b: *std.Build, upstream: *std.Build.Dependency, - target: std.zig.CrossTarget, + target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, ) !*std.Build.Step.Compile { const lib = b.addStaticLibrary(.{ diff --git a/pkg/tracy/build.zig b/pkg/tracy/build.zig index 86140938a..e274c2dc8 100644 --- a/pkg/tracy/build.zig +++ b/pkg/tracy/build.zig @@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("tracy", .{ .source_file = .{ .path = "tracy.zig" } }); + _ = b.addModule("tracy", .{ .root_source_file = .{ .path = "tracy.zig" } }); const upstream = b.dependency("tracy", .{}); const lib = b.addStaticLibrary(.{ @@ -14,7 +14,7 @@ pub fn build(b: *std.Build) !void { }); lib.linkLibC(); lib.linkLibCpp(); - if (target.isWindows()) { + if (target.result.os.tag == .windows) { lib.linkSystemLibrary("Advapi32"); lib.linkSystemLibrary("User32"); lib.linkSystemLibrary("Ws2_32"); @@ -29,7 +29,7 @@ pub fn build(b: *std.Build) !void { "-DTRACY_ENABLE", "-fno-sanitize=undefined", }); - if (target.isWindows()) { + if (target.result.os.tag == .windows) { try flags.appendSlice(&.{ "-D_WIN32_WINNT=0x601", }); diff --git a/src/apprt.zig b/src/apprt.zig index 39f01276d..26622297c 100644 --- a/src/apprt.zig +++ b/src/apprt.zig @@ -53,12 +53,12 @@ pub const Runtime = enum { /// GTK-backed. Rich windowed application. GTK is dynamically linked. gtk, - pub fn default(target: std.zig.CrossTarget) Runtime { + pub fn default(target: std.Target) Runtime { // The Linux default is GTK because it is full featured. - if (target.isLinux()) return .gtk; + if (target.os.tag == .linux) return .gtk; // Windows we currently only support glfw - if (target.isWindows()) return .glfw; + if (target.os.tag == .windows) return .glfw; // Otherwise, we do NONE so we don't create an exe. The GLFW // build is opt-in because it is missing so many features compared diff --git a/src/font/main.zig b/src/font/main.zig index d660e67de..3a03000bf 100644 --- a/src/font/main.zig +++ b/src/font/main.zig @@ -63,10 +63,10 @@ pub const Backend = enum { /// meant to be called at comptime by the build.zig script. To get the /// backend look at build_options. pub fn default( - target: std.zig.CrossTarget, + target: std.Target, wasm_target: WasmTarget, ) Backend { - if (target.getCpuArch() == .wasm32) { + if (target.cpu.arch == .wasm32) { return switch (wasm_target) { .browser => .web_canvas, }; diff --git a/src/renderer.zig b/src/renderer.zig index 65ad458b6..9b2ebe71c 100644 --- a/src/renderer.zig +++ b/src/renderer.zig @@ -30,10 +30,10 @@ pub const Impl = enum { webgl, pub fn default( - target: std.zig.CrossTarget, + target: std.Target, wasm_target: WasmTarget, ) Impl { - if (target.getCpuArch() == .wasm32) { + if (target.cpu.arch == .wasm32) { return switch (wasm_target) { .browser => .webgl, }; From 1d49492e0464fb0a48da7e016ce08542d74f860e Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Thu, 4 Jan 2024 13:29:43 +0100 Subject: [PATCH 02/24] build.zig: Make use of resolveTargetQuery for wasm_freestanding target --- build.zig | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/build.zig b/build.zig index ee043ee4f..0542c72e9 100644 --- a/build.zig +++ b/build.zig @@ -538,23 +538,19 @@ pub fn build(b: *std.Build) !void { // wasm { // Build our Wasm target. - const wasm_crosstarget: std.Target = .{ - .os = .{ .tag = .freestanding, .version_range = .{ .none = {} } }, - .cpu = .{ - .arch = .wasm32, - .model = &std.Target.wasm.cpu.mvp, - .features = std.Target.wasm.featureSet(&.{ - // We use this to explicitly request shared memory. - .atomics, + const wasm_crosstarget: std.Target.Query = .{ + .cpu_arch = .wasm32, + .os_tag = .freestanding, + .cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp }, + .cpu_features_add = std.Target.wasm.featureSet(&.{ + // We use this to explicitly request shared memory. + .atomics, - // Not explicitly used but compiler could use them if they want. - .bulk_memory, - .reference_types, - .sign_ext, - }), - }, - .abi = std.Target.Abi.default(.wasm32, .{ .tag = .freestanding, .version_range = .{ .none = {} } }), - .ofmt = std.Target.ObjectFormat.default(.freestanding, .wasm32), + // Not explicitly used but compiler could use them if they want. + .bulk_memory, + .reference_types, + .sign_ext, + }), }; // Whether we're using wasm shared memory. Some behaviors change. @@ -570,10 +566,7 @@ pub fn build(b: *std.Build) !void { const wasm = b.addSharedLibrary(.{ .name = "ghostty-wasm", .root_source_file = .{ .path = "src/main_wasm.zig" }, - .target = .{ - .result = wasm_crosstarget, - .query = std.Target.Query.fromTarget(wasm_crosstarget), - }, + .target = b.resolveTargetQuery(wasm_crosstarget), .optimize = optimize, }); wasm.root_module.addOptions("build_options", exe_options); @@ -604,10 +597,7 @@ pub fn build(b: *std.Build) !void { const main_test = b.addTest(.{ .name = "wasm-test", .root_source_file = .{ .path = "src/main_wasm.zig" }, - .target = .{ - .result = wasm_crosstarget, - .query = std.Target.Query.fromTarget(wasm_crosstarget), - }, + .target = b.resolveTargetQuery(wasm_crosstarget), }); main_test.root_module.addOptions("build_options", exe_options); _ = try addDeps(b, main_test, true); From 0842e572df3406f575ade518b84c40bf9ffae6ea Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Thu, 4 Jan 2024 13:30:34 +0100 Subject: [PATCH 03/24] Update usage of testing.expectEqual --- src/renderer/size.zig | 2 +- src/terminal/osc.zig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/size.zig b/src/renderer/size.zig index 00766a46b..d3047bb86 100644 --- a/src/renderer/size.zig +++ b/src/renderer/size.zig @@ -161,7 +161,7 @@ test "Padding balanced on zero" { const cell: CellSize = .{ .width = 10, .height = 20 }; const screen: ScreenSize = .{ .width = 0, .height = 0 }; const padding = Padding.balanced(screen, grid, cell); - try testing.expectEqual(padding, .{}); + try testing.expectEqual(Padding{}, padding); } test "GridSize update exact" { diff --git a/src/terminal/osc.zig b/src/terminal/osc.zig index 1d20786bb..b55b8a199 100644 --- a/src/terminal/osc.zig +++ b/src/terminal/osc.zig @@ -1209,7 +1209,7 @@ test "OSC: get palette color" { const cmd = p.end('\x1b').?; try testing.expect(cmd == .report_color); - try testing.expectEqual(cmd.report_color.kind, .{ .palette = 1 }); + try testing.expectEqual(Command.ColorKind{ .palette = 1 }, cmd.report_color.kind); try testing.expectEqual(cmd.report_color.terminator, .st); } @@ -1223,7 +1223,7 @@ test "OSC: set palette color" { const cmd = p.end('\x1b').?; try testing.expect(cmd == .set_color); - try testing.expectEqual(cmd.set_color.kind, .{ .palette = 17 }); + try testing.expectEqual(Command.ColorKind{ .palette = 17 }, cmd.set_color.kind); try testing.expectEqualStrings(cmd.set_color.value, "rgb:aa/bb/cc"); } From 5776c542252953f5d3cff32ea56ba860faf1b0a3 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 15:00:17 +0100 Subject: [PATCH 04/24] Update changed build.zig --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 1e9d891ef..8640f97cf 100644 --- a/build.zig +++ b/build.zig @@ -253,7 +253,7 @@ pub fn build(b: *std.Build) !void { // Building with LTO on Windows is broken. // https://github.com/ziglang/zig/issues/15958 - if (target.isWindows()) exe.want_lto = false; + if (target.result.os.tag == .windows) exe.want_lto = false; // If we're installing, we get the install step so we can add // additional dependencies to it. From 5bb25536e1c4c24cdf5003bb86098670336f9cf5 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 15:00:31 +0100 Subject: [PATCH 05/24] Update source for libxev --- build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index d8dcb38eb..9bb028fac 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,8 +5,8 @@ .dependencies = .{ // Zig libs .libxev = .{ - .url = "https://github.com/der-teufel-programming/libxev/archive/2bef0a64276df5f4f4a7f54e5757566502951a27.tar.gz", - .hash = "1220bfba76eaadfbee75acdd18a44df896252b1945280f69229b5b37ac1984ccccf1", + .url = "https://github.com/mitchellh/libxev/archive/74bc7aea4a8f88210f0ad4215108613ab7e7af1a.tar.gz", + .hash = "122029743e5d96aa1b57a1b99ff58bf13ff9ed6d8f624ac3ae8074062feb91c5bd8d", }, .mach_glfw = .{ .url = "https://github.com/der-teufel-programming/mach-glfw/archive/cf3a3fdfcbcdabe3529fa3ad6815ff5af7b38538.tar.gz", From eb4ede8b6f9b21a52b885e8a43aab3f6635531dc Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 17:37:42 +0100 Subject: [PATCH 06/24] Update sources for zig-objc and zig-js --- build.zig.zon | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 9bb028fac..9ced65705 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -13,12 +13,12 @@ .hash = "12200ce85e5d72069d695fe4ac4f4dcc4686d89bb80e1d9a3308396dfac898255f0e", }, .zig_objc = .{ - .url = "https://github.com/der-teufel-programming/zig-objc/archive/31298087bbb7b9346737a6dfd8c87e21db066152.tar.gz", - .hash = "122083bcd6341d2e7e2e34af42e86888a9f5e84516b28d2f61b1251c2fe054ee94d8", + .url = "https://github.com/mitchellh/zig-objc/archive/294e0f3765a96613b45ff7dd594bf99e22409e96.tar.gz", + .hash = "1220ae28cc6af7600c6f23db1573b33ca3b8accd15e60a1fe1a2c979c20868f151fa", }, .zig_js = .{ - .url = "https://github.com/der-teufel-programming/zig-js/archive/bbb15f9ff39c5caaf64998d8c6d2483cd575787b.tar.gz", - .hash = "1220ddc4e61d7bff3eab90661f0849dedeabc9840648084c994416bdd8ac4697d85b", + .url = "https://github.com/mitchellh/zig-js/archive/d4edb682733aef8dc3933683272bdf7c8b9fe658.tar.gz", + .hash = "1220df81f0e65cc9ccd3628572c611e6f267a71f1bff1be19d50f4ac49ee2a83c324", }, .ziglyph = .{ .url = "https://codeberg.org/dude_the_builder/ziglyph/archive/0e17bd36a4e882b194a87c283bd78562ea215116.tar.gz", From 9e14a7ea62744fe248235b6959f670048503faf4 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 17:39:39 +0100 Subject: [PATCH 07/24] Add include paths to modules in pkg/ --- pkg/fontconfig/build.zig | 4 +++- pkg/glslang/build.zig | 5 ++++- pkg/harfbuzz/build.zig | 1 + pkg/oniguruma/build.zig | 3 ++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/fontconfig/build.zig b/pkg/fontconfig/build.zig index 8009227e2..e2faf44cb 100644 --- a/pkg/fontconfig/build.zig +++ b/pkg/fontconfig/build.zig @@ -13,7 +13,7 @@ pub fn build(b: *std.Build) !void { ) orelse (target.result.os.tag != .windows); const freetype_enabled = b.option(bool, "enable-freetype", "Build freetype") orelse true; - _ = b.addModule("fontconfig", .{ .root_source_file = .{ .path = "main.zig" } }); + const module = b.addModule("fontconfig", .{ .root_source_file = .{ .path = "main.zig" } }); const upstream = b.dependency("fontconfig", .{}); const lib = b.addStaticLibrary(.{ @@ -40,6 +40,8 @@ pub fn build(b: *std.Build) !void { lib.addIncludePath(upstream.path("")); lib.addIncludePath(.{ .path = "override/include" }); + module.addIncludePath(upstream.path("")); + module.addIncludePath(.{ .path = "override/include" }); var flags = std.ArrayList([]const u8).init(b.allocator); defer flags.deinit(); diff --git a/pkg/glslang/build.zig b/pkg/glslang/build.zig index e699bd595..d73306071 100644 --- a/pkg/glslang/build.zig +++ b/pkg/glslang/build.zig @@ -4,12 +4,15 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("glslang", .{ .root_source_file = .{ .path = "main.zig" } }); + const module = b.addModule("glslang", .{ .root_source_file = .{ .path = "main.zig" } }); const upstream = b.dependency("glslang", .{}); const lib = try buildGlslang(b, upstream, target, optimize); b.installArtifact(lib); + module.addIncludePath(upstream.path("")); + module.addIncludePath(.{ .path = "override" }); + { const test_exe = b.addTest(.{ .name = "test", diff --git a/pkg/harfbuzz/build.zig b/pkg/harfbuzz/build.zig index d7a950414..dd2ba87d5 100644 --- a/pkg/harfbuzz/build.zig +++ b/pkg/harfbuzz/build.zig @@ -32,6 +32,7 @@ pub fn build(b: *std.Build) !void { lib.linkLibC(); lib.linkLibCpp(); lib.addIncludePath(upstream.path("src")); + module.addIncludePath(upstream.path("src")); const freetype_dep = b.dependency("freetype", .{ .target = target, .optimize = optimize }); lib.linkLibrary(freetype_dep.artifact("freetype")); diff --git a/pkg/oniguruma/build.zig b/pkg/oniguruma/build.zig index 9d51971d5..9fa8772cd 100644 --- a/pkg/oniguruma/build.zig +++ b/pkg/oniguruma/build.zig @@ -5,10 +5,11 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("oniguruma", .{ .root_source_file = .{ .path = "main.zig" } }); + const module = b.addModule("oniguruma", .{ .root_source_file = .{ .path = "main.zig" } }); const upstream = b.dependency("oniguruma", .{}); const lib = try buildOniguruma(b, upstream, target, optimize); + module.addIncludePath(upstream.path("src")); b.installArtifact(lib); { From 6c7c5eecce9c3ee34fd2287ca6272da556497d1d Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 18:45:07 +0100 Subject: [PATCH 08/24] Add include paths to freetype module --- pkg/freetype/build.zig | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/freetype/build.zig b/pkg/freetype/build.zig index 24a2723d0..1770e3e49 100644 --- a/pkg/freetype/build.zig +++ b/pkg/freetype/build.zig @@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void { const optimize = b.standardOptimizeOption(.{}); const libpng_enabled = b.option(bool, "enable-libpng", "Build libpng") orelse false; - _ = b.addModule("freetype", .{ .root_source_file = .{ .path = "main.zig" } }); + const module = b.addModule("freetype", .{ .root_source_file = .{ .path = "main.zig" } }); const upstream = b.dependency("freetype", .{}); const lib = b.addStaticLibrary(.{ @@ -15,6 +15,8 @@ pub fn build(b: *std.Build) !void { }); lib.linkLibC(); lib.addIncludePath(upstream.path("include")); + module.addIncludePath(upstream.path("include")); + module.addIncludePath(.{ .path = "" }); // Dependencies const zlib_dep = b.dependency("zlib", .{ .target = target, .optimize = optimize }); @@ -38,12 +40,11 @@ pub fn build(b: *std.Build) !void { }); if (libpng_enabled) try flags.append("-DFT_CONFIG_OPTION_USE_PNG=1"); - for (srcs) |src| { - lib.addCSourceFile(.{ - .file = upstream.path(src), - .flags = flags.items, - }); - } + lib.addCSourceFiles(.{ + .dependency = upstream, + .files = srcs, + .flags = flags.items, + }); switch (target.result.os.tag) { .linux => lib.addCSourceFile(.{ From ddebb31b8a594987f4dbba346adc81c48b07cad5 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 19:07:16 +0100 Subject: [PATCH 09/24] Add include paths to more modules in pkg/ --- pkg/cimgui/build.zig | 3 ++- pkg/harfbuzz/build.zig | 1 + pkg/opengl/build.zig | 3 ++- pkg/pixman/build.zig | 15 ++++++++------- pkg/spirv-cross/build.zig | 6 ++++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pkg/cimgui/build.zig b/pkg/cimgui/build.zig index 7a7957752..235b681fe 100644 --- a/pkg/cimgui/build.zig +++ b/pkg/cimgui/build.zig @@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("cimgui", .{ .root_source_file = .{ .path = "main.zig" } }); + const module = b.addModule("cimgui", .{ .root_source_file = .{ .path = "main.zig" } }); const imgui = b.dependency("imgui", .{}); const freetype = b.dependency("freetype", .{ @@ -26,6 +26,7 @@ pub fn build(b: *std.Build) !void { } lib.addIncludePath(imgui.path("")); + module.addIncludePath(.{ .path = "vendor" }); var flags = std.ArrayList([]const u8).init(b.allocator); defer flags.deinit(); diff --git a/pkg/harfbuzz/build.zig b/pkg/harfbuzz/build.zig index dd2ba87d5..08a2dc185 100644 --- a/pkg/harfbuzz/build.zig +++ b/pkg/harfbuzz/build.zig @@ -36,6 +36,7 @@ pub fn build(b: *std.Build) !void { const freetype_dep = b.dependency("freetype", .{ .target = target, .optimize = optimize }); lib.linkLibrary(freetype_dep.artifact("freetype")); + module.addIncludePath(freetype_dep.builder.dependency("freetype", .{}).path("include")); var flags = std.ArrayList([]const u8).init(b.allocator); defer flags.deinit(); diff --git a/pkg/opengl/build.zig b/pkg/opengl/build.zig index 5d4cb16fa..440b96ba0 100644 --- a/pkg/opengl/build.zig +++ b/pkg/opengl/build.zig @@ -1,5 +1,6 @@ const std = @import("std"); pub fn build(b: *std.Build) !void { - _ = b.addModule("opengl", .{ .root_source_file = .{ .path = "main.zig" } }); + const module = b.addModule("opengl", .{ .root_source_file = .{ .path = "main.zig" } }); + module.addIncludePath(.{ .path = "../../vendor/glad/include" }); } diff --git a/pkg/pixman/build.zig b/pkg/pixman/build.zig index cee740abe..a74fece29 100644 --- a/pkg/pixman/build.zig +++ b/pkg/pixman/build.zig @@ -13,12 +13,14 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }); lib.linkLibC(); - if (!(target.result.os.tag == .windows)) { + if (target.result.os.tag != .windows) { lib.linkSystemLibrary("pthread"); } lib.addIncludePath(upstream.path("")); lib.addIncludePath(.{ .path = "" }); + module.addIncludePath(upstream.path("pixman")); + module.addIncludePath(.{ .path = "" }); var flags = std.ArrayList([]const u8).init(b.allocator); defer flags.deinit(); @@ -50,12 +52,11 @@ pub fn build(b: *std.Build) !void { }); } - for (srcs) |src| { - lib.addCSourceFile(.{ - .file = upstream.path(src), - .flags = flags.items, - }); - } + lib.addCSourceFiles(.{ + .dependency = upstream, + .files = srcs, + .flags = flags.items, + }); lib.installHeader("pixman-version.h", "pixman-version.h"); lib.installHeadersDirectoryOptions(.{ diff --git a/pkg/spirv-cross/build.zig b/pkg/spirv-cross/build.zig index 9206deb83..76b29a279 100644 --- a/pkg/spirv-cross/build.zig +++ b/pkg/spirv-cross/build.zig @@ -4,9 +4,11 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("spirv_cross", .{ .root_source_file = .{ .path = "main.zig" } }); - const upstream = b.dependency("spirv_cross", .{}); + + const module = b.addModule("spirv_cross", .{ .root_source_file = .{ .path = "main.zig" } }); + module.addIncludePath(upstream.path("")); + const lib = try buildSpirvCross(b, upstream, target, optimize); b.installArtifact(lib); From 54e866d16eab6c7680e08577b8f8c576dbb58ad7 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 19:25:06 +0100 Subject: [PATCH 10/24] Change source of mach_glfw to experimental branch in fork --- build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 9ced65705..4980b1c28 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -9,8 +9,8 @@ .hash = "122029743e5d96aa1b57a1b99ff58bf13ff9ed6d8f624ac3ae8074062feb91c5bd8d", }, .mach_glfw = .{ - .url = "https://github.com/der-teufel-programming/mach-glfw/archive/cf3a3fdfcbcdabe3529fa3ad6815ff5af7b38538.tar.gz", - .hash = "12200ce85e5d72069d695fe4ac4f4dcc4686d89bb80e1d9a3308396dfac898255f0e", + .url = "https://github.com/der-teufel-programming/mach-glfw/archive/7dc809a7afdea4319d26e10f7eb2f80c61430ee3.tar.gz", + .hash = "122079bbfe9a438e11fa0ba02d3523cfbfcd0e07252c953743319124c87b48d594f5", }, .zig_objc = .{ .url = "https://github.com/mitchellh/zig-objc/archive/294e0f3765a96613b45ff7dd594bf99e22409e96.tar.gz", From 12f42105585d27e5ab57c99cbb01c68297af83a9 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 20:42:30 +0100 Subject: [PATCH 11/24] Update required zig version to 0.12.0-dev.2063+804cee3b9 --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 8640f97cf..a5d351bca 100644 --- a/build.zig +++ b/build.zig @@ -20,7 +20,7 @@ const Version = @import("src/build/Version.zig"); // but we liberally update it. In the future, we'll be more careful about // using released versions so that package managers can integrate better. comptime { - const required_zig = "0.12.0-dev.1754+2a3226453"; + const required_zig = "0.12.0-dev.2063+804cee3b9"; const current_zig = builtin.zig_version; const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable; if (current_zig.order(min_zig) == .lt) { From 9964a55d47f966fbcc563eaad6202247d389ef88 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 20:48:00 +0100 Subject: [PATCH 12/24] Update source for zig-build-macos-sdk for pkg/apple-sdk --- pkg/apple-sdk/build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apple-sdk/build.zig.zon b/pkg/apple-sdk/build.zig.zon index 7c0202076..5dc3e5a1d 100644 --- a/pkg/apple-sdk/build.zig.zon +++ b/pkg/apple-sdk/build.zig.zon @@ -3,8 +3,8 @@ .version = "0.1.0", .dependencies = .{ .macos_sdk = .{ - .url = "https://github.com/der-teufel-programming/zig-build-macos-sdk/archive/51dc3ff03b6f103043ed12f7d4508d270475b569.tar.gz", - .hash = "12201f1da86d5de762253305b89775ca70c4f1c818695a128649b88f358ca7a4f61f", + .url = "https://github.com/mitchellh/zig-build-macos-sdk/archive/4186e9fd445d12041651abe59ea5f396499b0844.tar.gz", + .hash = "1220bc2612b57b0cfaaecbcac38e3144e5a9362ff668d71eb8334e895047bdbb7148", }, }, } From 5698607a1c674c73f19585df71eb8d4cf563660b Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 20:54:22 +0100 Subject: [PATCH 13/24] Clean pkg/fontconfig/build.zig --- pkg/fontconfig/build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/fontconfig/build.zig b/pkg/fontconfig/build.zig index e2faf44cb..5575d2e5c 100644 --- a/pkg/fontconfig/build.zig +++ b/pkg/fontconfig/build.zig @@ -88,7 +88,7 @@ pub fn build(b: *std.Build) !void { "-fno-sanitize=undefined", "-fno-sanitize-trap=undefined", }); - // const target_info = try NativeTargetInfo.detect(target); + switch (target.result.ptrBitWidth()) { 32 => try flags.appendSlice(&.{ "-DSIZEOF_VOID_P=4", From c1bde28af445c65c9bcf0148bf95cbbfcf15b94f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 7 Jan 2024 12:03:23 -0800 Subject: [PATCH 14/24] update flake --- build.zig | 2 +- flake.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index a5d351bca..bbe1796fe 100644 --- a/build.zig +++ b/build.zig @@ -20,7 +20,7 @@ const Version = @import("src/build/Version.zig"); // but we liberally update it. In the future, we'll be more careful about // using released versions so that package managers can integrate better. comptime { - const required_zig = "0.12.0-dev.2063+804cee3b9"; + const required_zig = "0.12.0-dev.2059+42389cb9c"; const current_zig = builtin.zig_version; const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable; if (current_zig.order(min_zig) == .lt) { diff --git a/flake.lock b/flake.lock index 356fa52f7..1afd95ba7 100644 --- a/flake.lock +++ b/flake.lock @@ -194,11 +194,11 @@ ] }, "locked": { - "lastModified": 1702850407, - "narHash": "sha256-dG9eKPJXgZNcXkNJwBdx/7byx08Z3ppXU1E54EY1/t0=", + "lastModified": 1704542888, + "narHash": "sha256-Fb8tc4cXUkWw+Fva6JKbjkFFpZwu4c+ictSAQGEYjIM=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "f5d3c30b3f36ec5d3d5dd81fad850f5523767e5d", + "rev": "112cfb72e47cb85d17fc8075a4d70ab56964453d", "type": "github" }, "original": { From a8a42c8658e82ed2fd55f7592d6b87bda02b1665 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 7 Jan 2024 12:10:48 -0800 Subject: [PATCH 15/24] fix macos `zig build test` failures --- build.zig | 18 +++++++++--------- src/build/LibtoolStep.zig | 12 ++++++------ src/build/LipoStep.zig | 16 ++++++++-------- src/build/XCFrameworkStep.zig | 14 +++++++------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build.zig b/build.zig index bbe1796fe..44c374662 100644 --- a/build.zig +++ b/build.zig @@ -445,21 +445,21 @@ pub fn build(b: *std.Build) !void { } // On Mac we can build the embedding library. - if (builtin.target.isDarwin() and target.isDarwin()) { + if (builtin.target.isDarwin() and target.result.isDarwin()) { const static_lib_aarch64 = lib: { const lib = b.addStaticLibrary(.{ .name = "ghostty", .root_source_file = .{ .path = "src/main_c.zig" }, - .target = .{ + .target = b.resolveTargetQuery(.{ .cpu_arch = .aarch64, .os_tag = .macos, - .os_version_min = target.os_version_min, - }, + .os_version_min = target.query.os_version_min, + }), .optimize = optimize, }); lib.bundle_compiler_rt = true; lib.linkLibC(); - lib.addOptions("build_options", exe_options); + lib.root_module.addOptions("build_options", exe_options); // Create a single static lib with all our dependencies merged var lib_list = try addDeps(b, lib, true); @@ -479,16 +479,16 @@ pub fn build(b: *std.Build) !void { const lib = b.addStaticLibrary(.{ .name = "ghostty", .root_source_file = .{ .path = "src/main_c.zig" }, - .target = .{ + .target = b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .macos, - .os_version_min = target.os_version_min, - }, + .os_version_min = target.query.os_version_min, + }), .optimize = optimize, }); lib.bundle_compiler_rt = true; lib.linkLibC(); - lib.addOptions("build_options", exe_options); + lib.root_module.addOptions("build_options", exe_options); // Create a single static lib with all our dependencies merged var lib_list = try addDeps(b, lib, true); diff --git a/src/build/LibtoolStep.zig b/src/build/LibtoolStep.zig index adb2e77a2..d2b514927 100644 --- a/src/build/LibtoolStep.zig +++ b/src/build/LibtoolStep.zig @@ -3,9 +3,9 @@ const LibtoolStep = @This(); const std = @import("std"); -const Step = std.build.Step; -const RunStep = std.build.RunStep; -const FileSource = std.build.FileSource; +const Step = std.Build.Step; +const RunStep = std.Build.Step.Run; +const LazyPath = std.Build.LazyPath; pub const Options = struct { /// The name of this step. @@ -16,14 +16,14 @@ pub const Options = struct { out_name: []const u8, /// Library files (.a) to combine. - sources: []FileSource, + sources: []LazyPath, }; /// The step to depend on. step: *Step, /// The output file from the libtool run. -output: FileSource, +output: LazyPath, /// Run libtool against a list of library files to combine into a single /// static library. @@ -33,7 +33,7 @@ pub fn create(b: *std.Build, opts: Options) *LibtoolStep { const run_step = RunStep.create(b, b.fmt("libtool {s}", .{opts.name})); run_step.addArgs(&.{ "libtool", "-static", "-o" }); const output = run_step.addOutputFileArg(opts.out_name); - for (opts.sources) |source| run_step.addFileSourceArg(source); + for (opts.sources) |source| run_step.addFileArg(source); self.* = .{ .step = &run_step.step, diff --git a/src/build/LipoStep.zig b/src/build/LipoStep.zig index 49187f307..c9c1530ef 100644 --- a/src/build/LipoStep.zig +++ b/src/build/LipoStep.zig @@ -3,9 +3,9 @@ const LipoStep = @This(); const std = @import("std"); -const Step = std.build.Step; -const RunStep = std.build.RunStep; -const FileSource = std.build.FileSource; +const Step = std.Build.Step; +const RunStep = std.Build.Step.Run; +const LazyPath = std.Build.LazyPath; pub const Options = struct { /// The name of the xcframework to create. @@ -15,14 +15,14 @@ pub const Options = struct { out_name: []const u8, /// Library file (dylib, a) to package. - input_a: FileSource, - input_b: FileSource, + input_a: LazyPath, + input_b: LazyPath, }; step: *Step, /// Resulting binary -output: FileSource, +output: LazyPath, pub fn create(b: *std.Build, opts: Options) *LipoStep { const self = b.allocator.create(LipoStep) catch @panic("OOM"); @@ -30,8 +30,8 @@ pub fn create(b: *std.Build, opts: Options) *LipoStep { const run_step = RunStep.create(b, b.fmt("lipo {s}", .{opts.name})); run_step.addArgs(&.{ "lipo", "-create", "-output" }); const output = run_step.addOutputFileArg(opts.out_name); - run_step.addFileSourceArg(opts.input_a); - run_step.addFileSourceArg(opts.input_b); + run_step.addFileArg(opts.input_a); + run_step.addFileArg(opts.input_b); self.* = .{ .step = &run_step.step, diff --git a/src/build/XCFrameworkStep.zig b/src/build/XCFrameworkStep.zig index 36fdbebc6..a611edc4b 100644 --- a/src/build/XCFrameworkStep.zig +++ b/src/build/XCFrameworkStep.zig @@ -4,9 +4,9 @@ const XCFrameworkStep = @This(); const std = @import("std"); -const Step = std.build.Step; -const RunStep = std.build.RunStep; -const FileSource = std.build.FileSource; +const Step = std.Build.Step; +const RunStep = std.Build.Step.Run; +const LazyPath = std.Build.LazyPath; pub const Options = struct { /// The name of the xcframework to create. @@ -16,10 +16,10 @@ pub const Options = struct { out_path: []const u8, /// Library file (dylib, a) to package. - library: std.build.FileSource, + library: LazyPath, /// Path to a directory with the headers. - headers: std.build.FileSource, + headers: LazyPath, }; step: *Step, @@ -42,9 +42,9 @@ pub fn create(b: *std.Build, opts: Options) *XCFrameworkStep { run.has_side_effects = true; run.addArgs(&.{ "xcodebuild", "-create-xcframework" }); run.addArg("-library"); - run.addFileSourceArg(opts.library); + run.addFileArg(opts.library); run.addArg("-headers"); - run.addFileSourceArg(opts.headers); + run.addFileArg(opts.headers); run.addArg("-output"); run.addArg(opts.out_path); break :run run; From 2f5bcf2e27257e86e5fba8225cfec67756171ffc Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 21:17:17 +0100 Subject: [PATCH 16/24] Attempt to fix building on macos --- pkg/harfbuzz/build.zig | 1 + pkg/macos/build.zig | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/pkg/harfbuzz/build.zig b/pkg/harfbuzz/build.zig index 08a2dc185..242fdeec0 100644 --- a/pkg/harfbuzz/build.zig +++ b/pkg/harfbuzz/build.zig @@ -63,6 +63,7 @@ pub fn build(b: *std.Build) !void { try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"}); try apple_sdk.addPaths(b, lib); lib.linkFramework("ApplicationServices"); + module.linkFramework("ApplicationServices", .{}); } lib.addCSourceFile(.{ diff --git a/pkg/macos/build.zig b/pkg/macos/build.zig index 964e188bf..7cd1d67a4 100644 --- a/pkg/macos/build.zig +++ b/pkg/macos/build.zig @@ -29,6 +29,13 @@ pub fn build(b: *std.Build) !void { lib.linkFramework("CoreGraphics"); lib.linkFramework("CoreText"); lib.linkFramework("CoreVideo"); + + module.linkFramework("Carbon", .{}); + module.linkFramework("CoreFoundation", .{}); + module.linkFramework("CoreGraphics", .{}); + module.linkFramework("CoreText", .{}); + module.linkFramework("CoreVideo", .{}); + if (!target.query.isNative()) try apple_sdk.addPaths(b, lib); b.installArtifact(lib); From 8db0697b5d5e5b4909b45aea5f36d75f2be1d1a2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 7 Jan 2024 12:18:11 -0800 Subject: [PATCH 17/24] nix: update hash --- nix/build-support/check-zig-cache-hash.sh | 4 ++-- nix/zigCacheHash.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nix/build-support/check-zig-cache-hash.sh b/nix/build-support/check-zig-cache-hash.sh index 26669b008..2fd1ead5b 100755 --- a/nix/build-support/check-zig-cache-hash.sh +++ b/nix/build-support/check-zig-cache-hash.sh @@ -10,7 +10,7 @@ help() { echo "To fix, please (manually) re-run the script from the repository root," echo "commit, and push the update:" echo "" - echo " ./nix/build-support/check-zigCacheHash.sh --update" + echo " ./nix/build-support/check-zig-cache-hash.sh --update" echo " git add nix/zigCacheHash.nix" echo " git commit -m \"nix: update Zig cache hash\"" echo " git push" @@ -52,7 +52,7 @@ fi # Write out the cache file cat > "${CACHE_HASH_FILE}" < Date: Sun, 7 Jan 2024 21:39:53 +0100 Subject: [PATCH 19/24] Maybe this will help macos --- pkg/apple-sdk/build.zig | 5 +++++ pkg/apple-sdk/build.zig.zon | 4 ++-- pkg/cimgui/build.zig | 5 ++++- pkg/harfbuzz/build.zig | 1 + pkg/macos/build.zig | 6 ++++-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pkg/apple-sdk/build.zig b/pkg/apple-sdk/build.zig index 2d632a098..b8863cff2 100644 --- a/pkg/apple-sdk/build.zig +++ b/pkg/apple-sdk/build.zig @@ -11,3 +11,8 @@ pub fn addPaths(b: *std.Build, step: *std.Build.Step.Compile) !void { _ = b; @import("macos_sdk").addPaths(step); } + +pub fn addPathsModule(b: *std.Build, m: *std.Build.Module) !void { + _ = b; + @import("macos_sdk").addPathsModule(m); +} diff --git a/pkg/apple-sdk/build.zig.zon b/pkg/apple-sdk/build.zig.zon index 5dc3e5a1d..b41c9ac0d 100644 --- a/pkg/apple-sdk/build.zig.zon +++ b/pkg/apple-sdk/build.zig.zon @@ -3,8 +3,8 @@ .version = "0.1.0", .dependencies = .{ .macos_sdk = .{ - .url = "https://github.com/mitchellh/zig-build-macos-sdk/archive/4186e9fd445d12041651abe59ea5f396499b0844.tar.gz", - .hash = "1220bc2612b57b0cfaaecbcac38e3144e5a9362ff668d71eb8334e895047bdbb7148", + .url = "https://github.com/mitchellh/zig-build-macos-sdk/archive/ee70f27c08680307fa35ada92e6b2c36e0ff84c6.tar.gz", + .hash = "1220b415f529f1c04ed876c2b481e9f8119d353d4e3d4d7c8607ee302d2142e13eca", }, }, } diff --git a/pkg/cimgui/build.zig b/pkg/cimgui/build.zig index 235b681fe..d37cfc538 100644 --- a/pkg/cimgui/build.zig +++ b/pkg/cimgui/build.zig @@ -59,7 +59,10 @@ pub fn build(b: *std.Build) !void { }); if (target.result.isDarwin()) { - if (!target.query.isNative()) try @import("apple_sdk").addPaths(b, lib); + if (!target.query.isNative()) { + try @import("apple_sdk").addPaths(b, lib); + try @import("apple_sdk").addPathsModule(b, module); + } lib.addCSourceFile(.{ .file = imgui.path("backends/imgui_impl_metal.mm"), .flags = flags.items, diff --git a/pkg/harfbuzz/build.zig b/pkg/harfbuzz/build.zig index 242fdeec0..25d1ff00b 100644 --- a/pkg/harfbuzz/build.zig +++ b/pkg/harfbuzz/build.zig @@ -62,6 +62,7 @@ pub fn build(b: *std.Build) !void { if (coretext_enabled) { try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"}); try apple_sdk.addPaths(b, lib); + try apple_sdk.addPathsModule(b, module); lib.linkFramework("ApplicationServices"); module.linkFramework("ApplicationServices", .{}); } diff --git a/pkg/macos/build.zig b/pkg/macos/build.zig index 9bbc260cd..05035aa6a 100644 --- a/pkg/macos/build.zig +++ b/pkg/macos/build.zig @@ -38,8 +38,10 @@ pub fn build(b: *std.Build) !void { module.linkFramework("CoreVideo", .{}); } - if (!target.query.isNative()) try apple_sdk.addPaths(b, lib); - + if (!target.query.isNative()) { + try apple_sdk.addPaths(b, lib); + try apple_sdk.addPathsModule(b, module); + } b.installArtifact(lib); { From 42eed75b64c7f51131ac12f5122d1d68287965df Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 21:52:00 +0100 Subject: [PATCH 20/24] Update mach-glfw dependency --- build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 4980b1c28..360149607 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -9,8 +9,8 @@ .hash = "122029743e5d96aa1b57a1b99ff58bf13ff9ed6d8f624ac3ae8074062feb91c5bd8d", }, .mach_glfw = .{ - .url = "https://github.com/der-teufel-programming/mach-glfw/archive/7dc809a7afdea4319d26e10f7eb2f80c61430ee3.tar.gz", - .hash = "122079bbfe9a438e11fa0ba02d3523cfbfcd0e07252c953743319124c87b48d594f5", + .url = "https://github.com/der-teufel-programming/mach-glfw/archive/08811591de2cb0a12f8a89152f479175d2b352c9.tar.gz", + .hash = "122030ef71510fa089e743295528b961b195362343100dcc868d280b2ba0c1b51a67", }, .zig_objc = .{ .url = "https://github.com/mitchellh/zig-objc/archive/294e0f3765a96613b45ff7dd594bf99e22409e96.tar.gz", From b4a08dd5f17c9cce658a5a38e62a9be9328cfb7e Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 22:45:59 +0100 Subject: [PATCH 21/24] Update mach-glfw dependency --- build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 360149607..8c5ce9388 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -9,8 +9,8 @@ .hash = "122029743e5d96aa1b57a1b99ff58bf13ff9ed6d8f624ac3ae8074062feb91c5bd8d", }, .mach_glfw = .{ - .url = "https://github.com/der-teufel-programming/mach-glfw/archive/08811591de2cb0a12f8a89152f479175d2b352c9.tar.gz", - .hash = "122030ef71510fa089e743295528b961b195362343100dcc868d280b2ba0c1b51a67", + .url = "https://github.com/der-teufel-programming/mach-glfw/archive/c8bdbf777643e360c2176ad62cefcd9c3b64b32b.tar.gz", + .hash = "12204f7b735d5a6eaeafee501be4bc88a9ac25ca23826f67041f3788f9307e6e5181", }, .zig_objc = .{ .url = "https://github.com/mitchellh/zig-objc/archive/294e0f3765a96613b45ff7dd594bf99e22409e96.tar.gz", From 477a79087b807968ee1312ca49bb28e051d0c8f9 Mon Sep 17 00:00:00 2001 From: Chris Marchesi Date: Sun, 7 Jan 2024 13:51:29 -0800 Subject: [PATCH 22/24] nix: update nixpkgs-zig-0-12 input, also cache hash This updates zig_0_12 to be built off of 0.12.0-dev.2059+42389cb9c. Additionally, we update the cache hash. --- flake.lock | 6 +++--- nix/zigCacheHash.nix | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 1afd95ba7..6ff94f69e 100644 --- a/flake.lock +++ b/flake.lock @@ -147,11 +147,11 @@ }, "nixpkgs-zig-0-12": { "locked": { - "lastModified": 1703276979, - "narHash": "sha256-WD3FdpkPRLm0PJC26bZT/cSoPNgKANHq14U5O+CfLqI=", + "lastModified": 1704663772, + "narHash": "sha256-BIDaFQlRhjhrFk+UE7OsV3Jfo/9cbWAWwdjmdy1Hn34=", "owner": "vancluever", "repo": "nixpkgs", - "rev": "d81c22905455c896e79db93fdace8771db1bd995", + "rev": "4f7ae324049ecdf3a84db0bb59d2442bb080304f", "type": "github" }, "original": { diff --git a/nix/zigCacheHash.nix b/nix/zigCacheHash.nix index a8e14bcb2..7f904e8a8 100644 --- a/nix/zigCacheHash.nix +++ b/nix/zigCacheHash.nix @@ -1,3 +1,3 @@ # This file is auto-generated! check build-support/check-zig-cache-hash.sh for # more details. -"sha256-dkMHalbYjq1IGPMnU4v/U0faJH8KpXuQCN6G++WS2n8=" +"sha256-LFwQ1HP+J4CF/MUUG2fYDr3goqxeQ/9SgEkVVrUCvRU=" From df19a68dd661eb0dd7885521ff8f8b4c359cf119 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Sun, 7 Jan 2024 23:38:17 +0100 Subject: [PATCH 23/24] Update mach-glfw dependency --- build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 8c5ce9388..c1472894d 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -9,8 +9,8 @@ .hash = "122029743e5d96aa1b57a1b99ff58bf13ff9ed6d8f624ac3ae8074062feb91c5bd8d", }, .mach_glfw = .{ - .url = "https://github.com/der-teufel-programming/mach-glfw/archive/c8bdbf777643e360c2176ad62cefcd9c3b64b32b.tar.gz", - .hash = "12204f7b735d5a6eaeafee501be4bc88a9ac25ca23826f67041f3788f9307e6e5181", + .url = "https://github.com/der-teufel-programming/mach-glfw/archive/fe077f52e51c4eb7e4ff6bbe8d3ee3ecd9cc743d.tar.gz", + .hash = "1220838cb1781e328a0218facaa7e92ae97fd5bbcd81dd0429ac43c5b36fe70c1990", }, .zig_objc = .{ .url = "https://github.com/mitchellh/zig-objc/archive/294e0f3765a96613b45ff7dd594bf99e22409e96.tar.gz", From ad0db1d2ae6918131e932ba4f60631388e6bb264 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 7 Jan 2024 15:30:56 -0800 Subject: [PATCH 24/24] nix: update hash --- nix/zigCacheHash.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/zigCacheHash.nix b/nix/zigCacheHash.nix index 7f904e8a8..0e4626c77 100644 --- a/nix/zigCacheHash.nix +++ b/nix/zigCacheHash.nix @@ -1,3 +1,3 @@ # This file is auto-generated! check build-support/check-zig-cache-hash.sh for # more details. -"sha256-LFwQ1HP+J4CF/MUUG2fYDr3goqxeQ/9SgEkVVrUCvRU=" +"sha256-iRXzPgzOkt+TTcqPCRQubP3dN6lS+Wvn17l+0I/pDGg="