From f0d4e9c7c34868a4f7db39a430248f03cd3c4e47 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 1 Oct 2023 18:35:31 -0700 Subject: [PATCH] pkg: remove all old build.zig files --- pkg/freetype/build.old.zig | 172 ------------------------------------- pkg/harfbuzz/build.old.zig | 121 -------------------------- pkg/libpng/build.old.zig | 102 ---------------------- pkg/zlib/build.old.zig | 74 ---------------- 4 files changed, 469 deletions(-) delete mode 100644 pkg/freetype/build.old.zig delete mode 100644 pkg/harfbuzz/build.old.zig delete mode 100644 pkg/libpng/build.old.zig delete mode 100644 pkg/zlib/build.old.zig diff --git a/pkg/freetype/build.old.zig b/pkg/freetype/build.old.zig deleted file mode 100644 index 89534f10c..000000000 --- a/pkg/freetype/build.old.zig +++ /dev/null @@ -1,172 +0,0 @@ -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 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 { - 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 lib = b.addStaticLibrary(.{ - .name = "freetype", - .target = target, - .optimize = step.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"); - - 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 }); - } - - // Compile - var flags = std.ArrayList([]const u8).init(b.allocator); - defer flags.deinit(); - - try flags.appendSlice(&.{ - "-DFT2_BUILD_LIBRARY", - - "-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"); - - // C files - lib.addCSourceFiles(srcs, flags.items); - switch (target.getOsTag()) { - .linux => lib.addCSourceFile(.{ - .file = .{ .path = root ++ "builds/unix/ftsystem.c" }, - .flags = flags.items, - }), - .windows => lib.addCSourceFile(.{ - .file = .{ .path = root ++ "builds/windows/ftsystem.c" }, - .flags = flags.items, - }), - else => lib.addCSourceFile(.{ - .file = .{ .path = root ++ "src/base/ftsystem.c" }, - .flags = flags.items, - }), - } - switch (target.getOsTag()) { - .windows => { - lib.addCSourceFiles(&.{ - root ++ "builds/windows/ftdebug.c", - }, flags.items); - }, - else => lib.addCSourceFile(.{ - .file = .{ .path = root ++ "src/base/ftdebug.c" }, - .flags = flags.items, - }), - } - - return lib; -} - -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", -}; diff --git a/pkg/harfbuzz/build.old.zig b/pkg/harfbuzz/build.old.zig deleted file mode 100644 index 1135ca322..000000000 --- a/pkg/harfbuzz/build.old.zig +++ /dev/null @@ -1,121 +0,0 @@ -const std = @import("std"); - -/// Directories with our includes. -const root = thisDir() ++ "../../../vendor/harfbuzz/"; -const include_path = root ++ "src/"; - -pub const include_paths = .{include_path}; - -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" }, - .dependencies = &.{ - .{ .name = "freetype", .module = deps.freetype }, - .{ .name = "macos", .module = deps.macos }, - }, - }); -} - -fn thisDir() []const u8 { - return std.fs.path.dirname(@src().file) orelse "."; -} - -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, - }); - - // 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"); - - if (opt.freetype.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(&.{ - "-DHAVE_STDBOOL_H", - }); - - if (!step.target.isWindows()) { - try flags.appendSlice(&.{ - "-DHAVE_UNISTD_H", - "-DHAVE_SYS_MMAN_H", - "-DHAVE_PTHREAD=1", - }); - } - - if (opt.freetype.enabled) try flags.appendSlice(&.{ - "-DHAVE_FREETYPE=1", - - // Let's just assume a new freetype - "-DHAVE_FT_GET_VAR_BLEND_COORDINATES=1", - "-DHAVE_FT_SET_VAR_BLEND_COORDINATES=1", - "-DHAVE_FT_DONE_MM_VAR=1", - "-DHAVE_FT_GET_TRANSFORM=1", - }); - - if (opt.coretext.enabled) { - try flags.appendSlice(&.{ - "-DHAVE_CORETEXT=1", - }); - - lib.linkFramework("ApplicationServices"); - } - - // C files - lib.addCSourceFiles(srcs, flags.items); - - return lib; -} - -const srcs = &.{ - root ++ "src/harfbuzz.cc", -}; diff --git a/pkg/libpng/build.old.zig b/pkg/libpng/build.old.zig deleted file mode 100644 index 0e98059ac..000000000 --- a/pkg/libpng/build.old.zig +++ /dev/null @@ -1,102 +0,0 @@ -const std = @import("std"); - -/// Directories with our includes. -const root = thisDir() ++ "../../../vendor/libpng/"; -const include_path = root; -const include_path_pnglibconf = thisDir(); - -pub const include_paths = .{ include_path, include_path_pnglibconf }; - -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, - }); - - // 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"); - - 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", - }); - - // C files - lib.addCSourceFiles(srcs, flags.items); - - return 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", -}; diff --git a/pkg/zlib/build.old.zig b/pkg/zlib/build.old.zig deleted file mode 100644 index fa2a57acb..000000000 --- a/pkg/zlib/build.old.zig +++ /dev/null @@ -1,74 +0,0 @@ -const std = @import("std"); - -/// Directories with our includes. -const root = thisDir() ++ "../../../vendor/zlib/"; -const include_path = root; - -pub const include_paths = .{include_path}; - -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, - }); - - // 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", - }); - - // C files - lib.addCSourceFiles(srcs, flags.items); - - return 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", -};