Add format and check-format targets to Makefile

- Define 'format' target to apply clang-format to all C++ files.
- Define 'check-format' target to verify formatting without modifying files.
- Use '.clang-format' configuration file for style rules.
- Update DEVELOPMENT.md with formatting targets
- Update INSTALL.md with clang-format prerequisite
This commit is contained in:
François Degros
2026-05-04 10:57:31 +10:00
parent ab31b8823c
commit e1db2ac54e
6 changed files with 23 additions and 7 deletions
+2
View File
@@ -24,6 +24,8 @@ Current state: **1.21 (Development)**.
- `make all`: Build the `fuse-archive` binary and the man page.
- `make check-fast`: Run the fast subset of tests (recommended for most dev work).
- `make check`: Run the full test suite (including large file tests).
- `make check-format`: Verify that all C++ files are correctly formatted.
- `make format`: Apply `clang-format` to all C++ files.
- `make doc`: Regenerate the `fuse-archive.1` man page from `README.md`.
- `make release`: Run the automated release workflow (see below).
- `make clean-data`: Remove large generated test archives from `test/data`.
+2 -1
View File
@@ -28,13 +28,14 @@ To build **fuse-archive**, you also need the following tools:
* C++20 compiler (g++ or clang++)
* [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/)
* [GNU make](https://www.gnu.org/software/make/)
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html) (to format the code)
* [GoogleTest](https://github.com/google/googletest) (for unit tests)
* [Pandoc](https://pandoc.org) to regenerate the man page
On Debian systems, you can get these tools by installing the following packages:
```sh
$ sudo apt install g++ pkg-config make libgtest-dev pandoc
$ sudo apt install g++ pkg-config make clang-format libgtest-dev pandoc
```
To test **fuse-archive**, you also need the following external programs for
+13
View File
@@ -45,6 +45,19 @@ MANDIR = $(PREFIX)/share/man/man1
MAN = $(PROJECT).1
INSTALL = install
# ---- Formatting
FORMAT = clang-format
CC_FILES = $(wildcard *.cc lib/*.cc test/*.cc)
H_FILES = $(wildcard lib/*.h)
ALL_CXX_FILES = $(CC_FILES) $(H_FILES)
format:
$(FORMAT) -i -style=file $(ALL_CXX_FILES)
check-format:
$(FORMAT) --dry-run -Werror -style=file $(ALL_CXX_FILES)
# ---- Library
LIB_DIR = lib
+1 -1
View File
@@ -88,7 +88,7 @@ class FileDescriptor {
// Writes the data in 'b' to the file at 'pos' while detecting and skipping
// large NUL sequences. This creates a sparse file to save disk space.
// 'last_hole_start' tracks the start of the current potentially sparse
// region. 'on_hole' is called whenever a new hole is finalized.
// region. 'on_hole' is called whenever a new hole is finalized.
//
// Returns the position immediately following the last written bytes,
// or `last_hole_start` if nothing was written.
+2 -1
View File
@@ -458,7 +458,8 @@ i64 Reader::CacheEntryData(const FileDescriptor& dest_fd,
node->cache_offset = file_start_offset;
node->cached_size = offset;
node->size = offset;
node->last_hole_start = tree.options_.holes ? last_hole_start : dest_offset;
node->last_hole_start =
tree.options_.holes ? last_hole_start : dest_offset;
assert(node->IsFullyCached());
}
+3 -4
View File
@@ -56,10 +56,9 @@ class Tree {
// Returns a warm reader from the recycle bin or creates a new one,
// positioned at the requested entry and offset.
Reader::Ptr GetReader(
ArchiveDescriptor* descriptor,
i64 want_index_within_archive,
i64 want_offset_within_entry);
Reader::Ptr GetReader(ArchiveDescriptor* descriptor,
i64 want_index_within_archive,
i64 want_offset_within_entry);
// Scans the provided archives and populates the virtual file system tree.
void Load(std::span<const std::string> archives);