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, };