From 50cf1d1e85e13aa859348d1a0f96cebf3eceaa24 Mon Sep 17 00:00:00 2001 From: Ali Chraghi Date: Tue, 1 Aug 2023 06:28:02 +0330 Subject: [PATCH] build: depend on mach-freetype via package manager --- .gitmodules | 6 ------ build.zig | 12 +++++------- build.zig.zon | 4 ++++ libs/mach-freetype | 1 - 4 files changed, 9 insertions(+), 14 deletions(-) delete mode 160000 libs/mach-freetype diff --git a/.gitmodules b/.gitmodules index c1e33e3f..ad6bd57a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,9 +9,6 @@ shallow = true branch = "mach" -[submodule "freetype/upstream"] - path = libs/freetype/upstream - url = https://github.com/hexops-graveyard/freetype [submodule "glfw/upstream"] path = libs/glfw/upstream url = https://github.com/hexops-graveyard/glfw @@ -30,9 +27,6 @@ [submodule "libs/mach-gpu-dawn"] path = libs/mach-gpu-dawn url = https://github.com/hexops/mach-gpu-dawn -[submodule "libs/mach-freetype"] - path = libs/mach-freetype - url = https://github.com/hexops/mach-freetype [submodule "libs/mach-core"] path = libs/mach-core url = https://github.com/hexops/mach-core diff --git a/build.zig b/build.zig index 692fab07..d911df8c 100644 --- a/build.zig +++ b/build.zig @@ -1,6 +1,5 @@ const std = @import("std"); const builtin = @import("builtin"); -const freetype = @import("libs/mach-freetype/build.zig"); const glfw = @import("mach_glfw"); const sysaudio = @import("mach_sysaudio"); pub const gpu_dawn = @import("libs/mach-gpu-dawn/build.zig"); // TODO(build-system): make this private @@ -44,10 +43,7 @@ pub fn module(b: *std.Build, optimize: std.builtin.OptimizeMode, target: std.zig return _module.?; } -pub const Options = struct { - sysaudio: sysaudio.Options = .{}, - freetype: freetype.Options = .{}, -}; +pub const Options = struct { sysaudio: sysaudio.Options = .{} }; pub fn build(b: *std.Build) !void { const optimize = b.standardOptimizeOption(.{}); @@ -126,7 +122,10 @@ pub const App = struct { if (options.deps) |v| try deps.appendSlice(v); try deps.append(.{ .name = "mach", .module = module(b, options.optimize, options.target) }); try deps.append(.{ .name = "sysaudio", .module = sysaudio.module(b, options.optimize, options.target) }); - if (options.use_freetype) |_| try deps.append(.{ .name = "freetype", .module = freetype.module(b) }); + if (options.use_freetype) |name| { + const freetype_dep = b.dependency("mach_freetype", .{ .target = options.target, .optimize = options.optimize }); + try deps.append(.{ .name = name, .module = freetype_dep.module("mach-freetype") }); + } const app = try core.App.init(b, .{ .name = options.name, @@ -152,7 +151,6 @@ pub const App = struct { pub fn link(app: *const App, options: Options) !void { sysaudio.link(app.b, app.compile, options.sysaudio); - if (app.use_freetype) |_| freetype.link(app.b, app.compile, options.freetype); // TODO: basisu support in wasm if (app.platform != .web) { diff --git a/build.zig.zon b/build.zig.zon index cee8e6f5..a8837e97 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -34,6 +34,10 @@ .url = "https://pkg.machengine.org/mach-glfw/8e78e0175951117213ea65fec32fd61f2e39f4ea.tar.gz", .hash = "12202c9e56ab6822cf9a16f1b5c15ff17ba17c67c1ec12aa77bc2313dfe9d3c235ec", }, + .mach_freetype = .{ + .url = "https://pkg.machengine.org/mach-freetype/1f064ee503c6fbc25585a08e29e97977a39967ee.tar.gz", + .hash = "1220d25639a4f634e294a83787bbd70088f4d1fd03d840ca3cda2d2e76c1765ecebb", + }, .glfw = .{ .url = "https://pkg.machengine.org/glfw/0e4cdba4216c6def0423462a2f21fef80683d56d.tar.gz", .hash = "1220a0b036095c2c54af347c86514ed9dab431299f0140b0e434ed119f85a976c32b", diff --git a/libs/mach-freetype b/libs/mach-freetype deleted file mode 160000 index 1c9e2d00..00000000 --- a/libs/mach-freetype +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1c9e2d001bce6ea59544c84363e87e38841ea2ea