mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 12:07:27 +00:00
expose raylib artifact
This commit is contained in:
parent
654fd4b99f
commit
183347adaf
24
build.zig
24
build.zig
@ -16,11 +16,7 @@ pub fn link(
|
|||||||
target: std.zig.CrossTarget,
|
target: std.zig.CrossTarget,
|
||||||
optimize: std.builtin.Mode,
|
optimize: std.builtin.Mode,
|
||||||
) void {
|
) void {
|
||||||
const raylib = b.dependency("raylib", .{
|
const lib = getRaylib(b, target, optimize);
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
const art = raylib.artifact("raylib");
|
|
||||||
|
|
||||||
const target_os = exe.target.toTarget().os.tag;
|
const target_os = exe.target.toTarget().os.tag;
|
||||||
switch (target_os) {
|
switch (target_os) {
|
||||||
@ -61,20 +57,26 @@ pub fn link(
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
exe.linkLibrary(art);
|
exe.linkLibrary(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getArtifact(
|
var _raylib_lib_cache: ?*std.build.Step.Compile = null;
|
||||||
|
pub fn getRaylib(
|
||||||
b: *std.Build,
|
b: *std.Build,
|
||||||
target: std.zig.CrossTarget,
|
target: std.zig.CrossTarget,
|
||||||
optimize: std.builtin.Mode,
|
optimize: std.builtin.Mode,
|
||||||
) *std.Build.Step.Compile {
|
) *std.Build.Step.Compile {
|
||||||
|
if (_raylib_lib_cache) |lib| return lib else {
|
||||||
const raylib = b.dependency("raylib", .{
|
const raylib = b.dependency("raylib", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
return raylib.artifact("raylib");
|
const lib = raylib.artifact("raylib");
|
||||||
|
b.installArtifact(lib);
|
||||||
|
_raylib_lib_cache = lib;
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make these not comptime.
|
// TODO: Make these not comptime.
|
||||||
@ -187,12 +189,12 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const exe_lib = compileForEmscripten(b, ex.name, ex.path, target, optimize);
|
const exe_lib = compileForEmscripten(b, ex.name, ex.path, target, optimize);
|
||||||
exe_lib.addModule("raylib", raylib);
|
exe_lib.addModule("raylib", raylib);
|
||||||
exe_lib.addModule("raylib-math", raylib_math);
|
exe_lib.addModule("raylib-math", raylib_math);
|
||||||
const raylib_artifact = getArtifact(b, target, optimize);
|
const raylib_lib = getRaylib(b, target, optimize);
|
||||||
|
|
||||||
// Note that raylib itself isn't actually added to the exe_lib
|
// Note that raylib itself isn't actually added to the exe_lib
|
||||||
// output file, so it also needs to be linked with emscripten.
|
// output file, so it also needs to be linked with emscripten.
|
||||||
exe_lib.linkLibrary(raylib_artifact);
|
exe_lib.linkLibrary(raylib_lib);
|
||||||
const link_step = try linkWithEmscripten(b, &[_]*std.Build.Step.Compile{ exe_lib, raylib_artifact });
|
const link_step = try linkWithEmscripten(b, &[_]*std.Build.Step.Compile{ exe_lib, raylib_lib });
|
||||||
link_step.addArg("--embed-file");
|
link_step.addArg("--embed-file");
|
||||||
link_step.addArg("resources/");
|
link_step.addArg("resources/");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user