2023-01-18 22:00:27 -09:00
|
|
|
// SPDX-FileCopyrightText: 2021-2023 Yoran Heling <projects@yorhel.nl>
|
2021-07-18 01:36:05 -08:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
2021-04-29 02:48:45 -08:00
|
|
|
const std = @import("std");
|
|
|
|
|
|
2023-04-09 07:45:11 -08:00
|
|
|
pub fn build(b: *std.Build) void {
|
2021-04-29 02:48:45 -08:00
|
|
|
const target = b.standardTargetOptions(.{});
|
2024-01-03 04:35:20 -09:00
|
|
|
const t = target.result;
|
|
|
|
|
|
2023-04-09 07:45:11 -08:00
|
|
|
const optimize = b.standardOptimizeOption(.{});
|
2021-04-29 02:48:45 -08:00
|
|
|
|
2023-04-09 07:41:06 -08:00
|
|
|
const pie = b.option(bool, "pie", "Build with PIE support (by default false)") orelse false;
|
|
|
|
|
|
2023-04-09 07:45:11 -08:00
|
|
|
const exe = b.addExecutable(.{
|
|
|
|
|
.name = "ncdu",
|
|
|
|
|
.root_source_file = .{ .path = "src/main.zig" },
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
2024-01-03 04:35:20 -09:00
|
|
|
.link_libc = true,
|
2023-04-09 07:45:11 -08:00
|
|
|
});
|
|
|
|
|
|
2024-01-03 04:35:20 -09:00
|
|
|
exe.pie = pie;
|
|
|
|
|
exe.root_module.linkSystemLibrary("ncursesw", .{});
|
2023-02-21 20:51:08 -09:00
|
|
|
// https://github.com/ziglang/zig/blob/b52be973dfb7d1408218b8e75800a2da3dc69108/build.zig#L551-L554
|
2024-01-03 04:35:20 -09:00
|
|
|
if (t.isDarwin()) {
|
2023-02-21 20:51:08 -09:00
|
|
|
// useful for package maintainers
|
|
|
|
|
exe.headerpad_max_install_names = true;
|
|
|
|
|
}
|
2023-04-09 07:45:11 -08:00
|
|
|
b.installArtifact(exe);
|
2021-04-29 02:48:45 -08:00
|
|
|
|
2023-04-09 07:45:11 -08:00
|
|
|
const run_cmd = b.addRunArtifact(exe);
|
2021-04-29 02:48:45 -08:00
|
|
|
run_cmd.step.dependOn(b.getInstallStep());
|
|
|
|
|
if (b.args) |args| {
|
|
|
|
|
run_cmd.addArgs(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const run_step = b.step("run", "Run the app");
|
|
|
|
|
run_step.dependOn(&run_cmd.step);
|
2021-05-04 08:01:49 -08:00
|
|
|
|
2023-04-09 07:45:11 -08:00
|
|
|
const unit_tests = b.addTest(.{
|
|
|
|
|
.root_source_file = .{ .path = "src/main.zig" },
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
2024-01-03 04:35:20 -09:00
|
|
|
.link_libc = true,
|
2023-04-09 07:45:11 -08:00
|
|
|
});
|
|
|
|
|
unit_tests.pie = pie;
|
2024-01-03 04:35:20 -09:00
|
|
|
unit_tests.root_module.linkSystemLibrary("ncursesw", .{});
|
2023-04-09 07:45:11 -08:00
|
|
|
|
|
|
|
|
const run_unit_tests = b.addRunArtifact(unit_tests);
|
|
|
|
|
|
|
|
|
|
const test_step = b.step("test", "Run unit tests");
|
|
|
|
|
test_step.dependOn(&run_unit_tests.step);
|
|
|
|
|
}
|