mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-12 10:48:39 +03:00
pkg/harfbuzz
This commit is contained in:
@ -16,7 +16,6 @@ const Version = @import("src/build/Version.zig");
|
||||
|
||||
const glfw = @import("vendor/mach-glfw/build.zig");
|
||||
const fontconfig = @import("pkg/fontconfig/build.zig");
|
||||
const harfbuzz = @import("pkg/harfbuzz/build.zig");
|
||||
const js = @import("vendor/zig-js/build.zig");
|
||||
const libxev = @import("vendor/libxev/build.zig");
|
||||
const libxml2 = @import("vendor/zig-libxml2/libxml2.zig");
|
||||
@ -28,6 +27,7 @@ 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 zlib = @import("pkg/zlib/build.old.zig");
|
||||
|
||||
|
121
pkg/harfbuzz/build.old.zig
Normal file
121
pkg/harfbuzz/build.old.zig
Normal file
@ -0,0 +1,121 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/harfbuzz/";
|
||||
const include_path = root ++ "src/";
|
||||
|
||||
pub const include_paths = .{include_path};
|
||||
|
||||
pub fn module(b: *std.Build, deps: struct {
|
||||
freetype: *std.build.Module,
|
||||
macos: *std.build.Module,
|
||||
}) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = (comptime thisDir()) ++ "/main.zig" },
|
||||
.dependencies = &.{
|
||||
.{ .name = "freetype", .module = deps.freetype },
|
||||
.{ .name = "macos", .module = deps.macos },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub const Options = struct {
|
||||
freetype: Freetype = .{},
|
||||
coretext: CoreText = .{},
|
||||
|
||||
pub const Freetype = struct {
|
||||
enabled: bool = false,
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
|
||||
pub const CoreText = struct {
|
||||
enabled: bool = false,
|
||||
};
|
||||
};
|
||||
|
||||
pub fn link(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = try buildHarfbuzz(b, step, opt);
|
||||
step.linkLibrary(lib);
|
||||
step.addIncludePath(.{ .path = include_path });
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn buildHarfbuzz(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "harfbuzz",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
|
||||
// Include
|
||||
lib.addIncludePath(.{ .path = include_path });
|
||||
|
||||
// Link
|
||||
lib.linkLibC();
|
||||
lib.linkLibCpp();
|
||||
if (opt.freetype.enabled) {
|
||||
if (opt.freetype.step) |freetype|
|
||||
lib.linkLibrary(freetype)
|
||||
else
|
||||
lib.linkSystemLibrary("freetype2");
|
||||
|
||||
if (opt.freetype.include) |dirs|
|
||||
for (dirs) |dir| lib.addIncludePath(.{ .path = dir });
|
||||
}
|
||||
|
||||
// Compile
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_STDBOOL_H",
|
||||
});
|
||||
|
||||
if (!step.target.isWindows()) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_UNISTD_H",
|
||||
"-DHAVE_SYS_MMAN_H",
|
||||
"-DHAVE_PTHREAD=1",
|
||||
});
|
||||
}
|
||||
|
||||
if (opt.freetype.enabled) try flags.appendSlice(&.{
|
||||
"-DHAVE_FREETYPE=1",
|
||||
|
||||
// Let's just assume a new freetype
|
||||
"-DHAVE_FT_GET_VAR_BLEND_COORDINATES=1",
|
||||
"-DHAVE_FT_SET_VAR_BLEND_COORDINATES=1",
|
||||
"-DHAVE_FT_DONE_MM_VAR=1",
|
||||
"-DHAVE_FT_GET_TRANSFORM=1",
|
||||
});
|
||||
|
||||
if (opt.coretext.enabled) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_CORETEXT=1",
|
||||
});
|
||||
|
||||
lib.linkFramework("ApplicationServices");
|
||||
}
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
|
||||
return lib;
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "src/harfbuzz.cc",
|
||||
};
|
@ -1,98 +1,39 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/harfbuzz/";
|
||||
const include_path = root ++ "src/";
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
pub const include_paths = .{include_path};
|
||||
const coretext_enabled = b.option(bool, "enable-coretext", "Build coretext") orelse false;
|
||||
const freetype_enabled = b.option(bool, "enable-freetype", "Build freetype") orelse false;
|
||||
|
||||
pub fn module(b: *std.Build, deps: struct {
|
||||
freetype: *std.build.Module,
|
||||
macos: *std.build.Module,
|
||||
}) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = (comptime thisDir()) ++ "/main.zig" },
|
||||
.dependencies = &.{
|
||||
.{ .name = "freetype", .module = deps.freetype },
|
||||
.{ .name = "macos", .module = deps.macos },
|
||||
},
|
||||
});
|
||||
}
|
||||
const upstream_root = "../../vendor/harfbuzz";
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub const Options = struct {
|
||||
freetype: Freetype = .{},
|
||||
coretext: CoreText = .{},
|
||||
|
||||
pub const Freetype = struct {
|
||||
enabled: bool = false,
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
|
||||
pub const CoreText = struct {
|
||||
enabled: bool = false,
|
||||
};
|
||||
};
|
||||
|
||||
pub fn link(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = try buildHarfbuzz(b, step, opt);
|
||||
step.linkLibrary(lib);
|
||||
step.addIncludePath(.{ .path = include_path });
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn buildHarfbuzz(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "harfbuzz",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
// Include
|
||||
lib.addIncludePath(.{ .path = include_path });
|
||||
|
||||
// Link
|
||||
lib.linkLibC();
|
||||
lib.linkLibCpp();
|
||||
if (opt.freetype.enabled) {
|
||||
if (opt.freetype.step) |freetype|
|
||||
lib.linkLibrary(freetype)
|
||||
else
|
||||
lib.linkSystemLibrary("freetype2");
|
||||
lib.addIncludePath(.{ .path = upstream_root ++ "/src" });
|
||||
|
||||
if (opt.freetype.include) |dirs|
|
||||
for (dirs) |dir| lib.addIncludePath(.{ .path = dir });
|
||||
}
|
||||
const freetype_dep = b.dependency("freetype", .{ .target = target, .optimize = optimize });
|
||||
lib.linkLibrary(freetype_dep.artifact("freetype"));
|
||||
|
||||
// Compile
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_STDBOOL_H",
|
||||
});
|
||||
|
||||
if (!step.target.isWindows()) {
|
||||
if (!target.isWindows()) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_UNISTD_H",
|
||||
"-DHAVE_SYS_MMAN_H",
|
||||
"-DHAVE_PTHREAD=1",
|
||||
});
|
||||
}
|
||||
|
||||
if (opt.freetype.enabled) try flags.appendSlice(&.{
|
||||
if (freetype_enabled) try flags.appendSlice(&.{
|
||||
"-DHAVE_FREETYPE=1",
|
||||
|
||||
// Let's just assume a new freetype
|
||||
@ -101,21 +42,21 @@ pub fn buildHarfbuzz(
|
||||
"-DHAVE_FT_DONE_MM_VAR=1",
|
||||
"-DHAVE_FT_GET_TRANSFORM=1",
|
||||
});
|
||||
|
||||
if (opt.coretext.enabled) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_CORETEXT=1",
|
||||
});
|
||||
|
||||
if (coretext_enabled) {
|
||||
try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"});
|
||||
lib.linkFramework("ApplicationServices");
|
||||
}
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
lib.addCSourceFile(.{
|
||||
.file = .{ .path = upstream_root ++ "/src/harfbuzz.cc" },
|
||||
.flags = flags.items,
|
||||
});
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = .{ .path = upstream_root ++ "/src" },
|
||||
.install_dir = .header,
|
||||
.install_subdir = "",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
|
||||
return lib;
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "src/harfbuzz.cc",
|
||||
};
|
||||
|
7
pkg/harfbuzz/build.zig.zon
Normal file
7
pkg/harfbuzz/build.zig.zon
Normal file
@ -0,0 +1,7 @@
|
||||
.{
|
||||
.name = "harfbuzz",
|
||||
.version = "2.13.2",
|
||||
.dependencies = .{
|
||||
.freetype = .{ .path = "../freetype" },
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user