pkg/pixman

This commit is contained in:
Mitchell Hashimoto
2023-10-01 15:04:55 -07:00
parent 5f8dbb498f
commit 5feeac66b2
5 changed files with 215 additions and 99 deletions

View File

@ -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 pixman = @import("pkg/pixman/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 fontconfig = @import("pkg/fontconfig/build.old.zig");
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 zlib = @import("pkg/zlib/build.old.zig");
// Do a comptime Zig version requirement. The required Zig version is
@ -688,6 +688,10 @@ fn addDeps(
.target = step.target,
.optimize = step.optimize,
});
const pixman_dep = b.dependency("pixman", .{
.target = step.target,
.optimize = step.optimize,
});
const zlib_dep = b.dependency("zlib", .{
.target = step.target,
.optimize = step.optimize,
@ -790,8 +794,8 @@ fn addDeps(
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()) {

View File

@ -6,6 +6,7 @@
.freetype = .{ .path = "./pkg/freetype" },
.harfbuzz = .{ .path = "./pkg/harfbuzz" },
.libpng = .{ .path = "./pkg/libpng" },
.pixman = .{ .path = "./pkg/pixman" },
.zlib = .{ .path = "./pkg/zlib" },
},
}

144
pkg/pixman/build.old.zig Normal file
View File

@ -0,0 +1,144 @@
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

@ -1,80 +1,26 @@
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 upstream = b.dependency("pixman", .{});
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,
.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 +41,6 @@ pub fn buildPixman(
"-fno-sanitize=undefined",
"-fno-sanitize-trap=undefined",
});
if (!target.isWindows()) {
try flags.appendSlice(&.{
"-DHAVE_PTHREADS=1",
@ -104,41 +49,53 @@ 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 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
View 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",
},
},
}