diff --git a/build.zig b/build.zig index f052b07c1..c665e6d9d 100644 --- a/build.zig +++ b/build.zig @@ -16,12 +16,9 @@ const Version = @import("src/build/Version.zig"); const glfw = @import("vendor/mach-glfw/build.zig"); const libxml2 = @import("vendor/zig-libxml2/libxml2.zig"); -const macos = @import("pkg/macos/build.zig"); const tracylib = @import("pkg/tracy/build.zig"); const system_sdk = @import("vendor/mach-glfw/system_sdk.zig"); -const freetype = @import("pkg/freetype/build.old.zig"); -const harfbuzz = @import("pkg/harfbuzz/build.old.zig"); const libpng = @import("pkg/libpng/build.old.zig"); const pixman = @import("pkg/pixman/build.old.zig"); const utf8proc = @import("pkg/utf8proc/build.old.zig"); @@ -673,6 +670,10 @@ fn addDeps( .target = step.target, .optimize = step.optimize, }); + const macos_dep = b.dependency("macos", .{ + .target = step.target, + .optimize = step.optimize, + }); const pixman_dep = b.dependency("pixman", .{ .target = step.target, .optimize = step.optimize, @@ -733,13 +734,8 @@ fn addDeps( "fontconfig", fontconfig_dep.module("fontconfig"), ); - const mod_freetype = freetype.module(b); - const mod_macos = macos.module(b); - step.addModule("freetype", mod_freetype); - step.addModule("harfbuzz", harfbuzz.module(b, .{ - .freetype = mod_freetype, - .macos = mod_macos, - })); + step.addModule("freetype", freetype_dep.module("freetype")); + step.addModule("harfbuzz", harfbuzz_dep.module("harfbuzz")); step.addModule("xev", libxev_dep.module("xev")); step.addModule("pixman", pixman.module(b)); step.addModule("utf8proc", utf8proc.module(b)); @@ -747,8 +743,8 @@ fn addDeps( // Mac Stuff if (step.target.isDarwin()) { step.addModule("objc", objc_dep.module("objc")); - step.addModule("macos", mod_macos); - _ = try macos.link(b, step, .{}); + step.addModule("macos", macos_dep.module("macos")); + //_ = try macos.link(b, step, .{}); // todo: do this is in zig-objc instead. step.linkSystemLibraryName("objc"); @@ -767,7 +763,7 @@ fn addDeps( // Dynamic link if (!static) { - step.addIncludePath(.{ .path = freetype.include_path_self }); + // step.addIncludePath(.{ .path = freetype.include_path_self }); step.linkSystemLibrary2("bzip2", dynamic_link_opts); step.linkSystemLibrary2("freetype2", dynamic_link_opts); step.linkSystemLibrary2("harfbuzz", dynamic_link_opts); diff --git a/build.zig.zon b/build.zig.zon index e1e190006..98f27d840 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -21,6 +21,7 @@ .freetype = .{ .path = "./pkg/freetype" }, .harfbuzz = .{ .path = "./pkg/harfbuzz" }, .libpng = .{ .path = "./pkg/libpng" }, + .macos = .{ .path = "./pkg/macos" }, .pixman = .{ .path = "./pkg/pixman" }, .utf8proc = .{ .path = "./pkg/utf8proc" }, .zlib = .{ .path = "./pkg/zlib" }, diff --git a/pkg/freetype/build.zig b/pkg/freetype/build.zig index ad4414ee6..fb31777bb 100644 --- a/pkg/freetype/build.zig +++ b/pkg/freetype/build.zig @@ -5,8 +5,9 @@ pub fn build(b: *std.Build) !void { const optimize = b.standardOptimizeOption(.{}); const libpng_enabled = b.option(bool, "enable-libpng", "Build libpng") orelse false; - const upstream = b.dependency("freetype", .{}); + _ = b.addModule("freetype", .{ .source_file = .{ .path = "main.zig" } }); + const upstream = b.dependency("freetype", .{}); const lib = b.addStaticLibrary(.{ .name = "freetype", .target = target, diff --git a/pkg/harfbuzz/build.zig b/pkg/harfbuzz/build.zig index b9eeab26d..07afa0842 100644 --- a/pkg/harfbuzz/build.zig +++ b/pkg/harfbuzz/build.zig @@ -8,6 +8,17 @@ pub fn build(b: *std.Build) !void { const coretext_enabled = b.option(bool, "enable-coretext", "Build coretext") orelse false; const freetype_enabled = b.option(bool, "enable-freetype", "Build freetype") orelse false; + const freetype = b.dependency("freetype", .{ .target = target, .optimize = optimize }); + const macos = b.dependency("macos", .{ .target = target, .optimize = optimize }); + + _ = b.addModule("harfbuzz", .{ + .source_file = .{ .path = "main.zig" }, + .dependencies = &.{ + .{ .name = "freetype", .module = freetype.module("freetype") }, + .{ .name = "macos", .module = macos.module("macos") }, + }, + }); + const upstream_root = "../../vendor/harfbuzz"; const lib = b.addStaticLibrary(.{ diff --git a/pkg/harfbuzz/build.zig.zon b/pkg/harfbuzz/build.zig.zon index 2f5c08dba..5609dab3e 100644 --- a/pkg/harfbuzz/build.zig.zon +++ b/pkg/harfbuzz/build.zig.zon @@ -3,6 +3,7 @@ .version = "2.13.2", .dependencies = .{ .freetype = .{ .path = "../freetype" }, + .macos = .{ .path = "../macos" }, .apple_sdk = .{ .path = "../apple-sdk" }, }, } diff --git a/pkg/macos/build.zig b/pkg/macos/build.zig index 1a0b428f8..1b8df6b68 100644 --- a/pkg/macos/build.zig +++ b/pkg/macos/build.zig @@ -1,6 +1,15 @@ const std = @import("std"); const builtin = @import("builtin"); +pub fn build(b: *std.Build) !void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + _ = target; + _ = optimize; + + _ = b.addModule("macos", .{ .source_file = .{ .path = "main.zig" } }); +} + pub fn module(b: *std.Build) *std.build.Module { return b.createModule(.{ .source_file = .{ .path = (comptime thisDir()) ++ "/main.zig" },