@@ -7,27 +7,31 @@ pub fn build(b: *std.Build) void {
77 const target = b .standardTargetOptions (.{});
88 const optimize = b .standardOptimizeOption (.{});
99
10- const pie = b .option (bool , "pie" , "Build with PIE support (by default false )" ) orelse false ;
10+ const pie = b .option (bool , "pie" , "Build with PIE support (by default: target-dependant )" );
1111 const strip = b .option (bool , "strip" , "Strip debugging info (by default false)" ) orelse false ;
1212
13- const exe = b .addExecutable (.{
14- .name = "ncdu" ,
13+ const main_mod = b .createModule (.{
1514 .root_source_file = b .path ("src/main.zig" ),
1615 .target = target ,
1716 .optimize = optimize ,
1817 .strip = strip ,
1918 .link_libc = true ,
2019 });
20+ main_mod .linkSystemLibrary ("ncursesw" , .{});
21+ main_mod .linkSystemLibrary ("zstd" , .{});
2122
23+ const exe = b .addExecutable (.{
24+ .name = "ncdu" ,
25+ .root_module = main_mod ,
26+ });
2227 exe .pie = pie ;
23- exe .root_module .linkSystemLibrary ("ncursesw" , .{});
24- exe .root_module .linkSystemLibrary ("libzstd" , .{});
2528 // https://github.com/ziglang/zig/blob/faccd79ca5debbe22fe168193b8de54393257604/build.zig#L745-L748
2629 if (target .result .os .tag .isDarwin ()) {
2730 // useful for package maintainers
2831 exe .headerpad_max_install_names = true ;
2932 }
3033 b .installArtifact (exe );
34+ // exe.addLibraryPath(.{ .cwd_relative = "/lib/x86_64-linux-gnu" });
3135
3236 const run_cmd = b .addRunArtifact (exe );
3337 run_cmd .step .dependOn (b .getInstallStep ());
@@ -39,14 +43,9 @@ pub fn build(b: *std.Build) void {
3943 run_step .dependOn (& run_cmd .step );
4044
4145 const unit_tests = b .addTest (.{
42- .root_source_file = b .path ("src/main.zig" ),
43- .target = target ,
44- .optimize = optimize ,
45- .link_libc = true ,
46+ .root_module = main_mod ,
4647 });
4748 unit_tests .pie = pie ;
48- unit_tests .root_module .linkSystemLibrary ("ncursesw" , .{});
49- unit_tests .root_module .linkSystemLibrary ("libzstd" , .{});
5049
5150 const run_unit_tests = b .addRunArtifact (unit_tests );
5251
0 commit comments