glfw: support compiling with stage2 (-fno-stage1) (#365)
This commit is contained in:
parent
786e0d6263
commit
7bb877bd55
7 changed files with 35 additions and 32 deletions
|
|
@ -61,7 +61,7 @@ fn buildLibrary(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *
|
|||
// TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939
|
||||
ensureDependencySubmodule(b.allocator, "upstream") catch unreachable;
|
||||
|
||||
const main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/main.zig" }) catch unreachable;
|
||||
const main_abs = std.fs.path.join(b.allocator, &.{ (comptime thisDir()), "src/main.zig" }) catch unreachable;
|
||||
const lib = b.addStaticLibrary("glfw", main_abs);
|
||||
lib.setBuildMode(step.build_mode);
|
||||
lib.setTarget(step.target);
|
||||
|
|
@ -69,16 +69,16 @@ fn buildLibrary(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *
|
|||
// TODO(build-system): pass system SDK options through
|
||||
system_sdk.include(b, step, .{});
|
||||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
||||
const include_glfw_src = "-I" ++ thisDir() ++ "/upstream/glfw/src";
|
||||
const include_glfw_src = "-I" ++ (comptime thisDir()) ++ "/upstream/glfw/src";
|
||||
switch (target.os.tag) {
|
||||
.windows => lib.addCSourceFiles(&.{
|
||||
thisDir() ++ "/src/sources_all.c",
|
||||
thisDir() ++ "/src/sources_windows.c",
|
||||
(comptime thisDir()) ++ "/src/sources_all.c",
|
||||
(comptime thisDir()) ++ "/src/sources_windows.c",
|
||||
}, &.{ "-D_GLFW_WIN32", include_glfw_src }),
|
||||
.macos => lib.addCSourceFiles(&.{
|
||||
thisDir() ++ "/src/sources_all.c",
|
||||
thisDir() ++ "/src/sources_macos.m",
|
||||
thisDir() ++ "/src/sources_macos.c",
|
||||
(comptime thisDir()) ++ "/src/sources_all.c",
|
||||
(comptime thisDir()) ++ "/src/sources_macos.m",
|
||||
(comptime thisDir()) ++ "/src/sources_macos.c",
|
||||
}, &.{ "-D_GLFW_COCOA", include_glfw_src }),
|
||||
else => {
|
||||
// TODO(future): for now, Linux must be built with glibc, not musl:
|
||||
|
|
@ -92,17 +92,17 @@ fn buildLibrary(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *
|
|||
|
||||
var sources = std.ArrayList([]const u8).init(b.allocator);
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
sources.append(thisDir() ++ "/src/sources_all.c") catch unreachable;
|
||||
sources.append(thisDir() ++ "/src/sources_linux.c") catch unreachable;
|
||||
sources.append((comptime thisDir()) ++ "/src/sources_all.c") catch unreachable;
|
||||
sources.append((comptime thisDir()) ++ "/src/sources_linux.c") catch unreachable;
|
||||
if (options.x11) {
|
||||
sources.append(thisDir() ++ "/src/sources_linux_x11.c") catch unreachable;
|
||||
sources.append((comptime thisDir()) ++ "/src/sources_linux_x11.c") catch unreachable;
|
||||
flags.append("-D_GLFW_X11") catch unreachable;
|
||||
}
|
||||
if (options.wayland) {
|
||||
sources.append(thisDir() ++ "/src/sources_linux_wayland.c") catch unreachable;
|
||||
sources.append((comptime thisDir()) ++ "/src/sources_linux_wayland.c") catch unreachable;
|
||||
flags.append("-D_GLFW_WAYLAND") catch unreachable;
|
||||
}
|
||||
flags.append("-I" ++ thisDir() ++ "/upstream/glfw/src") catch unreachable;
|
||||
flags.append("-I" ++ (comptime thisDir()) ++ "/upstream/glfw/src") catch unreachable;
|
||||
|
||||
lib.addCSourceFiles(sources.items, flags.items);
|
||||
},
|
||||
|
|
@ -117,7 +117,7 @@ fn ensureDependencySubmodule(allocator: std.mem.Allocator, path: []const u8) !vo
|
|||
if (std.mem.eql(u8, no_ensure_submodules, "true")) return;
|
||||
} else |_| {}
|
||||
var child = std.ChildProcess.init(&.{ "git", "submodule", "update", "--init", path }, allocator);
|
||||
child.cwd = thisDir();
|
||||
child.cwd = (comptime thisDir());
|
||||
child.stderr = std.io.getStdErr();
|
||||
child.stdout = std.io.getStdOut();
|
||||
|
||||
|
|
@ -129,11 +129,11 @@ fn thisDir() []const u8 {
|
|||
}
|
||||
|
||||
fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
|
||||
const include_dir = std.fs.path.join(b.allocator, &.{ thisDir(), "upstream/glfw/include" }) catch unreachable;
|
||||
const include_dir = std.fs.path.join(b.allocator, &.{ (comptime thisDir()), "upstream/glfw/include" }) catch unreachable;
|
||||
defer b.allocator.free(include_dir);
|
||||
step.addIncludeDir(include_dir);
|
||||
|
||||
const vulkan_include_dir = std.fs.path.join(b.allocator, &.{ thisDir(), "upstream/vulkan_headers/include" }) catch unreachable;
|
||||
const vulkan_include_dir = std.fs.path.join(b.allocator, &.{ (comptime thisDir()), "upstream/vulkan_headers/include" }) catch unreachable;
|
||||
defer b.allocator.free(vulkan_include_dir);
|
||||
step.addIncludeDir(vulkan_include_dir);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue