Open ProIcons opened 7 months ago
now it does
are you sure that #40 is fixed with that? because it seems that I still get it
are you sure that #40 is fixed with that? because it seems that I still get it
just do:
raylib.addTo(b, exe, target.query, optimize, .{});
are you sure that #40 is fixed with that? because it seems that I still get it
just do:
raylib.addTo(b, exe, target.query, optimize, .{});
I guess this PR should also change the README to avoid confusions then.
Btw, I keep seeing the same error as #40 even when using your fork, zig 0.11.0 and this particular snippet. Maybe I'm doing something wrong.
are you sure that #40 is fixed with that? because it seems that I still get it
just do:
raylib.addTo(b, exe, target.query, optimize, .{});
I guess this PR should also change the README to avoid confusions then.
Btw, I keep seeing the same error as #40 even when using your fork, zig 0.11.0 and this particular snippet. Maybe I'm doing something wrong.
Changing:
std.Target.Query
-> std.Build.ResolvedTarget
b.resolveTargetQuery(target),
-> target,
fixes it for me (I'm using latest zig)
It seems like even the official raylib repo is having to use some workarounds to deal with these API breakages (see the anytype
there).
Tested with latest zig 0.12.0, working as expected
Tried it and i still get:
file paths added with 'addCSourceFiles' must be relative.
// game/ext/raylib/raylib/src/build.zig:51
addCSourceFilesVersioned(raylib, &.{
srcdir ++ "/rcore.c",
srcdir ++ "/utils.c",
}, raylib_flags_arr.items);
Thank you @ProIcons so much for the PR. I finally able to build with Zig 0.12! Here's my process:
cd $YOUR_SRC_FOLDER
git submodule add git@github.com:ProIcons/raylib.zig.git raylib
git submodule update --init --recursive
zig init
main.zig
to:
const std = @import("std");
const raylib = @import("raylib");
pub fn main() !void { raylib.SetConfigFlags(raylib.ConfigFlags{ .FLAG_WINDOW_RESIZABLE = true }); raylib.InitWindow(800, 800, "hello world!"); raylib.SetTargetFPS(60);
defer raylib.CloseWindow();
while (!raylib.WindowShouldClose()) {
raylib.BeginDrawing();
defer raylib.EndDrawing();
raylib.ClearBackground(raylib.BLACK);
raylib.DrawFPS(10, 10);
raylib.DrawText("hello world!", 100, 100, 20, raylib.YELLOW);
}
}
Edit `build.zig` to:
```zig
const raylib = @import("raylib/build.zig");
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const lib = b.addStaticLibrary(.{
.name = "rayray",
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(lib);
const exe = b.addExecutable(.{
.name = "rayray",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
raylib.addTo(b, exe, target.query, optimize, .{});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const lib_unit_tests = b.addTest(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const exe_unit_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
test_step.dependOn(&run_exe_unit_tests.step);
}
zig build run
I'm on Arch Linux, Zig 0.12.
It relies on: https://github.com/raysan5/raylib/pull/3891
Fixes: #40 #39 #37 It doesn't however fix the parsing, which in the end might cause crashes if raylib is changed significantly.