build: Expose -Dstrip flag

Compiling with -fstrip generates *much* smaller binaries, even compared
to running 'strip' after a regular build.
This commit is contained in:
Yorhel 2024-11-17 09:30:40 +01:00
parent 5593fa2233
commit e5a6a1c5ea
2 changed files with 3 additions and 1 deletions

View file

@ -9,7 +9,7 @@ ZIG ?= zig
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR ?= ${PREFIX}/bin BINDIR ?= ${PREFIX}/bin
MANDIR ?= ${PREFIX}/share/man/man1 MANDIR ?= ${PREFIX}/share/man/man1
ZIG_FLAGS ?= --release=fast ZIG_FLAGS ?= --release=fast -Dstrip
NCDU_VERSION=$(shell grep 'program_version = "' src/main.zig | sed -e 's/^.*"\(.\+\)".*$$/\1/') NCDU_VERSION=$(shell grep 'program_version = "' src/main.zig | sed -e 's/^.*"\(.\+\)".*$$/\1/')

View file

@ -8,12 +8,14 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const pie = b.option(bool, "pie", "Build with PIE support (by default false)") orelse false; const pie = b.option(bool, "pie", "Build with PIE support (by default false)") orelse false;
const strip = b.option(bool, "strip", "Strip debugging info (by default false)") orelse false;
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = "ncdu", .name = "ncdu",
.root_source_file = b.path("src/main.zig"), .root_source_file = b.path("src/main.zig"),
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.strip = strip,
.link_libc = true, .link_libc = true,
}); });