glfw: use package manager for direct3d-headers
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
70ff87ba8a
commit
4c7824fc75
2 changed files with 22 additions and 10 deletions
20
build.zig
20
build.zig
|
@ -77,21 +77,23 @@ pub fn module(b: *std.Build) *std.build.Module {
|
||||||
return _module.?;
|
return _module.?;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const LinkError = error{FailedToLinkGPU} || BuildError;
|
pub fn link(b: *Build, step: *std.build.CompileStep, options: Options) !void {
|
||||||
pub fn link(b: *Build, step: *std.build.CompileStep, options: Options) LinkError!void {
|
if (options.shared) step.defineCMacro("GLFW_DLL", null);
|
||||||
const lib = try buildLibrary(b, step.optimize, step.target, options);
|
const lib = try buildLibrary(b, step.optimize, step.target, options);
|
||||||
step.linkLibrary(lib);
|
step.linkLibrary(lib);
|
||||||
addGLFWIncludes(step);
|
addGLFWIncludes(step);
|
||||||
if (options.shared) {
|
|
||||||
step.defineCMacro("GLFW_DLL", null);
|
|
||||||
system_sdk.include(b, step, options.system_sdk);
|
|
||||||
} else {
|
|
||||||
linkGLFWDependencies(b, step, options);
|
linkGLFWDependencies(b, step, options);
|
||||||
|
if (step.target_info.target.os.tag != .windows) system_sdk.include(b, step, options.system_sdk);
|
||||||
|
if (step.target_info.target.os.tag == .windows) {
|
||||||
|
step.linkLibrary(b.dependency("direct3d_headers", .{
|
||||||
|
.target = step.target,
|
||||||
|
.optimize = step.optimize,
|
||||||
|
}).artifact("direct3d-headers"));
|
||||||
|
@import("direct3d_headers").addLibraryPath(step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const BuildError = error{CannotEnsureDependency} || std.mem.Allocator.Error;
|
fn buildLibrary(b: *Build, optimize: std.builtin.OptimizeMode, target: std.zig.CrossTarget, options: Options) !*std.build.CompileStep {
|
||||||
fn buildLibrary(b: *Build, optimize: std.builtin.OptimizeMode, target: std.zig.CrossTarget, options: Options) BuildError!*std.build.CompileStep {
|
|
||||||
// TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939
|
// TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939
|
||||||
ensureDependencySubmodule(b.allocator, "upstream") catch return error.CannotEnsureDependency;
|
ensureDependencySubmodule(b.allocator, "upstream") catch return error.CannotEnsureDependency;
|
||||||
|
|
||||||
|
@ -161,7 +163,7 @@ fn addGLFWSources(b: *Build, lib: *std.build.CompileStep, options: Options) std.
|
||||||
|
|
||||||
fn linkGLFWDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
|
fn linkGLFWDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void {
|
||||||
step.linkLibC();
|
step.linkLibC();
|
||||||
system_sdk.include(b, step, options.system_sdk);
|
if (step.target_info.target.os.tag != .windows) system_sdk.include(b, step, options.system_sdk);
|
||||||
switch (step.target_info.target.os.tag) {
|
switch (step.target_info.target.os.tag) {
|
||||||
.windows => {
|
.windows => {
|
||||||
step.linkSystemLibraryName("gdi32");
|
step.linkSystemLibraryName("gdi32");
|
||||||
|
|
10
build.zig.zon
Normal file
10
build.zig.zon
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
.{
|
||||||
|
.name = "mach-glfw",
|
||||||
|
.version = "0.2.0",
|
||||||
|
.dependencies = .{
|
||||||
|
.direct3d_headers = .{
|
||||||
|
.url = "https://github.com/hexops/direct3d-headers/archive/773dce3f079eecdccc7c71d1318a0741649d568b.tar.gz",
|
||||||
|
.hash = "12200d2155216c5eb5f111282cd355b5433cad6a68fd040294e695149cba329f7c12",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue