From 8e67b0d23e71692fb12148e36cdea768da761239 Mon Sep 17 00:00:00 2001 From: nothke Date: Tue, 18 Jun 2024 03:25:27 +0200 Subject: [PATCH 1/4] Added zig gitignore --- .gitignore | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e179b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# This file is for zig-specific build artifacts. +# If you have OS-specific or editor-specific files to ignore, +# such as *.swp or .DS_Store, put those in your global +# ~/.gitignore and put this in your ~/.gitconfig: +# +# [core] +# excludesfile = ~/.gitignore +# +# Cheers! +# -andrewrk + +.zig-cache/ +zig-out/ +/release/ +/debug/ +/build/ +/build-*/ +/docgen_tmp/ + +# Although this was renamed to .zig-cache, let's leave it here for a few +# releases to make it less annoying to work with multiple branches. +zig-cache/ \ No newline at end of file From 8b43d4cf4e11eb5f1921bbffe17f49d8843c6867 Mon Sep 17 00:00:00 2001 From: nothke Date: Tue, 18 Jun 2024 03:26:18 +0200 Subject: [PATCH 2/4] Now working with latest zig version 0.14.0-dev.2+0884a4341 --- build.zig | 4 ++-- build.zig.zon | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.zig b/build.zig index e489196..8373898 100644 --- a/build.zig +++ b/build.zig @@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void { .name = "zigraylib", // In this case the main source file is merely a path, however, in more // complicated build scripts, this could be a generated file. - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); @@ -74,7 +74,7 @@ pub fn build(b: *std.Build) void { // Creates a step for unit testing. This only builds the test executable // but does not run it. const unit_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); diff --git a/build.zig.zon b/build.zig.zon index d04a1e3..d35f122 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,10 +1,10 @@ .{ .name = "zigraylib", - .version = "0.0.1", + .version = "0.0.2", .dependencies = .{ .raylib = .{ - .url = "https://github.com/raysan5/raylib/archive/b03c8ba945a06ed1ec3d6ed7c3185e1264909323.tar.gz", - .hash = "1220b6b6198344837d51588b1ed3f63cd6b56b2d60da675219f7578018b54f885830", + .url = "https://github.com/raysan5/raylib/archive/52f2a10db610d0e9f619fd7c521db08a876547d0.tar.gz", + .hash = "122078ad3e79fb83b45b04bd30fb63aaf936c6774db60095bc6987d325cbe5743373", }, }, .paths = .{ From e4b3cffe9065d31ed3f746284e6d3b872b6e937d Mon Sep 17 00:00:00 2001 From: nothke Date: Tue, 18 Jun 2024 03:28:25 +0200 Subject: [PATCH 3/4] Added version note in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a6229e6..9c00a78 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ cd zigraylib zig build run ``` -tested with zig version: `0.12.0` -using raylib commit: https://github.com/raysan5/raylib/tree/b03c8ba945a06ed1ec3d6ed7c3185e1264909323 +tested with zig version: `0.14.0-dev.2+0884a4341` +using raylib commit: https://github.com/raysan5/raylib/tree/52f2a10db610d0e9f619fd7c521db08a876547d0 ## resources [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html) From 8903592ff108f65ec2df93aed75f0e3f0117798b Mon Sep 17 00:00:00 2001 From: nothke Date: Mon, 15 Jul 2024 21:37:17 +0200 Subject: [PATCH 4/4] Added a check step to provide zls error output on save --- README.md | 17 +++++++++++++++-- build.zig | 13 +++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9c00a78..4d9dc2f 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,27 @@ A fairly minimal [raylib](https://www.raylib.com/) [zig](https://ziglang.org/dow This example requires one of the recent development releases of zig. ## install + ```bash git clone https://github.com/SimonLSchlee/zigraylib.git cd zigraylib zig build run ``` -tested with zig version: `0.14.0-dev.2+0884a4341` -using raylib commit: https://github.com/raysan5/raylib/tree/52f2a10db610d0e9f619fd7c521db08a876547d0 +Tested with zig version: `0.14.0-dev.2+0884a4341` +Using raylib commit: https://github.com/raysan5/raylib/tree/52f2a10db610d0e9f619fd7c521db08a876547d0 + +Note: If you don't have zig installed yet, I recommend using [zvm](https://www.zvm.app/) to help with installation. It also provides correct version of ZLS (Zig Language Server) that is compatible with the appropriate version. For example use `zvm i --zls master` to install the latest master with zls. + +### Live error checking + +This project has been configured so that ZLS can show live compile errors on save. To make it work, you need to set these zls config params (in VSCode just copy these to your preferences): +``` + "zig.zls.enableBuildOnSave": true, + "zig.zls.buildOnSaveStep": "check" +``` + +Also, if you're in VSCode, install ErrorLens extension so you can see the errors inline. ## resources [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html) diff --git a/build.zig b/build.zig index 8373898..0747297 100644 --- a/build.zig +++ b/build.zig @@ -48,6 +48,19 @@ pub fn build(b: *std.Build) void { // step when running `zig build`). b.installArtifact(exe); + // Check step - used by zls to show errors on build + const exe_check = b.addExecutable(.{ + .name = "check_step", + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }); + + exe_check.linkLibrary(raylib_dep.artifact("raylib")); + + const check = b.step("check", "Check if project compiles"); + check.dependOn(&exe_check.step); + // This *creates* a Run step in the build graph, to be executed when another // step is evaluated that depends on it. The next line below will establish // such a dependency.