Reorganize and refactor project tooling
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kayomn 2022-10-17 12:20:35 +01:00
parent 489ece4b7b
commit 1891a420e8
6 changed files with 38 additions and 42 deletions

4
.vscode/launch.json vendored
View File

@ -2,13 +2,13 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Build", "name": "Debug",
"type": "gdb", "type": "gdb",
"request": "launch", "request": "launch",
"target": "${workspaceFolder}/zig-out/bin/ona", "target": "${workspaceFolder}/zig-out/bin/ona",
"cwd": "${workspaceRoot}", "cwd": "${workspaceRoot}",
"valuesFormatting": "parseText", "valuesFormatting": "parseText",
"preLaunchTask": "Build", "preLaunchTask": "Build Debug",
}, },
{ {
"name": "Test", "name": "Test",

11
.vscode/tasks.json vendored
View File

@ -3,7 +3,7 @@
"tasks": [ "tasks": [
{ {
"label": "Build", "label": "Build Debug",
"type": "shell", "type": "shell",
"command": "zig build", "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", "label": "Build Test",
"type": "shell", "type": "shell",

View File

@ -10,39 +10,35 @@ pub fn build(builder: *std.build.Builder) void {
// Engine executable. // Engine executable.
{ {
const engine_exe = builder.addExecutable("ona", "./src/engine/main.zig"); const exe = builder.addExecutable("engine", "./src/engine/main.zig");
const oar_pkg = projectPkg("oar", &.{ona_pkg});
engine_exe.addPackage(oar_pkg); exe.addPackage(projectPkg("oar", &.{ona_pkg}));
engine_exe.addPackage(ona_pkg); exe.addPackage(ona_pkg);
engine_exe.setTarget(target); exe.setTarget(target);
engine_exe.setBuildMode(mode); exe.setBuildMode(mode);
engine_exe.install(); exe.install();
engine_exe.addIncludeDir("./ext"); exe.addIncludeDir("./ext");
engine_exe.linkSystemLibrary("SDL2"); exe.linkSystemLibrary("SDL2");
engine_exe.linkLibC(); 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);
} }
// Oar executable. // 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); tests.setTarget(target);
ona_tests.setBuildMode(mode); tests.setBuildMode(mode);
builder.step("test", "Run Ona unit tests").dependOn(&ona_tests.step); builder.step("test", "Run unit tests").dependOn(&tests.step);
} }
} }

View File

@ -3,7 +3,7 @@ const std = @import("std");
const sys = @import("./sys.zig"); const sys = @import("./sys.zig");
/// ///
/// Entry point. /// Starts the the game engine.
/// ///
pub fn main() anyerror!void { pub fn main() anyerror!void {
return nosuspend await async sys.runGraphics(anyerror, run); return nosuspend await async sys.runGraphics(anyerror, run);

View File

@ -48,7 +48,7 @@ pub const Archive = struct {
.header = find_header: { .header = find_header: {
var header = Entry.Header{ var header = Entry.Header{
.revision = 0, .revision = 0,
.path = Path.empty, .path = std.mem.zeroes(Path),
.file_size = 0, .file_size = 0,
.absolute_offset = 0 .absolute_offset = 0
}; };
@ -161,9 +161,13 @@ pub const Entry = struct {
pub const Path = extern struct { pub const Path = extern struct {
buffer: [255]u8, buffer: [255]u8,
length: 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;
}

5
src/tests.zig Normal file
View File

@ -0,0 +1,5 @@
test {
_ = @import("./engine/main.zig");
_ = @import("./oar/main.zig");
_ = @import("./ona/main.zig");
}