freetype: improve build system
This commit is contained in:
parent
997328ddc6
commit
ef7904bf27
24 changed files with 36 additions and 74 deletions
|
|
@ -6,6 +6,11 @@ const ft_include_path = ft_root ++ "/include";
|
|||
const hb_root = thisDir() ++ "/upstream/harfbuzz";
|
||||
const hb_include_path = hb_root ++ "/src";
|
||||
|
||||
const c_pkg = std.build.Pkg{
|
||||
.name = "c",
|
||||
.source = .{ .path = thisDir() ++ "/src/c.zig" },
|
||||
};
|
||||
|
||||
const utils_pkg = std.build.Pkg{
|
||||
.name = "utils",
|
||||
.source = .{ .path = thisDir() ++ "/src/utils.zig" },
|
||||
|
|
@ -14,13 +19,13 @@ const utils_pkg = std.build.Pkg{
|
|||
pub const pkg = std.build.Pkg{
|
||||
.name = "freetype",
|
||||
.source = .{ .path = thisDir() ++ "/src/freetype/main.zig" },
|
||||
.dependencies = &.{utils_pkg},
|
||||
.dependencies = &.{ c_pkg, utils_pkg },
|
||||
};
|
||||
|
||||
pub const harfbuzz_pkg = std.build.Pkg{
|
||||
.name = "harfbuzz",
|
||||
.source = .{ .path = thisDir() ++ "/src/harfbuzz/main.zig" },
|
||||
.dependencies = &.{utils_pkg},
|
||||
.dependencies = &.{ c_pkg, utils_pkg, pkg },
|
||||
};
|
||||
|
||||
pub const Options = struct {
|
||||
|
|
@ -44,18 +49,22 @@ pub fn build(b: *std.build.Builder) !void {
|
|||
const freetype_tests = b.addTestSource(pkg.source);
|
||||
freetype_tests.setBuildMode(mode);
|
||||
freetype_tests.setTarget(target);
|
||||
freetype_tests.addPackage(c_pkg);
|
||||
freetype_tests.addPackage(utils_pkg);
|
||||
link(b, freetype_tests, .{});
|
||||
|
||||
const harfbuzz_tests = b.addTestSource(harfbuzz_pkg.source);
|
||||
harfbuzz_tests.setBuildMode(mode);
|
||||
harfbuzz_tests.setTarget(target);
|
||||
harfbuzz_tests.addPackage(c_pkg);
|
||||
harfbuzz_tests.addPackage(utils_pkg);
|
||||
harfbuzz_tests.addPackage(pkg);
|
||||
link(b, harfbuzz_tests, .{ .harfbuzz = .{} });
|
||||
|
||||
const main_tests = b.addTest("test/main.zig");
|
||||
main_tests.setBuildMode(mode);
|
||||
main_tests.setTarget(target);
|
||||
main_tests.addPackage(c_pkg);
|
||||
main_tests.addPackage(pkg);
|
||||
link(b, main_tests, .{ .freetype = .{ .ft_config_path = "./test/ft" } });
|
||||
|
||||
|
|
@ -93,12 +102,11 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
|
|||
const ft_lib = buildFreetype(b, step, options.freetype);
|
||||
step.linkLibrary(ft_lib);
|
||||
step.addIncludePath(ft_include_path);
|
||||
step.addIncludePath(hb_include_path);
|
||||
|
||||
if (options.harfbuzz) |hb_options| {
|
||||
const hb_lib = buildHarfbuzz(b, step, hb_options);
|
||||
hb_lib.linkLibrary(ft_lib);
|
||||
step.linkLibrary(hb_lib);
|
||||
step.addIncludePath(hb_include_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +155,8 @@ pub fn buildHarfbuzz(b: *Builder, step: *std.build.LibExeObjStep, options: Harfb
|
|||
lib.setTarget(step.target);
|
||||
lib.linkLibCpp();
|
||||
lib.addIncludePath(hb_include_path);
|
||||
lib.addCSourceFiles(harfbuzz_base_sources, &.{});
|
||||
lib.addIncludePath(ft_include_path);
|
||||
lib.defineCMacro("HAVE_FREETYPE", "1");
|
||||
lib.install();
|
||||
return lib;
|
||||
}
|
||||
|
|
@ -209,44 +218,3 @@ const freetype_base_sources = &[_][]const u8{
|
|||
ft_root ++ "/src/type42/type42.c",
|
||||
ft_root ++ "/src/winfonts/winfnt.c",
|
||||
};
|
||||
|
||||
const harfbuzz_base_sources = &[_][]const u8{
|
||||
hb_root ++ "/src/hb-aat-layout.cc",
|
||||
hb_root ++ "/src/hb-aat-map.cc",
|
||||
hb_root ++ "/src/hb-blob.cc",
|
||||
hb_root ++ "/src/hb-buffer-serialize.cc",
|
||||
hb_root ++ "/src/hb-buffer-verify.cc",
|
||||
hb_root ++ "/src/hb-buffer.cc",
|
||||
hb_root ++ "/src/hb-common.cc",
|
||||
hb_root ++ "/src/hb-draw.cc",
|
||||
hb_root ++ "/src/hb-face.cc",
|
||||
hb_root ++ "/src/hb-fallback-shape.cc",
|
||||
hb_root ++ "/src/hb-font.cc",
|
||||
hb_root ++ "/src/hb-map.cc",
|
||||
hb_root ++ "/src/hb-number.cc",
|
||||
hb_root ++ "/src/hb-ot-cff1-table.cc",
|
||||
hb_root ++ "/src/hb-ot-cff2-table.cc",
|
||||
hb_root ++ "/src/hb-ot-color.cc",
|
||||
hb_root ++ "/src/hb-ot-face.cc",
|
||||
hb_root ++ "/src/hb-ot-font.cc",
|
||||
hb_root ++ "/src/hb-ot-layout.cc",
|
||||
hb_root ++ "/src/hb-ot-map.cc",
|
||||
hb_root ++ "/src/hb-ot-math.cc",
|
||||
hb_root ++ "/src/hb-ot-meta.cc",
|
||||
hb_root ++ "/src/hb-ot-metrics.cc",
|
||||
hb_root ++ "/src/hb-ot-name.cc",
|
||||
hb_root ++ "/src/hb-ot-shape-fallback.cc",
|
||||
hb_root ++ "/src/hb-ot-shape-normalize.cc",
|
||||
hb_root ++ "/src/hb-ot-shape.cc",
|
||||
hb_root ++ "/src/hb-ot-tag.cc",
|
||||
hb_root ++ "/src/hb-ot-var.cc",
|
||||
hb_root ++ "/src/hb-set.cc",
|
||||
hb_root ++ "/src/hb-shape-plan.cc",
|
||||
hb_root ++ "/src/hb-shape.cc",
|
||||
hb_root ++ "/src/hb-shaper.cc",
|
||||
hb_root ++ "/src/hb-static.cc",
|
||||
hb_root ++ "/src/hb-style.cc",
|
||||
hb_root ++ "/src/hb-ucd.cc",
|
||||
hb_root ++ "/src/hb-unicode.cc",
|
||||
hb_root ++ "/src/hb-ft.cc", // freetype integration
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
pub usingnamespace @cImport({
|
||||
@cInclude("freetype/freetype.h");
|
||||
@cInclude("hb-ft.h");
|
||||
@cInclude("freetype/ftbbox.h");
|
||||
@cInclude("freetype/ftcolor.h");
|
||||
@cInclude("freetype/ftlcdfil.h");
|
||||
@cInclude("freetype/ftmodapi.h");
|
||||
@cInclude("freetype/ftsizes.h");
|
||||
@cInclude("freetype/ftstroke.h");
|
||||
@cInclude("freetype/ftsystem.h");
|
||||
@cInclude("ft2build.h");
|
||||
});
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
const std = @import("std");
|
||||
const utils = @import("utils");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
const GlyphSlot = @import("freetype.zig").GlyphSlot;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
const Stroker = @import("Stroker.zig");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
const Glyph = @import("Glyph.zig");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
const Stroker = @import("Stroker.zig");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const errorToInt = @import("error.zig").errorToInt;
|
||||
const Error = @import("error.zig").Error;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
|
||||
const Stroker = @This();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const utils = @import("utils");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const Face = @import("freetype.zig").Face;
|
||||
|
||||
pub const Color = c.FT_Color;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
|
||||
pub const Error = error{
|
||||
CannotOpenResource,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const std = @import("std");
|
||||
const utils = @import("utils");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
const Generic = @import("types.zig").Generic;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
|
||||
pub const Outline = @import("Outline.zig");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
|
||||
pub const LcdFilter = enum(u5) {
|
||||
none = c.FT_LCD_FILTER_NONE,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ pub usingnamespace @import("types.zig");
|
|||
pub usingnamespace @import("image.zig");
|
||||
pub usingnamespace @import("color.zig");
|
||||
pub usingnamespace @import("lcdfilter.zig");
|
||||
pub const c = @import("c.zig");
|
||||
pub const c = @import("c");
|
||||
pub const Glyph = @import("Glyph.zig");
|
||||
pub const Stroker = @import("Stroker.zig");
|
||||
pub const Error = @import("error.zig").Error;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
|
||||
pub const Matrix = c.FT_Matrix;
|
||||
pub const Generic = c.FT_Generic;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
|
||||
pub const MemoryMode = enum(u2) {
|
||||
duplicate = c.HB_MEMORY_MODE_DUPLICATE,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const std = @import("std");
|
||||
const utils = @import("utils");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const Direction = @import("common.zig").Direction;
|
||||
const Script = @import("common.zig").Script;
|
||||
const Language = @import("common.zig").Language;
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
pub usingnamespace @cImport({
|
||||
@cInclude("hb.h");
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
|
||||
pub const Direction = enum(u3) {
|
||||
invalid = c.HB_DIRECTION_INVALID,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const Blob = @import("blob.zig").Blob;
|
||||
|
||||
pub const UnicodeIterator = struct {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const Face = @import("face.zig").Face;
|
||||
const Buffer = @import("buffer.zig").Buffer;
|
||||
const Feature = @import("common.zig").Feature;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ pub usingnamespace @import("face.zig");
|
|||
pub usingnamespace @import("font.zig");
|
||||
pub usingnamespace @import("shape.zig");
|
||||
pub usingnamespace @import("shape_plan.zig");
|
||||
pub const c = @import("c.zig");
|
||||
pub const c = @import("c");
|
||||
|
||||
const utils = @import("utils");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
|
||||
pub const ListShapers = struct {
|
||||
index: usize,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
const c = @import("c");
|
||||
const Buffer = @import("buffer.zig").Buffer;
|
||||
const Font = @import("font.zig").Font;
|
||||
const Face = @import("face.zig").Face;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue