Skip to content

Commit

Permalink
build: depend on mach-freetype via package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
alichraghi committed Aug 1, 2023
1 parent a20476a commit edde8ec
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
12 changes: 5 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(.{});
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion libs/mach-freetype
Submodule mach-freetype deleted from 1c9e2d

0 comments on commit edde8ec

Please sign in to comment.