diff --git a/.gitignore b/.gitignore index 6ef2e7b..b220efd 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ # Cheers! # -andrewrk +.zig-cache/ +.zig-out/ zig-cache/ zig-out/ /release/ diff --git a/build.zig b/build.zig index ba0bb21..f211c98 100644 --- a/build.zig +++ b/build.zig @@ -1,7 +1,7 @@ const std = @import("std"); const builtin = @import("builtin"); -const mach_core = @import("mach_core"); +const mach = @import("mach"); pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); @@ -9,15 +9,15 @@ pub fn build(b: *std.Build) !void { const use_freetype = b.option(bool, "use_freetype", "Use Freetype") orelse false; - const mach_core_dep = b.dependency("mach_core", .{ + const mach_dep = b.dependency("mach", .{ .target = target, .optimize = optimize, }); const module = b.addModule("zig-imgui", .{ - .root_source_file = .{ .path = "src/imgui.zig" }, + .root_source_file = b.path("src/imgui.zig"), .imports = &.{ - .{ .name = "mach-core", .module = mach_core_dep.module("mach-core") }, + .{ .name = "mach", .module = mach_dep.module("mach") }, }, }); @@ -38,11 +38,11 @@ pub fn build(b: *std.Build) !void { try files.appendSlice(&.{ "src/cimgui.cpp", - imgui_dep.path("imgui.cpp").getPath(b), - imgui_dep.path("imgui_widgets.cpp").getPath(b), - imgui_dep.path("imgui_tables.cpp").getPath(b), - imgui_dep.path("imgui_draw.cpp").getPath(b), - imgui_dep.path("imgui_demo.cpp").getPath(b), + imgui_dep.builder.path("imgui.cpp").getPath(b), + imgui_dep.builder.path("imgui_widgets.cpp").getPath(b), + imgui_dep.builder.path("imgui_tables.cpp").getPath(b), + imgui_dep.builder.path("imgui_draw.cpp").getPath(b), + imgui_dep.builder.path("imgui_demo.cpp").getPath(b), }); if (use_freetype) { @@ -56,16 +56,21 @@ pub fn build(b: *std.Build) !void { } lib.addIncludePath(imgui_dep.path(".")); - lib.addCSourceFiles(.{ - .files = files.items, - .flags = flags.items, - }); + + for (files.items, 0..) |file, i| { + if (i == 0) { + lib.addCSourceFile(.{ .file = b.path(file), .flags = flags.items }); + } else { + lib.addCSourceFile(.{ .file = .{ .cwd_relative = file }, .flags = flags.items }); + } + } + b.installArtifact(lib); // Example const build_options = b.addOptions(); - const app = try mach_core.App.init(b, mach_core_dep.builder, .{ + const app = try mach.CoreApp.init(b, mach_dep.builder, .{ .name = "mach-imgui-example", .src = "examples/example_mach.zig", .target = target, @@ -83,7 +88,7 @@ pub fn build(b: *std.Build) !void { // Generator const generator_exe = b.addExecutable(.{ .name = "mach-imgui-generator", - .root_source_file = .{ .path = "src/generate.zig" }, + .root_source_file = b.path("src/generate.zig"), .target = target, .optimize = optimize, }); diff --git a/build.zig.zon b/build.zig.zon index e3e4a3f..4ec1d47 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -7,13 +7,14 @@ .name = "mach-imgui", .version = "0.1.0", .dependencies = .{ - .mach_core = .{ - .url = "https://pkg.machengine.org/mach-core/370bc1504cebaffcda5ed1ae9915fd2ac6778479.tar.gz", - .hash = "12205da1ecba58ba8c9ca65dbf75e32f42fde0490d34a98596ae72d4d3db81659dc5", + .mach = .{ + .url = "https://pkg.machengine.org/mach/b72f0e11b6d292c2b60789359a61f7ee6d7dc371.tar.gz", + .hash = "122015e1dac4afaf275f7f2adde3814e6a27f5799cbef96bb487ee305f7e33f4dca3", }, - .freetype = .{ - .url = "https://pkg.machengine.org/freetype/398638fd1cb723e478658ea371fe3be1a4dce0ae.tar.gz", - .hash = "12208c57b72e3fb5c8d5d3e667e2e21ca1d9e2b6fc3f84182b320f63933f591823da", + .mach_freetype = .{ + .url = "https://pkg.machengine.org/mach-freetype/86fc8024d4ddd53df75dfa4f3ad4eebe0b1b4284.tar.gz", + .hash = "12206251ed342f400b80abf3c338521f5d8c83eb596899abf77a2afe0cfd46e61ff0", + .lazy = true, }, .imgui = .{ .url = "https://github.com/ocornut/imgui/archive/refs/tags/v1.90.tar.gz", diff --git a/examples/example_mach.zig b/examples/example_mach.zig index 050b5de..c9510ac 100644 --- a/examples/example_mach.zig +++ b/examples/example_mach.zig @@ -2,8 +2,9 @@ const std = @import("std"); const build_options = @import("build-options"); const imgui = @import("imgui"); const imgui_mach = imgui.backends.mach; -const core = @import("mach-core"); -const gpu = core.gpu; +const mach = @import("mach"); +const core = mach.core; +const gpu = mach.gpu; pub const App = @This(); diff --git a/src/imgui_mach.zig b/src/imgui_mach.zig index 5831441..65bc365 100644 --- a/src/imgui_mach.zig +++ b/src/imgui_mach.zig @@ -1,6 +1,6 @@ const std = @import("std"); const imgui = @import("imgui.zig"); -const core = @import("mach-core"); +const core = @import("mach").core; const gpu = core.gpu; var allocator: std.mem.Allocator = undefined;