build: do not build/link harfbuzz on macOS

This commit is contained in:
Mitchell Hashimoto
2024-04-04 12:22:35 -07:00
parent e41e45e1ad
commit fd4d2313d0
4 changed files with 30 additions and 8 deletions

View File

@ -1055,11 +1055,14 @@ fn addDeps(
"fontconfig", "fontconfig",
fontconfig_dep.module("fontconfig"), fontconfig_dep.module("fontconfig"),
); );
if (config.font_backend.hasHarfbuzz()) step.root_module.addImport(
"harfbuzz",
harfbuzz_dep.module("harfbuzz"),
);
step.root_module.addImport("oniguruma", oniguruma_dep.module("oniguruma")); step.root_module.addImport("oniguruma", oniguruma_dep.module("oniguruma"));
step.root_module.addImport("freetype", freetype_dep.module("freetype")); step.root_module.addImport("freetype", freetype_dep.module("freetype"));
step.root_module.addImport("glslang", glslang_dep.module("glslang")); 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("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("xev", libxev_dep.module("xev"));
step.root_module.addImport("opengl", opengl_dep.module("opengl")); step.root_module.addImport("opengl", opengl_dep.module("opengl"));
step.root_module.addImport("pixman", pixman_dep.module("pixman")); step.root_module.addImport("pixman", pixman_dep.module("pixman"));
@ -1110,7 +1113,6 @@ fn addDeps(
step.addIncludePath(freetype_dep.path("")); step.addIncludePath(freetype_dep.path(""));
step.linkSystemLibrary2("bzip2", dynamic_link_opts); step.linkSystemLibrary2("bzip2", dynamic_link_opts);
step.linkSystemLibrary2("freetype2", dynamic_link_opts); step.linkSystemLibrary2("freetype2", dynamic_link_opts);
step.linkSystemLibrary2("harfbuzz", dynamic_link_opts);
step.linkSystemLibrary2("libpng", dynamic_link_opts); step.linkSystemLibrary2("libpng", dynamic_link_opts);
step.linkSystemLibrary2("oniguruma", dynamic_link_opts); step.linkSystemLibrary2("oniguruma", dynamic_link_opts);
step.linkSystemLibrary2("pixman-1", dynamic_link_opts); step.linkSystemLibrary2("pixman-1", dynamic_link_opts);
@ -1119,6 +1121,9 @@ fn addDeps(
if (config.font_backend.hasFontconfig()) { if (config.font_backend.hasFontconfig()) {
step.linkSystemLibrary2("fontconfig", dynamic_link_opts); step.linkSystemLibrary2("fontconfig", dynamic_link_opts);
} }
if (config.font_backend.hasHarfbuzz()) {
step.linkSystemLibrary2("harfbuzz", dynamic_link_opts);
}
} }
// Other dependencies, we may dynamically link // Other dependencies, we may dynamically link
@ -1136,14 +1141,16 @@ fn addDeps(
step.linkLibrary(freetype_dep.artifact("freetype")); step.linkLibrary(freetype_dep.artifact("freetype"));
try static_libs.append(freetype_dep.artifact("freetype").getEmittedBin()); try static_libs.append(freetype_dep.artifact("freetype").getEmittedBin());
// Harfbuzz
step.linkLibrary(harfbuzz_dep.artifact("harfbuzz"));
try static_libs.append(harfbuzz_dep.artifact("harfbuzz").getEmittedBin());
// Pixman // Pixman
step.linkLibrary(pixman_dep.artifact("pixman")); step.linkLibrary(pixman_dep.artifact("pixman"));
try static_libs.append(pixman_dep.artifact("pixman").getEmittedBin()); try static_libs.append(pixman_dep.artifact("pixman").getEmittedBin());
// Harfbuzz
if (config.font_backend.hasHarfbuzz()) {
step.linkLibrary(harfbuzz_dep.artifact("harfbuzz"));
try static_libs.append(harfbuzz_dep.artifact("harfbuzz").getEmittedBin());
}
// Only Linux gets fontconfig // Only Linux gets fontconfig
if (config.font_backend.hasFontconfig()) { if (config.font_backend.hasFontconfig()) {
// Fontconfig // Fontconfig

View File

@ -28,7 +28,7 @@ pub const Face = struct {
/// True if our build is using Harfbuzz. If we're not, we can avoid /// True if our build is using Harfbuzz. If we're not, we can avoid
/// some Harfbuzz-specific code paths. /// some Harfbuzz-specific code paths.
const harfbuzz_shaper = font.Shaper == font.shape.harfbuzz.Shaper; const harfbuzz_shaper = font.options.backend.hasHarfbuzz();
/// The matrix applied to a regular font to auto-italicize it. /// The matrix applied to a regular font to auto-italicize it.
pub const italic_skew = macos.graphics.AffineTransform{ pub const italic_skew = macos.graphics.AffineTransform{

View File

@ -115,6 +115,19 @@ pub const Backend = enum {
=> false, => false,
}; };
} }
pub fn hasHarfbuzz(self: Backend) bool {
return switch (self) {
.freetype,
.fontconfig_freetype,
.coretext_freetype,
=> true,
.coretext,
.web_canvas,
=> false,
};
}
}; };
/// The styles that a family can take. /// The styles that a family can take.

View File

@ -256,7 +256,9 @@ pub const GlobalState = struct {
std.log.info("ghostty build optimize={s}", .{build_config.mode_string}); std.log.info("ghostty build optimize={s}", .{build_config.mode_string});
std.log.info("runtime={}", .{build_config.app_runtime}); std.log.info("runtime={}", .{build_config.app_runtime});
std.log.info("font_backend={}", .{build_config.font_backend}); std.log.info("font_backend={}", .{build_config.font_backend});
if (comptime build_config.font_backend.hasHarfbuzz()) {
std.log.info("dependency harfbuzz={s}", .{harfbuzz.versionString()}); std.log.info("dependency harfbuzz={s}", .{harfbuzz.versionString()});
}
if (comptime build_config.font_backend.hasFontconfig()) { if (comptime build_config.font_backend.hasFontconfig()) {
std.log.info("dependency fontconfig={d}", .{fontconfig.version()}); std.log.info("dependency fontconfig={d}", .{fontconfig.version()});
} }