You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+101-7Lines changed: 101 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,32 +10,124 @@ Thank you for your interest in CFBox. This document covers building, testing, an
10
10
11
11
## Building
12
12
13
+
### Debug Build (Default)
14
+
13
15
```bash
14
16
cmake -B build
15
17
cmake --build build
16
18
```
17
19
18
-
Debug builds (default) include AddressSanitizer and UBSan. For a release build:
20
+
Debug builds automatically enable AddressSanitizer (ASan) and UndefinedBehaviorSanitizer (UBSan) with `-g3 -O0`. Compiler warnings are treated as errors (`-Werror`) with extensive warning flags (see [CompilerFlag.cmake](cmake/compile/CompilerFlag.cmake)).
21
+
22
+
### Release Build
19
23
20
24
```bash
21
25
cmake -B build -DCMAKE_BUILD_TYPE=Release
22
26
cmake --build build
23
27
```
24
28
29
+
Release builds use `-O2` by default and enable LTO. For size-optimized builds, add `-DCFBOX_OPTIMIZE_FOR_SIZE=ON` to use `-Os` instead.
30
+
25
31
## Running Tests
26
32
27
33
```bash
28
34
# Unit tests (108 GTest cases)
29
35
ctest --test-dir build --output-on-failure
30
36
31
-
# Integration tests (16 shell scripts)
37
+
# Integration tests (16 shell scripts comparing against GNU coreutils)
Requires: [Arm GNU Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain) (`arm-none-linux-gnueabihf-g++`).
|**qemu-user-test**| Integration tests under QEMU user-mode emulation |
125
+
|**qemu-system-test**| Full boot test with CFBox as PID 1 (main/release branches only) |
126
+
35
127
## Code Style
36
128
37
-
- Format code with the project `.clang-format` (LLVM-based, 4-space indent, 100-column limit).
38
-
- All code must compile cleanly with the flags in `cmake/compile/CompilerFlag.cmake` (`-Wall -Wextra -Wpedantic` plus additional warnings).
129
+
- Format code with the project [.clang-format](.clang-format) (LLVM-based, 4-space indent, 100-column limit).
130
+
- All code must compile cleanly with the flags in [CompilerFlag.cmake](cmake/compile/CompilerFlag.cmake) (`-Wall -Wextra -Wpedantic` plus additional warnings, all treated as errors).
39
131
- Follow existing patterns:
40
132
-`std::expected<T, Error>` with `CFBOX_TRY` for error handling
- Add a comment header listing supported flags and known differences from GNU.
49
-
2. Declare the function in `include/cfbox/applets.hpp`.
50
-
3. Add one entry to `APPLET_REGISTRY` in `include/cfbox/applets.hpp`.
51
-
4. Add GTest unit tests in `tests/unit/test_<name>.cpp` (see `test_capture.hpp` for stdout capture and `TempDir` utilities).
141
+
2. Declare the function in [applets.hpp](include/cfbox/applets.hpp).
142
+
3. Add one entry to `APPLET_REGISTRY` in [applets.hpp](include/cfbox/applets.hpp).
143
+
4. Add GTest unit tests in `tests/unit/test_<name>.cpp` (see [test_capture.hpp](tests/unit/test_capture.hpp) for stdout capture and `TempDir` utilities).
52
144
5. Add shell integration tests in `tests/integration/test_<name>.sh` following the pattern in existing scripts.
53
145
146
+
> **Note:** The `init` applet is special — it runs as PID 1 in QEMU system-mode tests. Regular applets should not need special PID 1 handling.
CFBox is a single-executable Unix utility collection distributed via symbolic links. Each subcommand can be invoked either through `argv[0]` detection or explicit subcommand syntax.
16
+
CFBox is a single-executable Unix utility collection distributed via symbolic links. All development is complete — 17 applets implemented and tested, with a CI pipeline covering native builds, cross-compilation, and QEMU user/system-mode testing across 5 stages.
16
17
17
-
**Design philosophy:**
18
-
-**Simplicity first** — Get core functionality working before pursuing full POSIX compliance
19
-
-**Modern C++** — Leverage C++23 features with `std::expected` for error handling
|`init`| System initialization — auto-mounts proc/sysfs/devtmpfs when PID 1, runs smoke tests, then powers off |
63
77
64
78
## Requirements
65
79
66
80
-**Compiler:** GCC 13+ / Clang 17+ (C++23 support required)
67
81
-**CMake:** 3.26+
68
82
-**Platform:** Linux (x86_64 / aarch64)
69
83
70
-
## Architecture
84
+
## Documentation
71
85
72
-
**Dispatch mechanism:**`main.cpp` detects the invoked name via `argv[0]` (symlink detection) and falls back to subcommand syntax (`cfbox echo ...`). The `APPLET_REGISTRY` in [applets.hpp](include/cfbox/applets.hpp) is a `constexpr std::array` mapping names to entry functions.
73
-
74
-
**Core infrastructure:**
75
-
76
-
| Header | Purpose |
77
-
|--------|---------|
78
-
|[error.hpp](include/cfbox/error.hpp)|`std::expected<T, Error>` with `CFBOX_TRY` macro for error propagation |
79
-
|[applet.hpp](include/cfbox/applet.hpp)|`AppEntry` struct and `find_applet()` lookup |
80
-
|[args.hpp](include/cfbox/args.hpp)| CLI argument parser — short flags, flag values, `--` separator, positional args |
0 commit comments