build fontconfig

This commit is contained in:
Mitchell Hashimoto
2022-09-13 14:34:40 -07:00
parent d422d1ee78
commit 59191b05cd
6 changed files with 47 additions and 9 deletions

3
.gitmodules vendored
View File

@ -25,3 +25,6 @@
[submodule "vendor/harfbuzz"]
path = vendor/harfbuzz
url = https://github.com/harfbuzz/harfbuzz.git
[submodule "vendor/zig-libxml2"]
path = vendor/zig-libxml2
url = https://github.com/mitchellh/zig-libxml2.git

View File

@ -3,8 +3,10 @@ const fs = std.fs;
const Builder = std.build.Builder;
const LibExeObjStep = std.build.LibExeObjStep;
const glfw = @import("vendor/mach/glfw/build.zig");
const fontconfig = @import("pkg/fontconfig/build.zig");
const freetype = @import("pkg/freetype/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 libpng = @import("pkg/libpng/build.zig");
const utf8proc = @import("pkg/utf8proc/build.zig");
@ -156,6 +158,7 @@ fn addDeps(
static: bool,
) !void {
// We always need the Zig packages
step.addPackage(fontconfig.pkg);
step.addPackage(freetype.pkg);
step.addPackage(harfbuzz.pkg);
step.addPackage(glfw.pkg);
@ -186,6 +189,7 @@ fn addDeps(
if (!static) {
step.addIncludePath(freetype.include_path_self);
step.linkSystemLibrary("bzip2");
step.linkSystemLibrary("fontconfig");
step.linkSystemLibrary("freetype2");
step.linkSystemLibrary("harfbuzz");
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
const libuv_step = try libuv.link(b, step);
system_sdk.include(b, libuv_step, .{});

View File

@ -20,6 +20,7 @@ fn thisDir() []const u8 {
pub const Options = struct {
freetype: Freetype = .{},
expat: Expat = .{},
libxml2: bool = false,
pub const Freetype = struct {
enabled: bool = false,
@ -109,8 +110,8 @@ pub fn buildFontconfig(
"-DHAVE_MKDTEMP",
"-DHAVE_GETOPT",
"-DHAVE_GETOPT_LONG",
"-DHAVE_GETPROGNAME",
"-DHAVE_GETEXECNAME",
//"-DHAVE_GETPROGNAME",
//"-DHAVE_GETEXECNAME",
"-DHAVE_RAND",
"-DHAVE_RANDOM",
"-DHAVE_LRAND48",
@ -158,13 +159,19 @@ pub fn buildFontconfig(
else => @panic("unsupported arch"),
}
if (opt.libxml2) {
try flags.appendSlice(&.{
"-DENABLE_LIBXML2",
});
}
if (!target.isWindows()) {
try flags.appendSlice(&.{
"-DHAVE_PTHREAD",
"-DFC_CACHEDIR=\"/usr/local/fontconfig/cache\"",
"-DFC_TEMPLATEDIR=\"/usr/local/fontconfig/templates\"",
"-DFONTCONFIG_PATH=\"/usr/local/fontconfig/fonts\"",
"-DFC_CACHEDIR=\"/var/cache/fontconfig\"",
"-DFC_TEMPLATEDIR=\"/usr/share/fontconfig/conf.avail\"",
"-DFONTCONFIG_PATH=\"/etc/fonts\"",
"-DCONFIGDIR=\"/usr/local/fontconfig/conf.d\"",
"-DFC_DEFAULT_FONTS=\"<dir>/usr/share/fonts</dir><dir>/usr/local/share/fonts</dir>\"",
});

View File

@ -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%.
var i: usize = 0;
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| {
switch (terminal.parse_table.table[c][@enumToInt(terminal.Parser.State.ground)].action) {
// Print, call directly.

View File

@ -2,6 +2,7 @@ const builtin = @import("builtin");
const options = @import("build_options");
const std = @import("std");
const glfw = @import("glfw");
const fontconfig = @import("fontconfig");
const freetype = @import("freetype");
const harfbuzz = @import("harfbuzz");
const tracy = @import("tracy");
@ -14,9 +15,10 @@ const log = std.log.scoped(.main);
pub fn main() !void {
// Output some debug information right away
log.info("dependency versions harfbuzz={s}", .{
harfbuzz.versionString(),
});
log.info("dependency harfbuzz={s}", .{harfbuzz.versionString()});
if (builtin.os.tag == .linux) {
log.info("dependency fontconfig={d}", .{fontconfig.version()});
}
const gpa = gpa: {
// Use the libc allocator if it is available beacuse it is WAY

1
vendor/zig-libxml2 vendored Submodule

@ -0,0 +1 @@
Subproject commit 559e909eeda65508b0a3b7c1c5107f6621fe8218