[build.zig] Fix local dependency breakage (#3913)
* fix local dependency breakage * revert accidental change in include path
This commit is contained in:
parent
214b1997a8
commit
ba2a103011
2 changed files with 34 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const raylib = @import("src/build.zig");
|
const raylib = @import("src/build.zig");
|
||||||
|
|
||||||
// This has been tested to work with zig 0.11.0 and zig 0.12.0-dev.2075+f5978181e
|
// This has been tested to work with zig 0.11.0 and zig 0.12.0-dev.3632+7fb5a0b18
|
||||||
pub fn build(b: *std.Build) !void {
|
pub fn build(b: *std.Build) !void {
|
||||||
try raylib.build(b);
|
try raylib.build(b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ const builtin = @import("builtin");
|
||||||
|
|
||||||
// This has been tested with zig version(s):
|
// This has been tested with zig version(s):
|
||||||
// 0.11.0
|
// 0.11.0
|
||||||
// 0.12.0-dev.3580+e204a6edb
|
// 0.12.0-dev.3632+7fb5a0b18
|
||||||
//
|
//
|
||||||
// Anytype is used here to preserve compatibility, in 0.12.0dev the std.zig.CrossTarget type
|
// Anytype is used here to preserve compatibility, in 0.12.0dev the std.zig.CrossTarget type
|
||||||
// was reworked into std.Target.Query and std.Build.ResolvedTarget. Using anytype allows
|
// was reworked into std.Target.Query and std.Build.ResolvedTarget. Using anytype allows
|
||||||
|
@ -50,37 +50,37 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||||
|
|
||||||
// No GLFW required on PLATFORM_DRM
|
// No GLFW required on PLATFORM_DRM
|
||||||
if (!options.platform_drm) {
|
if (!options.platform_drm) {
|
||||||
raylib.addIncludePath(.{ .path = "src/external/glfw/include" });
|
raylib.addIncludePath(.{ .cwd_relative = srcdir ++ "external/glfw/include" });
|
||||||
}
|
}
|
||||||
|
|
||||||
addCSourceFilesVersioned(raylib, &.{
|
addCSourceFilesVersioned(raylib, &.{
|
||||||
"src/rcore.c",
|
"rcore.c",
|
||||||
"src/utils.c",
|
"utils.c",
|
||||||
}, raylib_flags_arr.items);
|
}, raylib_flags_arr.items);
|
||||||
|
|
||||||
if (options.raudio) {
|
if (options.raudio) {
|
||||||
addCSourceFilesVersioned(raylib, &.{
|
addCSourceFilesVersioned(raylib, &.{
|
||||||
"src/raudio.c",
|
"raudio.c",
|
||||||
}, raylib_flags_arr.items);
|
}, raylib_flags_arr.items);
|
||||||
}
|
}
|
||||||
if (options.rmodels) {
|
if (options.rmodels) {
|
||||||
addCSourceFilesVersioned(raylib, &.{
|
addCSourceFilesVersioned(raylib, &.{
|
||||||
"src/rmodels.c",
|
"rmodels.c",
|
||||||
}, raylib_flags_arr.items);
|
}, raylib_flags_arr.items);
|
||||||
}
|
}
|
||||||
if (options.rshapes) {
|
if (options.rshapes) {
|
||||||
addCSourceFilesVersioned(raylib, &.{
|
addCSourceFilesVersioned(raylib, &.{
|
||||||
"src/rshapes.c",
|
"rshapes.c",
|
||||||
}, raylib_flags_arr.items);
|
}, raylib_flags_arr.items);
|
||||||
}
|
}
|
||||||
if (options.rtext) {
|
if (options.rtext) {
|
||||||
addCSourceFilesVersioned(raylib, &.{
|
addCSourceFilesVersioned(raylib, &.{
|
||||||
"src/rtext.c",
|
"rtext.c",
|
||||||
}, raylib_flags_arr.items);
|
}, raylib_flags_arr.items);
|
||||||
}
|
}
|
||||||
if (options.rtextures) {
|
if (options.rtextures) {
|
||||||
addCSourceFilesVersioned(raylib, &.{
|
addCSourceFilesVersioned(raylib, &.{
|
||||||
"src/rtextures.c",
|
"rtextures.c",
|
||||||
}, raylib_flags_arr.items);
|
}, raylib_flags_arr.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,14 +90,14 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||||
if (options.raygui) {
|
if (options.raygui) {
|
||||||
const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
|
const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
|
||||||
raylib.addCSourceFile(.{ .file = raygui_c_path, .flags = raylib_flags_arr.items });
|
raylib.addCSourceFile(.{ .file = raygui_c_path, .flags = raylib_flags_arr.items });
|
||||||
raylib.addIncludePath(.{ .path = "src" });
|
raylib.addIncludePath(.{ .cwd_relative = srcdir });
|
||||||
raylib.addIncludePath(.{ .path = "../raygui/src" });
|
raylib.addIncludePath(.{ .cwd_relative = srcdir ++ "../../raygui/src" });
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (getOsTagVersioned(target)) {
|
switch (getOsTagVersioned(target)) {
|
||||||
.windows => {
|
.windows => {
|
||||||
addCSourceFilesVersioned(raylib, &.{
|
addCSourceFilesVersioned(raylib, &.{
|
||||||
"src/rglfw.c",
|
"rglfw.c",
|
||||||
}, raylib_flags_arr.items);
|
}, raylib_flags_arr.items);
|
||||||
raylib.linkSystemLibrary("winmm");
|
raylib.linkSystemLibrary("winmm");
|
||||||
raylib.linkSystemLibrary("gdi32");
|
raylib.linkSystemLibrary("gdi32");
|
||||||
|
@ -108,7 +108,7 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||||
.linux => {
|
.linux => {
|
||||||
if (!options.platform_drm) {
|
if (!options.platform_drm) {
|
||||||
addCSourceFilesVersioned(raylib, &.{
|
addCSourceFilesVersioned(raylib, &.{
|
||||||
"src/rglfw.c",
|
"rglfw.c",
|
||||||
}, raylib_flags_arr.items);
|
}, raylib_flags_arr.items);
|
||||||
raylib.linkSystemLibrary("GL");
|
raylib.linkSystemLibrary("GL");
|
||||||
raylib.linkSystemLibrary("rt");
|
raylib.linkSystemLibrary("rt");
|
||||||
|
@ -129,7 +129,7 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||||
raylib.linkSystemLibrary("wayland-cursor");
|
raylib.linkSystemLibrary("wayland-cursor");
|
||||||
raylib.linkSystemLibrary("wayland-egl");
|
raylib.linkSystemLibrary("wayland-egl");
|
||||||
raylib.linkSystemLibrary("xkbcommon");
|
raylib.linkSystemLibrary("xkbcommon");
|
||||||
raylib.addIncludePath(.{ .path = "src" });
|
raylib.addIncludePath(.{ .path = srcdir });
|
||||||
try waylandGenerate(gpa, "wayland.xml", "wayland-client-protocol");
|
try waylandGenerate(gpa, "wayland.xml", "wayland-client-protocol");
|
||||||
try waylandGenerate(gpa, "xdg-shell.xml", "xdg-shell-client-protocol");
|
try waylandGenerate(gpa, "xdg-shell.xml", "xdg-shell-client-protocol");
|
||||||
try waylandGenerate(gpa, "xdg-decoration-unstable-v1.xml", "xdg-decoration-unstable-v1-client-protocol");
|
try waylandGenerate(gpa, "xdg-decoration-unstable-v1.xml", "xdg-decoration-unstable-v1-client-protocol");
|
||||||
|
@ -162,7 +162,7 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||||
},
|
},
|
||||||
.freebsd, .openbsd, .netbsd, .dragonfly => {
|
.freebsd, .openbsd, .netbsd, .dragonfly => {
|
||||||
addCSourceFilesVersioned(raylib, &.{
|
addCSourceFilesVersioned(raylib, &.{
|
||||||
"src/rglfw.c",
|
"rglfw.c",
|
||||||
}, raylib_flags_arr.items);
|
}, raylib_flags_arr.items);
|
||||||
raylib.linkSystemLibrary("GL");
|
raylib.linkSystemLibrary("GL");
|
||||||
raylib.linkSystemLibrary("rt");
|
raylib.linkSystemLibrary("rt");
|
||||||
|
@ -181,7 +181,7 @@ pub fn addRaylib(b: *std.Build, target: anytype, optimize: std.builtin.OptimizeM
|
||||||
// On macos rglfw.c include Objective-C files.
|
// On macos rglfw.c include Objective-C files.
|
||||||
try raylib_flags_arr.append("-ObjC");
|
try raylib_flags_arr.append("-ObjC");
|
||||||
addCSourceFilesVersioned(raylib, &.{
|
addCSourceFilesVersioned(raylib, &.{
|
||||||
"src/rglfw.c",
|
"rglfw.c",
|
||||||
}, raylib_flags_arr.items);
|
}, raylib_flags_arr.items);
|
||||||
raylib.linkFramework("Foundation");
|
raylib.linkFramework("Foundation");
|
||||||
raylib.linkFramework("CoreServices");
|
raylib.linkFramework("CoreServices");
|
||||||
|
@ -269,7 +269,13 @@ pub fn build(b: *std.Build) !void {
|
||||||
b.installArtifact(lib);
|
b.installArtifact(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
const waylandDir = "src/external/glfw/deps/wayland";
|
const srcdir = struct {
|
||||||
|
fn getSrcDir() []const u8 {
|
||||||
|
return std.fs.path.dirname(@src().file).?;
|
||||||
|
}
|
||||||
|
}.getSrcDir() ++ "/";
|
||||||
|
|
||||||
|
const waylandDir = srcdir ++ "external/glfw/deps/wayland";
|
||||||
|
|
||||||
fn getOsTagVersioned(target: anytype) std.Target.Os.Tag {
|
fn getOsTagVersioned(target: anytype) std.Target.Os.Tag {
|
||||||
if (comptime builtin.zig_version.minor >= 12) {
|
if (comptime builtin.zig_version.minor >= 12) {
|
||||||
|
@ -279,18 +285,24 @@ fn getOsTagVersioned(target: anytype) std.Target.Os.Tag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn addCSourceFilesVersioned(
|
inline fn addCSourceFilesVersioned(
|
||||||
exe: *std.Build.Step.Compile,
|
exe: *std.Build.Step.Compile,
|
||||||
files: []const []const u8,
|
files: []const []const u8,
|
||||||
flags: []const []const u8,
|
flags: []const []const u8,
|
||||||
) void {
|
) void {
|
||||||
if (comptime builtin.zig_version.minor >= 12) {
|
if (comptime builtin.zig_version.minor >= 12) {
|
||||||
exe.addCSourceFiles(.{
|
exe.addCSourceFiles(.{
|
||||||
|
.root = .{ .path = srcdir },
|
||||||
.files = files,
|
.files = files,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
});
|
});
|
||||||
} else if (comptime builtin.zig_version.minor == 11) {
|
} else if (comptime builtin.zig_version.minor == 11) {
|
||||||
exe.addCSourceFiles(files, flags);
|
inline for (files) |file| {
|
||||||
|
exe.addCSourceFile(.{
|
||||||
|
.file = .{ .path = srcdir ++ file },
|
||||||
|
.flags = flags,
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
@compileError("Expected zig version 11 or 12");
|
@compileError("Expected zig version 11 or 12");
|
||||||
}
|
}
|
||||||
|
@ -315,8 +327,8 @@ else
|
||||||
|
|
||||||
fn waylandGenerate(allocator: std.mem.Allocator, comptime protocol: []const u8, comptime basename: []const u8) !void {
|
fn waylandGenerate(allocator: std.mem.Allocator, comptime protocol: []const u8, comptime basename: []const u8) !void {
|
||||||
const protocolDir = waylandDir ++ "/" ++ protocol;
|
const protocolDir = waylandDir ++ "/" ++ protocol;
|
||||||
const clientHeader = "src/" ++ basename ++ ".h";
|
const clientHeader = srcdir ++ basename ++ ".h";
|
||||||
const privateCode = "src/" ++ basename ++ "-code.h";
|
const privateCode = srcdir ++ basename ++ "-code.h";
|
||||||
_ = try childRunVersioned(.{
|
_ = try childRunVersioned(.{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.argv = &[_][]const u8{ "wayland-scanner", "client-header", protocolDir, clientHeader },
|
.argv = &[_][]const u8{ "wayland-scanner", "client-header", protocolDir, clientHeader },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue