Skip to content

Commit 2723e3d

Browse files
feat: sync with upstream
1 parent dda6626 commit 2723e3d

File tree

13 files changed

+610
-704
lines changed

13 files changed

+610
-704
lines changed

ChangeLog

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
# SPDX-FileCopyrightText: 2021-2023 Yoran Heling <[email protected]>
1+
# SPDX-FileCopyrightText: Yorhel <[email protected]>
22
# SPDX-License-Identifier: MIT
33

4+
2.4 - 2024-04-21
5+
- Now requires Zig 0.12
6+
- Revert default color scheme back to 'off'
7+
- Rewrite man page in mdoc, drop pod2man dependency
8+
- Fix updating parent dir error status on refresh
9+
410
2.3 - 2023-08-04
511
- Now requires Zig 0.11
612
- Add --(enable|disable)-natsort options

Makefile

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2021-2023 Yoran Heling <[email protected]>
1+
# SPDX-FileCopyrightText: Yorhel <[email protected]>
22
# SPDX-License-Identifier: MIT
33

44
# Optional semi-standard Makefile with some handy tools.
@@ -9,12 +9,12 @@ ZIG ?= zig
99
PREFIX ?= /usr/local
1010
BINDIR ?= ${PREFIX}/bin
1111
MANDIR ?= ${PREFIX}/share/man/man1
12-
ZIG_FLAGS ?= -Doptimize=ReleaseFast
12+
ZIG_FLAGS ?= --release
1313

1414
NCDU_VERSION=$(shell grep 'program_version = "' src/main.zig | sed -e 's/^.*"\(.\+\)".*$$/\1/')
1515

16-
.PHONY: build
17-
build: release doc
16+
.PHONY: build test
17+
build: release
1818

1919
release:
2020
$(ZIG) build ${ZIG_FLAGS}
@@ -25,21 +25,13 @@ debug:
2525
clean:
2626
rm -rf zig-cache zig-out
2727

28-
distclean: clean
29-
rm -f ncdu.1
30-
31-
doc: ncdu.1
32-
33-
ncdu.1: ncdu.pod src/main.zig
34-
pod2man --center "ncdu manual" --release "ncdu-${NCDU_VERSION}" ncdu.pod >ncdu.1
35-
3628
install: install-bin install-doc
3729

3830
install-bin: release
3931
mkdir -p ${BINDIR}
4032
install -m0755 zig-out/bin/ncdu ${BINDIR}/
4133

42-
install-doc: doc
34+
install-doc:
4335
mkdir -p ${MANDIR}
4436
install -m0644 ncdu.1 ${MANDIR}/
4537

@@ -52,10 +44,10 @@ uninstall-bin:
5244
uninstall-doc:
5345
rm -f ${MANDIR}/ncdu.1
5446

55-
dist: doc
47+
dist:
5648
rm -f ncdu-${NCDU_VERSION}.tar.gz
5749
mkdir ncdu-${NCDU_VERSION}
58-
for f in ncdu.1 `git ls-files | grep -v ^\.gitignore`; do mkdir -p ncdu-${NCDU_VERSION}/`dirname $$f`; ln -s "`pwd`/$$f" ncdu-${NCDU_VERSION}/$$f; done
50+
for f in `git ls-files | grep -v ^\.gitignore`; do mkdir -p ncdu-${NCDU_VERSION}/`dirname $$f`; ln -s "`pwd`/$$f" ncdu-${NCDU_VERSION}/$$f; done
5951
tar -cophzf ncdu-${NCDU_VERSION}.tar.gz --sort=name ncdu-${NCDU_VERSION}
6052
rm -rf ncdu-${NCDU_VERSION}
6153

@@ -73,14 +65,14 @@ static-%.tar.gz:
7365
CC="${ZIG} cc --target=$*"\
7466
LD="${ZIG} cc --target=$*"\
7567
AR="${ZIG} ar" RANLIB="${ZIG} ranlib"\
76-
CPPFLAGS=-D_GNU_SOURCE && make && make install.libs
68+
CPPFLAGS=-D_GNU_SOURCE && make -j8 && make install.libs
7769
@# zig-build - cleaner approach but doesn't work, results in a dynamically linked binary.
7870
@#cd static-$* && PKG_CONFIG_LIBDIR="`pwd`/inst/pkg" zig build -Dtarget=$*
7971
@# --build-file ../build.zig --search-prefix inst/ --cache-dir zig -Drelease-fast=true
8072
@# Alternative approach, bypassing zig-build
8173
cd static-$* && ${ZIG} build-exe -target $*\
8274
-Iinst/include -Iinst/include/ncursesw -lc inst/lib/libncursesw.a\
83-
--cache-dir zig-cache -static -fstrip -O ReleaseFast ../src/main.zig ../src/ncurses_refs.c
75+
--cache-dir zig-cache -static -fstrip -O ReleaseFast ../src/main.zig
8476
cd static-$* && mv main ncdu && tar -czf ../static-$*.tar.gz ncdu
8577
rm -rf static-$*
8678

@@ -101,3 +93,8 @@ static:\
10193
static-linux-x86 \
10294
static-linux-aarch64 \
10395
static-linux-arm
96+
97+
test:
98+
zig build test
99+
mandoc -T lint ncdu.1
100+
reuse lint

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
SPDX-FileCopyrightText: 2021-2023 Yoran Heling <[email protected]>
2+
SPDX-FileCopyrightText: Yorhel <[email protected]>
33
SPDX-License-Identifier: MIT
44
-->
55

@@ -20,7 +20,7 @@ C version (1.x).
2020

2121
## Requirements
2222

23-
- Zig 0.11.0
23+
- Zig 0.12.0
2424
- Some sort of POSIX-like OS
2525
- ncurses libraries and header files
2626

build.zig

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
// SPDX-FileCopyrightText: 2021-2023 Yoran Heling <[email protected]>
1+
// SPDX-FileCopyrightText: Yorhel <[email protected]>
22
// SPDX-License-Identifier: MIT
33

44
const std = @import("std");
55

66
pub fn build(b: *std.Build) void {
77
const target = b.standardTargetOptions(.{});
8-
const optimize = b.standardOptimizeOption(.{});
8+
const optimize = b.standardOptimizeOption(.{
9+
.preferred_optimize_mode = .ReleaseFast,
10+
});
911

1012
const pie = b.option(bool, "pie", "Build with PIE support (by default false)") orelse false;
1113

1214
const exe = b.addExecutable(.{
1315
.name = "ncdu",
14-
.root_source_file = .{ .path = "src/main.zig" },
16+
.root_source_file = b.path("src/main.zig"),
1517
.target = target,
1618
.optimize = optimize,
19+
.link_libc = true,
1720
});
1821

22+
exe.pie = pie;
23+
exe.root_module.linkSystemLibrary("ncursesw", .{});
1924
// https://github.com/ziglang/zig/blob/b52be973dfb7d1408218b8e75800a2da3dc69108/build.zig#L551-L554
20-
if (exe.target.isDarwin()) {
25+
if (target.result.isDarwin()) {
2126
// useful for package maintainers
2227
exe.headerpad_max_install_names = true;
2328
}
24-
linkNcurses(exe);
25-
exe.pie = pie;
2629
b.installArtifact(exe);
2730

2831
const run_cmd = b.addRunArtifact(exe);
@@ -35,21 +38,16 @@ pub fn build(b: *std.Build) void {
3538
run_step.dependOn(&run_cmd.step);
3639

3740
const unit_tests = b.addTest(.{
38-
.root_source_file = .{ .path = "src/main.zig" },
41+
.root_source_file = b.path("src/main.zig"),
3942
.target = target,
4043
.optimize = optimize,
44+
.link_libc = true,
4145
});
42-
linkNcurses(unit_tests);
4346
unit_tests.pie = pie;
47+
unit_tests.root_module.linkSystemLibrary("ncursesw", .{});
4448

4549
const run_unit_tests = b.addRunArtifact(unit_tests);
4650

4751
const test_step = b.step("test", "Run unit tests");
4852
test_step.dependOn(&run_unit_tests.step);
4953
}
50-
51-
pub fn linkNcurses(compile_step: *std.Build.CompileStep) void {
52-
compile_step.linkSystemLibrary("ncursesw");
53-
compile_step.linkLibC();
54-
compile_step.addCSourceFile(.{ .file = .{ .path = "src/ncurses_refs.c" }, .flags = &.{} });
55-
}

0 commit comments

Comments
 (0)