mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 01:06:08 +03:00
freetype builds in png support, uses our own zlib
This commit is contained in:
11
build.zig
11
build.zig
@ -145,11 +145,12 @@ fn addDeps(
|
||||
step.addIncludeDir("vendor/glad/include/");
|
||||
step.addCSourceFile("vendor/glad/src/gl.c", &.{});
|
||||
|
||||
// Dependencies of other dependencies
|
||||
const zlib_step = try zlib.link(b, step);
|
||||
const libpng_step = try libpng.link(b, step, .{
|
||||
.zlib = .{
|
||||
.step = zlib_step,
|
||||
.include = zlib.include_path,
|
||||
.include = &zlib.include_paths,
|
||||
},
|
||||
});
|
||||
|
||||
@ -157,7 +158,15 @@ fn addDeps(
|
||||
step.addPackage(freetype.pkg);
|
||||
_ = try freetype.link(b, step, .{
|
||||
.libpng = freetype.Options.Libpng{
|
||||
.enabled = true,
|
||||
.step = libpng_step,
|
||||
.include = &libpng.include_paths,
|
||||
},
|
||||
|
||||
.zlib = .{
|
||||
.enabled = true,
|
||||
.step = zlib_step,
|
||||
.include = &zlib.include_paths,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -16,11 +16,18 @@ fn thisDir() []const u8 {
|
||||
|
||||
pub const Options = struct {
|
||||
libpng: Libpng = .{},
|
||||
zlib: Zlib = .{},
|
||||
|
||||
pub const Libpng = struct {
|
||||
enabled: bool = false,
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const u8 = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
|
||||
pub const Zlib = struct {
|
||||
enabled: bool = false,
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
};
|
||||
|
||||
@ -57,8 +64,17 @@ pub fn buildFreetype(
|
||||
else
|
||||
lib.linkSystemLibrary("libpng");
|
||||
|
||||
if (opt.libpng.include) |dir|
|
||||
lib.addIncludePath(dir);
|
||||
if (opt.libpng.include) |dirs|
|
||||
for (dirs) |dir| lib.addIncludePath(dir);
|
||||
}
|
||||
if (opt.zlib.enabled) {
|
||||
if (opt.zlib.step) |zlib|
|
||||
lib.linkLibrary(zlib)
|
||||
else
|
||||
lib.linkSystemLibrary("z");
|
||||
|
||||
if (opt.zlib.include) |dirs|
|
||||
for (dirs) |dir| lib.addIncludePath(dir);
|
||||
}
|
||||
|
||||
// Compile
|
||||
@ -71,7 +87,8 @@ pub fn buildFreetype(
|
||||
"-DHAVE_UNISTD_H",
|
||||
"-DHAVE_FCNTL_H",
|
||||
});
|
||||
if (opt.libpng.enabled) try flags.append("-DFT_CONFIG_OPTION_USE_PNG");
|
||||
if (opt.libpng.enabled) try flags.append("-DFT_CONFIG_OPTION_USE_PNG=1");
|
||||
if (opt.zlib.enabled) try flags.append("-DFT_CONFIG_OPTION_SYSTEM_ZLIB=1");
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
|
@ -5,6 +5,8 @@ const root = thisDir() ++ "../../../vendor/libpng/";
|
||||
const include_path = root;
|
||||
const include_path_pnglibconf = thisDir();
|
||||
|
||||
pub const include_paths = .{ include_path, include_path_pnglibconf };
|
||||
|
||||
pub const pkg = std.build.Pkg{
|
||||
.name = "libpng",
|
||||
.source = .{ .path = thisDir() ++ "/main.zig" },
|
||||
@ -19,7 +21,7 @@ pub const Options = struct {
|
||||
|
||||
pub const Zlib = struct {
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const u8 = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
};
|
||||
|
||||
@ -59,8 +61,8 @@ pub fn buildLib(
|
||||
else
|
||||
lib.linkSystemLibrary("z");
|
||||
|
||||
if (opt.zlib.include) |dir|
|
||||
lib.addIncludePath(dir);
|
||||
if (opt.zlib.include) |dirs|
|
||||
for (dirs) |dir| lib.addIncludePath(dir);
|
||||
|
||||
// Compile
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
|
@ -2,7 +2,9 @@ const std = @import("std");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/zlib/";
|
||||
pub const include_path = root;
|
||||
const include_path = root;
|
||||
|
||||
pub const include_paths = .{include_path};
|
||||
|
||||
pub const pkg = std.build.Pkg{
|
||||
.name = "zlib",
|
||||
|
Reference in New Issue
Block a user