From 17020ec40a277adf78a9cdd21e0f416a2e03aaac Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Tue, 9 Sep 2025 14:08:57 -0700 Subject: [PATCH] add structural aspects to repo --- .mise.toml | 8 ++++++++ .pre-commit-config.yaml | 30 ++++++++++++++++++++++++++++++ build.zig | 7 ++++++- build.zig.zon | 4 ++++ flake.nix | 3 +-- 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.mise.toml b/.mise.toml index 1deab06..4ef9eaf 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,3 +1,11 @@ [tools] zig = "0.15.1" zls = "0.15.0" +pre-commit = "latest" +"ubi:DonIsaac/zlint" = "latest" + +[hooks] +enter = 'echo use "nix develop" if you want to build' + +[settings] +experimental = true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..8b4786c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - repo: https://github.com/batmac/pre-commit-zig + rev: v0.3.0 + hooks: + - id: zig-fmt + - id: zig-build + - repo: local + hooks: + - id: test + name: Run zig build test + entry: zig + args: ["build", "test"] + language: system + types: [file] + pass_filenames: false + - id: zlint + name: Run zlint + entry: zlint + args: ["--deny-warnings", "--fix"] + language: system + types: [zig] diff --git a/build.zig b/build.zig index 424e1c6..961a197 100644 --- a/build.zig +++ b/build.zig @@ -8,7 +8,11 @@ pub fn build(b: *std.Build) void { const zlib_dep = b.dependency("zlib", .{ .target = target, - .optimize = optimize, + .optimize = .ReleaseFast, + }); + const sdl_dep = b.dependency("SDL", .{ + .target = target, + .optimize = .ReleaseFast, }); // We need to use curl for this as the domain doesn't work with zig TLS const model_step = ModelDownloadStep.create(b); @@ -35,6 +39,7 @@ pub fn build(b: *std.Build) void { exe.addIncludePath(vosk_dep.path("")); exe.addLibraryPath(vosk_dep.path("")); exe.linkLibrary(zlib_dep.artifact("z")); + exe.linkLibrary(sdl_dep.artifact("SDL2")); exe.linkSystemLibrary("vosk"); exe.linkSystemLibrary("asound"); diff --git a/build.zig.zon b/build.zig.zon index e06f2da..f4653f6 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -12,6 +12,10 @@ .url = "git+https://github.com/allyourcodebase/zlib#61e7df7e996ec5a5f13a653db3c419adb340d6ef", .hash = "zlib-1.3.1-ZZQ7lbYMAAB1hTSOKSXAKAgHsfDcyWNH_37ojw5WSpgR", }, + .SDL = .{ + .url = "git+https://github.com/allyourcodebase/SDL#d29847ebcb6da34dec466a06163431982500a092", + .hash = "SDL-2.32.6-JToi38aTEgECY2mV9iUG7dNouCbarfJ1mkzjjm53gC80", + }, }, .paths = .{ "build.zig", diff --git a/flake.nix b/flake.nix index 554b5d7..5c13104 100644 --- a/flake.nix +++ b/flake.nix @@ -15,10 +15,9 @@ devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ pkg-config - # zlib # handled directly in zig build alsa-lib alsa-plugins - SDL2 + SDL2 # This exists in AllYourCodeBase, but doesn't do it properly by handling dependencies ]; shellHook = ''