mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-05 17:36:26 +00:00
Simplify build.zig to not require user to specify raylib path (#2383)
We can figure out the source file location based on the location of the build.zig file. No need to require the library user to specify where raylib is stored.
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn Pkg(srcdir: []const u8) type {
|
|
||||||
return struct {
|
|
||||||
pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.LibExeObjStep {
|
pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.LibExeObjStep {
|
||||||
// Standard release options allow the person running `zig build` to select
|
// Standard release options allow the person running `zig build` to select
|
||||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||||
@@ -76,14 +74,8 @@ pub fn Pkg(srcdir: []const u8) type {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
raylib.setOutputDir("./");
|
|
||||||
raylib.install();
|
|
||||||
return raylib;
|
return raylib;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const lib = Pkg(".");
|
|
||||||
|
|
||||||
pub fn build(b: *std.build.Builder) void {
|
pub fn build(b: *std.build.Builder) void {
|
||||||
// Standard target options allows the person running `zig build` to choose
|
// Standard target options allows the person running `zig build` to choose
|
||||||
@@ -92,5 +84,13 @@ pub fn build(b: *std.build.Builder) void {
|
|||||||
// for restricting supported target set are available.
|
// for restricting supported target set are available.
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
|
|
||||||
_ = lib.addRaylib(b, target);
|
const lib = addRaylib(b, target);
|
||||||
|
lib.setOutputDir(srcdir);
|
||||||
|
lib.install();
|
||||||
|
}
|
||||||
|
|
||||||
|
const srcdir = getSrcDir();
|
||||||
|
|
||||||
|
fn getSrcDir() []const u8 {
|
||||||
|
return std.fs.path.dirname(@src().file) orelse ".";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user