mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Merge pull request #603 from mitchellh/zig-pkg2
Adopt Zig Package Manager, drop most submodules
This commit is contained in:
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@ -8,14 +8,16 @@ jobs:
|
||||
os: [ubuntu-latest]
|
||||
|
||||
target: [
|
||||
aarch64-macos,
|
||||
x86_64-macos,
|
||||
|
||||
aarch64-linux-gnu,
|
||||
x86_64-linux-gnu,
|
||||
# No windows support currently.
|
||||
# i386-windows,
|
||||
# x86_64-windows-gnu,
|
||||
|
||||
# We don't support cross-compiling to macOS because the macOS build
|
||||
# requires xcode due to the swift harness.
|
||||
#aarch64-macos,
|
||||
#x86_64-macos,
|
||||
]
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: test
|
||||
|
42
.gitmodules
vendored
42
.gitmodules
vendored
@ -1,42 +1,6 @@
|
||||
[submodule "vendor/freetype"]
|
||||
path = vendor/freetype
|
||||
url = https://github.com/freetype/freetype.git
|
||||
[submodule "vendor/tracy"]
|
||||
path = vendor/tracy
|
||||
url = https://github.com/wolfpld/tracy.git
|
||||
[submodule "vendor/mach-sdk/sdk-linux-aarch64"]
|
||||
path = vendor/mach-sdk/sdk-linux-aarch64
|
||||
url = https://github.com/hexops/sdk-linux-aarch64.git
|
||||
[submodule "vendor/zlib"]
|
||||
path = vendor/zlib
|
||||
url = https://github.com/madler/zlib.git
|
||||
[submodule "vendor/libpng"]
|
||||
path = vendor/libpng
|
||||
url = https://github.com/glennrp/libpng.git
|
||||
[submodule "vendor/utf8proc"]
|
||||
path = vendor/utf8proc
|
||||
url = https://github.com/JuliaStrings/utf8proc.git
|
||||
[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
|
||||
[submodule "vendor/cimgui"]
|
||||
path = vendor/cimgui
|
||||
url = https://github.com/cimgui/cimgui.git
|
||||
[submodule "vendor/zig-js"]
|
||||
path = vendor/zig-js
|
||||
url = https://github.com/mitchellh/zig-js.git
|
||||
[submodule "vendor/zig-objc"]
|
||||
path = vendor/zig-objc
|
||||
url = https://github.com/mitchellh/zig-objc.git
|
||||
[submodule "vendor/libxev"]
|
||||
path = vendor/libxev
|
||||
url = https://github.com/mitchellh/libxev.git
|
||||
[submodule "vendor/mach-sdk/sdk-linux-x86_64"]
|
||||
path = vendor/mach-sdk/sdk-linux-x86_64
|
||||
url = https://github.com/hexops/sdk-linux-x86_64.git
|
||||
[submodule "vendor/mach-glfw"]
|
||||
path = vendor/mach-glfw
|
||||
url = https://github.com/mitchellh/mach-glfw.git
|
||||
[submodule "vendor/libxml2"]
|
||||
path = vendor/libxml2
|
||||
url = https://github.com/GNOME/libxml2.git
|
||||
|
290
build.zig
290
build.zig
@ -14,22 +14,6 @@ const LipoStep = @import("src/build/LipoStep.zig");
|
||||
const XCFrameworkStep = @import("src/build/XCFrameworkStep.zig");
|
||||
const Version = @import("src/build/Version.zig");
|
||||
|
||||
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 js = @import("vendor/zig-js/build.zig");
|
||||
const libxev = @import("vendor/libxev/build.zig");
|
||||
const libxml2 = @import("vendor/zig-libxml2/libxml2.zig");
|
||||
const libpng = @import("pkg/libpng/build.zig");
|
||||
const macos = @import("pkg/macos/build.zig");
|
||||
const objc = @import("vendor/zig-objc/build.zig");
|
||||
const pixman = @import("pkg/pixman/build.zig");
|
||||
const utf8proc = @import("pkg/utf8proc/build.zig");
|
||||
const zlib = @import("pkg/zlib/build.zig");
|
||||
const tracylib = @import("pkg/tracy/build.zig");
|
||||
const system_sdk = @import("vendor/mach-glfw/system_sdk.zig");
|
||||
|
||||
// Do a comptime Zig version requirement. The required Zig version is
|
||||
// somewhat arbitrary: it is meant to be a version that we feel works well,
|
||||
// but we liberally update it. In the future, we'll be more careful about
|
||||
@ -610,33 +594,6 @@ pub fn build(b: *std.Build) !void {
|
||||
const test_run = b.addRunArtifact(main_test);
|
||||
test_step.dependOn(&test_run.step);
|
||||
}
|
||||
|
||||
// Named package dependencies don't have their tests run by reference,
|
||||
// so we iterate through them here. We're only interested in dependencies
|
||||
// we wrote (are in the "pkg/" directory).
|
||||
var it = main_test.modules.iterator();
|
||||
while (it.next()) |entry| {
|
||||
const name = entry.key_ptr.*;
|
||||
const module = entry.value_ptr.*;
|
||||
if (std.mem.eql(u8, name, "build_options")) continue;
|
||||
if (std.mem.eql(u8, name, "glfw")) continue;
|
||||
|
||||
const test_exe = b.addTest(.{
|
||||
.name = b.fmt("{s}-test", .{name}),
|
||||
.root_source_file = module.source_file,
|
||||
.target = target,
|
||||
});
|
||||
if (emit_test_exe) b.installArtifact(test_exe);
|
||||
|
||||
_ = try addDeps(b, test_exe, true);
|
||||
// if (pkg.dependencies) |children| {
|
||||
// test_.packages = std.ArrayList(std.build.Pkg).init(b.allocator);
|
||||
// try test_.packages.appendSlice(children);
|
||||
// }
|
||||
|
||||
const test_run = b.addRunArtifact(test_exe);
|
||||
test_step.dependOn(&test_run.step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -652,20 +609,6 @@ fn addDeps(
|
||||
var static_libs = FileSourceList.init(b.allocator);
|
||||
errdefer static_libs.deinit();
|
||||
|
||||
// Wasm we do manually since it is such a different build.
|
||||
if (step.target.getCpuArch() == .wasm32) {
|
||||
// We link this package but its a no-op since Tracy
|
||||
// never actually WORKS with wasm.
|
||||
step.addModule("tracy", tracylib.module(b));
|
||||
step.addModule("utf8proc", utf8proc.module(b));
|
||||
step.addModule("zig-js", js.module(b));
|
||||
|
||||
// utf8proc
|
||||
_ = try utf8proc.link(b, step);
|
||||
|
||||
return static_libs;
|
||||
}
|
||||
|
||||
// For dynamic linking, we prefer dynamic linking and to search by
|
||||
// mode first. Mode first will search all paths for a dynamic library
|
||||
// before falling back to static.
|
||||
@ -674,6 +617,68 @@ fn addDeps(
|
||||
.search_strategy = .mode_first,
|
||||
};
|
||||
|
||||
// Dependencies
|
||||
const js_dep = b.dependency("zig_js", .{ .target = step.target, .optimize = step.optimize });
|
||||
const libxev_dep = b.dependency("libxev", .{ .target = step.target, .optimize = step.optimize });
|
||||
const objc_dep = b.dependency("zig_objc", .{ .target = step.target, .optimize = step.optimize });
|
||||
const fontconfig_dep = b.dependency("fontconfig", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
const freetype_dep = b.dependency("freetype", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.@"enable-libpng" = true,
|
||||
});
|
||||
const mach_glfw_dep = b.dependency("mach_glfw", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
const libpng_dep = b.dependency("libpng", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
const macos_dep = b.dependency("macos", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
const pixman_dep = b.dependency("pixman", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
const tracy_dep = b.dependency("tracy", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
const zlib_dep = b.dependency("zlib", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
const utf8proc_dep = b.dependency("utf8proc", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
const harfbuzz_dep = b.dependency("harfbuzz", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.@"enable-freetype" = true,
|
||||
.@"enable-coretext" = font_backend.hasCoretext(),
|
||||
});
|
||||
|
||||
// Wasm we do manually since it is such a different build.
|
||||
if (step.target.getCpuArch() == .wasm32) {
|
||||
// We link this package but its a no-op since Tracy
|
||||
// never actually WORKS with wasm.
|
||||
step.addModule("tracy", tracy_dep.module("tracy"));
|
||||
step.addModule("utf8proc", utf8proc_dep.module("utf8proc"));
|
||||
step.addModule("zig-js", js_dep.module("zig-js"));
|
||||
|
||||
// utf8proc
|
||||
step.linkLibrary(utf8proc_dep.artifact("utf8proc"));
|
||||
|
||||
return static_libs;
|
||||
}
|
||||
|
||||
// On Linux, we need to add a couple common library paths that aren't
|
||||
// on the standard search list. i.e. GTK is often in /usr/lib/x86_64-linux-gnu
|
||||
// on x86_64.
|
||||
@ -692,50 +697,43 @@ fn addDeps(
|
||||
|
||||
// We always require the system SDK so that our system headers are available.
|
||||
// This makes things like `os/log.h` available for cross-compiling.
|
||||
system_sdk.include(b, step, .{});
|
||||
try addSystemSDK(b, step);
|
||||
|
||||
// We always need the Zig packages
|
||||
// TODO: This can't be the right way to use the new Zig modules system,
|
||||
// so take a closer look at this again later.
|
||||
if (font_backend.hasFontconfig()) step.addModule("fontconfig", fontconfig.module(b));
|
||||
const mod_freetype = freetype.module(b);
|
||||
const mod_macos = macos.module(b);
|
||||
const mod_libxev = b.createModule(.{
|
||||
.source_file = .{ .path = "vendor/libxev/src/main.zig" },
|
||||
});
|
||||
step.addModule("freetype", mod_freetype);
|
||||
step.addModule("harfbuzz", harfbuzz.module(b, .{
|
||||
.freetype = mod_freetype,
|
||||
.macos = mod_macos,
|
||||
}));
|
||||
step.addModule("xev", mod_libxev);
|
||||
step.addModule("pixman", pixman.module(b));
|
||||
step.addModule("utf8proc", utf8proc.module(b));
|
||||
if (font_backend.hasFontconfig()) step.addModule(
|
||||
"fontconfig",
|
||||
fontconfig_dep.module("fontconfig"),
|
||||
);
|
||||
step.addModule("freetype", freetype_dep.module("freetype"));
|
||||
step.addModule("harfbuzz", harfbuzz_dep.module("harfbuzz"));
|
||||
step.addModule("xev", libxev_dep.module("xev"));
|
||||
step.addModule("pixman", pixman_dep.module("pixman"));
|
||||
step.addModule("utf8proc", utf8proc_dep.module("utf8proc"));
|
||||
|
||||
// Mac Stuff
|
||||
if (step.target.isDarwin()) {
|
||||
step.addModule("objc", objc.module(b));
|
||||
step.addModule("macos", mod_macos);
|
||||
_ = try macos.link(b, step, .{});
|
||||
|
||||
// todo: do this is in zig-objc instead.
|
||||
step.linkSystemLibraryName("objc");
|
||||
step.addModule("objc", objc_dep.module("objc"));
|
||||
step.addModule("macos", macos_dep.module("macos"));
|
||||
step.linkLibrary(macos_dep.artifact("macos"));
|
||||
try static_libs.append(macos_dep.artifact("macos").getEmittedBin());
|
||||
}
|
||||
|
||||
// Tracy
|
||||
step.addModule("tracy", tracylib.module(b));
|
||||
step.addModule("tracy", tracy_dep.module("tracy"));
|
||||
if (tracy) {
|
||||
var tracy_step = try tracylib.link(b, step);
|
||||
system_sdk.include(b, tracy_step, .{});
|
||||
step.linkLibrary(tracy_dep.artifact("tracy"));
|
||||
try static_libs.append(tracy_dep.artifact("tracy").getEmittedBin());
|
||||
}
|
||||
|
||||
// utf8proc
|
||||
const utf8proc_step = try utf8proc.link(b, step);
|
||||
try static_libs.append(utf8proc_step.getEmittedBin());
|
||||
step.linkLibrary(utf8proc_dep.artifact("utf8proc"));
|
||||
try static_libs.append(utf8proc_dep.artifact("utf8proc").getEmittedBin());
|
||||
|
||||
// Dynamic link
|
||||
if (!static) {
|
||||
step.addIncludePath(.{ .path = freetype.include_path_self });
|
||||
step.addIncludePath(freetype_dep.path(""));
|
||||
step.linkSystemLibrary2("bzip2", dynamic_link_opts);
|
||||
step.linkSystemLibrary2("freetype2", dynamic_link_opts);
|
||||
step.linkSystemLibrary2("harfbuzz", dynamic_link_opts);
|
||||
@ -750,78 +748,28 @@ fn addDeps(
|
||||
|
||||
// Other dependencies, we may dynamically link
|
||||
if (static) {
|
||||
const zlib_step = try zlib.link(b, step);
|
||||
try static_libs.append(zlib_step.getEmittedBin());
|
||||
step.linkLibrary(zlib_dep.artifact("z"));
|
||||
try static_libs.append(zlib_dep.artifact("z").getEmittedBin());
|
||||
|
||||
const libpng_step = try libpng.link(b, step, .{
|
||||
.zlib = .{
|
||||
.step = zlib_step,
|
||||
.include = &zlib.include_paths,
|
||||
},
|
||||
});
|
||||
try static_libs.append(libpng_step.getEmittedBin());
|
||||
step.linkLibrary(libpng_dep.artifact("png"));
|
||||
try static_libs.append(libpng_dep.artifact("png").getEmittedBin());
|
||||
|
||||
// Freetype
|
||||
const freetype_step = 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,
|
||||
},
|
||||
});
|
||||
try static_libs.append(freetype_step.getEmittedBin());
|
||||
step.linkLibrary(freetype_dep.artifact("freetype"));
|
||||
try static_libs.append(freetype_dep.artifact("freetype").getEmittedBin());
|
||||
|
||||
// Harfbuzz
|
||||
const harfbuzz_step = try harfbuzz.link(b, step, .{
|
||||
.freetype = .{
|
||||
.enabled = true,
|
||||
.step = freetype_step,
|
||||
.include = &freetype.include_paths,
|
||||
},
|
||||
|
||||
.coretext = .{
|
||||
.enabled = font_backend.hasCoretext(),
|
||||
},
|
||||
});
|
||||
system_sdk.include(b, harfbuzz_step, .{});
|
||||
try static_libs.append(harfbuzz_step.getEmittedBin());
|
||||
step.linkLibrary(harfbuzz_dep.artifact("harfbuzz"));
|
||||
try static_libs.append(harfbuzz_dep.artifact("harfbuzz").getEmittedBin());
|
||||
|
||||
// Pixman
|
||||
const pixman_step = try pixman.link(b, step, .{});
|
||||
try static_libs.append(pixman_step.getEmittedBin());
|
||||
step.linkLibrary(pixman_dep.artifact("pixman"));
|
||||
try static_libs.append(pixman_dep.artifact("pixman").getEmittedBin());
|
||||
|
||||
// Only Linux gets fontconfig
|
||||
if (font_backend.hasFontconfig()) {
|
||||
// Libxml2
|
||||
const libxml2_lib = try libxml2.create(
|
||||
b,
|
||||
step.target,
|
||||
step.optimize,
|
||||
.{
|
||||
.lzma = false,
|
||||
.zlib = false,
|
||||
.iconv = !step.target.isWindows(),
|
||||
},
|
||||
);
|
||||
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);
|
||||
step.linkLibrary(fontconfig_dep.artifact("fontconfig"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -837,26 +785,29 @@ fn addDeps(
|
||||
// get access to glib for dbus.
|
||||
if (flatpak) step.linkSystemLibrary2("gtk4", dynamic_link_opts);
|
||||
|
||||
// We may link GLFW below
|
||||
const glfw_dep = b.dependency("glfw", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.x11 = step.target.isLinux(),
|
||||
.wayland = step.target.isLinux(),
|
||||
.metal = step.target.isDarwin(),
|
||||
});
|
||||
|
||||
switch (app_runtime) {
|
||||
.none => {},
|
||||
|
||||
.glfw => {
|
||||
step.addModule("glfw", glfw.module(b));
|
||||
const glfw_opts: glfw.Options = .{
|
||||
.metal = step.target.isDarwin(),
|
||||
.opengl = false,
|
||||
};
|
||||
try glfw.link(b, step, glfw_opts);
|
||||
step.addModule("glfw", mach_glfw_dep.module("mach-glfw"));
|
||||
step.linkLibrary(mach_glfw_dep.artifact("mach-glfw"));
|
||||
step.linkLibrary(glfw_dep.artifact("glfw"));
|
||||
},
|
||||
|
||||
.gtk => {
|
||||
// We need glfw for GTK because we use GLFW to get DPI.
|
||||
step.addModule("glfw", glfw.module(b));
|
||||
const glfw_opts: glfw.Options = .{
|
||||
.metal = step.target.isDarwin(),
|
||||
.opengl = false,
|
||||
};
|
||||
try glfw.link(b, step, glfw_opts);
|
||||
step.addModule("glfw", mach_glfw_dep.module("mach-glfw"));
|
||||
step.linkLibrary(mach_glfw_dep.artifact("mach-glfw"));
|
||||
step.linkLibrary(glfw_dep.artifact("glfw"));
|
||||
|
||||
step.linkSystemLibrary2("gtk4", dynamic_link_opts);
|
||||
},
|
||||
@ -866,6 +817,31 @@ fn addDeps(
|
||||
return static_libs;
|
||||
}
|
||||
|
||||
/// Adds the proper system headers for the target.
|
||||
fn addSystemSDK(
|
||||
b: *std.Build,
|
||||
step: *std.Build.CompileStep,
|
||||
) !void {
|
||||
if (step.target.isDarwin()) {
|
||||
try @import("apple_sdk").addPaths(b, step);
|
||||
}
|
||||
|
||||
if (step.target.isLinux()) {
|
||||
step.linkLibrary(b.dependency("x11_headers", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
}).artifact("x11-headers"));
|
||||
}
|
||||
|
||||
// GLFW requires these on all platforms so we just add them here. It
|
||||
// doesn't hurt to add them if we don't use GLFW since they're all
|
||||
// namespaced.
|
||||
step.linkLibrary(b.dependency("vulkan_headers", .{
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
}).artifact("vulkan-headers"));
|
||||
}
|
||||
|
||||
fn benchSteps(
|
||||
b: *std.Build,
|
||||
target: std.zig.CrossTarget,
|
||||
|
50
build.zig.zon
Normal file
50
build.zig.zon
Normal file
@ -0,0 +1,50 @@
|
||||
.{
|
||||
.name = "ghostty",
|
||||
.version = "0.1.0",
|
||||
.dependencies = .{
|
||||
// Zig libs
|
||||
.libxev = .{
|
||||
.url = "https://github.com/mitchellh/libxev/archive/ecbc161a5dace26a1fd47e494f8be2cfd051cbfb.tar.gz",
|
||||
.hash = "1220f34357168affd9aab1a3fcafcaff093c44beb75ce1d4d4b75490e90729221771",
|
||||
},
|
||||
.mach_glfw = .{
|
||||
.url = "https://github.com/hexops/mach-glfw/archive/321efd4065b57e31d8ab0bce720852c1d680d443.tar.gz",
|
||||
.hash = "122002e355cf42b8d257efc95229c9ee6be4cca189c1718f86179cb7c21225beeb75",
|
||||
},
|
||||
.zig_objc = .{
|
||||
.url = "https://github.com/mitchellh/zig-objc/archive/01c16aaeeb674622f4a0e715aeeb16c8ce0bc30e.tar.gz",
|
||||
.hash = "1220f9c919a1171ecf5d097a0d0349e8a9a01b45afa41006dd7eb0afa6243a5fa21f",
|
||||
},
|
||||
.zig_js = .{
|
||||
.url = "https://github.com/mitchellh/zig-js/archive/60ac42ab137461cdba2b38cc6c5e16376470aae6.tar.gz",
|
||||
.hash = "1220319b42fbc0116f3f198343256018e9f1da9483cef259201afe4ebab0ce0d8f6a",
|
||||
},
|
||||
|
||||
.glfw = .{
|
||||
.url = "https://pkg.machengine.org/glfw/92abc63294d389c8f2a546686b6c072930b029e0.tar.gz",
|
||||
.hash = "12205a6ce386007b97e22ef4b78a4f68c98af2cd6e1fde82589191fda79b9de54d0d",
|
||||
},
|
||||
|
||||
// C libs
|
||||
.fontconfig = .{ .path = "./pkg/fontconfig" },
|
||||
.freetype = .{ .path = "./pkg/freetype" },
|
||||
.harfbuzz = .{ .path = "./pkg/harfbuzz" },
|
||||
.libpng = .{ .path = "./pkg/libpng" },
|
||||
.macos = .{ .path = "./pkg/macos" },
|
||||
.pixman = .{ .path = "./pkg/pixman" },
|
||||
.tracy = .{ .path = "./pkg/tracy" },
|
||||
.utf8proc = .{ .path = "./pkg/utf8proc" },
|
||||
.zlib = .{ .path = "./pkg/zlib" },
|
||||
|
||||
// System headers
|
||||
.apple_sdk = .{ .path = "./pkg/apple-sdk" },
|
||||
.vulkan_headers = .{
|
||||
.url = "https://pkg.machengine.org/vulkan-headers/fc495148a910ac7817ce0ec2d5948231806f2ac0.tar.gz",
|
||||
.hash = "12209aeba80369fa8638b82179b47e6742adb98a3a5b01bc518565504a922baad3e4",
|
||||
},
|
||||
.x11_headers = .{
|
||||
.url = "https://pkg.machengine.org/x11-headers/26d12e9fc0d893085bcb711088a4a19afdff1adc.tar.gz",
|
||||
.hash = "1220371a61d8bb57fce8ee1741f623cc19b0edd7d1b4adc9918663f8a7ef08aa4f3f",
|
||||
},
|
||||
},
|
||||
}
|
@ -51,6 +51,7 @@ let
|
||||
freetype
|
||||
harfbuzz
|
||||
libpng
|
||||
pixman
|
||||
zlib
|
||||
|
||||
libX11
|
||||
|
141
pkg/apple-sdk/build.zig
Normal file
141
pkg/apple-sdk/build.zig
Normal file
@ -0,0 +1,141 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "stub",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
lib.linkLibC();
|
||||
lib.addCSourceFiles(&.{"stub.c"}, &.{});
|
||||
try addPaths(b, lib);
|
||||
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
/// Add the necessary paths to the given compilation step for the Xcode SDK.
|
||||
///
|
||||
/// This is required to workaround a Zig issue where we can't depend directly
|
||||
/// on the hexops/xcode-frameworks repository: https://github.com/ziglang/zig/pull/15382
|
||||
///
|
||||
/// This is copied and adapted from hexops/mach. I modified it slightly
|
||||
/// for my own personal taste (nothing wrong with theirs!), but the logic
|
||||
/// is effectively identical.
|
||||
pub fn addPaths(b: *std.Build, step: *std.build.CompileStep) !void {
|
||||
// branch: mach
|
||||
try ensureGitRepoCloned(
|
||||
b.allocator,
|
||||
// WARNING: forked temporarily for https://github.com/hexops/xcode-frameworks/issues/4
|
||||
"https://github.com/mitchellh/xcode-frameworks",
|
||||
"983deb1ab8d03861db30ea297cc78e6d121da4db",
|
||||
xSdkPath("/zig-cache/xcode_frameworks"),
|
||||
);
|
||||
|
||||
// https://github.com/ziglang/zig/issues/17358
|
||||
if (step.target.isNative()) b.sysroot = xSdkPath("/zig-cache/xcode_frameworks");
|
||||
|
||||
step.addSystemFrameworkPath(.{ .path = xSdkPath("/zig-cache/xcode_frameworks/Frameworks") });
|
||||
step.addSystemIncludePath(.{ .path = xSdkPath("/zig-cache/xcode_frameworks/include") });
|
||||
step.addLibraryPath(.{ .path = xSdkPath("/zig-cache/xcode_frameworks/lib") });
|
||||
}
|
||||
|
||||
fn ensureGitRepoCloned(
|
||||
allocator: std.mem.Allocator,
|
||||
clone_url: []const u8,
|
||||
revision: []const u8,
|
||||
dir: []const u8,
|
||||
) !void {
|
||||
if (envVarIsTruthy(allocator, "NO_ENSURE_SUBMODULES") or
|
||||
envVarIsTruthy(allocator, "NO_ENSURE_GIT")) return;
|
||||
|
||||
ensureGit(allocator);
|
||||
|
||||
if (std.fs.openDirAbsolute(dir, .{})) |_| {
|
||||
const current_revision = try currentGitRevision(allocator, dir);
|
||||
if (!std.mem.eql(u8, current_revision, revision)) {
|
||||
// Reset to the desired revision
|
||||
exec(
|
||||
allocator,
|
||||
&[_][]const u8{ "git", "fetch" },
|
||||
dir,
|
||||
) catch |err| std.debug.print(
|
||||
"warning: failed to 'git fetch' in {s}: {s}\n",
|
||||
.{ dir, @errorName(err) },
|
||||
);
|
||||
try exec(allocator, &[_][]const u8{ "git", "checkout", "--quiet", "--force", revision }, dir);
|
||||
try exec(allocator, &[_][]const u8{ "git", "submodule", "update", "--init", "--recursive" }, dir);
|
||||
}
|
||||
return;
|
||||
} else |err| return switch (err) {
|
||||
error.FileNotFound => {
|
||||
std.log.info("cloning required dependency..\ngit clone {s} {s}..\n", .{ clone_url, dir });
|
||||
try exec(allocator, &[_][]const u8{ "git", "clone", "-c", "core.longpaths=true", clone_url, dir }, ".");
|
||||
try exec(allocator, &[_][]const u8{ "git", "checkout", "--quiet", "--force", revision }, dir);
|
||||
try exec(allocator, &[_][]const u8{ "git", "submodule", "update", "--init", "--recursive" }, dir);
|
||||
return;
|
||||
},
|
||||
else => err,
|
||||
};
|
||||
}
|
||||
|
||||
fn exec(
|
||||
allocator: std.mem.Allocator,
|
||||
argv: []const []const u8,
|
||||
cwd: []const u8,
|
||||
) !void {
|
||||
var child = std.ChildProcess.init(argv, allocator);
|
||||
child.cwd = cwd;
|
||||
_ = try child.spawnAndWait();
|
||||
}
|
||||
|
||||
fn currentGitRevision(allocator: std.mem.Allocator, cwd: []const u8) ![]const u8 {
|
||||
const result = try std.ChildProcess.exec(.{
|
||||
.allocator = allocator,
|
||||
.argv = &.{ "git", "rev-parse", "HEAD" },
|
||||
.cwd = cwd,
|
||||
});
|
||||
allocator.free(result.stderr);
|
||||
if (result.stdout.len > 0) return result.stdout[0 .. result.stdout.len - 1]; // trim newline
|
||||
return result.stdout;
|
||||
}
|
||||
|
||||
fn ensureGit(allocator: std.mem.Allocator) void {
|
||||
const argv = &[_][]const u8{ "git", "--version" };
|
||||
const result = std.ChildProcess.exec(.{
|
||||
.allocator = allocator,
|
||||
.argv = argv,
|
||||
.cwd = ".",
|
||||
}) catch { // e.g. FileNotFound
|
||||
std.log.err("mach: error: 'git --version' failed. Is git not installed?", .{});
|
||||
std.process.exit(1);
|
||||
};
|
||||
defer {
|
||||
allocator.free(result.stderr);
|
||||
allocator.free(result.stdout);
|
||||
}
|
||||
if (result.term.Exited != 0) {
|
||||
std.log.err("mach: error: 'git --version' failed. Is git not installed?", .{});
|
||||
std.process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
fn envVarIsTruthy(allocator: std.mem.Allocator, name: []const u8) bool {
|
||||
if (std.process.getEnvVarOwned(allocator, name)) |truthy| {
|
||||
defer allocator.free(truthy);
|
||||
if (std.mem.eql(u8, truthy, "true")) return true;
|
||||
return false;
|
||||
} else |_| {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fn xSdkPath(comptime suffix: []const u8) []const u8 {
|
||||
if (suffix[0] != '/') @compileError("suffix must be an absolute path");
|
||||
return comptime blk: {
|
||||
const root_dir = std.fs.path.dirname(@src().file) orelse ".";
|
||||
break :blk root_dir ++ suffix;
|
||||
};
|
||||
}
|
1
pkg/apple-sdk/stub.c
Normal file
1
pkg/apple-sdk/stub.c
Normal file
@ -0,0 +1 @@
|
||||
// Blank on purpose
|
@ -1,107 +1,52 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const NativeTargetInfo = std.zig.system.NativeTargetInfo;
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/fontconfig-2.14.0/";
|
||||
const include_path = root;
|
||||
const include_path_self = thisDir();
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
pub const include_paths = .{ include_path, include_path_self };
|
||||
const libxml2_enabled = b.option(bool, "enable-libxml2", "Build libxml2") orelse true;
|
||||
const freetype_enabled = b.option(bool, "enable-freetype", "Build freetype") orelse true;
|
||||
|
||||
pub fn module(b: *std.Build) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = (comptime thisDir()) ++ "/main.zig" },
|
||||
});
|
||||
}
|
||||
_ = b.addModule("fontconfig", .{ .source_file = .{ .path = "main.zig" } });
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub const Options = struct {
|
||||
freetype: Freetype = .{},
|
||||
expat: Expat = .{},
|
||||
libxml2: bool = false,
|
||||
|
||||
pub const Freetype = struct {
|
||||
enabled: bool = false,
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
|
||||
pub const Expat = struct {
|
||||
enabled: bool = false,
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
};
|
||||
|
||||
pub fn link(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = try buildFontconfig(b, step, opt);
|
||||
step.linkLibrary(lib);
|
||||
step.addIncludePath(.{ .path = include_path });
|
||||
step.addIncludePath(.{ .path = include_path_self });
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn buildFontconfig(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const target = step.target;
|
||||
const upstream = b.dependency("fontconfig", .{});
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "fontconfig",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
// Include
|
||||
lib.addIncludePath(.{ .path = include_path });
|
||||
lib.addIncludePath(.{ .path = include_path_self });
|
||||
|
||||
// Link
|
||||
lib.linkLibC();
|
||||
if (opt.expat.enabled) {
|
||||
if (opt.expat.step) |expat|
|
||||
lib.linkLibrary(expat)
|
||||
else
|
||||
lib.linkSystemLibrary("expat");
|
||||
|
||||
if (opt.expat.include) |dirs|
|
||||
for (dirs) |dir| lib.addIncludePath(.{ .path = dir });
|
||||
}
|
||||
if (opt.freetype.enabled) {
|
||||
if (opt.freetype.step) |freetype|
|
||||
lib.linkLibrary(freetype)
|
||||
else
|
||||
lib.linkSystemLibrary("freetype2");
|
||||
|
||||
if (opt.freetype.include) |dirs|
|
||||
for (dirs) |dir| lib.addIncludePath(.{ .path = dir });
|
||||
}
|
||||
if (!target.isWindows()) {
|
||||
lib.linkSystemLibrary("pthread");
|
||||
}
|
||||
if (freetype_enabled) {
|
||||
const freetype_dep = b.dependency("freetype", .{ .target = target, .optimize = optimize });
|
||||
lib.linkLibrary(freetype_dep.artifact("freetype"));
|
||||
}
|
||||
if (libxml2_enabled) {
|
||||
const libxml2_dep = b.dependency("libxml2", .{ .target = target, .optimize = optimize });
|
||||
lib.linkLibrary(libxml2_dep.artifact("xml2"));
|
||||
}
|
||||
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
lib.addIncludePath(.{ .path = "override/include" });
|
||||
|
||||
// Compile
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_DIRENT_H",
|
||||
"-DHAVE_FCNTL_H",
|
||||
"-DHAVE_STDLIB_H",
|
||||
"-DHAVE_STRING_H",
|
||||
"-DHAVE_UNISTD_H",
|
||||
"-DHAVE_SYS_STATVFS_H",
|
||||
"-DHAVE_SYS_PARAM_H",
|
||||
"-DHAVE_SYS_MOUNT_H",
|
||||
|
||||
"-DHAVE_LINK",
|
||||
"-DHAVE_MKSTEMP",
|
||||
"-DHAVE_MKOSTEMP",
|
||||
"-DHAVE__MKTEMP_S",
|
||||
"-DHAVE_MKDTEMP",
|
||||
"-DHAVE_GETOPT",
|
||||
@ -109,9 +54,15 @@ pub fn buildFontconfig(
|
||||
//"-DHAVE_GETPROGNAME",
|
||||
//"-DHAVE_GETEXECNAME",
|
||||
"-DHAVE_RAND",
|
||||
"-DHAVE_RANDOM",
|
||||
"-DHAVE_LRAND48",
|
||||
//"-DHAVE_RANDOM_R",
|
||||
"-DHAVE_RAND_R",
|
||||
"-DHAVE_READLINK",
|
||||
"-DHAVE_FSTATVFS",
|
||||
"-DHAVE_FSTATFS",
|
||||
"-DHAVE_LSTAT",
|
||||
"-DHAVE_MMAP",
|
||||
"-DHAVE_VPRINTF",
|
||||
|
||||
"-DHAVE_FT_GET_BDF_PROPERTY",
|
||||
@ -156,21 +107,6 @@ pub fn buildFontconfig(
|
||||
|
||||
else => @panic("unsupported arch"),
|
||||
}
|
||||
|
||||
if (opt.libxml2) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DENABLE_LIBXML2",
|
||||
"-DLIBXML_STATIC",
|
||||
"-DLIBXML_PUSH_ENABLED",
|
||||
});
|
||||
if (target.isWindows()) {
|
||||
// NOTE: this should be defined on all targets
|
||||
try flags.appendSlice(&.{
|
||||
"-Werror=implicit-function-declaration",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (target.isWindows()) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DFC_CACHEDIR=\"LOCAL_APPDATA_FONTCONFIG_CACHE\"",
|
||||
@ -181,8 +117,6 @@ pub fn buildFontconfig(
|
||||
} else {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_SYS_STATVFS_H",
|
||||
"-DHAVE_SYS_VFS_H",
|
||||
"-DHAVE_SYS_STATFS_H",
|
||||
"-DHAVE_SYS_MOUNT_H",
|
||||
"-DHAVE_LINK",
|
||||
"-DHAVE_MKOSTEMP",
|
||||
@ -200,41 +134,88 @@ pub fn buildFontconfig(
|
||||
"-DCONFIGDIR=\"/usr/local/fontconfig/conf.d\"",
|
||||
"-DFC_DEFAULT_FONTS=\"<dir>/usr/share/fonts</dir><dir>/usr/local/share/fonts</dir>\"",
|
||||
});
|
||||
if (target.isLinux()) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_SYS_STATFS_H",
|
||||
"-DHAVE_SYS_VFS_H",
|
||||
});
|
||||
}
|
||||
}
|
||||
if (libxml2_enabled) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DENABLE_LIBXML2",
|
||||
"-DLIBXML_STATIC",
|
||||
"-DLIBXML_PUSH_ENABLED",
|
||||
});
|
||||
if (target.isWindows()) {
|
||||
// NOTE: this should be defined on all targets
|
||||
try flags.appendSlice(&.{
|
||||
"-Werror=implicit-function-declaration",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
for (srcs) |src| {
|
||||
lib.addCSourceFile(.{
|
||||
.file = upstream.path(src),
|
||||
.flags = flags.items,
|
||||
});
|
||||
}
|
||||
|
||||
return lib;
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = upstream.path("fontconfig"),
|
||||
.install_dir = .header,
|
||||
.install_subdir = "fontconfig",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
|
||||
b.installArtifact(lib);
|
||||
|
||||
const test_exe = b.addTest(.{
|
||||
.name = "test",
|
||||
.root_source_file = .{ .path = "main.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
test_exe.linkLibrary(lib);
|
||||
const tests_run = b.addRunArtifact(test_exe);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&tests_run.step);
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "src/fcatomic.c",
|
||||
root ++ "src/fccache.c",
|
||||
root ++ "src/fccfg.c",
|
||||
root ++ "src/fccharset.c",
|
||||
root ++ "src/fccompat.c",
|
||||
root ++ "src/fcdbg.c",
|
||||
root ++ "src/fcdefault.c",
|
||||
root ++ "src/fcdir.c",
|
||||
root ++ "src/fcformat.c",
|
||||
root ++ "src/fcfreetype.c",
|
||||
root ++ "src/fcfs.c",
|
||||
root ++ "src/fcptrlist.c",
|
||||
root ++ "src/fchash.c",
|
||||
root ++ "src/fcinit.c",
|
||||
root ++ "src/fclang.c",
|
||||
root ++ "src/fclist.c",
|
||||
root ++ "src/fcmatch.c",
|
||||
root ++ "src/fcmatrix.c",
|
||||
root ++ "src/fcname.c",
|
||||
root ++ "src/fcobjs.c",
|
||||
root ++ "src/fcpat.c",
|
||||
root ++ "src/fcrange.c",
|
||||
root ++ "src/fcserialize.c",
|
||||
root ++ "src/fcstat.c",
|
||||
root ++ "src/fcstr.c",
|
||||
root ++ "src/fcweight.c",
|
||||
root ++ "src/fcxml.c",
|
||||
root ++ "src/ftglue.c",
|
||||
const headers = &.{
|
||||
"fontconfig/fontconfig.h",
|
||||
"fontconfig/fcprivate.h",
|
||||
"fontconfig/fcfreetype.h",
|
||||
};
|
||||
|
||||
const srcs: []const []const u8 = &.{
|
||||
"src/fcatomic.c",
|
||||
"src/fccache.c",
|
||||
"src/fccfg.c",
|
||||
"src/fccharset.c",
|
||||
"src/fccompat.c",
|
||||
"src/fcdbg.c",
|
||||
"src/fcdefault.c",
|
||||
"src/fcdir.c",
|
||||
"src/fcformat.c",
|
||||
"src/fcfreetype.c",
|
||||
"src/fcfs.c",
|
||||
"src/fcptrlist.c",
|
||||
"src/fchash.c",
|
||||
"src/fcinit.c",
|
||||
"src/fclang.c",
|
||||
"src/fclist.c",
|
||||
"src/fcmatch.c",
|
||||
"src/fcmatrix.c",
|
||||
"src/fcname.c",
|
||||
"src/fcobjs.c",
|
||||
"src/fcpat.c",
|
||||
"src/fcrange.c",
|
||||
"src/fcserialize.c",
|
||||
"src/fcstat.c",
|
||||
"src/fcstr.c",
|
||||
"src/fcweight.c",
|
||||
"src/fcxml.c",
|
||||
"src/ftglue.c",
|
||||
};
|
||||
|
13
pkg/fontconfig/build.zig.zon
Normal file
13
pkg/fontconfig/build.zig.zon
Normal file
@ -0,0 +1,13 @@
|
||||
.{
|
||||
.name = "fontconfig",
|
||||
.version = "2.14.2",
|
||||
.dependencies = .{
|
||||
.fontconfig = .{
|
||||
.url = "https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.14.2.tar.gz",
|
||||
.hash = "12201149afb3326c56c05bb0a577f54f76ac20deece63aa2f5cd6ff31a4fa4fcb3b7",
|
||||
},
|
||||
|
||||
.freetype = .{ .path = "../freetype" },
|
||||
.libxml2 = .{ .path = "../libxml2" },
|
||||
},
|
||||
}
|
0
pkg/fontconfig/override/include/fcalias.h
Normal file
0
pkg/fontconfig/override/include/fcalias.h
Normal file
0
pkg/fontconfig/override/include/fcaliastail.h
Normal file
0
pkg/fontconfig/override/include/fcaliastail.h
Normal file
0
pkg/fontconfig/override/include/fcftalias.h
Normal file
0
pkg/fontconfig/override/include/fcftalias.h
Normal file
0
pkg/fontconfig/override/include/fcftaliastail.h
Normal file
0
pkg/fontconfig/override/include/fcftaliastail.h
Normal file
347
pkg/fontconfig/override/include/fcobjshash.h
Normal file
347
pkg/fontconfig/override/include/fcobjshash.h
Normal file
@ -0,0 +1,347 @@
|
||||
/* ANSI-C code produced by gperf version 3.1 */
|
||||
/* Command-line: gperf --pic -m 100 fcobjshash.gperf */
|
||||
/* Computed positions: -k'3,5' */
|
||||
|
||||
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
||||
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
||||
/* The character set is not based on ISO-646. */
|
||||
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
|
||||
#endif
|
||||
|
||||
#line 1 "fcobjshash.gperf"
|
||||
|
||||
#line 13 "fcobjshash.gperf"
|
||||
struct FcObjectTypeInfo {
|
||||
int name;
|
||||
int id;
|
||||
};
|
||||
#include <string.h>
|
||||
/* maximum key range = 59, duplicates = 0 */
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
inline
|
||||
#endif
|
||||
#endif
|
||||
static unsigned int
|
||||
FcObjectTypeHash (register const char *str, register size_t len)
|
||||
{
|
||||
static const unsigned char asso_values[] =
|
||||
{
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 4, 10, 32,
|
||||
21, 29, 28, 49, 14, 4, 66, 66, 5, 31,
|
||||
18, 22, 27, 66, 15, 9, 8, 23, 23, 13,
|
||||
23, 16, 4, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
||||
66, 66, 66, 66, 66, 66
|
||||
};
|
||||
register unsigned int hval = len;
|
||||
|
||||
switch (hval)
|
||||
{
|
||||
default:
|
||||
hval += asso_values[(unsigned char)str[4]];
|
||||
/*FALLTHROUGH*/
|
||||
case 4:
|
||||
case 3:
|
||||
hval += asso_values[(unsigned char)str[2]];
|
||||
break;
|
||||
}
|
||||
return hval;
|
||||
}
|
||||
|
||||
struct FcObjectTypeNamePool_t
|
||||
{
|
||||
char FcObjectTypeNamePool_str7[sizeof("dpi")];
|
||||
char FcObjectTypeNamePool_str8[sizeof("size")];
|
||||
char FcObjectTypeNamePool_str9[sizeof("file")];
|
||||
char FcObjectTypeNamePool_str13[sizeof("hash")];
|
||||
char FcObjectTypeNamePool_str14[sizeof("rgba")];
|
||||
char FcObjectTypeNamePool_str15[sizeof("spacing")];
|
||||
char FcObjectTypeNamePool_str16[sizeof("scalable")];
|
||||
char FcObjectTypeNamePool_str17[sizeof("slant")];
|
||||
char FcObjectTypeNamePool_str18[sizeof("matrix")];
|
||||
char FcObjectTypeNamePool_str19[sizeof("outline")];
|
||||
char FcObjectTypeNamePool_str20[sizeof("charset")];
|
||||
char FcObjectTypeNamePool_str21[sizeof("antialias")];
|
||||
char FcObjectTypeNamePool_str22[sizeof("lang")];
|
||||
char FcObjectTypeNamePool_str23[sizeof("embolden")];
|
||||
char FcObjectTypeNamePool_str24[sizeof("weight")];
|
||||
char FcObjectTypeNamePool_str25[sizeof("color")];
|
||||
char FcObjectTypeNamePool_str26[sizeof("charwidth")];
|
||||
char FcObjectTypeNamePool_str27[sizeof("variable")];
|
||||
char FcObjectTypeNamePool_str28[sizeof("charheight")];
|
||||
char FcObjectTypeNamePool_str29[sizeof("hinting")];
|
||||
char FcObjectTypeNamePool_str30[sizeof("autohint")];
|
||||
char FcObjectTypeNamePool_str31[sizeof("fullname")];
|
||||
char FcObjectTypeNamePool_str32[sizeof("postscriptname")];
|
||||
char FcObjectTypeNamePool_str33[sizeof("verticallayout")];
|
||||
char FcObjectTypeNamePool_str34[sizeof("lcdfilter")];
|
||||
char FcObjectTypeNamePool_str35[sizeof("fullnamelang")];
|
||||
char FcObjectTypeNamePool_str36[sizeof("hintstyle")];
|
||||
char FcObjectTypeNamePool_str37[sizeof("pixelsize")];
|
||||
char FcObjectTypeNamePool_str38[sizeof("scale")];
|
||||
char FcObjectTypeNamePool_str39[sizeof("globaladvance")];
|
||||
char FcObjectTypeNamePool_str40[sizeof("width")];
|
||||
char FcObjectTypeNamePool_str41[sizeof("order")];
|
||||
char FcObjectTypeNamePool_str42[sizeof("family")];
|
||||
char FcObjectTypeNamePool_str43[sizeof("fonthashint")];
|
||||
char FcObjectTypeNamePool_str44[sizeof("namelang")];
|
||||
char FcObjectTypeNamePool_str45[sizeof("embeddedbitmap")];
|
||||
char FcObjectTypeNamePool_str46[sizeof("familylang")];
|
||||
char FcObjectTypeNamePool_str47[sizeof("capability")];
|
||||
char FcObjectTypeNamePool_str48[sizeof("rasterizer")];
|
||||
char FcObjectTypeNamePool_str49[sizeof("index")];
|
||||
char FcObjectTypeNamePool_str50[sizeof("style")];
|
||||
char FcObjectTypeNamePool_str51[sizeof("foundry")];
|
||||
char FcObjectTypeNamePool_str52[sizeof("fontversion")];
|
||||
char FcObjectTypeNamePool_str53[sizeof("minspace")];
|
||||
char FcObjectTypeNamePool_str54[sizeof("stylelang")];
|
||||
char FcObjectTypeNamePool_str55[sizeof("fontvariations")];
|
||||
char FcObjectTypeNamePool_str56[sizeof("fontformat")];
|
||||
char FcObjectTypeNamePool_str57[sizeof("decorative")];
|
||||
char FcObjectTypeNamePool_str58[sizeof("fontfeatures")];
|
||||
char FcObjectTypeNamePool_str59[sizeof("symbol")];
|
||||
char FcObjectTypeNamePool_str60[sizeof("prgname")];
|
||||
char FcObjectTypeNamePool_str65[sizeof("aspect")];
|
||||
};
|
||||
static const struct FcObjectTypeNamePool_t FcObjectTypeNamePool_contents =
|
||||
{
|
||||
"dpi",
|
||||
"size",
|
||||
"file",
|
||||
"hash",
|
||||
"rgba",
|
||||
"spacing",
|
||||
"scalable",
|
||||
"slant",
|
||||
"matrix",
|
||||
"outline",
|
||||
"charset",
|
||||
"antialias",
|
||||
"lang",
|
||||
"embolden",
|
||||
"weight",
|
||||
"color",
|
||||
"charwidth",
|
||||
"variable",
|
||||
"charheight",
|
||||
"hinting",
|
||||
"autohint",
|
||||
"fullname",
|
||||
"postscriptname",
|
||||
"verticallayout",
|
||||
"lcdfilter",
|
||||
"fullnamelang",
|
||||
"hintstyle",
|
||||
"pixelsize",
|
||||
"scale",
|
||||
"globaladvance",
|
||||
"width",
|
||||
"order",
|
||||
"family",
|
||||
"fonthashint",
|
||||
"namelang",
|
||||
"embeddedbitmap",
|
||||
"familylang",
|
||||
"capability",
|
||||
"rasterizer",
|
||||
"index",
|
||||
"style",
|
||||
"foundry",
|
||||
"fontversion",
|
||||
"minspace",
|
||||
"stylelang",
|
||||
"fontvariations",
|
||||
"fontformat",
|
||||
"decorative",
|
||||
"fontfeatures",
|
||||
"symbol",
|
||||
"prgname",
|
||||
"aspect"
|
||||
};
|
||||
#define FcObjectTypeNamePool ((const char *) &FcObjectTypeNamePool_contents)
|
||||
const struct FcObjectTypeInfo *
|
||||
FcObjectTypeLookup (register const char *str, register size_t len)
|
||||
{
|
||||
enum
|
||||
{
|
||||
TOTAL_KEYWORDS = 52,
|
||||
MIN_WORD_LENGTH = 3,
|
||||
MAX_WORD_LENGTH = 14,
|
||||
MIN_HASH_VALUE = 7,
|
||||
MAX_HASH_VALUE = 65
|
||||
};
|
||||
|
||||
static const struct FcObjectTypeInfo wordlist[] =
|
||||
{
|
||||
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
|
||||
#line 43 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str7,FC_DPI_OBJECT},
|
||||
#line 27 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str8,FC_SIZE_OBJECT},
|
||||
#line 38 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str9,FC_FILE_OBJECT},
|
||||
{-1}, {-1}, {-1},
|
||||
#line 62 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str13,FC_HASH_OBJECT},
|
||||
#line 44 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str14,FC_RGBA_OBJECT},
|
||||
#line 30 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str15,FC_SPACING_OBJECT},
|
||||
#line 42 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str16,FC_SCALABLE_OBJECT},
|
||||
#line 24 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str17,FC_SLANT_OBJECT},
|
||||
#line 49 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str18,FC_MATRIX_OBJECT},
|
||||
#line 41 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str19,FC_OUTLINE_OBJECT},
|
||||
#line 50 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str20,FC_CHARSET_OBJECT},
|
||||
#line 32 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str21,FC_ANTIALIAS_OBJECT},
|
||||
#line 51 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str22,FC_LANG_OBJECT},
|
||||
#line 55 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str23,FC_EMBOLDEN_OBJECT},
|
||||
#line 25 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str24,FC_WEIGHT_OBJECT},
|
||||
#line 64 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str25,FC_COLOR_OBJECT},
|
||||
#line 47 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str26,FC_CHARWIDTH_OBJECT},
|
||||
#line 67 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str27,FC_VARIABLE_OBJECT},
|
||||
#line 48 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str28,FC_CHAR_HEIGHT_OBJECT},
|
||||
#line 34 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str29,FC_HINTING_OBJECT},
|
||||
#line 36 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str30,FC_AUTOHINT_OBJECT},
|
||||
#line 22 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str31,FC_FULLNAME_OBJECT},
|
||||
#line 63 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str32,FC_POSTSCRIPT_NAME_OBJECT},
|
||||
#line 35 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str33,FC_VERTICAL_LAYOUT_OBJECT},
|
||||
#line 58 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str34,FC_LCD_FILTER_OBJECT},
|
||||
#line 23 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str35,FC_FULLNAMELANG_OBJECT},
|
||||
#line 33 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str36,FC_HINT_STYLE_OBJECT},
|
||||
#line 29 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str37,FC_PIXEL_SIZE_OBJECT},
|
||||
#line 45 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str38,FC_SCALE_OBJECT},
|
||||
#line 37 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str39,FC_GLOBAL_ADVANCE_OBJECT},
|
||||
#line 26 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str40,FC_WIDTH_OBJECT},
|
||||
#line 69 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str41,FC_ORDER_OBJECT},
|
||||
#line 18 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str42,FC_FAMILY_OBJECT},
|
||||
#line 68 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str43,FC_FONT_HAS_HINT_OBJECT},
|
||||
#line 59 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str44,FC_NAMELANG_OBJECT},
|
||||
#line 56 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str45,FC_EMBEDDED_BITMAP_OBJECT},
|
||||
#line 19 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str46,FC_FAMILYLANG_OBJECT},
|
||||
#line 53 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str47,FC_CAPABILITY_OBJECT},
|
||||
#line 40 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str48,FC_RASTERIZER_OBJECT},
|
||||
#line 39 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str49,FC_INDEX_OBJECT},
|
||||
#line 20 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str50,FC_STYLE_OBJECT},
|
||||
#line 31 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str51,FC_FOUNDRY_OBJECT},
|
||||
#line 52 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str52,FC_FONTVERSION_OBJECT},
|
||||
#line 46 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str53,FC_MINSPACE_OBJECT},
|
||||
#line 21 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str54,FC_STYLELANG_OBJECT},
|
||||
#line 66 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str55,FC_FONT_VARIATIONS_OBJECT},
|
||||
#line 54 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str56,FC_FONTFORMAT_OBJECT},
|
||||
#line 57 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str57,FC_DECORATIVE_OBJECT},
|
||||
#line 60 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str58,FC_FONT_FEATURES_OBJECT},
|
||||
#line 65 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str59,FC_SYMBOL_OBJECT},
|
||||
#line 61 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str60,FC_PRGNAME_OBJECT},
|
||||
{-1}, {-1}, {-1}, {-1},
|
||||
#line 28 "fcobjshash.gperf"
|
||||
{(int)(size_t)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str65,FC_ASPECT_OBJECT}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
{
|
||||
register unsigned int key = FcObjectTypeHash (str, len);
|
||||
|
||||
if (key <= MAX_HASH_VALUE)
|
||||
{
|
||||
register int o = wordlist[key].name;
|
||||
if (o >= 0)
|
||||
{
|
||||
register const char *s = o + FcObjectTypeNamePool;
|
||||
|
||||
if (*str == *s && !strcmp (str + 1, s + 1))
|
||||
return &wordlist[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,172 +1,143 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/freetype/";
|
||||
const include_path = root ++ "include";
|
||||
pub const include_path_self = thisDir();
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const libpng_enabled = b.option(bool, "enable-libpng", "Build libpng") orelse false;
|
||||
|
||||
pub const include_paths = .{ include_path, include_path_self };
|
||||
_ = b.addModule("freetype", .{ .source_file = .{ .path = "main.zig" } });
|
||||
|
||||
pub fn module(b: *std.Build) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = (comptime thisDir()) ++ "/main.zig" },
|
||||
});
|
||||
}
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub const Options = struct {
|
||||
libpng: Libpng = .{},
|
||||
zlib: Zlib = .{},
|
||||
|
||||
pub const Libpng = struct {
|
||||
enabled: bool = false,
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
|
||||
pub const Zlib = struct {
|
||||
enabled: bool = false,
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
};
|
||||
|
||||
pub fn link(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = try buildFreetype(b, step, opt);
|
||||
step.linkLibrary(lib);
|
||||
step.addIncludePath(.{ .path = include_path });
|
||||
step.addIncludePath(.{ .path = include_path_self });
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn buildFreetype(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const target = step.target;
|
||||
const upstream = b.dependency("freetype", .{});
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "freetype",
|
||||
.target = target,
|
||||
.optimize = step.optimize,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
// Include
|
||||
lib.addIncludePath(.{ .path = include_path });
|
||||
|
||||
// Link
|
||||
lib.linkLibC();
|
||||
if (opt.libpng.enabled) {
|
||||
if (opt.libpng.step) |libpng|
|
||||
lib.linkLibrary(libpng)
|
||||
else
|
||||
lib.linkSystemLibrary("libpng");
|
||||
lib.addIncludePath(upstream.path("include"));
|
||||
|
||||
if (opt.libpng.include) |dirs|
|
||||
for (dirs) |dir| lib.addIncludePath(.{ .path = 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(.{ .path = dir });
|
||||
// Dependencies
|
||||
const zlib_dep = b.dependency("zlib", .{ .target = target, .optimize = optimize });
|
||||
lib.linkLibrary(zlib_dep.artifact("z"));
|
||||
if (libpng_enabled) {
|
||||
const libpng_dep = b.dependency("libpng", .{ .target = target, .optimize = optimize });
|
||||
lib.linkLibrary(libpng_dep.artifact("png"));
|
||||
}
|
||||
|
||||
// Compile
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
|
||||
try flags.appendSlice(&.{
|
||||
"-DFT2_BUILD_LIBRARY",
|
||||
|
||||
"-DFT_CONFIG_OPTION_SYSTEM_ZLIB=1",
|
||||
|
||||
"-DHAVE_UNISTD_H",
|
||||
"-DHAVE_FCNTL_H",
|
||||
|
||||
"-fno-sanitize=undefined",
|
||||
});
|
||||
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");
|
||||
if (libpng_enabled) try flags.append("-DFT_CONFIG_OPTION_USE_PNG=1");
|
||||
|
||||
for (srcs) |src| {
|
||||
lib.addCSourceFile(.{
|
||||
.file = upstream.path(src),
|
||||
.flags = flags.items,
|
||||
});
|
||||
}
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
switch (target.getOsTag()) {
|
||||
.linux => lib.addCSourceFile(.{
|
||||
.file = .{ .path = root ++ "builds/unix/ftsystem.c" },
|
||||
.file = upstream.path("builds/unix/ftsystem.c"),
|
||||
.flags = flags.items,
|
||||
}),
|
||||
.windows => lib.addCSourceFile(.{
|
||||
.file = .{ .path = root ++ "builds/windows/ftsystem.c" },
|
||||
.file = upstream.path("builds/windows/ftsystem.c"),
|
||||
.flags = flags.items,
|
||||
}),
|
||||
else => lib.addCSourceFile(.{
|
||||
.file = .{ .path = root ++ "src/base/ftsystem.c" },
|
||||
.file = upstream.path("src/base/ftsystem.c"),
|
||||
.flags = flags.items,
|
||||
}),
|
||||
}
|
||||
switch (target.getOsTag()) {
|
||||
.windows => {
|
||||
lib.addCSourceFiles(&.{
|
||||
root ++ "builds/windows/ftdebug.c",
|
||||
}, flags.items);
|
||||
lib.addCSourceFile(.{
|
||||
.file = upstream.path("builds/windows/ftdebug.c"),
|
||||
.flags = flags.items,
|
||||
});
|
||||
lib.addWin32ResourceFile(.{
|
||||
.file = upstream.path("src/base/ftver.rc"),
|
||||
});
|
||||
},
|
||||
else => lib.addCSourceFile(.{
|
||||
.file = .{ .path = root ++ "src/base/ftdebug.c" },
|
||||
.file = upstream.path("src/base/ftdebug.c"),
|
||||
.flags = flags.items,
|
||||
}),
|
||||
}
|
||||
|
||||
return lib;
|
||||
lib.installHeader("freetype-zig.h", "freetype-zig.h");
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = upstream.path("include"),
|
||||
.install_dir = .header,
|
||||
.install_subdir = "",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
|
||||
b.installArtifact(lib);
|
||||
|
||||
{
|
||||
const test_exe = b.addTest(.{
|
||||
.name = "test",
|
||||
.root_source_file = .{ .path = "main.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
test_exe.linkLibrary(lib);
|
||||
const tests_run = b.addRunArtifact(test_exe);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&tests_run.step);
|
||||
}
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "src/autofit/autofit.c",
|
||||
root ++ "src/base/ftbase.c",
|
||||
root ++ "src/base/ftbbox.c",
|
||||
root ++ "src/base/ftbdf.c",
|
||||
root ++ "src/base/ftbitmap.c",
|
||||
root ++ "src/base/ftcid.c",
|
||||
root ++ "src/base/ftfstype.c",
|
||||
root ++ "src/base/ftgasp.c",
|
||||
root ++ "src/base/ftglyph.c",
|
||||
root ++ "src/base/ftgxval.c",
|
||||
root ++ "src/base/ftinit.c",
|
||||
root ++ "src/base/ftmm.c",
|
||||
root ++ "src/base/ftotval.c",
|
||||
root ++ "src/base/ftpatent.c",
|
||||
root ++ "src/base/ftpfr.c",
|
||||
root ++ "src/base/ftstroke.c",
|
||||
root ++ "src/base/ftsynth.c",
|
||||
root ++ "src/base/fttype1.c",
|
||||
root ++ "src/base/ftwinfnt.c",
|
||||
root ++ "src/bdf/bdf.c",
|
||||
root ++ "src/bzip2/ftbzip2.c",
|
||||
root ++ "src/cache/ftcache.c",
|
||||
root ++ "src/cff/cff.c",
|
||||
root ++ "src/cid/type1cid.c",
|
||||
root ++ "src/gzip/ftgzip.c",
|
||||
root ++ "src/lzw/ftlzw.c",
|
||||
root ++ "src/pcf/pcf.c",
|
||||
root ++ "src/pfr/pfr.c",
|
||||
root ++ "src/psaux/psaux.c",
|
||||
root ++ "src/pshinter/pshinter.c",
|
||||
root ++ "src/psnames/psnames.c",
|
||||
root ++ "src/raster/raster.c",
|
||||
root ++ "src/sdf/sdf.c",
|
||||
root ++ "src/sfnt/sfnt.c",
|
||||
root ++ "src/smooth/smooth.c",
|
||||
root ++ "src/svg/svg.c",
|
||||
root ++ "src/truetype/truetype.c",
|
||||
root ++ "src/type1/type1.c",
|
||||
root ++ "src/type42/type42.c",
|
||||
root ++ "src/winfonts/winfnt.c",
|
||||
const srcs: []const []const u8 = &.{
|
||||
"src/autofit/autofit.c",
|
||||
"src/base/ftbase.c",
|
||||
"src/base/ftbbox.c",
|
||||
"src/base/ftbdf.c",
|
||||
"src/base/ftbitmap.c",
|
||||
"src/base/ftcid.c",
|
||||
"src/base/ftfstype.c",
|
||||
"src/base/ftgasp.c",
|
||||
"src/base/ftglyph.c",
|
||||
"src/base/ftgxval.c",
|
||||
"src/base/ftinit.c",
|
||||
"src/base/ftmm.c",
|
||||
"src/base/ftotval.c",
|
||||
"src/base/ftpatent.c",
|
||||
"src/base/ftpfr.c",
|
||||
"src/base/ftstroke.c",
|
||||
"src/base/ftsynth.c",
|
||||
"src/base/fttype1.c",
|
||||
"src/base/ftwinfnt.c",
|
||||
"src/bdf/bdf.c",
|
||||
"src/bzip2/ftbzip2.c",
|
||||
"src/cache/ftcache.c",
|
||||
"src/cff/cff.c",
|
||||
"src/cid/type1cid.c",
|
||||
"src/gzip/ftgzip.c",
|
||||
"src/lzw/ftlzw.c",
|
||||
"src/pcf/pcf.c",
|
||||
"src/pfr/pfr.c",
|
||||
"src/psaux/psaux.c",
|
||||
"src/pshinter/pshinter.c",
|
||||
"src/psnames/psnames.c",
|
||||
"src/raster/raster.c",
|
||||
"src/sdf/sdf.c",
|
||||
"src/sfnt/sfnt.c",
|
||||
"src/smooth/smooth.c",
|
||||
"src/svg/svg.c",
|
||||
"src/truetype/truetype.c",
|
||||
"src/type1/type1.c",
|
||||
"src/type42/type42.c",
|
||||
"src/winfonts/winfnt.c",
|
||||
};
|
||||
|
13
pkg/freetype/build.zig.zon
Normal file
13
pkg/freetype/build.zig.zon
Normal file
@ -0,0 +1,13 @@
|
||||
.{
|
||||
.name = "freetype",
|
||||
.version = "2.13.2",
|
||||
.dependencies = .{
|
||||
.freetype = .{
|
||||
.url = "https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-2.tar.gz",
|
||||
.hash = "1220b81f6ecfb3fd222f76cf9106fecfa6554ab07ec7fdc4124b9bb063ae2adf969d",
|
||||
},
|
||||
|
||||
.libpng = .{ .path = "../libpng" },
|
||||
.zlib = .{ .path = "../zlib" },
|
||||
},
|
||||
}
|
@ -1,98 +1,55 @@
|
||||
const std = @import("std");
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/harfbuzz/";
|
||||
const include_path = root ++ "src/";
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
pub const include_paths = .{include_path};
|
||||
const coretext_enabled = b.option(bool, "enable-coretext", "Build coretext") orelse false;
|
||||
const freetype_enabled = b.option(bool, "enable-freetype", "Build freetype") orelse true;
|
||||
|
||||
pub fn module(b: *std.Build, deps: struct {
|
||||
freetype: *std.build.Module,
|
||||
macos: *std.build.Module,
|
||||
}) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = (comptime thisDir()) ++ "/main.zig" },
|
||||
const freetype = b.dependency("freetype", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.@"enable-libpng" = true,
|
||||
});
|
||||
const macos = b.dependency("macos", .{ .target = target, .optimize = optimize });
|
||||
|
||||
const module = b.addModule("harfbuzz", .{
|
||||
.source_file = .{ .path = "main.zig" },
|
||||
.dependencies = &.{
|
||||
.{ .name = "freetype", .module = deps.freetype },
|
||||
.{ .name = "macos", .module = deps.macos },
|
||||
.{ .name = "freetype", .module = freetype.module("freetype") },
|
||||
.{ .name = "macos", .module = macos.module("macos") },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
const upstream_root = "../../vendor/harfbuzz";
|
||||
|
||||
pub const Options = struct {
|
||||
freetype: Freetype = .{},
|
||||
coretext: CoreText = .{},
|
||||
|
||||
pub const Freetype = struct {
|
||||
enabled: bool = false,
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
|
||||
pub const CoreText = struct {
|
||||
enabled: bool = false,
|
||||
};
|
||||
};
|
||||
|
||||
pub fn link(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = try buildHarfbuzz(b, step, opt);
|
||||
step.linkLibrary(lib);
|
||||
step.addIncludePath(.{ .path = include_path });
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn buildHarfbuzz(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "harfbuzz",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
// Include
|
||||
lib.addIncludePath(.{ .path = include_path });
|
||||
|
||||
// Link
|
||||
lib.linkLibC();
|
||||
lib.linkLibCpp();
|
||||
if (opt.freetype.enabled) {
|
||||
if (opt.freetype.step) |freetype|
|
||||
lib.linkLibrary(freetype)
|
||||
else
|
||||
lib.linkSystemLibrary("freetype2");
|
||||
lib.addIncludePath(.{ .path = upstream_root ++ "/src" });
|
||||
|
||||
if (opt.freetype.include) |dirs|
|
||||
for (dirs) |dir| lib.addIncludePath(.{ .path = dir });
|
||||
}
|
||||
const freetype_dep = b.dependency("freetype", .{ .target = target, .optimize = optimize });
|
||||
lib.linkLibrary(freetype_dep.artifact("freetype"));
|
||||
|
||||
// Compile
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_STDBOOL_H",
|
||||
});
|
||||
|
||||
if (!step.target.isWindows()) {
|
||||
if (!target.isWindows()) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_UNISTD_H",
|
||||
"-DHAVE_SYS_MMAN_H",
|
||||
"-DHAVE_PTHREAD=1",
|
||||
});
|
||||
}
|
||||
|
||||
if (opt.freetype.enabled) try flags.appendSlice(&.{
|
||||
if (freetype_enabled) try flags.appendSlice(&.{
|
||||
"-DHAVE_FREETYPE=1",
|
||||
|
||||
// Let's just assume a new freetype
|
||||
@ -101,21 +58,39 @@ pub fn buildHarfbuzz(
|
||||
"-DHAVE_FT_DONE_MM_VAR=1",
|
||||
"-DHAVE_FT_GET_TRANSFORM=1",
|
||||
});
|
||||
|
||||
if (opt.coretext.enabled) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_CORETEXT=1",
|
||||
});
|
||||
|
||||
if (coretext_enabled) {
|
||||
try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"});
|
||||
try apple_sdk.addPaths(b, lib);
|
||||
lib.linkFramework("ApplicationServices");
|
||||
}
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
lib.addCSourceFile(.{
|
||||
.file = .{ .path = upstream_root ++ "/src/harfbuzz.cc" },
|
||||
.flags = flags.items,
|
||||
});
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = .{ .path = upstream_root ++ "/src" },
|
||||
.install_dir = .header,
|
||||
.install_subdir = "",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
|
||||
return lib;
|
||||
b.installArtifact(lib);
|
||||
|
||||
{
|
||||
const test_exe = b.addTest(.{
|
||||
.name = "test",
|
||||
.root_source_file = .{ .path = "main.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
test_exe.linkLibrary(lib);
|
||||
|
||||
var it = module.dependencies.iterator();
|
||||
while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*);
|
||||
test_exe.linkLibrary(freetype_dep.artifact("freetype"));
|
||||
const tests_run = b.addRunArtifact(test_exe);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&tests_run.step);
|
||||
}
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "src/harfbuzz.cc",
|
||||
};
|
||||
|
9
pkg/harfbuzz/build.zig.zon
Normal file
9
pkg/harfbuzz/build.zig.zon
Normal file
@ -0,0 +1,9 @@
|
||||
.{
|
||||
.name = "harfbuzz",
|
||||
.version = "2.13.2",
|
||||
.dependencies = .{
|
||||
.freetype = .{ .path = "../freetype" },
|
||||
.macos = .{ .path = "../macos" },
|
||||
.apple_sdk = .{ .path = "../apple-sdk" },
|
||||
},
|
||||
}
|
BIN
pkg/harfbuzz/libharfbuzz.a
Normal file
BIN
pkg/harfbuzz/libharfbuzz.a
Normal file
Binary file not shown.
@ -1,102 +1,66 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/libpng/";
|
||||
const include_path = root;
|
||||
const include_path_pnglibconf = thisDir();
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
pub const include_paths = .{ include_path, include_path_pnglibconf };
|
||||
const upstream = b.dependency("libpng", .{});
|
||||
|
||||
pub const pkg = std.build.Pkg{
|
||||
.name = "libpng",
|
||||
.source = .{ .path = thisDir() ++ "/main.zig" },
|
||||
};
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub const Options = struct {
|
||||
zlib: Zlib = .{},
|
||||
|
||||
pub const Zlib = struct {
|
||||
step: ?*std.build.LibExeObjStep = null,
|
||||
include: ?[]const []const u8 = null,
|
||||
};
|
||||
};
|
||||
|
||||
pub fn link(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = try buildLib(b, step, opt);
|
||||
step.linkLibrary(lib);
|
||||
step.addIncludePath(.{ .path = include_path });
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn buildLib(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const target = step.target;
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "png",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
// Include
|
||||
lib.addIncludePath(.{ .path = include_path });
|
||||
lib.addIncludePath(.{ .path = include_path_pnglibconf });
|
||||
|
||||
// Link
|
||||
lib.linkLibC();
|
||||
if (target.isLinux()) {
|
||||
lib.linkSystemLibrary("m");
|
||||
}
|
||||
|
||||
if (opt.zlib.step) |zlib|
|
||||
lib.linkLibrary(zlib)
|
||||
else
|
||||
lib.linkSystemLibrary("z");
|
||||
const zlib_dep = b.dependency("zlib", .{ .target = target, .optimize = optimize });
|
||||
lib.linkLibrary(zlib_dep.artifact("z"));
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
lib.addIncludePath(.{ .path = "" });
|
||||
|
||||
if (opt.zlib.include) |dirs|
|
||||
for (dirs) |dir| lib.addIncludePath(.{ .path = dir });
|
||||
|
||||
// Compile
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
|
||||
try flags.appendSlice(&.{
|
||||
"-DPNG_ARM_NEON_OPT=0",
|
||||
"-DPNG_POWERPC_VSX_OPT=0",
|
||||
"-DPNG_INTEL_SSE_OPT=0",
|
||||
"-DPNG_MIPS_MSA_OPT=0",
|
||||
});
|
||||
for (srcs) |src| {
|
||||
lib.addCSourceFile(.{
|
||||
.file = upstream.path(src),
|
||||
.flags = flags.items,
|
||||
});
|
||||
}
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
lib.installHeader("pnglibconf.h", "pnglibconf.h");
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = upstream.path(""),
|
||||
.install_dir = .header,
|
||||
.install_subdir = "",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
|
||||
return lib;
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "png.c",
|
||||
root ++ "pngerror.c",
|
||||
root ++ "pngget.c",
|
||||
root ++ "pngmem.c",
|
||||
root ++ "pngpread.c",
|
||||
root ++ "pngread.c",
|
||||
root ++ "pngrio.c",
|
||||
root ++ "pngrtran.c",
|
||||
root ++ "pngrutil.c",
|
||||
root ++ "pngset.c",
|
||||
root ++ "pngtrans.c",
|
||||
root ++ "pngwio.c",
|
||||
root ++ "pngwrite.c",
|
||||
root ++ "pngwtran.c",
|
||||
root ++ "pngwutil.c",
|
||||
const srcs: []const []const u8 = &.{
|
||||
"png.c",
|
||||
"pngerror.c",
|
||||
"pngget.c",
|
||||
"pngmem.c",
|
||||
"pngpread.c",
|
||||
"pngread.c",
|
||||
"pngrio.c",
|
||||
"pngrtran.c",
|
||||
"pngrutil.c",
|
||||
"pngset.c",
|
||||
"pngtrans.c",
|
||||
"pngwio.c",
|
||||
"pngwrite.c",
|
||||
"pngwtran.c",
|
||||
"pngwutil.c",
|
||||
};
|
||||
|
14
pkg/libpng/build.zig.zon
Normal file
14
pkg/libpng/build.zig.zon
Normal file
@ -0,0 +1,14 @@
|
||||
.{
|
||||
.name = "libpng",
|
||||
.version = "1.6.40",
|
||||
.dependencies = .{
|
||||
.libpng = .{
|
||||
.url = "https://github.com/glennrp/libpng/archive/refs/tags/v1.6.40.tar.gz",
|
||||
.hash = "12203d2722e3af6f9556503b114c25fe3eead528a93f5f26eefcb187a460d1548e07",
|
||||
},
|
||||
|
||||
.zlib = .{
|
||||
.path = "../zlib",
|
||||
},
|
||||
},
|
||||
}
|
221
pkg/libxml2/build.zig
Normal file
221
pkg/libxml2/build.zig
Normal file
@ -0,0 +1,221 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const upstream_root = "../../vendor/libxml2";
|
||||
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "xml2",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
lib.linkLibC();
|
||||
|
||||
lib.addIncludePath(.{ .path = upstream_root ++ "/include" });
|
||||
lib.addIncludePath(.{ .path = "override/include" });
|
||||
if (target.isWindows()) {
|
||||
lib.addIncludePath(.{ .path = "override/config/win32" });
|
||||
lib.linkSystemLibrary("ws2_32");
|
||||
} else {
|
||||
lib.addIncludePath(.{ .path = "override/config/posix" });
|
||||
}
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
try flags.appendSlice(&.{
|
||||
// Version info, hardcoded
|
||||
comptime "-DLIBXML_VERSION=" ++ Version.number(),
|
||||
comptime "-DLIBXML_VERSION_STRING=" ++ Version.string(),
|
||||
"-DLIBXML_VERSION_EXTRA=\"\"",
|
||||
comptime "-DLIBXML_DOTTED_VERSION=" ++ Version.dottedString(),
|
||||
|
||||
// These might now always be true (particularly Windows) but for
|
||||
// now we just set them all. We should do some detection later.
|
||||
"-DSEND_ARG2_CAST=",
|
||||
"-DGETHOSTBYNAME_ARG_CAST=",
|
||||
"-DGETHOSTBYNAME_ARG_CAST_CONST=",
|
||||
|
||||
// Always on
|
||||
"-DLIBXML_STATIC=1",
|
||||
"-DLIBXML_AUTOMATA_ENABLED=1",
|
||||
"-DWITHOUT_TRIO=1",
|
||||
});
|
||||
if (!target.isWindows()) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_ARPA_INET_H=1",
|
||||
"-DHAVE_ARPA_NAMESER_H=1",
|
||||
"-DHAVE_DL_H=1",
|
||||
"-DHAVE_NETDB_H=1",
|
||||
"-DHAVE_NETINET_IN_H=1",
|
||||
"-DHAVE_PTHREAD_H=1",
|
||||
"-DHAVE_SHLLOAD=1",
|
||||
"-DHAVE_SYS_DIR_H=1",
|
||||
"-DHAVE_SYS_MMAN_H=1",
|
||||
"-DHAVE_SYS_NDIR_H=1",
|
||||
"-DHAVE_SYS_SELECT_H=1",
|
||||
"-DHAVE_SYS_SOCKET_H=1",
|
||||
"-DHAVE_SYS_TIMEB_H=1",
|
||||
"-DHAVE_SYS_TIME_H=1",
|
||||
"-DHAVE_SYS_TYPES_H=1",
|
||||
});
|
||||
}
|
||||
|
||||
// Enable our `./configure` options. For bool-type fields we translate
|
||||
// it to the `LIBXML_{field}_ENABLED` C define where field is uppercased.
|
||||
inline for (std.meta.fields(Options)) |field| {
|
||||
const opt = b.option(bool, field.name, "Configure flag") orelse
|
||||
@as(*const bool, @ptrCast(field.default_value.?)).*;
|
||||
if (opt) {
|
||||
var nameBuf: [32]u8 = undefined;
|
||||
const name = std.ascii.upperString(&nameBuf, field.name);
|
||||
const define = try std.fmt.allocPrint(b.allocator, "-DLIBXML_{s}_ENABLED=1", .{name});
|
||||
try flags.append(define);
|
||||
|
||||
if (std.mem.eql(u8, field.name, "history")) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_LIBHISTORY=1",
|
||||
"-DHAVE_LIBREADLINE=1",
|
||||
});
|
||||
}
|
||||
if (std.mem.eql(u8, field.name, "mem_debug")) {
|
||||
try flags.append("-DDEBUG_MEMORY_LOCATION=1");
|
||||
}
|
||||
if (std.mem.eql(u8, field.name, "regexp")) {
|
||||
try flags.append("-DLIBXML_UNICODE_ENABLED=1");
|
||||
}
|
||||
if (std.mem.eql(u8, field.name, "run_debug")) {
|
||||
try flags.append("-DLIBXML_DEBUG_RUNTIME=1");
|
||||
}
|
||||
if (std.mem.eql(u8, field.name, "thread")) {
|
||||
try flags.append("-DHAVE_LIBPTHREAD=1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline for (srcs) |src| {
|
||||
lib.addCSourceFile(.{
|
||||
.file = .{ .path = upstream_root ++ "/" ++ src },
|
||||
.flags = flags.items,
|
||||
});
|
||||
}
|
||||
|
||||
lib.installHeader("override/include/libxml/xmlversion.h", "libxml/xmlversion.h");
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = .{ .path = upstream_root ++ "/include" },
|
||||
.install_dir = .header,
|
||||
.install_subdir = "",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
/// The version information for this library. This is hardcoded for now but
|
||||
/// in the future we will parse this from configure.ac.
|
||||
pub const Version = struct {
|
||||
pub const major = "2";
|
||||
pub const minor = "11";
|
||||
pub const micro = "5";
|
||||
|
||||
pub fn number() []const u8 {
|
||||
return comptime major ++ "0" ++ minor ++ "0" ++ micro;
|
||||
}
|
||||
|
||||
pub fn string() []const u8 {
|
||||
return comptime "\"" ++ number() ++ "\"";
|
||||
}
|
||||
|
||||
pub fn dottedString() []const u8 {
|
||||
return comptime "\"" ++ major ++ "." ++ minor ++ "." ++ micro ++ "\"";
|
||||
}
|
||||
};
|
||||
|
||||
/// Compile-time options for the library. These mostly correspond to
|
||||
/// options exposed by the native build system used by the library.
|
||||
/// These are mapped to `b.option` calls.
|
||||
const Options = struct {
|
||||
// These options are all defined in libxml2's configure.c and correspond
|
||||
// to `--with-X` options for `./configure`. Their defaults are properly set.
|
||||
c14n: bool = true,
|
||||
catalog: bool = true,
|
||||
debug: bool = true,
|
||||
ftp: bool = false,
|
||||
history: bool = true,
|
||||
html: bool = true,
|
||||
iconv: bool = true,
|
||||
icu: bool = false,
|
||||
iso8859x: bool = true,
|
||||
legacy: bool = false,
|
||||
mem_debug: bool = false,
|
||||
minimum: bool = true,
|
||||
output: bool = true,
|
||||
pattern: bool = true,
|
||||
push: bool = true,
|
||||
reader: bool = true,
|
||||
regexp: bool = true,
|
||||
run_debug: bool = false,
|
||||
sax1: bool = true,
|
||||
schemas: bool = true,
|
||||
schematron: bool = true,
|
||||
thread: bool = true,
|
||||
thread_alloc: bool = false,
|
||||
tree: bool = true,
|
||||
valid: bool = true,
|
||||
writer: bool = true,
|
||||
xinclude: bool = true,
|
||||
xpath: bool = true,
|
||||
xptr: bool = true,
|
||||
xptr_locs: bool = false,
|
||||
modules: bool = true,
|
||||
lzma: bool = false,
|
||||
zlib: bool = false,
|
||||
};
|
||||
|
||||
const srcs = &.{
|
||||
"buf.c",
|
||||
"c14n.c",
|
||||
"catalog.c",
|
||||
"chvalid.c",
|
||||
"debugXML.c",
|
||||
"dict.c",
|
||||
"encoding.c",
|
||||
"entities.c",
|
||||
"error.c",
|
||||
"globals.c",
|
||||
"hash.c",
|
||||
"HTMLparser.c",
|
||||
"HTMLtree.c",
|
||||
"legacy.c",
|
||||
"list.c",
|
||||
"nanoftp.c",
|
||||
"nanohttp.c",
|
||||
"parser.c",
|
||||
"parserInternals.c",
|
||||
"pattern.c",
|
||||
"relaxng.c",
|
||||
"SAX.c",
|
||||
"SAX2.c",
|
||||
"schematron.c",
|
||||
"threads.c",
|
||||
"tree.c",
|
||||
"uri.c",
|
||||
"valid.c",
|
||||
"xinclude.c",
|
||||
"xlink.c",
|
||||
"xmlIO.c",
|
||||
"xmlmemory.c",
|
||||
"xmlmodule.c",
|
||||
"xmlreader.c",
|
||||
"xmlregexp.c",
|
||||
"xmlsave.c",
|
||||
"xmlschemas.c",
|
||||
"xmlschemastypes.c",
|
||||
"xmlstring.c",
|
||||
"xmlunicode.c",
|
||||
"xmlwriter.c",
|
||||
"xpath.c",
|
||||
"xpointer.c",
|
||||
"xzlib.c",
|
||||
};
|
5
pkg/libxml2/build.zig.zon
Normal file
5
pkg/libxml2/build.zig.zon
Normal file
@ -0,0 +1,5 @@
|
||||
.{
|
||||
.name = "libxml2",
|
||||
.version = "2.11.5",
|
||||
.dependencies = .{},
|
||||
}
|
80
pkg/libxml2/override/config/posix/config.h
Normal file
80
pkg/libxml2/override/config/posix/config.h
Normal file
@ -0,0 +1,80 @@
|
||||
// This recreates parts of the generated config.h from cmake. Most of the
|
||||
// defines actually happen directly in libxml2.zig. Some of these SHOULD
|
||||
// be converted to build-time determined.
|
||||
|
||||
/* Whether struct sockaddr::__ss_family exists */
|
||||
// #define HAVE_BROKEN_SS_FAMILY 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Have dlopen based dso */
|
||||
#define HAVE_DLOPEN 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `ftime' function. */
|
||||
#define HAVE_FTIME 1
|
||||
|
||||
/* Define if getaddrinfo is there */
|
||||
#define HAVE_GETADDRINFO 1
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `isascii' function. */
|
||||
#define HAVE_ISASCII 1
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#define HAVE_MMAP 1
|
||||
|
||||
/* Define to 1 if you have the `munmap' function. */
|
||||
#define HAVE_MUNMAP 1
|
||||
|
||||
/* mmap() is no good without munmap() */
|
||||
#if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
|
||||
# undef /**/ HAVE_MMAP
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <poll.h> header file. */
|
||||
#define HAVE_POLL_H 1
|
||||
|
||||
/* Define to 1 if you have the `putenv' function. */
|
||||
#define HAVE_PUTENV 1
|
||||
|
||||
/* Define to 1 if you have the `rand_r' function. */
|
||||
#define HAVE_RAND_R 1
|
||||
|
||||
/* Define to 1 if you have the <resolv.h> header file. */
|
||||
#define HAVE_RESOLV_H 1
|
||||
|
||||
/* Define to 1 if you have the `stat' function. */
|
||||
#define HAVE_STAT 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Whether va_copy() is available */
|
||||
#define HAVE_VA_COPY 1
|
||||
|
||||
/* Define to 1 if you have the <zlib.h> header file. */
|
||||
#define HAVE_ZLIB_H 1
|
||||
|
||||
/* Whether __va_copy() is available */
|
||||
#define HAVE___VA_COPY 1
|
||||
|
||||
/* Support for IPv6 */
|
||||
#define SUPPORT_IP6 1
|
||||
|
||||
/* Define if va_list is an array type */
|
||||
#define VA_LIST_IS_ARRAY 1
|
20
pkg/libxml2/override/config/win32/config.h
Normal file
20
pkg/libxml2/override/config/win32/config.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef __LIBXML_WIN32_CONFIG__
|
||||
#define __LIBXML_WIN32_CONFIG__
|
||||
|
||||
#define SEND_ARG2_CAST
|
||||
#define GETHOSTBYNAME_ARG_CAST
|
||||
|
||||
#define HAVE_SYS_STAT_H
|
||||
#define HAVE_STAT
|
||||
#define HAVE_FCNTL_H
|
||||
|
||||
#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1600)
|
||||
#define HAVE_STDINT_H
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
#endif /* __LIBXML_WIN32_CONFIG__ */
|
18
pkg/libxml2/override/include/libxml/xmlversion.h
Normal file
18
pkg/libxml2/override/include/libxml/xmlversion.h
Normal file
@ -0,0 +1,18 @@
|
||||
// This recreates parts of the generated libxml/xmlversion.h.in that we need
|
||||
// to build libxml2 without actually templating the header file. We define most
|
||||
// of the defines in that file using flags to the compiler in libxml2.zig
|
||||
|
||||
#ifndef __XML_VERSION_H__
|
||||
#define __XML_VERSION_H__
|
||||
|
||||
#include <libxml/xmlexports.h>
|
||||
|
||||
// We are not GCC.
|
||||
#define XML_IGNORE_FPTR_CAST_WARNINGS
|
||||
#define XML_POP_WARNINGS
|
||||
#define LIBXML_ATTR_FORMAT(fmt,args)
|
||||
#define LIBXML_ATTR_ALLOC_SIZE(x)
|
||||
#define ATTRIBUTE_UNUSED
|
||||
#define XML_DEPRECATED
|
||||
|
||||
#endif
|
@ -1,43 +1,50 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
|
||||
pub fn module(b: *std.Build) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = (comptime thisDir()) ++ "/main.zig" },
|
||||
});
|
||||
}
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub const Options = struct {};
|
||||
|
||||
pub fn link(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
_ = opt;
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
const module = b.addModule("macos", .{ .source_file = .{ .path = "main.zig" } });
|
||||
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "macos",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
step.addCSourceFile(.{
|
||||
.file = .{ .path = comptime thisDir() ++ "/os/log.c" },
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
lib.addCSourceFile(.{
|
||||
.file = .{ .path = "os/log.c" },
|
||||
.flags = flags.items,
|
||||
});
|
||||
step.addCSourceFile(.{
|
||||
.file = .{ .path = comptime thisDir() ++ "/text/ext.c" },
|
||||
lib.addCSourceFile(.{
|
||||
.file = .{ .path = "text/ext.c" },
|
||||
.flags = flags.items,
|
||||
});
|
||||
step.linkFramework("Carbon");
|
||||
step.linkFramework("CoreFoundation");
|
||||
step.linkFramework("CoreGraphics");
|
||||
step.linkFramework("CoreText");
|
||||
return lib;
|
||||
lib.linkFramework("Carbon");
|
||||
lib.linkFramework("CoreFoundation");
|
||||
lib.linkFramework("CoreGraphics");
|
||||
lib.linkFramework("CoreText");
|
||||
try apple_sdk.addPaths(b, lib);
|
||||
|
||||
b.installArtifact(lib);
|
||||
|
||||
{
|
||||
const test_exe = b.addTest(.{
|
||||
.name = "test",
|
||||
.root_source_file = .{ .path = "main.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
test_exe.linkLibrary(lib);
|
||||
var it = module.dependencies.iterator();
|
||||
while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*);
|
||||
|
||||
const tests_run = b.addRunArtifact(test_exe);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&tests_run.step);
|
||||
}
|
||||
}
|
||||
|
7
pkg/macos/build.zig.zon
Normal file
7
pkg/macos/build.zig.zon
Normal file
@ -0,0 +1,7 @@
|
||||
.{
|
||||
.name = "macos",
|
||||
.version = "0.1.0",
|
||||
.dependencies = .{
|
||||
.apple_sdk = .{ .path = "../apple-sdk" },
|
||||
},
|
||||
}
|
@ -1,80 +1,27 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/pixman/";
|
||||
const include_path = root ++ "pixman/";
|
||||
const include_path_self = thisDir();
|
||||
|
||||
pub const include_paths = .{ include_path, include_path_self };
|
||||
|
||||
pub fn module(b: *std.Build) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = (comptime thisDir()) ++ "/main.zig" },
|
||||
});
|
||||
}
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub const Options = struct {};
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const mode = b.standardReleaseOptions();
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const tests = b.addTestExe("pixman-test", "main.zig");
|
||||
tests.setBuildMode(mode);
|
||||
tests.setTarget(target);
|
||||
_ = try link(b, tests, .{});
|
||||
b.installArtifact(tests);
|
||||
const module = b.addModule("pixman", .{ .source_file = .{ .path = "main.zig" } });
|
||||
|
||||
const test_step = b.step("test", "Run tests");
|
||||
const tests_run = b.addRunArtifact(tests);
|
||||
test_step.dependOn(&tests_run.step);
|
||||
}
|
||||
|
||||
pub fn link(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = try buildPixman(b, step, opt);
|
||||
step.linkLibrary(lib);
|
||||
step.addIncludePath(.{ .path = include_path });
|
||||
step.addIncludePath(.{ .path = include_path_self });
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn buildPixman(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
_ = opt;
|
||||
|
||||
const target = step.target;
|
||||
const upstream = b.dependency("pixman", .{});
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "pixman",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
// Include
|
||||
lib.addIncludePath(.{ .path = include_path });
|
||||
lib.addIncludePath(.{ .path = include_path_self });
|
||||
|
||||
// Link
|
||||
lib.linkLibC();
|
||||
if (!target.isWindows()) {
|
||||
lib.linkSystemLibrary("pthread");
|
||||
}
|
||||
|
||||
// Compile
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
lib.addIncludePath(.{ .path = "" });
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_SIGACTION=1",
|
||||
"-DHAVE_ALARM=1",
|
||||
@ -95,7 +42,6 @@ pub fn buildPixman(
|
||||
"-fno-sanitize=undefined",
|
||||
"-fno-sanitize-trap=undefined",
|
||||
});
|
||||
|
||||
if (!target.isWindows()) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_PTHREADS=1",
|
||||
@ -104,41 +50,69 @@ pub fn buildPixman(
|
||||
});
|
||||
}
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
for (srcs) |src| {
|
||||
lib.addCSourceFile(.{
|
||||
.file = upstream.path(src),
|
||||
.flags = flags.items,
|
||||
});
|
||||
}
|
||||
|
||||
return lib;
|
||||
lib.installHeader("pixman-version.h", "pixman-version.h");
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = upstream.path("pixman"),
|
||||
.install_dir = .header,
|
||||
.install_subdir = "",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
|
||||
b.installArtifact(lib);
|
||||
|
||||
{
|
||||
const test_exe = b.addTest(.{
|
||||
.name = "test",
|
||||
.root_source_file = .{ .path = "main.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
test_exe.linkLibrary(lib);
|
||||
var it = module.dependencies.iterator();
|
||||
while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*);
|
||||
|
||||
const tests_run = b.addRunArtifact(test_exe);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&tests_run.step);
|
||||
}
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "pixman/pixman.c",
|
||||
root ++ "pixman/pixman-access.c",
|
||||
root ++ "pixman/pixman-access-accessors.c",
|
||||
root ++ "pixman/pixman-bits-image.c",
|
||||
root ++ "pixman/pixman-combine32.c",
|
||||
root ++ "pixman/pixman-combine-float.c",
|
||||
root ++ "pixman/pixman-conical-gradient.c",
|
||||
root ++ "pixman/pixman-filter.c",
|
||||
root ++ "pixman/pixman-x86.c",
|
||||
root ++ "pixman/pixman-mips.c",
|
||||
root ++ "pixman/pixman-arm.c",
|
||||
root ++ "pixman/pixman-ppc.c",
|
||||
root ++ "pixman/pixman-edge.c",
|
||||
root ++ "pixman/pixman-edge-accessors.c",
|
||||
root ++ "pixman/pixman-fast-path.c",
|
||||
root ++ "pixman/pixman-glyph.c",
|
||||
root ++ "pixman/pixman-general.c",
|
||||
root ++ "pixman/pixman-gradient-walker.c",
|
||||
root ++ "pixman/pixman-image.c",
|
||||
root ++ "pixman/pixman-implementation.c",
|
||||
root ++ "pixman/pixman-linear-gradient.c",
|
||||
root ++ "pixman/pixman-matrix.c",
|
||||
root ++ "pixman/pixman-noop.c",
|
||||
root ++ "pixman/pixman-radial-gradient.c",
|
||||
root ++ "pixman/pixman-region16.c",
|
||||
root ++ "pixman/pixman-region32.c",
|
||||
root ++ "pixman/pixman-solid-fill.c",
|
||||
//root ++ "pixman/pixman-timer.c",
|
||||
root ++ "pixman/pixman-trap.c",
|
||||
root ++ "pixman/pixman-utils.c",
|
||||
const srcs: []const []const u8 = &.{
|
||||
"pixman/pixman.c",
|
||||
"pixman/pixman-access.c",
|
||||
"pixman/pixman-access-accessors.c",
|
||||
"pixman/pixman-bits-image.c",
|
||||
"pixman/pixman-combine32.c",
|
||||
"pixman/pixman-combine-float.c",
|
||||
"pixman/pixman-conical-gradient.c",
|
||||
"pixman/pixman-filter.c",
|
||||
"pixman/pixman-x86.c",
|
||||
"pixman/pixman-mips.c",
|
||||
"pixman/pixman-arm.c",
|
||||
"pixman/pixman-ppc.c",
|
||||
"pixman/pixman-edge.c",
|
||||
"pixman/pixman-edge-accessors.c",
|
||||
"pixman/pixman-fast-path.c",
|
||||
"pixman/pixman-glyph.c",
|
||||
"pixman/pixman-general.c",
|
||||
"pixman/pixman-gradient-walker.c",
|
||||
"pixman/pixman-image.c",
|
||||
"pixman/pixman-implementation.c",
|
||||
"pixman/pixman-linear-gradient.c",
|
||||
"pixman/pixman-matrix.c",
|
||||
"pixman/pixman-noop.c",
|
||||
"pixman/pixman-radial-gradient.c",
|
||||
"pixman/pixman-region16.c",
|
||||
"pixman/pixman-region32.c",
|
||||
"pixman/pixman-solid-fill.c",
|
||||
//"pixman/pixman-timer.c",
|
||||
"pixman/pixman-trap.c",
|
||||
"pixman/pixman-utils.c",
|
||||
};
|
||||
|
10
pkg/pixman/build.zig.zon
Normal file
10
pkg/pixman/build.zig.zon
Normal file
@ -0,0 +1,10 @@
|
||||
.{
|
||||
.name = "pixman",
|
||||
.version = "0.42.2",
|
||||
.dependencies = .{
|
||||
.pixman = .{
|
||||
.url = "https://gitlab.freedesktop.org/pixman/pixman/-/archive/pixman-0.42.2/pixman-pixman-0.42.2.tar.gz",
|
||||
.hash = "12209b9206f9a5d31ccd9a2312cc72cb9dfc3e034aee1883c549dc1d753fae457230",
|
||||
},
|
||||
},
|
||||
}
|
@ -1,68 +1,91 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/tracy/";
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
pub fn module(b: *std.Build) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = (comptime thisDir()) ++ "/tracy.zig" },
|
||||
});
|
||||
}
|
||||
_ = b.addModule("tracy", .{ .source_file = .{ .path = "tracy.zig" } });
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub fn link(b: *std.Build, step: *std.build.LibExeObjStep) !*std.build.LibExeObjStep {
|
||||
const tracy = try buildTracy(b, step);
|
||||
step.linkLibrary(tracy);
|
||||
step.addIncludePath(.{ .path = root });
|
||||
return tracy;
|
||||
}
|
||||
|
||||
pub fn buildTracy(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const target = step.target;
|
||||
const upstream = b.dependency("tracy", .{});
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "tracy",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
|
||||
try flags.appendSlice(&.{
|
||||
"-DTRACY_ENABLE",
|
||||
"-fno-sanitize=undefined",
|
||||
});
|
||||
|
||||
if (target.isWindows()) {
|
||||
try flags.appendSlice(&.{
|
||||
"-D_WIN32_WINNT=0x601",
|
||||
});
|
||||
}
|
||||
|
||||
lib.addIncludePath(.{ .path = root });
|
||||
lib.addCSourceFile(.{
|
||||
.file = .{ .path = try std.fs.path.join(
|
||||
b.allocator,
|
||||
&.{ root, "TracyClient.cpp" },
|
||||
) },
|
||||
.flags = flags.items,
|
||||
});
|
||||
|
||||
lib.linkLibC();
|
||||
lib.linkSystemLibrary("c++");
|
||||
|
||||
if (lib.target.isWindows()) {
|
||||
lib.linkLibCpp();
|
||||
if (target.isWindows()) {
|
||||
lib.linkSystemLibrary("Advapi32");
|
||||
lib.linkSystemLibrary("User32");
|
||||
lib.linkSystemLibrary("Ws2_32");
|
||||
lib.linkSystemLibrary("DbgHelp");
|
||||
}
|
||||
|
||||
return lib;
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
try flags.appendSlice(&.{
|
||||
"-DTRACY_ENABLE",
|
||||
"-fno-sanitize=undefined",
|
||||
});
|
||||
if (target.isWindows()) {
|
||||
try flags.appendSlice(&.{
|
||||
"-D_WIN32_WINNT=0x601",
|
||||
});
|
||||
}
|
||||
|
||||
lib.addCSourceFile(.{
|
||||
.file = upstream.path("TracyClient.cpp"),
|
||||
.flags = flags.items,
|
||||
});
|
||||
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = upstream.path(""),
|
||||
.install_dir = .header,
|
||||
.install_subdir = "",
|
||||
.include_extensions = &.{ ".h", ".hpp" },
|
||||
});
|
||||
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
const headers = &.{
|
||||
"TracyC.h",
|
||||
"TracyOpenGL.hpp",
|
||||
"Tracy.hpp",
|
||||
"TracyD3D11.hpp",
|
||||
"TracyD3D12.hpp",
|
||||
"TracyOpenCL.hpp",
|
||||
"TracyVulkan.hpp",
|
||||
"client/TracyCallstack.h",
|
||||
"client/TracyScoped.hpp",
|
||||
"client/TracyStringHelpers.hpp",
|
||||
"client/TracySysTrace.hpp",
|
||||
"client/TracyDxt1.hpp",
|
||||
"client/TracyRingBuffer.hpp",
|
||||
"client/tracy_rpmalloc.hpp",
|
||||
"client/TracyDebug.hpp",
|
||||
"client/TracyLock.hpp",
|
||||
"client/TracyThread.hpp",
|
||||
"client/TracyArmCpuTable.hpp",
|
||||
"client/TracyProfiler.hpp",
|
||||
"client/TracyCallstack.hpp",
|
||||
"client/TracySysTime.hpp",
|
||||
"client/TracyFastVector.hpp",
|
||||
"common/TracyApi.h",
|
||||
"common/TracyYield.hpp",
|
||||
"common/tracy_lz4hc.hpp",
|
||||
"common/TracySystem.hpp",
|
||||
"common/TracyProtocol.hpp",
|
||||
"common/TracyQueue.hpp",
|
||||
"common/TracyUwp.hpp",
|
||||
"common/TracyAlloc.hpp",
|
||||
"common/TracyAlign.hpp",
|
||||
"common/TracyForceInline.hpp",
|
||||
"common/TracyColor.hpp",
|
||||
"common/tracy_lz4.hpp",
|
||||
"common/TracyStackFrames.hpp",
|
||||
"common/TracySocket.hpp",
|
||||
"common/TracyMutex.hpp",
|
||||
};
|
||||
|
10
pkg/tracy/build.zig.zon
Normal file
10
pkg/tracy/build.zig.zon
Normal file
@ -0,0 +1,10 @@
|
||||
.{
|
||||
.name = "tracy",
|
||||
.version = "0.8.2",
|
||||
.dependencies = .{
|
||||
.tracy = .{
|
||||
.url = "https://github.com/wolfpld/tracy/archive/refs/tags/v0.8.2.1.tar.gz",
|
||||
.hash = "1220289ca424ec488316b75c992b9f02846caaa70287f958b3966e02d5ca81789d27",
|
||||
},
|
||||
},
|
||||
}
|
@ -1,55 +1,39 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/utf8proc/";
|
||||
const include_path = root;
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
pub const include_paths = .{include_path};
|
||||
_ = b.addModule("utf8proc", .{ .source_file = .{ .path = "main.zig" } });
|
||||
|
||||
pub fn module(b: *std.Build) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = (comptime thisDir()) ++ "/main.zig" },
|
||||
});
|
||||
}
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub fn link(b: *std.Build, step: *std.build.LibExeObjStep) !*std.build.LibExeObjStep {
|
||||
const lib = try buildLib(b, step);
|
||||
step.linkLibrary(lib);
|
||||
step.addIncludePath(.{ .path = include_path });
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn buildLib(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const upstream = b.dependency("utf8proc", .{});
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "utf8proc",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
lib.linkLibC();
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = upstream.path(""),
|
||||
.install_dir = .header,
|
||||
.install_subdir = "",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
|
||||
// Include
|
||||
lib.addIncludePath(.{ .path = include_path });
|
||||
|
||||
// Link
|
||||
lib.linkLibC();
|
||||
|
||||
// Compile
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
try flags.append("-DUTF8PROC_EXPORTS");
|
||||
defer flags.deinit();
|
||||
for (srcs) |src| {
|
||||
lib.addCSourceFile(.{
|
||||
.file = upstream.path(src),
|
||||
.flags = flags.items,
|
||||
});
|
||||
}
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
|
||||
return lib;
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "utf8proc.c",
|
||||
const srcs: []const []const u8 = &.{
|
||||
"utf8proc.c",
|
||||
};
|
||||
|
10
pkg/utf8proc/build.zig.zon
Normal file
10
pkg/utf8proc/build.zig.zon
Normal file
@ -0,0 +1,10 @@
|
||||
.{
|
||||
.name = "utf8proc",
|
||||
.version = "2.8.0",
|
||||
.dependencies = .{
|
||||
.utf8proc = .{
|
||||
.url = "https://github.com/JuliaStrings/utf8proc/archive/refs/tags/v2.8.0.tar.gz",
|
||||
.hash = "1220056ce228a8c58f1fa66ab778f5c8965e62f720c1d30603c7d534cb7d8a605ad7",
|
||||
},
|
||||
},
|
||||
}
|
@ -1,74 +1,57 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/zlib/";
|
||||
const include_path = root;
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
pub const include_paths = .{include_path};
|
||||
const upstream = b.dependency("zlib", .{});
|
||||
|
||||
pub const pkg = std.build.Pkg{
|
||||
.name = "zlib",
|
||||
.source = .{ .path = thisDir() ++ "/main.zig" },
|
||||
};
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub fn link(b: *std.build.Builder, step: *std.build.LibExeObjStep) !*std.build.LibExeObjStep {
|
||||
const lib = try buildLib(b, step);
|
||||
step.linkLibrary(lib);
|
||||
step.addIncludePath(.{ .path = include_path });
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn buildLib(
|
||||
b: *std.build.Builder,
|
||||
step: *std.build.LibExeObjStep,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "z",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
lib.linkLibC();
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = upstream.path(""),
|
||||
.install_dir = .header,
|
||||
.install_subdir = "",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
|
||||
// Include
|
||||
lib.addIncludePath(.{ .path = include_path });
|
||||
|
||||
// Link
|
||||
lib.linkLibC();
|
||||
|
||||
// Compile
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_SYS_TYPES_H",
|
||||
"-DHAVE_STDINT_H",
|
||||
"-DHAVE_STDDEF_H",
|
||||
"-DZ_HAVE_UNISTD_H",
|
||||
});
|
||||
for (srcs) |src| {
|
||||
lib.addCSourceFile(.{
|
||||
.file = upstream.path(src),
|
||||
.flags = flags.items,
|
||||
});
|
||||
}
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
|
||||
return lib;
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "adler32.c",
|
||||
root ++ "compress.c",
|
||||
root ++ "crc32.c",
|
||||
root ++ "deflate.c",
|
||||
root ++ "gzclose.c",
|
||||
root ++ "gzlib.c",
|
||||
root ++ "gzread.c",
|
||||
root ++ "gzwrite.c",
|
||||
root ++ "inflate.c",
|
||||
root ++ "infback.c",
|
||||
root ++ "inftrees.c",
|
||||
root ++ "inffast.c",
|
||||
root ++ "trees.c",
|
||||
root ++ "uncompr.c",
|
||||
root ++ "zutil.c",
|
||||
const srcs: []const []const u8 = &.{
|
||||
"adler32.c",
|
||||
"compress.c",
|
||||
"crc32.c",
|
||||
"deflate.c",
|
||||
"gzclose.c",
|
||||
"gzlib.c",
|
||||
"gzread.c",
|
||||
"gzwrite.c",
|
||||
"inflate.c",
|
||||
"infback.c",
|
||||
"inftrees.c",
|
||||
"inffast.c",
|
||||
"trees.c",
|
||||
"uncompr.c",
|
||||
"zutil.c",
|
||||
};
|
||||
|
10
pkg/zlib/build.zig.zon
Normal file
10
pkg/zlib/build.zig.zon
Normal file
@ -0,0 +1,10 @@
|
||||
.{
|
||||
.name = "zlib",
|
||||
.version = "1.3.0",
|
||||
.dependencies = .{
|
||||
.zlib = .{
|
||||
.url = "https://github.com/madler/zlib/archive/refs/tags/v1.3.tar.gz",
|
||||
.hash = "12207d353609d95cee9da7891919e6d9582e97b7aa2831bd50f33bf523a582a08547",
|
||||
},
|
||||
},
|
||||
}
|
1
vendor/cimgui
vendored
1
vendor/cimgui
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 9ce2c32dada1e1fcb90f2c9bab2568895db719f5
|
1
vendor/freetype
vendored
1
vendor/freetype
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 4d8db130ea4342317581bab65fc96365ce806b77
|
1
vendor/libpng
vendored
1
vendor/libpng
vendored
@ -1 +0,0 @@
|
||||
Subproject commit f8e5fa92b0e37ab597616f554bee254157998227
|
1
vendor/libxev
vendored
1
vendor/libxev
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 9068c5d954f97b8498f265b1dd6db9d67f6bc103
|
1
vendor/libxml2
vendored
Submodule
1
vendor/libxml2
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 58de9d31da4d0e8cb6bcf7f5e99714f9df2c4411
|
1
vendor/mach-glfw
vendored
1
vendor/mach-glfw
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 30727db96a3f6bccf51bcf2b68b200527f25fa9c
|
1
vendor/mach-sdk/sdk-linux-aarch64
vendored
1
vendor/mach-sdk/sdk-linux-aarch64
vendored
@ -1 +0,0 @@
|
||||
Subproject commit a279b0a3ef2f103b308defcd7e1a32e20346f70b
|
1
vendor/mach-sdk/sdk-linux-x86_64
vendored
1
vendor/mach-sdk/sdk-linux-x86_64
vendored
@ -1 +0,0 @@
|
||||
Subproject commit ebd1ce12e9abc152c7ed43afbcdb4b6e1c95be07
|
1
vendor/tracy
vendored
1
vendor/tracy
vendored
@ -1 +0,0 @@
|
||||
Subproject commit a8511d357650282c6915f7aa9775e9c4945e42b5
|
1
vendor/utf8proc
vendored
1
vendor/utf8proc
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 1cb28a66ca79a0845e99433fd1056257456cef8b
|
1
vendor/zig-js
vendored
1
vendor/zig-js
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 3639752be98d5168f821704dca02b5eb8b915ea9
|
1
vendor/zig-libxml2
vendored
1
vendor/zig-libxml2
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 5aae6093c9faa8699d4a39b530b44daf5df91c0e
|
1
vendor/zig-objc
vendored
1
vendor/zig-objc
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 51584a2f7842ae10c9859b76ba5722ddf3f58e24
|
1
vendor/zlib
vendored
1
vendor/zlib
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 09155eaa2f9270dc4ed1fa13e2b4b2613e6e4851
|
Reference in New Issue
Block a user