From 17498ce122ca02ba23497e0a8606888c32ef81d2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 21 Sep 2025 10:36:37 -0700 Subject: [PATCH] build: many more lazy dependencies, defer deps add unless needed This makes more dependencies lazy. This has a practical effect of reducing the number of dependencies that need to be downloaded when running certain zig build steps. This is all limited because we're blocked on an upstream Zig issue: https://github.com/ziglang/zig/issues/21525 This prevents us from fully avoiding downloading many dependencies, but at least they're relatively small. One major improvement here is the usage of `lazyImport` for `zig-wayland` that prevents downloading `zig_wayland` unconditionally on all platforms. On macOS, we don't download this at all anymore. Another, weirder change is that all our transitive dependencies are now marked lazy (e.g. glslang's upstream source) even if the glslang build always requires it. This was necessary because without this, even if we simply referenced glslang in the root build.zig, it would force the source package to download unconditionally. This no longer happens. --- build.zig.zon | 3 + pkg/cimgui/build.zig | 45 +++++----- pkg/cimgui/build.zig.zon | 1 + pkg/glslang/build.zig | 158 +++++++++++++++++----------------- pkg/glslang/build.zig.zon | 1 + pkg/highway/build.zig | 46 +++++----- pkg/highway/build.zig.zon | 1 + pkg/libxml2/build.zig | 34 ++++---- pkg/libxml2/build.zig.zon | 1 + pkg/spirv-cross/build.zig | 7 +- pkg/spirv-cross/build.zig.zon | 1 + src/build/SharedDeps.zig | 75 ++++++++-------- 12 files changed, 198 insertions(+), 175 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 0e349cd6d..6968d0ab3 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -45,6 +45,7 @@ // codeberg ifreund/zig-wayland .url = "https://codeberg.org/ifreund/zig-wayland/archive/f3c5d503e540ada8cbcb056420de240af0c094f7.tar.gz", .hash = "wayland-0.4.0-dev-lQa1kjfIAQCmhhQu3xF0KH-94-TzeMXOqfnP0-Dg6Wyy", + .lazy = true, }, .zf = .{ // natecraddock/zf @@ -103,10 +104,12 @@ .jetbrains_mono = .{ .url = "https://deps.files.ghostty.org/JetBrainsMono-2.304.tar.gz", .hash = "N-V-__8AAIC5lwAVPJJzxnCAahSvZTIlG-HhtOvnM1uh-66x", + .lazy = true, }, .nerd_fonts_symbols_only = .{ .url = "https://deps.files.ghostty.org/NerdFontsSymbolsOnly-3.4.0.tar.gz", .hash = "N-V-__8AAMVLTABmYkLqhZPLXnMl-KyN38R8UVYqGrxqO26s", + .lazy = true, }, // Other diff --git a/pkg/cimgui/build.zig b/pkg/cimgui/build.zig index 83d60737e..f14bc1242 100644 --- a/pkg/cimgui/build.zig +++ b/pkg/cimgui/build.zig @@ -11,7 +11,7 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }); - const imgui = b.dependency("imgui", .{}); + const imgui_ = b.lazyDependency("imgui", .{}); const lib = b.addLibrary(.{ .name = "cimgui", .root_module = b.createModule(.{ @@ -52,7 +52,7 @@ pub fn build(b: *std.Build) !void { } } - lib.addIncludePath(imgui.path("")); + if (imgui_) |imgui| lib.addIncludePath(imgui.path("")); module.addIncludePath(b.path("vendor")); var flags = std.ArrayList([]const u8).init(b.allocator); @@ -72,32 +72,33 @@ pub fn build(b: *std.Build) !void { }); } - lib.addCSourceFile(.{ .file = b.path("vendor/cimgui.cpp"), .flags = flags.items }); - lib.addCSourceFile(.{ .file = imgui.path("imgui.cpp"), .flags = flags.items }); - lib.addCSourceFile(.{ .file = imgui.path("imgui_draw.cpp"), .flags = flags.items }); - lib.addCSourceFile(.{ .file = imgui.path("imgui_demo.cpp"), .flags = flags.items }); - lib.addCSourceFile(.{ .file = imgui.path("imgui_widgets.cpp"), .flags = flags.items }); - lib.addCSourceFile(.{ .file = imgui.path("imgui_tables.cpp"), .flags = flags.items }); - lib.addCSourceFile(.{ .file = imgui.path("misc/freetype/imgui_freetype.cpp"), .flags = flags.items }); - - lib.addCSourceFile(.{ - .file = imgui.path("backends/imgui_impl_opengl3.cpp"), - .flags = flags.items, - }); - - if (target.result.os.tag.isDarwin()) { - if (!target.query.isNative()) { - try @import("apple_sdk").addPaths(b, lib); - } + if (imgui_) |imgui| { + lib.addCSourceFile(.{ .file = b.path("vendor/cimgui.cpp"), .flags = flags.items }); + lib.addCSourceFile(.{ .file = imgui.path("imgui.cpp"), .flags = flags.items }); + lib.addCSourceFile(.{ .file = imgui.path("imgui_draw.cpp"), .flags = flags.items }); + lib.addCSourceFile(.{ .file = imgui.path("imgui_demo.cpp"), .flags = flags.items }); + lib.addCSourceFile(.{ .file = imgui.path("imgui_widgets.cpp"), .flags = flags.items }); + lib.addCSourceFile(.{ .file = imgui.path("imgui_tables.cpp"), .flags = flags.items }); + lib.addCSourceFile(.{ .file = imgui.path("misc/freetype/imgui_freetype.cpp"), .flags = flags.items }); lib.addCSourceFile(.{ - .file = imgui.path("backends/imgui_impl_metal.mm"), + .file = imgui.path("backends/imgui_impl_opengl3.cpp"), .flags = flags.items, }); - if (target.result.os.tag == .macos) { + + if (target.result.os.tag.isDarwin()) { + if (!target.query.isNative()) { + try @import("apple_sdk").addPaths(b, lib); + } lib.addCSourceFile(.{ - .file = imgui.path("backends/imgui_impl_osx.mm"), + .file = imgui.path("backends/imgui_impl_metal.mm"), .flags = flags.items, }); + if (target.result.os.tag == .macos) { + lib.addCSourceFile(.{ + .file = imgui.path("backends/imgui_impl_osx.mm"), + .flags = flags.items, + }); + } } } diff --git a/pkg/cimgui/build.zig.zon b/pkg/cimgui/build.zig.zon index 2d62f6e84..f539a8fd6 100644 --- a/pkg/cimgui/build.zig.zon +++ b/pkg/cimgui/build.zig.zon @@ -10,6 +10,7 @@ // ocornut/imgui .url = "https://deps.files.ghostty.org/imgui-1220bc6b9daceaf7c8c60f3c3998058045ba0c5c5f48ae255ff97776d9cd8bfc6402.tar.gz", .hash = "N-V-__8AAH0GaQC8a52s6vfIxg88OZgFgEW6DFxfSK4lX_l3", + .lazy = true, }, .apple_sdk = .{ .path = "../apple-sdk" }, diff --git a/pkg/glslang/build.zig b/pkg/glslang/build.zig index c5e76008a..52993a662 100644 --- a/pkg/glslang/build.zig +++ b/pkg/glslang/build.zig @@ -10,11 +10,11 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }); - const upstream = b.dependency("glslang", .{}); + const upstream = b.lazyDependency("glslang", .{}); const lib = try buildGlslang(b, upstream, target, optimize); b.installArtifact(lib); - module.addIncludePath(upstream.path("")); + if (upstream) |v| module.addIncludePath(v.path("")); module.addIncludePath(b.path("override")); if (target.query.isNative()) { @@ -38,7 +38,7 @@ pub fn build(b: *std.Build) !void { fn buildGlslang( b: *std.Build, - upstream: *std.Build.Dependency, + upstream_: ?*std.Build.Dependency, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, ) !*std.Build.Step.Compile { @@ -52,7 +52,7 @@ fn buildGlslang( }); lib.linkLibC(); lib.linkLibCpp(); - lib.addIncludePath(upstream.path("")); + if (upstream_) |upstream| lib.addIncludePath(upstream.path("")); lib.addIncludePath(b.path("override")); if (target.result.os.tag.isDarwin()) { const apple_sdk = @import("apple_sdk"); @@ -66,87 +66,89 @@ fn buildGlslang( "-fno-sanitize-trap=undefined", }); - lib.addCSourceFiles(.{ - .root = upstream.path(""), - .flags = flags.items, - .files = &.{ - // GenericCodeGen - "glslang/GenericCodeGen/CodeGen.cpp", - "glslang/GenericCodeGen/Link.cpp", - - // MachineIndependent - //"MachineIndependent/glslang.y", - "glslang/MachineIndependent/glslang_tab.cpp", - "glslang/MachineIndependent/attribute.cpp", - "glslang/MachineIndependent/Constant.cpp", - "glslang/MachineIndependent/iomapper.cpp", - "glslang/MachineIndependent/InfoSink.cpp", - "glslang/MachineIndependent/Initialize.cpp", - "glslang/MachineIndependent/IntermTraverse.cpp", - "glslang/MachineIndependent/Intermediate.cpp", - "glslang/MachineIndependent/ParseContextBase.cpp", - "glslang/MachineIndependent/ParseHelper.cpp", - "glslang/MachineIndependent/PoolAlloc.cpp", - "glslang/MachineIndependent/RemoveTree.cpp", - "glslang/MachineIndependent/Scan.cpp", - "glslang/MachineIndependent/ShaderLang.cpp", - "glslang/MachineIndependent/SpirvIntrinsics.cpp", - "glslang/MachineIndependent/SymbolTable.cpp", - "glslang/MachineIndependent/Versions.cpp", - "glslang/MachineIndependent/intermOut.cpp", - "glslang/MachineIndependent/limits.cpp", - "glslang/MachineIndependent/linkValidate.cpp", - "glslang/MachineIndependent/parseConst.cpp", - "glslang/MachineIndependent/reflection.cpp", - "glslang/MachineIndependent/preprocessor/Pp.cpp", - "glslang/MachineIndependent/preprocessor/PpAtom.cpp", - "glslang/MachineIndependent/preprocessor/PpContext.cpp", - "glslang/MachineIndependent/preprocessor/PpScanner.cpp", - "glslang/MachineIndependent/preprocessor/PpTokens.cpp", - "glslang/MachineIndependent/propagateNoContraction.cpp", - - // C Interface - "glslang/CInterface/glslang_c_interface.cpp", - - // ResourceLimits - "glslang/ResourceLimits/ResourceLimits.cpp", - "glslang/ResourceLimits/resource_limits_c.cpp", - - // SPIRV - "SPIRV/GlslangToSpv.cpp", - "SPIRV/InReadableOrder.cpp", - "SPIRV/Logger.cpp", - "SPIRV/SpvBuilder.cpp", - "SPIRV/SpvPostProcess.cpp", - "SPIRV/doc.cpp", - "SPIRV/disassemble.cpp", - "SPIRV/CInterface/spirv_c_interface.cpp", - }, - }); - - if (target.result.os.tag != .windows) { + if (upstream_) |upstream| { lib.addCSourceFiles(.{ .root = upstream.path(""), .flags = flags.items, .files = &.{ - "glslang/OSDependent/Unix/ossource.cpp", - }, - }); - } else { - lib.addCSourceFiles(.{ - .root = upstream.path(""), - .flags = flags.items, - .files = &.{ - "glslang/OSDependent/Windows/ossource.cpp", + // GenericCodeGen + "glslang/GenericCodeGen/CodeGen.cpp", + "glslang/GenericCodeGen/Link.cpp", + + // MachineIndependent + //"MachineIndependent/glslang.y", + "glslang/MachineIndependent/glslang_tab.cpp", + "glslang/MachineIndependent/attribute.cpp", + "glslang/MachineIndependent/Constant.cpp", + "glslang/MachineIndependent/iomapper.cpp", + "glslang/MachineIndependent/InfoSink.cpp", + "glslang/MachineIndependent/Initialize.cpp", + "glslang/MachineIndependent/IntermTraverse.cpp", + "glslang/MachineIndependent/Intermediate.cpp", + "glslang/MachineIndependent/ParseContextBase.cpp", + "glslang/MachineIndependent/ParseHelper.cpp", + "glslang/MachineIndependent/PoolAlloc.cpp", + "glslang/MachineIndependent/RemoveTree.cpp", + "glslang/MachineIndependent/Scan.cpp", + "glslang/MachineIndependent/ShaderLang.cpp", + "glslang/MachineIndependent/SpirvIntrinsics.cpp", + "glslang/MachineIndependent/SymbolTable.cpp", + "glslang/MachineIndependent/Versions.cpp", + "glslang/MachineIndependent/intermOut.cpp", + "glslang/MachineIndependent/limits.cpp", + "glslang/MachineIndependent/linkValidate.cpp", + "glslang/MachineIndependent/parseConst.cpp", + "glslang/MachineIndependent/reflection.cpp", + "glslang/MachineIndependent/preprocessor/Pp.cpp", + "glslang/MachineIndependent/preprocessor/PpAtom.cpp", + "glslang/MachineIndependent/preprocessor/PpContext.cpp", + "glslang/MachineIndependent/preprocessor/PpScanner.cpp", + "glslang/MachineIndependent/preprocessor/PpTokens.cpp", + "glslang/MachineIndependent/propagateNoContraction.cpp", + + // C Interface + "glslang/CInterface/glslang_c_interface.cpp", + + // ResourceLimits + "glslang/ResourceLimits/ResourceLimits.cpp", + "glslang/ResourceLimits/resource_limits_c.cpp", + + // SPIRV + "SPIRV/GlslangToSpv.cpp", + "SPIRV/InReadableOrder.cpp", + "SPIRV/Logger.cpp", + "SPIRV/SpvBuilder.cpp", + "SPIRV/SpvPostProcess.cpp", + "SPIRV/doc.cpp", + "SPIRV/disassemble.cpp", + "SPIRV/CInterface/spirv_c_interface.cpp", }, }); + + if (target.result.os.tag != .windows) { + lib.addCSourceFiles(.{ + .root = upstream.path(""), + .flags = flags.items, + .files = &.{ + "glslang/OSDependent/Unix/ossource.cpp", + }, + }); + } else { + lib.addCSourceFiles(.{ + .root = upstream.path(""), + .flags = flags.items, + .files = &.{ + "glslang/OSDependent/Windows/ossource.cpp", + }, + }); + } + + lib.installHeadersDirectory( + upstream.path(""), + "", + .{ .include_extensions = &.{".h"} }, + ); } - lib.installHeadersDirectory( - upstream.path(""), - "", - .{ .include_extensions = &.{".h"} }, - ); - return lib; } diff --git a/pkg/glslang/build.zig.zon b/pkg/glslang/build.zig.zon index cbcb08e5d..252237e58 100644 --- a/pkg/glslang/build.zig.zon +++ b/pkg/glslang/build.zig.zon @@ -8,6 +8,7 @@ .glslang = .{ .url = "https://deps.files.ghostty.org/glslang-12201278a1a05c0ce0b6eb6026c65cd3e9247aa041b1c260324bf29cee559dd23ba1.tar.gz", .hash = "N-V-__8AABzkUgISeKGgXAzgtutgJsZc0-kkeqBBscJgMkvy", + .lazy = true, }, .apple_sdk = .{ .path = "../apple-sdk" }, diff --git a/pkg/highway/build.zig b/pkg/highway/build.zig index c8ef2d18e..1013f1643 100644 --- a/pkg/highway/build.zig +++ b/pkg/highway/build.zig @@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const upstream = b.dependency("highway", .{}); + const upstream_ = b.lazyDependency("highway", .{}); const module = b.addModule("highway", .{ .root_source_file = b.path("main.zig"), @@ -21,8 +21,10 @@ pub fn build(b: *std.Build) !void { .linkage = .static, }); lib.linkLibCpp(); - lib.addIncludePath(upstream.path("")); - module.addIncludePath(upstream.path("")); + if (upstream_) |upstream| { + lib.addIncludePath(upstream.path("")); + module.addIncludePath(upstream.path("")); + } if (target.result.os.tag.isDarwin()) { const apple_sdk = @import("apple_sdk"); @@ -74,24 +76,26 @@ pub fn build(b: *std.Build) !void { } lib.addCSourceFiles(.{ .flags = flags.items, .files = &.{"bridge.cpp"} }); - lib.addCSourceFiles(.{ - .root = upstream.path(""), - .flags = flags.items, - .files = &.{ - "hwy/abort.cc", - "hwy/aligned_allocator.cc", - "hwy/nanobenchmark.cc", - "hwy/per_target.cc", - "hwy/print.cc", - "hwy/targets.cc", - "hwy/timer.cc", - }, - }); - lib.installHeadersDirectory( - upstream.path("hwy"), - "hwy", - .{ .include_extensions = &.{".h"} }, - ); + if (upstream_) |upstream| { + lib.addCSourceFiles(.{ + .root = upstream.path(""), + .flags = flags.items, + .files = &.{ + "hwy/abort.cc", + "hwy/aligned_allocator.cc", + "hwy/nanobenchmark.cc", + "hwy/per_target.cc", + "hwy/print.cc", + "hwy/targets.cc", + "hwy/timer.cc", + }, + }); + lib.installHeadersDirectory( + upstream.path("hwy"), + "hwy", + .{ .include_extensions = &.{".h"} }, + ); + } b.installArtifact(lib); diff --git a/pkg/highway/build.zig.zon b/pkg/highway/build.zig.zon index 8fc05641e..0777fcb7a 100644 --- a/pkg/highway/build.zig.zon +++ b/pkg/highway/build.zig.zon @@ -8,6 +8,7 @@ .highway = .{ .url = "https://deps.files.ghostty.org/highway-66486a10623fa0d72fe91260f96c892e41aceb06.tar.gz", .hash = "N-V-__8AAGmZhABbsPJLfbqrh6JTHsXhY6qCaLAQyx25e0XE", + .lazy = true, }, .apple_sdk = .{ .path = "../apple-sdk" }, diff --git a/pkg/libxml2/build.zig b/pkg/libxml2/build.zig index 7c3c2b607..acebfaf63 100644 --- a/pkg/libxml2/build.zig +++ b/pkg/libxml2/build.zig @@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const upstream = b.dependency("libxml2", .{}); + const upstream_ = b.lazyDependency("libxml2", .{}); const lib = b.addLibrary(.{ .name = "xml2", @@ -16,7 +16,7 @@ pub fn build(b: *std.Build) !void { }); lib.linkLibC(); - lib.addIncludePath(upstream.path("include")); + if (upstream_) |upstream| lib.addIncludePath(upstream.path("include")); lib.addIncludePath(b.path("override/include")); if (target.result.os.tag == .windows) { lib.addIncludePath(b.path("override/config/win32")); @@ -97,21 +97,23 @@ pub fn build(b: *std.Build) !void { } } - lib.addCSourceFiles(.{ - .root = upstream.path(""), - .files = srcs, - .flags = flags.items, - }); + if (upstream_) |upstream| { + lib.addCSourceFiles(.{ + .root = upstream.path(""), + .files = srcs, + .flags = flags.items, + }); - lib.installHeader( - b.path("override/include/libxml/xmlversion.h"), - "libxml/xmlversion.h", - ); - lib.installHeadersDirectory( - upstream.path("include"), - "", - .{ .include_extensions = &.{".h"} }, - ); + lib.installHeader( + b.path("override/include/libxml/xmlversion.h"), + "libxml/xmlversion.h", + ); + lib.installHeadersDirectory( + upstream.path("include"), + "", + .{ .include_extensions = &.{".h"} }, + ); + } b.installArtifact(lib); } diff --git a/pkg/libxml2/build.zig.zon b/pkg/libxml2/build.zig.zon index 3f6906a50..f932835aa 100644 --- a/pkg/libxml2/build.zig.zon +++ b/pkg/libxml2/build.zig.zon @@ -7,6 +7,7 @@ .libxml2 = .{ .url = "https://deps.files.ghostty.org/libxml2-2.11.5.tar.gz", .hash = "N-V-__8AAG3RoQEyRC2Vw7Qoro5SYBf62IHn3HjqtNVY6aWK", + .lazy = true, }, }, } diff --git a/pkg/spirv-cross/build.zig b/pkg/spirv-cross/build.zig index b359ccd9c..9e84689ca 100644 --- a/pkg/spirv-cross/build.zig +++ b/pkg/spirv-cross/build.zig @@ -4,10 +4,10 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const upstream = b.dependency("spirv_cross", .{}); + const upstream = b.lazyDependency("spirv_cross", .{}); const module = b.addModule("spirv_cross", .{ .root_source_file = b.path("main.zig") }); - module.addIncludePath(upstream.path("")); + if (upstream) |v| module.addIncludePath(v.path("")); const lib = try buildSpirvCross(b, upstream, target, optimize); b.installArtifact(lib); @@ -33,7 +33,7 @@ pub fn build(b: *std.Build) !void { fn buildSpirvCross( b: *std.Build, - upstream: *std.Build.Dependency, + upstream_: ?*std.Build.Dependency, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, ) !*std.Build.Step.Compile { @@ -62,6 +62,7 @@ fn buildSpirvCross( "-fno-sanitize-trap=undefined", }); + const upstream = upstream_ orelse return lib; lib.addCSourceFiles(.{ .root = upstream.path(""), .flags = flags.items, diff --git a/pkg/spirv-cross/build.zig.zon b/pkg/spirv-cross/build.zig.zon index a7ad7133d..30eea9501 100644 --- a/pkg/spirv-cross/build.zig.zon +++ b/pkg/spirv-cross/build.zig.zon @@ -8,6 +8,7 @@ .spirv_cross = .{ .url = "https://deps.files.ghostty.org/spirv_cross-1220fb3b5586e8be67bc3feb34cbe749cf42a60d628d2953632c2f8141302748c8da.tar.gz", .hash = "N-V-__8AANb6pwD7O1WG6L5nvD_rNMvnSc9Cpg1ijSlTYywv", + .lazy = true, }, .apple_sdk = .{ .path = "../apple-sdk" }, diff --git a/src/build/SharedDeps.zig b/src/build/SharedDeps.zig index 77dec3350..ab5b0d8bf 100644 --- a/src/build/SharedDeps.zig +++ b/src/build/SharedDeps.zig @@ -502,38 +502,40 @@ pub fn add( // Fonts { // JetBrains Mono - const jb_mono = b.dependency("jetbrains_mono", .{}); - step.root_module.addAnonymousImport( - "jetbrains_mono_regular", - .{ .root_source_file = jb_mono.path("fonts/ttf/JetBrainsMono-Regular.ttf") }, - ); - step.root_module.addAnonymousImport( - "jetbrains_mono_bold", - .{ .root_source_file = jb_mono.path("fonts/ttf/JetBrainsMono-Bold.ttf") }, - ); - step.root_module.addAnonymousImport( - "jetbrains_mono_italic", - .{ .root_source_file = jb_mono.path("fonts/ttf/JetBrainsMono-Italic.ttf") }, - ); - step.root_module.addAnonymousImport( - "jetbrains_mono_bold_italic", - .{ .root_source_file = jb_mono.path("fonts/ttf/JetBrainsMono-BoldItalic.ttf") }, - ); - step.root_module.addAnonymousImport( - "jetbrains_mono_variable", - .{ .root_source_file = jb_mono.path("fonts/variable/JetBrainsMono[wght].ttf") }, - ); - step.root_module.addAnonymousImport( - "jetbrains_mono_variable_italic", - .{ .root_source_file = jb_mono.path("fonts/variable/JetBrainsMono-Italic[wght].ttf") }, - ); + if (b.lazyDependency("jetbrains_mono", .{})) |jb_mono| { + step.root_module.addAnonymousImport( + "jetbrains_mono_regular", + .{ .root_source_file = jb_mono.path("fonts/ttf/JetBrainsMono-Regular.ttf") }, + ); + step.root_module.addAnonymousImport( + "jetbrains_mono_bold", + .{ .root_source_file = jb_mono.path("fonts/ttf/JetBrainsMono-Bold.ttf") }, + ); + step.root_module.addAnonymousImport( + "jetbrains_mono_italic", + .{ .root_source_file = jb_mono.path("fonts/ttf/JetBrainsMono-Italic.ttf") }, + ); + step.root_module.addAnonymousImport( + "jetbrains_mono_bold_italic", + .{ .root_source_file = jb_mono.path("fonts/ttf/JetBrainsMono-BoldItalic.ttf") }, + ); + step.root_module.addAnonymousImport( + "jetbrains_mono_variable", + .{ .root_source_file = jb_mono.path("fonts/variable/JetBrainsMono[wght].ttf") }, + ); + step.root_module.addAnonymousImport( + "jetbrains_mono_variable_italic", + .{ .root_source_file = jb_mono.path("fonts/variable/JetBrainsMono-Italic[wght].ttf") }, + ); + } // Symbols-only nerd font - const nf_symbols = b.dependency("nerd_fonts_symbols_only", .{}); - step.root_module.addAnonymousImport( - "nerd_fonts_symbols_only", - .{ .root_source_file = nf_symbols.path("SymbolsNerdFont-Regular.ttf") }, - ); + if (b.lazyDependency("nerd_fonts_symbols_only", .{})) |nf_symbols| { + step.root_module.addAnonymousImport( + "nerd_fonts_symbols_only", + .{ .root_source_file = nf_symbols.path("SymbolsNerdFont-Regular.ttf") }, + ); + } } // If we're building an exe then we have additional dependencies. @@ -615,17 +617,20 @@ fn addGtkNg( "plasma_wayland_protocols", .{}, ); + const zig_wayland_import_ = b.lazyImport( + @import("../../build.zig"), + "zig_wayland", + ); + const zig_wayland_dep_ = b.lazyDependency("zig_wayland", .{}); // Unwrap or return, there are no more dependencies below. const wayland_dep = wayland_dep_ orelse break :wayland; const wayland_protocols_dep = wayland_protocols_dep_ orelse break :wayland; const plasma_wayland_protocols_dep = plasma_wayland_protocols_dep_ orelse break :wayland; + const zig_wayland_import = zig_wayland_import_ orelse break :wayland; + const zig_wayland_dep = zig_wayland_dep_ orelse break :wayland; - // Note that zig_wayland cannot be lazy because lazy dependencies - // can't be imported since they don't exist and imports are - // resolved at compile time of the build. - const zig_wayland_dep = b.dependency("zig_wayland", .{}); - const Scanner = @import("zig_wayland").Scanner; + const Scanner = zig_wayland_import.Scanner; const scanner = Scanner.create(zig_wayland_dep.builder, .{ .wayland_xml = wayland_dep.path("protocol/wayland.xml"), .wayland_protocols = wayland_protocols_dep.path(""),