From df3f85282ab7ff3e2482bcee1aea23bda1880cef Mon Sep 17 00:00:00 2001 From: Makosai Date: Sun, 18 Aug 2024 10:10:50 -0400 Subject: [PATCH] Rename main to Zig and update build.zig. --- .gitmodules | 4 ++++ zig/.gitmodules | 3 --- zig/build.zig | 20 +++++++++++++++++++- zig/src/{Reia.zig => main.zig} | 0 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 .gitmodules delete mode 100644 zig/.gitmodules rename zig/src/{Reia.zig => main.zig} (100%) diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..d2afda60 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "godot-zig"] + path = zig/godot-zig + url = https://github.com/godot-zig/godot-zig + branch = stable diff --git a/zig/.gitmodules b/zig/.gitmodules deleted file mode 100644 index a3438309..00000000 --- a/zig/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "godot-zig"] - path = godot-zig - url = https://github.com/godot-zig/godot-zig \ No newline at end of file diff --git a/zig/build.zig b/zig/build.zig index b8062052..c2fce6ad 100644 --- a/zig/build.zig +++ b/zig/build.zig @@ -7,20 +7,31 @@ pub fn build(b: *std.Build) !void { const lib = b.addSharedLibrary(.{ .name = "reia", - .root_source_file = .{ .path = "src/Reia.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); + const tests = b.addTest(.{ + .name = "test", + .target = target, + .optimize = optimize, + .root_source_file = b.path("src/main.zig"), + .test_runner = b.path("test_runner.zig"), + }); + const godot_zig_build = @import("./godot-zig/build.zig"); const godot = godot_zig_build.createModule(b, target, optimize, godot_path); + lib.root_module.addImport("godot", godot); + tests.root_module.addImport("godot", godot); // use explicit imports to make jump work properly // todo: remove this once zls get improved var iter = godot.import_table.iterator(); while (iter.next()) |it| { lib.root_module.addImport(it.key_ptr.*, it.value_ptr.*); + tests.root_module.addImport(it.key_ptr.*, it.value_ptr.*); } ///////////////////////////////////////////////// @@ -30,7 +41,14 @@ pub fn build(b: *std.Build) !void { const run_cmd = b.addSystemCommand(&.{ godot_path, "--path", "../godot", }); + run_cmd.step.dependOn(b.getInstallStep()); const run_step = b.step("run", "Run with Godot"); run_step.dependOn(&run_cmd.step); + + const run_tests = b.addRunArtifact(tests); + run_tests.has_side_effects = true; + run_tests.step.dependOn(b.getInstallStep()); + const test_step = b.step("test", "Run tests with Godot"); + test_step.dependOn(&run_tests.step); } diff --git a/zig/src/Reia.zig b/zig/src/main.zig similarity index 100% rename from zig/src/Reia.zig rename to zig/src/main.zig