mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
build fontconfig
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -25,3 +25,6 @@
|
|||||||
[submodule "vendor/harfbuzz"]
|
[submodule "vendor/harfbuzz"]
|
||||||
path = vendor/harfbuzz
|
path = vendor/harfbuzz
|
||||||
url = https://github.com/harfbuzz/harfbuzz.git
|
url = https://github.com/harfbuzz/harfbuzz.git
|
||||||
|
[submodule "vendor/zig-libxml2"]
|
||||||
|
path = vendor/zig-libxml2
|
||||||
|
url = https://github.com/mitchellh/zig-libxml2.git
|
||||||
|
25
build.zig
25
build.zig
@ -3,8 +3,10 @@ const fs = std.fs;
|
|||||||
const Builder = std.build.Builder;
|
const Builder = std.build.Builder;
|
||||||
const LibExeObjStep = std.build.LibExeObjStep;
|
const LibExeObjStep = std.build.LibExeObjStep;
|
||||||
const glfw = @import("vendor/mach/glfw/build.zig");
|
const glfw = @import("vendor/mach/glfw/build.zig");
|
||||||
|
const fontconfig = @import("pkg/fontconfig/build.zig");
|
||||||
const freetype = @import("pkg/freetype/build.zig");
|
const freetype = @import("pkg/freetype/build.zig");
|
||||||
const harfbuzz = @import("pkg/harfbuzz/build.zig");
|
const harfbuzz = @import("pkg/harfbuzz/build.zig");
|
||||||
|
const libxml2 = @import("vendor/zig-libxml2/libxml2.zig");
|
||||||
const libuv = @import("pkg/libuv/build.zig");
|
const libuv = @import("pkg/libuv/build.zig");
|
||||||
const libpng = @import("pkg/libpng/build.zig");
|
const libpng = @import("pkg/libpng/build.zig");
|
||||||
const utf8proc = @import("pkg/utf8proc/build.zig");
|
const utf8proc = @import("pkg/utf8proc/build.zig");
|
||||||
@ -156,6 +158,7 @@ fn addDeps(
|
|||||||
static: bool,
|
static: bool,
|
||||||
) !void {
|
) !void {
|
||||||
// We always need the Zig packages
|
// We always need the Zig packages
|
||||||
|
step.addPackage(fontconfig.pkg);
|
||||||
step.addPackage(freetype.pkg);
|
step.addPackage(freetype.pkg);
|
||||||
step.addPackage(harfbuzz.pkg);
|
step.addPackage(harfbuzz.pkg);
|
||||||
step.addPackage(glfw.pkg);
|
step.addPackage(glfw.pkg);
|
||||||
@ -186,6 +189,7 @@ fn addDeps(
|
|||||||
if (!static) {
|
if (!static) {
|
||||||
step.addIncludePath(freetype.include_path_self);
|
step.addIncludePath(freetype.include_path_self);
|
||||||
step.linkSystemLibrary("bzip2");
|
step.linkSystemLibrary("bzip2");
|
||||||
|
step.linkSystemLibrary("fontconfig");
|
||||||
step.linkSystemLibrary("freetype2");
|
step.linkSystemLibrary("freetype2");
|
||||||
step.linkSystemLibrary("harfbuzz");
|
step.linkSystemLibrary("harfbuzz");
|
||||||
step.linkSystemLibrary("libpng");
|
step.linkSystemLibrary("libpng");
|
||||||
@ -227,6 +231,27 @@ fn addDeps(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Libxml2
|
||||||
|
const libxml2_lib = try libxml2.create(
|
||||||
|
b,
|
||||||
|
step.target,
|
||||||
|
step.build_mode,
|
||||||
|
.{ .lzma = false, .zlib = false },
|
||||||
|
);
|
||||||
|
libxml2_lib.link(step);
|
||||||
|
|
||||||
|
// Fontconfig
|
||||||
|
const fontconfig_step = try fontconfig.link(b, step, .{
|
||||||
|
.freetype = .{
|
||||||
|
.enabled = true,
|
||||||
|
.step = freetype_step,
|
||||||
|
.include = &freetype.include_paths,
|
||||||
|
},
|
||||||
|
|
||||||
|
.libxml2 = true,
|
||||||
|
});
|
||||||
|
libxml2_lib.link(fontconfig_step);
|
||||||
|
|
||||||
// Libuv
|
// Libuv
|
||||||
const libuv_step = try libuv.link(b, step);
|
const libuv_step = try libuv.link(b, step);
|
||||||
system_sdk.include(b, libuv_step, .{});
|
system_sdk.include(b, libuv_step, .{});
|
||||||
|
@ -20,6 +20,7 @@ fn thisDir() []const u8 {
|
|||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
freetype: Freetype = .{},
|
freetype: Freetype = .{},
|
||||||
expat: Expat = .{},
|
expat: Expat = .{},
|
||||||
|
libxml2: bool = false,
|
||||||
|
|
||||||
pub const Freetype = struct {
|
pub const Freetype = struct {
|
||||||
enabled: bool = false,
|
enabled: bool = false,
|
||||||
@ -109,8 +110,8 @@ pub fn buildFontconfig(
|
|||||||
"-DHAVE_MKDTEMP",
|
"-DHAVE_MKDTEMP",
|
||||||
"-DHAVE_GETOPT",
|
"-DHAVE_GETOPT",
|
||||||
"-DHAVE_GETOPT_LONG",
|
"-DHAVE_GETOPT_LONG",
|
||||||
"-DHAVE_GETPROGNAME",
|
//"-DHAVE_GETPROGNAME",
|
||||||
"-DHAVE_GETEXECNAME",
|
//"-DHAVE_GETEXECNAME",
|
||||||
"-DHAVE_RAND",
|
"-DHAVE_RAND",
|
||||||
"-DHAVE_RANDOM",
|
"-DHAVE_RANDOM",
|
||||||
"-DHAVE_LRAND48",
|
"-DHAVE_LRAND48",
|
||||||
@ -158,13 +159,19 @@ pub fn buildFontconfig(
|
|||||||
else => @panic("unsupported arch"),
|
else => @panic("unsupported arch"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt.libxml2) {
|
||||||
|
try flags.appendSlice(&.{
|
||||||
|
"-DENABLE_LIBXML2",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!target.isWindows()) {
|
if (!target.isWindows()) {
|
||||||
try flags.appendSlice(&.{
|
try flags.appendSlice(&.{
|
||||||
"-DHAVE_PTHREAD",
|
"-DHAVE_PTHREAD",
|
||||||
|
|
||||||
"-DFC_CACHEDIR=\"/usr/local/fontconfig/cache\"",
|
"-DFC_CACHEDIR=\"/var/cache/fontconfig\"",
|
||||||
"-DFC_TEMPLATEDIR=\"/usr/local/fontconfig/templates\"",
|
"-DFC_TEMPLATEDIR=\"/usr/share/fontconfig/conf.avail\"",
|
||||||
"-DFONTCONFIG_PATH=\"/usr/local/fontconfig/fonts\"",
|
"-DFONTCONFIG_PATH=\"/etc/fonts\"",
|
||||||
"-DCONFIGDIR=\"/usr/local/fontconfig/conf.d\"",
|
"-DCONFIGDIR=\"/usr/local/fontconfig/conf.d\"",
|
||||||
"-DFC_DEFAULT_FONTS=\"<dir>/usr/share/fonts</dir><dir>/usr/local/share/fonts</dir>\"",
|
"-DFC_DEFAULT_FONTS=\"<dir>/usr/share/fonts</dir><dir>/usr/local/share/fonts</dir>\"",
|
||||||
});
|
});
|
||||||
|
@ -1296,7 +1296,7 @@ fn ttyRead(t: *libuv.Tty, n: isize, buf: []const u8) void {
|
|||||||
// Empirically, this alone improved throughput of large text output by ~20%.
|
// Empirically, this alone improved throughput of large text output by ~20%.
|
||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
const end = @intCast(usize, n);
|
const end = @intCast(usize, n);
|
||||||
if (win.terminal_stream.parser.state == .ground) {
|
if (win.terminal_stream.parser.state == .ground and false) {
|
||||||
for (buf[i..end]) |c| {
|
for (buf[i..end]) |c| {
|
||||||
switch (terminal.parse_table.table[c][@enumToInt(terminal.Parser.State.ground)].action) {
|
switch (terminal.parse_table.table[c][@enumToInt(terminal.Parser.State.ground)].action) {
|
||||||
// Print, call directly.
|
// Print, call directly.
|
||||||
|
@ -2,6 +2,7 @@ const builtin = @import("builtin");
|
|||||||
const options = @import("build_options");
|
const options = @import("build_options");
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const glfw = @import("glfw");
|
const glfw = @import("glfw");
|
||||||
|
const fontconfig = @import("fontconfig");
|
||||||
const freetype = @import("freetype");
|
const freetype = @import("freetype");
|
||||||
const harfbuzz = @import("harfbuzz");
|
const harfbuzz = @import("harfbuzz");
|
||||||
const tracy = @import("tracy");
|
const tracy = @import("tracy");
|
||||||
@ -14,9 +15,10 @@ const log = std.log.scoped(.main);
|
|||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
// Output some debug information right away
|
// Output some debug information right away
|
||||||
log.info("dependency versions harfbuzz={s}", .{
|
log.info("dependency harfbuzz={s}", .{harfbuzz.versionString()});
|
||||||
harfbuzz.versionString(),
|
if (builtin.os.tag == .linux) {
|
||||||
});
|
log.info("dependency fontconfig={d}", .{fontconfig.version()});
|
||||||
|
}
|
||||||
|
|
||||||
const gpa = gpa: {
|
const gpa = gpa: {
|
||||||
// Use the libc allocator if it is available beacuse it is WAY
|
// Use the libc allocator if it is available beacuse it is WAY
|
||||||
|
1
vendor/zig-libxml2
vendored
Submodule
1
vendor/zig-libxml2
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 559e909eeda65508b0a3b7c1c5107f6621fe8218
|
Reference in New Issue
Block a user