Revert "[build] Only cache raygui impl (#170)"
This reverts commit 2f773da6b3.
This commit is contained in:
parent
2f773da6b3
commit
90109ff804
1 changed files with 42 additions and 45 deletions
19
build.zig
19
build.zig
|
|
@ -97,16 +97,9 @@ fn link(
|
||||||
exe.linkLibrary(lib);
|
exe.linkLibrary(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
var _raygui_impl_cache: ?*std.Build.Step.WriteFile = null;
|
var _raylib_lib_cache: ?*std.Build.Step.Compile = 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 {
|
fn getRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) *std.Build.Step.Compile {
|
||||||
if (_raygui_impl_cache == null) {
|
if (_raylib_lib_cache) |lib| return lib else {
|
||||||
var gen_step = b.addWriteFiles();
|
|
||||||
|
|
||||||
_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", .{
|
const raylib = b.dependency("raylib", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
|
|
@ -128,10 +121,12 @@ fn getRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.buil
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
lib.step.dependOn(&(_raygui_impl_cache orelse unreachable).step);
|
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(.{
|
lib.addCSourceFile(.{
|
||||||
.file = (_raygui_impl_path_cache orelse unreachable),
|
.file = raygui_c_path,
|
||||||
.flags = &[_][]const u8{
|
.flags = &[_][]const u8{
|
||||||
"-std=gnu99",
|
"-std=gnu99",
|
||||||
"-D_GNU_SOURCE",
|
"-D_GNU_SOURCE",
|
||||||
|
|
@ -145,8 +140,10 @@ fn getRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.buil
|
||||||
lib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h");
|
lib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h");
|
||||||
|
|
||||||
b.installArtifact(lib);
|
b.installArtifact(lib);
|
||||||
|
_raylib_lib_cache = lib;
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn getModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Module {
|
fn getModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Module {
|
||||||
if (b.modules.contains("raylib")) {
|
if (b.modules.contains("raylib")) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue