Skip to content

Commit

Permalink
[build.zig] pass the real build.zig file (#4113)
Browse files Browse the repository at this point in the history
`@This()` was naively passed to `dependencyFromBuildZig` while inside
a file that is not actually the build file, causing a panic when
actually used. Passing `@import("../build.zig")` fixes this.
  • Loading branch information
InKryption committed Jun 27, 2024
1 parent 57b5f11 commit 5e91444
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ comptime {
// get the flags a second time when adding raygui
var raylib_flags_arr: std.ArrayListUnmanaged([]const u8) = .{};

/// we're not inside the actual build script recognized by the
/// zig build system; use this type where one would otherwise
/// use `@This()` when inside the actual entrypoint file.
const BuildScript = @import("../build.zig");

// This has been tested with zig version 0.12.0
pub fn addRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile {
const raylib_dep = b.dependencyFromBuildZig(@This(), .{
const raylib_dep = b.dependencyFromBuildZig(BuildScript, .{
.target = target,
.optimize = optimize,
.raudio = options.raudio,
Expand Down

0 comments on commit 5e91444

Please sign in to comment.