Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the ones from /release/ to /docgen_tmp/ I have never seen these, what does generate those?


# 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/
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 15 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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.
Expand All @@ -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,
});
Expand Down
6 changes: 3 additions & 3 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -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 = .{
Expand Down