pkg/pixman, utf8proc

This commit is contained in:
Mitchell Hashimoto
2023-10-01 16:59:24 -07:00
parent 2237b43df0
commit fefbd7afbe
5 changed files with 7 additions and 209 deletions

View File

@ -19,11 +19,6 @@ const libxml2 = @import("vendor/zig-libxml2/libxml2.zig");
const tracylib = @import("pkg/tracy/build.zig");
const system_sdk = @import("vendor/mach-glfw/system_sdk.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
// 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
@ -698,7 +693,7 @@ fn addDeps(
// 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("utf8proc", utf8proc_dep.module("utf8proc"));
step.addModule("zig-js", js_dep.module("zig-js"));
// utf8proc
@ -737,8 +732,8 @@ fn addDeps(
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.module(b));
step.addModule("utf8proc", utf8proc.module(b));
step.addModule("pixman", pixman_dep.module("pixman"));
step.addModule("utf8proc", utf8proc_dep.module("utf8proc"));
// Mac Stuff
if (step.target.isDarwin()) {

View File

@ -1,144 +0,0 @@
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 tests = b.addTestExe("pixman-test", "main.zig");
tests.setBuildMode(mode);
tests.setTarget(target);
_ = try link(b, tests, .{});
b.installArtifact(tests);
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 lib = b.addStaticLibrary(.{
.name = "pixman",
.target = step.target,
.optimize = step.optimize,
});
// Include
lib.addIncludePath(.{ .path = include_path });
lib.addIncludePath(.{ .path = include_path_self });
// Link
lib.linkLibC();
if (!target.isWindows()) {
lib.linkSystemLibrary("pthread");
}
// Compile
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
try flags.appendSlice(&.{
"-DHAVE_SIGACTION=1",
"-DHAVE_ALARM=1",
"-DHAVE_MPROTECT=1",
"-DHAVE_GETPAGESIZE=1",
"-DHAVE_MMAP=1",
"-DHAVE_GETISAX=1",
"-DHAVE_GETTIMEOFDAY=1",
"-DHAVE_FENV_H=1",
"-DHAVE_SYS_MMAN_H=1",
"-DHAVE_UNISTD_H=1",
"-DSIZEOF_LONG=8",
"-DPACKAGE=foo",
// There is ubsan
"-fno-sanitize=undefined",
"-fno-sanitize-trap=undefined",
});
if (!target.isWindows()) {
try flags.appendSlice(&.{
"-DHAVE_PTHREADS=1",
"-DHAVE_POSIX_MEMALIGN=1",
});
}
// C files
lib.addCSourceFiles(srcs, flags.items);
return lib;
}
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",
};

View File

@ -4,8 +4,9 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const upstream = b.dependency("pixman", .{});
_ = b.addModule("pixman", .{ .source_file = .{ .path = "main.zig" } });
const upstream = b.dependency("pixman", .{});
const lib = b.addStaticLibrary(.{
.name = "pixman",
.target = target,

View File

@ -1,55 +0,0 @@
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",
};

View File

@ -4,8 +4,9 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const upstream = b.dependency("utf8proc", .{});
_ = b.addModule("utf8proc", .{ .source_file = .{ .path = "main.zig" } });
const upstream = b.dependency("utf8proc", .{});
const lib = b.addStaticLibrary(.{
.name = "utf8proc",
.target = target,