From 1891a420e86db0d3b54e12b9da600736f3f0bb81 Mon Sep 17 00:00:00 2001 From: kayomn Date: Mon, 17 Oct 2022 12:20:35 +0100 Subject: [PATCH] Reorganize and refactor project tooling --- .vscode/launch.json | 4 ++-- .vscode/tasks.json | 11 +---------- build.zig | 42 +++++++++++++++++++----------------------- src/engine/main.zig | 2 +- src/oar/main.zig | 16 ++++++++++------ src/tests.zig | 5 +++++ 6 files changed, 38 insertions(+), 42 deletions(-) create mode 100644 src/tests.zig diff --git a/.vscode/launch.json b/.vscode/launch.json index 195c1f0..4476fb8 100755 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,13 +2,13 @@ "version": "0.2.0", "configurations": [ { - "name": "Build", + "name": "Debug", "type": "gdb", "request": "launch", "target": "${workspaceFolder}/zig-out/bin/ona", "cwd": "${workspaceRoot}", "valuesFormatting": "parseText", - "preLaunchTask": "Build", + "preLaunchTask": "Build Debug", }, { "name": "Test", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 61ebf8f..c94af69 100755 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -3,7 +3,7 @@ "tasks": [ { - "label": "Build", + "label": "Build Debug", "type": "shell", "command": "zig build", @@ -41,15 +41,6 @@ } } }, - { - "label": "Test", - "type": "shell", - "command": "$(find zig-cache -name test) src/main.zig", - "group": { - "kind": "test", - "isDefault": true - }, - }, { "label": "Build Test", "type": "shell", diff --git a/build.zig b/build.zig index f0a0a5b..89dc34a 100644 --- a/build.zig +++ b/build.zig @@ -10,39 +10,35 @@ pub fn build(builder: *std.build.Builder) void { // Engine executable. { - const engine_exe = builder.addExecutable("ona", "./src/engine/main.zig"); - const oar_pkg = projectPkg("oar", &.{ona_pkg}); + const exe = builder.addExecutable("engine", "./src/engine/main.zig"); - engine_exe.addPackage(oar_pkg); - engine_exe.addPackage(ona_pkg); - engine_exe.setTarget(target); - engine_exe.setBuildMode(mode); - engine_exe.install(); - engine_exe.addIncludeDir("./ext"); - engine_exe.linkSystemLibrary("SDL2"); - engine_exe.linkLibC(); - - const run_cmd = engine_exe.run(); - - run_cmd.step.dependOn(builder.getInstallStep()); - - if (builder.args) |args| run_cmd.addArgs(args); - - builder.step("run", "Run Ona application").dependOn(&run_cmd.step); + exe.addPackage(projectPkg("oar", &.{ona_pkg})); + exe.addPackage(ona_pkg); + exe.setTarget(target); + exe.setBuildMode(mode); + exe.install(); + exe.addIncludeDir("./ext"); + exe.linkSystemLibrary("SDL2"); + exe.linkLibC(); } // Oar executable. { + const exe = builder.addExecutable("oar", "./src/oar/main.zig"); + exe.addPackage(ona_pkg); + exe.setTarget(target); + exe.setBuildMode(mode); + exe.install(); } - // Ona tests. + // Tests executable. { - const ona_tests = builder.addTestExe("test", "./src/main.zig"); + const tests = builder.addTestExe("test", "./src/tests.zig"); - ona_tests.setTarget(target); - ona_tests.setBuildMode(mode); - builder.step("test", "Run Ona unit tests").dependOn(&ona_tests.step); + tests.setTarget(target); + tests.setBuildMode(mode); + builder.step("test", "Run unit tests").dependOn(&tests.step); } } diff --git a/src/engine/main.zig b/src/engine/main.zig index 98a5af0..1dd0322 100644 --- a/src/engine/main.zig +++ b/src/engine/main.zig @@ -3,7 +3,7 @@ const std = @import("std"); const sys = @import("./sys.zig"); /// -/// Entry point. +/// Starts the the game engine. /// pub fn main() anyerror!void { return nosuspend await async sys.runGraphics(anyerror, run); diff --git a/src/oar/main.zig b/src/oar/main.zig index 98429ed..d5358fb 100644 --- a/src/oar/main.zig +++ b/src/oar/main.zig @@ -48,7 +48,7 @@ pub const Archive = struct { .header = find_header: { var header = Entry.Header{ .revision = 0, - .path = Path.empty, + .path = std.mem.zeroes(Path), .file_size = 0, .absolute_offset = 0 }; @@ -161,9 +161,13 @@ pub const Entry = struct { pub const Path = extern struct { buffer: [255]u8, length: u8, - - /// - /// - /// - pub const empty = std.mem.zeroes(Path); }; + +/// +/// Starts the **O**na **Ar**chive packer utility. +/// +pub fn main() u8 { + // TODO: Implement. + + return 0; +} diff --git a/src/tests.zig b/src/tests.zig new file mode 100644 index 0000000..0444b9e --- /dev/null +++ b/src/tests.zig @@ -0,0 +1,5 @@ +test { + _ = @import("./engine/main.zig"); + _ = @import("./oar/main.zig"); + _ = @import("./ona/main.zig"); +}