diff --git a/.gitmodules b/.gitmodules index eb3e87bf2..7250a6c86 100644 --- a/.gitmodules +++ b/.gitmodules @@ -31,3 +31,6 @@ [submodule "vendor/cimgui"] path = vendor/cimgui url = https://github.com/cimgui/cimgui.git +[submodule "vendor/pixman"] + path = vendor/pixman + url = https://github.com/freedesktop/pixman.git diff --git a/pkg/pixman/build.zig b/pkg/pixman/build.zig new file mode 100644 index 000000000..bb5be82dd --- /dev/null +++ b/pkg/pixman/build.zig @@ -0,0 +1,137 @@ +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 const pkg = std.build.Pkg{ + .name = "pixman", + .source = .{ .path = 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.Builder) !void { + const target = b.standardTargetOptions(.{}); + const mode = b.standardReleaseOptions(); + _ = target; + _ = mode; + + const tests = b.addTestExe("pixman-test", "main.zig"); + _ = try link(b, tests, .{}); + tests.install(); + + const test_step = b.step("test", "Run tests"); + const tests_run = tests.run(); + test_step.dependOn(&tests_run.step); +} + +pub fn link( + b: *std.build.Builder, + step: *std.build.LibExeObjStep, + opt: Options, +) !*std.build.LibExeObjStep { + const lib = try buildPixman(b, step, opt); + step.linkLibrary(lib); + step.addIncludePath(include_path); + step.addIncludePath(include_path_self); + return lib; +} + +pub fn buildPixman( + b: *std.build.Builder, + step: *std.build.LibExeObjStep, + opt: Options, +) !*std.build.LibExeObjStep { + _ = opt; + + const target = step.target; + const lib = b.addStaticLibrary("pixman", null); + lib.setTarget(step.target); + lib.setBuildMode(step.build_mode); + + // Include + lib.addIncludePath(include_path); + lib.addIncludePath(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", + }); + + 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", +}; diff --git a/pkg/pixman/main.zig b/pkg/pixman/main.zig new file mode 100644 index 000000000..c12b911fb --- /dev/null +++ b/pkg/pixman/main.zig @@ -0,0 +1,5 @@ +const std = @import("std"); + +test { + std.testing.refAllDecls(@This()); +} diff --git a/pkg/pixman/pixman-version.h b/pkg/pixman/pixman-version.h new file mode 100644 index 000000000..c2342d3d5 --- /dev/null +++ b/pkg/pixman/pixman-version.h @@ -0,0 +1,54 @@ +/* + * Copyright © 2008 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Author: Carl D. Worth + */ + +#ifndef PIXMAN_VERSION_H__ +#define PIXMAN_VERSION_H__ + +#ifndef PIXMAN_H__ +# error pixman-version.h should only be included by pixman.h +#endif + +#define PIXMAN_VERSION_MAJOR 999 +#define PIXMAN_VERSION_MINOR 999 +#define PIXMAN_VERSION_MICRO 999 + +#define PIXMAN_VERSION_STRING "999.999.999" + +#define PIXMAN_VERSION_ENCODE(major, minor, micro) ( \ + ((major) * 10000) \ + + ((minor) * 100) \ + + ((micro) * 1)) + +#define PIXMAN_VERSION PIXMAN_VERSION_ENCODE( \ + PIXMAN_VERSION_MAJOR, \ + PIXMAN_VERSION_MINOR, \ + PIXMAN_VERSION_MICRO) + +#ifndef PIXMAN_API +# define PIXMAN_API +#endif + +#endif /* PIXMAN_VERSION_H__ */ diff --git a/vendor/pixman b/vendor/pixman new file mode 160000 index 000000000..713077d0a --- /dev/null +++ b/vendor/pixman @@ -0,0 +1 @@ +Subproject commit 713077d0a3c310ca1955bc331d46d55d0ae4a72b