From c41e3f5828a83429335ed28294d0db4eea1fb143 Mon Sep 17 00:00:00 2001 From: Eric Joldasov Date: Wed, 3 Jan 2024 19:35:20 +0600 Subject: [PATCH] build.zig: update to Zig 0.12.0-dev.2018+9a56228c2 * ZBS was reorganized around `Module` struct: https://www.github.com/ziglang/zig/pull/18160 . * Changes for ReleaseSafe: error return tracing is now off by default. Signed-off-by: Eric Joldasov --- build.zig | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/build.zig b/build.zig index 00c6dbe..defd8ad 100644 --- a/build.zig +++ b/build.zig @@ -5,6 +5,8 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); + const t = target.result; + const optimize = b.standardOptimizeOption(.{}); const pie = b.option(bool, "pie", "Build with PIE support (by default false)") orelse false; @@ -14,15 +16,16 @@ pub fn build(b: *std.Build) void { .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, + .link_libc = true, }); + exe.pie = pie; + exe.root_module.linkSystemLibrary("ncursesw", .{}); // https://github.com/ziglang/zig/blob/b52be973dfb7d1408218b8e75800a2da3dc69108/build.zig#L551-L554 - if (exe.target.isDarwin()) { + if (t.isDarwin()) { // useful for package maintainers exe.headerpad_max_install_names = true; } - linkNcurses(exe); - exe.pie = pie; b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); @@ -38,17 +41,13 @@ pub fn build(b: *std.Build) void { .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, + .link_libc = true, }); - linkNcurses(unit_tests); unit_tests.pie = pie; + unit_tests.root_module.linkSystemLibrary("ncursesw", .{}); const run_unit_tests = b.addRunArtifact(unit_tests); const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_unit_tests.step); } - -pub fn linkNcurses(compile_step: *std.Build.CompileStep) void { - compile_step.linkSystemLibrary("ncursesw"); - compile_step.linkLibC(); -}