diff --git a/.gitmodules b/.gitmodules index 89a90e84a..a7820d48f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/build.zig b/build.zig index b2abfa4f5..ae687cd72 100644 --- a/build.zig +++ b/build.zig @@ -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, .{}); diff --git a/pkg/fontconfig/build.zig b/pkg/fontconfig/build.zig index 07bdc4726..bb1456c1d 100644 --- a/pkg/fontconfig/build.zig +++ b/pkg/fontconfig/build.zig @@ -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=\"