diff --git a/.gitmodules b/.gitmodules index aebde7ac..b43b4a42 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "mach-freetype"] - path = mach-freetype - url = https://github.com/hexops/mach-freetype [submodule "portaudio"] path = portaudio url = git@github.com:PortAudio/portaudio.git diff --git a/build.zig b/build.zig index e6a76186..539044c9 100644 --- a/build.zig +++ b/build.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const freetype = @import("mach-freetype/build.zig"); pub fn build(b: *std.build.Builder) !void { // Standard target options allows the person running `zig build` to choose @@ -13,11 +12,11 @@ pub fn build(b: *std.build.Builder) !void { const optimize = b.standardOptimizeOption(.{}); const exe = b.addExecutable(.{ .name = "Cubyzig", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = .{.path = "src/main.zig"}, .target = target, .optimize = optimize, }); - exe.addIncludePath("include"); + exe.addIncludePath(.{.path = "include"}); exe.linkLibC(); { // compile glfw from source: if(target.getOsTag() == .windows) { @@ -44,10 +43,10 @@ pub fn build(b: *std.build.Builder) !void { } } { // compile portaudio from source: - exe.addIncludePath("portaudio/include"); - exe.addIncludePath("portaudio/src/common"); + exe.addIncludePath(.{.path = "portaudio/include"}); + exe.addIncludePath(.{.path = "portaudio/src/common"}); exe.addCSourceFiles(&[_][]const u8 { - "portaudio/src/common/pa_allocation.c", + "portaudio/src/common/pa_allocation.c", "portaudio/src/common/pa_converters.c", "portaudio/src/common/pa_cpuload.c", "portaudio/src/common/pa_debugprint.c", @@ -61,7 +60,7 @@ pub fn build(b: *std.build.Builder) !void { if(target.getOsTag() == .windows) { // windows: exe.addCSourceFiles(&[_][]const u8 {"portaudio/src/os/win/pa_win_coinitialize.c", "portaudio/src/os/win/pa_win_hostapis.c", "portaudio/src/os/win/pa_win_util.c", "portaudio/src/os/win/pa_win_waveformat.c", "portaudio/src/os/win/pa_win_wdmks_utils.c", "portaudio/src/os/win/pa_x86_plain_converters.c", }, &[_][]const u8{"-g", "-O3", "-DPA_USE_WASAPI"}); - exe.addIncludePath("portaudio/src/os/win"); + exe.addIncludePath(.{.path = "portaudio/src/os/win"}); exe.linkSystemLibrary("ole32"); exe.linkSystemLibrary("winmm"); exe.linkSystemLibrary("uuid"); @@ -70,7 +69,7 @@ pub fn build(b: *std.build.Builder) !void { } else if(target.getOsTag() == .linux) { // unix: exe.addCSourceFiles(&[_][]const u8 {"portaudio/src/os/unix/pa_unix_hostapis.c", "portaudio/src/os/unix/pa_unix_util.c"}, &[_][]const u8{"-g", "-O3", "-DPA_USE_ALSA"}); - exe.addIncludePath("portaudio/src/os/unix"); + exe.addIncludePath(.{.path = "portaudio/src/os/unix"}); // ALSA: exe.addCSourceFiles(&[_][]const u8 {"portaudio/src/hostapi/alsa/pa_linux_alsa.c"}, &[_][]const u8{"-g", "-O3"}); exe.linkSystemLibrary("asound"); @@ -81,11 +80,18 @@ pub fn build(b: *std.build.Builder) !void { exe.addCSourceFiles(&[_][]const u8{"lib/glad.c", "lib/stb_image.c", "lib/stb_image_write.c", "lib/stb_vorbis.c"}, &[_][]const u8{"-g", "-O3"}); exe.addAnonymousModule("gui", .{.source_file = .{.path = "src/gui/gui.zig"}}); exe.addAnonymousModule("server", .{.source_file = .{.path = "src/server/server.zig"}}); - const harfbuzzModule = freetype.harfbuzzModule(b); - const freetypeModule = harfbuzzModule.dependencies.get("freetype").?; - exe.addModule("harfbuzz", harfbuzzModule); - exe.addModule("freetype", freetypeModule); - freetype.link(b, exe, .{ .harfbuzz = .{} }); + + @import("mach_freetype").brotli_import_path = "mach_freetype.freetype.brotli"; + @import("mach_freetype").freetype_import_path = "mach_freetype.freetype"; + const mach_freetype_dep = b.dependency("mach_freetype", .{ + .target = target, + .optimize = optimize, + }); + exe.addModule("freetype", mach_freetype_dep.module("mach-freetype")); + exe.addModule("harfbuzz", mach_freetype_dep.module("mach-harfbuzz")); + @import("mach_freetype").linkFreetype(b, optimize, target, exe); + @import("mach_freetype").linkHarfbuzz(b, optimize, target, exe); + //exe.strip = true; // Improves compile-time //exe.sanitize_thread = true; b.installArtifact(exe); diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 00000000..14f56ce4 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,22 @@ +.{ + .name = "Cubyzig", + .version = "0.0.0", + .dependencies = .{ + .mach_freetype = .{ + .url = "https://pkg.machengine.org/mach-freetype/de94b3a5fa14b717936a8881c7e7966d544bf4d0.tar.gz", + .hash = "1220b1c6027993ca41ea5a3a62b16de2f6689092205c39508af4de3e9cfec0bb7607", + }, + .freetype = .{ + .url = "https://pkg.machengine.org/freetype/835d7f07c605eec021911c671f0dad2b25ee5a30.tar.gz", + .hash = "122093dd7a4c91fcad6d44601f879a2d7d66700cdf8a2053e4ffdbfb26cd1b597a18", + }, + .brotli = .{ + .url = "https://pkg.machengine.org/brotli/b574788e32438f543ee552beec8bc70b05a465c2.tar.gz", + .hash = "122054602e178b287f13ed7b37c4bd54eb50af88dc2f9d9ba9e3c084fb4175f298a1", + }, + .harfbuzz = .{ + .url = "https://pkg.machengine.org/harfbuzz/616fc99a8408309da7ce07aa43de2eb634b0bc19.tar.gz", + .hash = "12206659398359bd48edbdcc5cf610ccff2b7af04a93acc946197a444bbe6ad34061", + }, + }, +} \ No newline at end of file diff --git a/mach-freetype b/mach-freetype deleted file mode 160000 index 3365aadd..00000000 --- a/mach-freetype +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3365aadd69674eeed497f0bf6ca535e64f4937a9 diff --git a/src/graphics.zig b/src/graphics.zig index a37cf1fa..4e53fb5e 100644 --- a/src/graphics.zig +++ b/src/graphics.zig @@ -576,7 +576,7 @@ pub const TextBuffer = struct { buffer.setDirection(.ltr); buffer.setScript(.common); buffer.setLanguage(harfbuzz.Language.getDefault()); - harfbuzz.hb_shape(TextRendering.harfbuzzFont.handle, buffer.handle, null, 0); + TextRendering.harfbuzzFont.shape(buffer, null); const glyphInfos = buffer.getGlyphInfos(); const glyphPositions = buffer.getGlyphPositions().?;