pkg/freetype, harfbuzz modules

This commit is contained in:
Mitchell Hashimoto
2023-10-01 16:57:45 -07:00
parent bc0f5c3012
commit 2237b43df0
6 changed files with 33 additions and 14 deletions

View File

@ -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);

View File

@ -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" },

View File

@ -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,

View File

@ -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(.{

View File

@ -3,6 +3,7 @@
.version = "2.13.2",
.dependencies = .{
.freetype = .{ .path = "../freetype" },
.macos = .{ .path = "../macos" },
.apple_sdk = .{ .path = "../apple-sdk" },
},
}

View File

@ -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" },