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 diff --git a/README.md b/README.md index a6229e6..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.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 + +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 e489196..0747297 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, }); @@ -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. @@ -74,7 +87,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 = .{