update to Zig 2024.1.0-mach
helps hexops/mach#1135 Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
e8d3deacdc
commit
0fdefbd764
2 changed files with 19 additions and 26 deletions
41
build.zig
41
build.zig
|
@ -1,24 +1,19 @@
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Build = std.Build;
|
|
||||||
|
|
||||||
pub fn build(b: *Build) !void {
|
pub fn build(b: *std.Build) !void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
|
|
||||||
|
const glfw_dep = b.dependency("glfw", .{
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
const module = b.addModule("mach-glfw", .{
|
const module = b.addModule("mach-glfw", .{
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
.root_source_file = .{ .path = "src/main.zig" },
|
||||||
});
|
});
|
||||||
module.addIncludePath(b.dependency("glfw", .{}).path("include"));
|
module.linkLibrary(glfw_dep.artifact("glfw"));
|
||||||
|
|
||||||
const lib = b.addStaticLibrary(.{
|
|
||||||
.name = "mach-glfw",
|
|
||||||
.root_source_file = b.addWriteFiles().add("empty.c", ""),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
link(b, lib);
|
|
||||||
b.installArtifact(lib);
|
|
||||||
|
|
||||||
const test_step = b.step("test", "Run library tests");
|
const test_step = b.step("test", "Run library tests");
|
||||||
const main_tests = b.addTest(.{
|
const main_tests = b.addTest(.{
|
||||||
|
@ -27,22 +22,20 @@ pub fn build(b: *Build) !void {
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
main_tests.linkLibrary(glfw_dep.artifact("glfw"));
|
||||||
main_tests.linkLibrary(lib);
|
addPaths(main_tests);
|
||||||
link(b, main_tests);
|
|
||||||
b.installArtifact(main_tests);
|
b.installArtifact(main_tests);
|
||||||
|
|
||||||
test_step.dependOn(&b.addRunArtifact(main_tests).step);
|
test_step.dependOn(&b.addRunArtifact(main_tests).step);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn link(b: *std.Build, step: *std.Build.Step.Compile) void {
|
pub fn link(b: *std.Build, step: *std.Build.Step.Compile) void {
|
||||||
const target_triple: []const u8 = step.rootModuleTarget().zigTriple(b.allocator) catch @panic("OOM");
|
_ = b;
|
||||||
const cpu_opts: []const u8 = step.root_module.resolved_target.?.query.serializeCpuAlloc(b.allocator) catch @panic("OOM");
|
_ = step;
|
||||||
const glfw_dep = b.dependency("glfw", .{
|
|
||||||
.target = target_triple,
|
@panic(".link(b, step) has been replaced by .addPaths(step)");
|
||||||
.cpu = cpu_opts,
|
}
|
||||||
.optimize = step.root_module.optimize.?,
|
|
||||||
});
|
pub fn addPaths(step: *std.Build.Step.Compile) void {
|
||||||
@import("glfw").link(glfw_dep.builder, step);
|
@import("glfw").addPaths(step);
|
||||||
step.linkLibrary(glfw_dep.artifact("glfw"));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
},
|
},
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.glfw = .{
|
.glfw = .{
|
||||||
.url = "https://github.com/der-teufel-programming/glfw/archive/523dc59dc16ceabd7665b38aabf969e330decaf6.tar.gz",
|
.url = "https://pkg.machengine.org/glfw/4a39c70a6347419ae95f0718684b6b10e65e015a.tar.gz",
|
||||||
.hash = "1220dbfb5484019e82fb064090afbe09c83b2d6ab80aac11ceb43a37af78a792cf52",
|
.hash = "12209e5e9c8850f4beebf1e620c73ba9daa5cf587ffa5dbd5376b8a4f18bb0e1c819",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue