Skip to content

Commit

Permalink
Rename main to Zig and update build.zig.
Browse files Browse the repository at this point in the history
  • Loading branch information
Makosai committed Aug 18, 2024
1 parent f77909c commit df3f852
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "godot-zig"]
path = zig/godot-zig
url = https://github.com/godot-zig/godot-zig
branch = stable
3 changes: 0 additions & 3 deletions zig/.gitmodules

This file was deleted.

20 changes: 19 additions & 1 deletion zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.*);
}
/////////////////////////////////////////////////

Expand All @@ -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);
}
File renamed without changes.

0 comments on commit df3f852

Please sign in to comment.