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:
parent
cda1324e87
commit
8065504aba
1 changed files with 82 additions and 82 deletions
|
@ -1,7 +1,5 @@
|
|||
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 {
|
||||
// Standard release options allow the person running `zig build` to select
|
||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||
|
@ -76,14 +74,8 @@ pub fn Pkg(srcdir: []const u8) type {
|
|||
},
|
||||
}
|
||||
|
||||
raylib.setOutputDir("./");
|
||||
raylib.install();
|
||||
return raylib;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const lib = Pkg(".");
|
||||
|
||||
pub fn build(b: *std.build.Builder) void {
|
||||
// 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.
|
||||
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 ".";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue