mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
pkg/utf8proc
This commit is contained in:
38
build.zig
38
build.zig
@ -20,7 +20,6 @@ const libxev = @import("vendor/libxev/build.zig");
|
||||
const libxml2 = @import("vendor/zig-libxml2/libxml2.zig");
|
||||
const macos = @import("pkg/macos/build.zig");
|
||||
const objc = @import("vendor/zig-objc/build.zig");
|
||||
const utf8proc = @import("pkg/utf8proc/build.zig");
|
||||
const tracylib = @import("pkg/tracy/build.zig");
|
||||
const system_sdk = @import("vendor/mach-glfw/system_sdk.zig");
|
||||
|
||||
@ -29,6 +28,7 @@ const freetype = @import("pkg/freetype/build.old.zig");
|
||||
const harfbuzz = @import("pkg/harfbuzz/build.old.zig");
|
||||
const libpng = @import("pkg/libpng/build.old.zig");
|
||||
const pixman = @import("pkg/pixman/build.old.zig");
|
||||
const utf8proc = @import("pkg/utf8proc/build.old.zig");
|
||||
const zlib = @import("pkg/zlib/build.old.zig");
|
||||
|
||||
// Do a comptime Zig version requirement. The required Zig version is
|
||||
@ -653,20 +653,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.
|
||||
@ -696,6 +682,10 @@ fn addDeps(
|
||||
.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,
|
||||
@ -703,6 +693,20 @@ fn addDeps(
|
||||
.@"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", tracylib.module(b));
|
||||
step.addModule("utf8proc", utf8proc.module(b));
|
||||
step.addModule("zig-js", js.module(b));
|
||||
|
||||
// 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.
|
||||
@ -759,8 +763,8 @@ fn addDeps(
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
.harfbuzz = .{ .path = "./pkg/harfbuzz" },
|
||||
.libpng = .{ .path = "./pkg/libpng" },
|
||||
.pixman = .{ .path = "./pkg/pixman" },
|
||||
.utf8proc = .{ .path = "./pkg/utf8proc" },
|
||||
.zlib = .{ .path = "./pkg/zlib" },
|
||||
},
|
||||
}
|
||||
|
55
pkg/utf8proc/build.old.zig
Normal file
55
pkg/utf8proc/build.old.zig
Normal file
@ -0,0 +1,55 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir() ++ "../../../vendor/utf8proc/";
|
||||
const include_path = root;
|
||||
|
||||
pub const include_paths = .{include_path};
|
||||
|
||||
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 lib = b.addStaticLibrary(.{
|
||||
.name = "utf8proc",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
|
||||
// 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();
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
|
||||
return lib;
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "utf8proc.c",
|
||||
};
|
@ -1,55 +1,38 @@
|
||||
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};
|
||||
const upstream = b.dependency("utf8proc", .{});
|
||||
|
||||
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 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();
|
||||
|
||||
// C files
|
||||
lib.addCSourceFiles(srcs, flags.items);
|
||||
|
||||
return lib;
|
||||
for (srcs) |src| {
|
||||
lib.addCSourceFile(.{
|
||||
.file = upstream.path(src),
|
||||
.flags = flags.items,
|
||||
});
|
||||
}
|
||||
|
||||
const srcs = &.{
|
||||
root ++ "utf8proc.c",
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
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",
|
||||
},
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user