mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 03:57:29 +00:00
[build] Only cache raygui impl (#170)
This commit is contained in:
parent
a420751c0d
commit
2f773da6b3
87
build.zig
87
build.zig
@ -97,52 +97,55 @@ fn link(
|
||||
exe.linkLibrary(lib);
|
||||
}
|
||||
|
||||
var _raylib_lib_cache: ?*std.Build.Step.Compile = null;
|
||||
var _raygui_impl_cache: ?*std.Build.Step.WriteFile = null;
|
||||
var _raygui_impl_path_cache: ?std.Build.LazyPath = null;
|
||||
fn getRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) *std.Build.Step.Compile {
|
||||
if (_raylib_lib_cache) |lib| return lib else {
|
||||
const raylib = b.dependency("raylib", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.raudio = options.raudio,
|
||||
.rmodels = options.rmodels,
|
||||
.rshapes = options.rshapes,
|
||||
.rtext = options.rtext,
|
||||
.rtextures = options.rtextures,
|
||||
.platform = options.platform,
|
||||
.shared = options.shared,
|
||||
.linux_display_backend = options.linux_display_backend,
|
||||
.opengl_version = options.opengl_version,
|
||||
});
|
||||
|
||||
const lib = raylib.artifact("raylib");
|
||||
|
||||
const raygui_dep = b.dependency("raygui", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
if (_raygui_impl_cache == null) {
|
||||
var gen_step = b.addWriteFiles();
|
||||
lib.step.dependOn(&gen_step.step);
|
||||
|
||||
const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
|
||||
lib.addCSourceFile(.{
|
||||
.file = raygui_c_path,
|
||||
.flags = &[_][]const u8{
|
||||
"-std=gnu99",
|
||||
"-D_GNU_SOURCE",
|
||||
"-DGL_SILENCE_DEPRECATION=199309L",
|
||||
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/3674
|
||||
},
|
||||
});
|
||||
lib.addIncludePath(raylib.path("src"));
|
||||
lib.addIncludePath(raygui_dep.path("src"));
|
||||
|
||||
lib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h");
|
||||
|
||||
b.installArtifact(lib);
|
||||
_raylib_lib_cache = lib;
|
||||
return lib;
|
||||
_raygui_impl_cache = gen_step;
|
||||
_raygui_impl_path_cache = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
|
||||
}
|
||||
|
||||
const raylib = b.dependency("raylib", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.raudio = options.raudio,
|
||||
.rmodels = options.rmodels,
|
||||
.rshapes = options.rshapes,
|
||||
.rtext = options.rtext,
|
||||
.rtextures = options.rtextures,
|
||||
.platform = options.platform,
|
||||
.shared = options.shared,
|
||||
.linux_display_backend = options.linux_display_backend,
|
||||
.opengl_version = options.opengl_version,
|
||||
});
|
||||
|
||||
const lib = raylib.artifact("raylib");
|
||||
|
||||
const raygui_dep = b.dependency("raygui", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
lib.step.dependOn(&(_raygui_impl_cache orelse unreachable).step);
|
||||
|
||||
lib.addCSourceFile(.{
|
||||
.file = (_raygui_impl_path_cache orelse unreachable),
|
||||
.flags = &[_][]const u8{
|
||||
"-std=gnu99",
|
||||
"-D_GNU_SOURCE",
|
||||
"-DGL_SILENCE_DEPRECATION=199309L",
|
||||
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/3674
|
||||
},
|
||||
});
|
||||
lib.addIncludePath(raylib.path("src"));
|
||||
lib.addIncludePath(raygui_dep.path("src"));
|
||||
|
||||
lib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h");
|
||||
|
||||
b.installArtifact(lib);
|
||||
return lib;
|
||||
}
|
||||
|
||||
fn getModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Module {
|
||||
|
Loading…
x
Reference in New Issue
Block a user