Compare commits

...

3 Commits

Author SHA1 Message Date
kayomn f49906c714 Fix Zig test build errors
continuous-integration/drone/push Build is passing Details
2024-07-24 00:56:14 +01:00
kayomn 09872990a1 Fix test build error 2024-07-24 00:54:44 +01:00
kayomn 08b5d7539c Update readme with promotional content and new build instructions 2024-07-24 00:54:14 +01:00
7 changed files with 76 additions and 8 deletions

View File

@ -21,5 +21,5 @@ steps:
- wget https://ziglang.org/download/$${ZIG_VERSION}/zig-linux-x86_64-$${ZIG_VERSION}.tar.xz - wget https://ziglang.org/download/$${ZIG_VERSION}/zig-linux-x86_64-$${ZIG_VERSION}.tar.xz
- tar -xf zig-linux-x86_64-$${ZIG_VERSION}.tar.xz - tar -xf zig-linux-x86_64-$${ZIG_VERSION}.tar.xz
- export PATH=$PATH:$(pwd)/zig-linux-x86_64-$${ZIG_VERSION} - export PATH=$PATH:$(pwd)/zig-linux-x86_64-$${ZIG_VERSION}
- zig build - zig build tests
- zig build test - zig build demos

1
.gitattributes vendored
View File

@ -1,2 +1,3 @@
*.bmp filter=lfs diff=lfs merge=lfs -text *.bmp filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.spv filter=lfs diff=lfs merge=lfs -text *.spv filter=lfs diff=lfs merge=lfs -text

View File

@ -21,6 +21,5 @@
"**/Thumbs.db": true, "**/Thumbs.db": true,
"**/.zig-cache": true, "**/.zig-cache": true,
"zig-out": true, "zig-out": true,
".drone.yml": true,
}, },
} }

View File

@ -59,7 +59,7 @@ const Project = struct {
} }
pub fn find_tests(self: Project, b: *std.Build) !void { pub fn find_tests(self: Project, b: *std.Build) !void {
const tests = b.step("test", "Build and run tests"); const tests = b.step("tests", "Build and run tests");
for (self.imports.items) |import| { for (self.imports.items) |import| {
tests.dependOn(&b.addRunArtifact(b.addTest(.{ tests.dependOn(&b.addRunArtifact(b.addTest(.{

BIN
promo/effects.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,5 +1,7 @@
# Ona # Ona
![Screenshot of Ona rendering a CRT display distrotion effect on the default texture](promo/effects.png)
## Table of Contents ## Table of Contents
1. [Overview](#overview) 1. [Overview](#overview)
@ -32,12 +34,75 @@ Ona is also the Catalan word for "wave".
Ona currently depends the following third-party tools to build it: Ona currently depends the following third-party tools to build it:
* Platform support for SDL2 at version 2.0.20 or above. * Platform support for SDL2 at version 2.0.20 installed via the standard shared binary format redistributable.
* SPIR-V shader compilation system utilities, namely `glslangValidator`. * SPIR-V shader compilation system utilities available from the system path, namely `glslangValidator`.
* Zig compiler toolchain. * Zig compiler toolchain.
As the project evolves, dependencies on libraries external to the project codebase will be minimized or removed outright to meet the goals of the project as closely as possible. As the project evolves, dependencies on libraries external to the project codebase will be minimized or removed outright to meet the goals of the project as closely as possible.
### Building ### Building
Once all third-party tools and system-wide dependencies are satisfied, navigate to the root project folder and run `zig build` to build everything. After the repository has finished cloning, you will then want to also clone all Git submodule dependencies via the `git submodule update --init --recursive` command. If you are using a Git front-end, this may be a menu option or is handled *automagically*, it varies depending on the front-end.
Once all third-party tools and dependencies are satisfied, navigate to the root project folder and run `zig build demos` to build the demo executables. The resulting binaries will be placed in `/demos` will a name respective to the source file it was built from.
To experiment without creating your own Zig project, you can create a new uniquely named source file in this directory and the `zig build demos` step will (re)build it along with everything else.
The unit testing suite for the engine modules (`src/ona`, `src/coral`, etc.) may be built and ran via `zig build tests`.
Tests are ran by our continuous integration host so should these shouldn't fail locally without user intervention. If they do, feel free to report an issue via my email linked in my Sauce Control bio or through any other means of public communication I have.
### Packaging
Since this is a Zig package it can be consumed via the Zig package manager using the usual steps.
(These steps have been adapted from [Andre Weissflog's tutorial for for setting up Sokol with Zig package manager](https://github.com/floooh/sokol-zig/blob/master/README.md).)
1. Create a new Zig project if you have not already.
2. Create a `build.zig.zon` accompanying your `build.zig` if you do not already have one.
3. Your `build.zig.zon` should, at minimum, contain the following dependency listed in the dependencies section:
```zig
.{
.dependencies = .{
.ona = .{
.url = "git+https://sauce.pizzawednes.day/kayomn/ona.git#[commit-hash]",
},
},
}
```
4. Make sure the `[commit-hash]` is a recent commit that will work with your version of the Zig compiler and, when in doubt, choose the latest `master` commit.
5. Run `zig build` and add the content hash it outputs in your terminal to your dependencies:
```zig
.{
.dependencies = .{
.ona = .{
.url = "git+https://sauce.pizzawednes.day/kayomn/ona.git#[commit-hash]",
.hash = "[content-hash]",
},
},
}
```
6. Add a package declaration for Ona to your `build.zig` and add the relevant modules to your application.
```zig
const ona_dependency = b.dependency("ona", .{
.target = target,
.optimize = optimize,
});
const app = b.addExecutable(.{
.name = "My Ona App",
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/main.zig"),
});
app.root_module.addImport("ona", ona_dependency.module("ona"));
app.root_module.addImport("coral", ona_dependency.module("coral"));
app.root_module.addImport("input", ona_dependency.module("input"));
```

View File

@ -3,7 +3,7 @@ const ona = @import("ona");
const std = @import("std"); const std = @import("std");
pub const Axis = struct { pub const Axis = struct {
keys: ?[2]Event.Key = null, keys: ?[2]Key = null,
}; };
pub const Event = union (enum) { pub const Event = union (enum) {