summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralaric <alaric@netmythos.org>2024-04-15 15:49:33 -0700
committeralaric <alaric@netmythos.org>2024-04-15 15:49:33 -0700
commit7180e5b0907f9125b3f45c9efa75fb03e400c98b (patch)
tree86a532566caa6e99dad2bdd58ffbe19cae1d45a6
downloadtiny-synth-7180e5b0907f9125b3f45c9efa75fb03e400c98b.tar.gz
tiny-synth-7180e5b0907f9125b3f45c9efa75fb03e400c98b.zip
Initial Commit
-rw-r--r--.gitignore1
-rw-r--r--.gitmodules3
-rw-r--r--build.zig45
-rw-r--r--build.zig.zon35
m---------engine0
-rw-r--r--flake.lock146
-rw-r--r--flake.nix48
-rw-r--r--src/main.zig14
8 files changed, 292 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4c80a22
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+zig-*
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..933415a
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "engine"]
+ path = engine
+ url = git@netmythos.org:engine.git
diff --git a/build.zig b/build.zig
new file mode 100644
index 0000000..e0567c3
--- /dev/null
+++ b/build.zig
@@ -0,0 +1,45 @@
+const std = @import("std");
+
+pub fn build(b: *std.Build) void {
+ // The engine only supports wasm right now so if you set a whitelist here,
+ // you won't have to remember to specify your target each time you compile.
+ const wasm_target: std.Target.Query = .{
+ .cpu_arch = .wasm32,
+ .os_tag = .freestanding,
+ };
+ const target = b.standardTargetOptions(.{
+ .whitelist = &.{wasm_target},
+ .default_target = wasm_target,
+ });
+ const optimize = b.standardOptimizeOption(.{});
+
+ // Import the dependency via your build.zig.zon
+ const engine = b.dependency("engine", .{});
+
+ const exe = b.addExecutable(.{
+ // IMPORTANT! Right now the shell expects a file named game.wasm in the bin directory.
+ // I will make it flexible eventually. But right now if you change this line,
+ // Your project won't work right.
+ .name = "game",
+ .root_source_file = .{ .path = "src/main.zig" },
+ .target = target,
+ .optimize = optimize,
+ });
+ // WASM doesn't use a normal entry point. The HTML/JS shell code is going
+ // to handle calling our functions.
+ exe.entry = .disabled;
+ exe.root_module.addImport("engine", engine.module("engine"));
+
+ // Here we install a pre-written HTML/JS shell. After building, if you
+ // run a webserver with your zig-out dir as the root, you should see your
+ // program.
+ const shell_files = engine.namedWriteFiles("shell");
+ const install_shell = b.addInstallDirectory(.{
+ .source_dir = .{ .generated = &shell_files.generated_directory },
+ .install_dir = .prefix,
+ .install_subdir = "",
+ });
+ b.getInstallStep().dependOn(&install_shell.step);
+
+ b.installArtifact(exe);
+}
diff --git a/build.zig.zon b/build.zig.zon
new file mode 100644
index 0000000..2f05195
--- /dev/null
+++ b/build.zig.zon
@@ -0,0 +1,35 @@
+.{
+ .name = "tiny-synth",
+ // This is a [Semantic Version](https://semver.org/).
+ // In a future version of Zig it will be used for package deduplication.
+ .version = "0.0.0",
+
+ // This field is optional.
+ // This is currently advisory only; Zig does not yet do anything
+ // with this value.
+ //.minimum_zig_version = "0.11.0",
+
+ // This field is optional.
+ // Each dependency must either provide a `url` and `hash`, or a `path`.
+ // `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
+ // Once all dependencies are fetched, `zig build` no longer requires
+ // internet connectivity.
+ .dependencies = .{
+ .engine = .{
+ .path = "engine",
+ },
+ },
+ .paths = .{
+ // This makes *all* files, recursively, included in this package. It is generally
+ // better to explicitly list the files and directories instead, to insure that
+ // fetching from tarballs, file system paths, and version control all result
+ // in the same contents hash.
+ "",
+ // For example...
+ //"build.zig",
+ //"build.zig.zon",
+ //"src",
+ //"LICENSE",
+ //"README.md",
+ },
+}
diff --git a/engine b/engine
new file mode 160000
+Subproject 89ed3b75abde2bc08eb1638d5c0becc8606e6a9
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..301523f
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,146 @@
+{
+ "nodes": {
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1696426674,
+ "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-compat_2": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1673956053,
+ "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1710146030,
+ "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "flake-utils_2": {
+ "locked": {
+ "lastModified": 1659877975,
+ "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1704290814,
+ "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-23.05",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1702350026,
+ "narHash": "sha256-A+GNZFZdfl4JdDphYKBJ5Ef1HOiFsP18vQe9mqjmUis=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "9463103069725474698139ab10f17a9d125da859",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-23.05",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs",
+ "zig": "zig"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ },
+ "zig": {
+ "inputs": {
+ "flake-compat": "flake-compat_2",
+ "flake-utils": "flake-utils_2",
+ "nixpkgs": "nixpkgs_2"
+ },
+ "locked": {
+ "lastModified": 1713148774,
+ "narHash": "sha256-Rgre3huuqrhbf7u5wUosNSBTMMriq64FOhf5eA6c9yI=",
+ "owner": "mitchellh",
+ "repo": "zig-overlay",
+ "rev": "cc3d23d74b1141edf0ce9be39b7b1af80141f9f0",
+ "type": "github"
+ },
+ "original": {
+ "owner": "mitchellh",
+ "repo": "zig-overlay",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..2859429
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,48 @@
+{
+ description = "The flake for the Tiny TD";
+
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
+ flake-utils.url = "github:numtide/flake-utils";
+ zig.url = "github:mitchellh/zig-overlay";
+
+ # Used for shell.nix
+ flake-compat = {
+ url = "github:edolstra/flake-compat";
+ flake = false;
+ };
+ };
+
+ outputs = {
+ self,
+ nixpkgs,
+ flake-utils,
+ ...
+ } @ inputs: let
+ overlays = [
+ # Other overlays
+ (final: prev: {
+ zigpkgs = inputs.zig.packages.${prev.system};
+ })
+ ];
+
+ # Our supported systems are the same supported systems as the Zig binaries
+ systems = builtins.attrNames inputs.zig.packages;
+ in
+ flake-utils.lib.eachSystem systems (
+ system: let
+ pkgs = import nixpkgs {inherit overlays system;};
+ in {
+ devShells.default = pkgs.mkShell {
+ nativeBuildInputs = with pkgs; [
+ zigpkgs.master
+ python3
+ ];
+ };
+
+ # For compatibility with older versions of the `nix` binary
+ devShell = self.devShells.${system}.default;
+ }
+ );
+}
+
diff --git a/src/main.zig b/src/main.zig
new file mode 100644
index 0000000..11ee946
--- /dev/null
+++ b/src/main.zig
@@ -0,0 +1,14 @@
+const engine = @import("engine");
+const input = engine.input;
+
+pub fn init() void {}
+pub fn update(dt: f32) void {
+ _ = dt;
+}
+pub fn handleInput(ev: input.InputEvent) void {
+ _ = ev;
+}
+
+comptime {
+ _ = engine;
+}