xuxin930 opened a new pull request, #22036:
URL: https://github.com/apache/nuttx/pull/22036
## Summary
Both `tools/refresh.sh` and `tools/checkkconfig.py` assume a Make-based,
in-tree configuration (`nuttx/.config` + `Make.defs`). Board configs that
are CMake-only (no `Make.defs`) cannot be normalized, and Kconfig impact
analysis cannot run against an out-of-tree CMake build directory. This PR
adds CMake support to both tools.
* tools/refresh.sh: add CMake refresh support
- Add a `--cmake` option. For each config, refresh.sh configures a
temporary CMake build dir, runs the `refreshsilent` target, and then
diffs, prompts and saves the result in the same way as the Make flow.
The temporary build dir is removed afterwards.
- `refreshsilent` no longer copies the generated defconfig back to the
board's defconfig. It only produces `${NUTTX_BINARY_DIR}/defconfig`.
Before this change, refreshsilent rewrote the source defconfig before
refresh.sh could compare it, so refresh.sh never saw a difference,
always exited 0, and `--prompt` had no effect.
Usage:
./tools/refresh.sh --silent --cmake sim:nsh
* tools/checkkconfig.py: add out-of-tree config check support
- Add `-o/--out_dir <cmake binary dir>` to run the analysis against a
CMake build dir instead of the in-tree `.config`.
- `-s/--set` now takes several `SYMBOL VALUE` pairs in a single run
(previously `-s/--single` took exactly one pair). An odd number of
arguments is rejected.
- Values other than y/m/n (int/hex/string) are now applied directly
instead of being skipped.
Usage:
checkkconfig.py -o build -f build/.config -s DEBUG_FEATURES n
TASK_NAME_SIZE 16
## Impact
* Build: no change to normal builds. Only the `refreshsilent` utility
target and two host tools are affected.
* Behavior change: running `cmake --build <dir> -t refreshsilent` directly
no longer modifies the board's defconfig. The result is left in
`<dir>/defconfig`; use `tools/refresh.sh --cmake` to save it.
* tools/refresh.sh: the default (Make) path is unchanged. `--cmake` is
opt-in.
* tools/checkkconfig.py: the long option `--single` is renamed to `--set`.
The short `-s` option still works and is a superset of the old behavior.
* Hardware, security, documentation: none.
## Testing
Host: Ubuntu 24.04.3 LTS (Linux 7.0.0, x86_64), CMake 3.23.0,
Python 3.12.3, GCC 13.3.0, Ninja. apps: apache/nuttx-apps master.
1. CMake refresh on an already normalized config (no change, exit 0):
$ ./tools/refresh.sh --silent --cmake sim:nsh; echo rc=$?
[1/1] Normalize sim:nsh
...
Loaded configuration '.../refresh/.config'
Minimal configuration saved to '.../refresh/defconfig.tmp'
rc=0
`git status`: board defconfig is unmodified.
2. CMake refresh on a stale defconfig (appended a duplicate
`CONFIG_DEBUG_FEATURES=n`). The diff is reported, the defconfig is
saved, and the exit code is 1:
$ ./tools/refresh.sh --silent --cmake sim:nsh; echo rc=$?
[1/1] Normalize sim:nsh
21,23d20
< CONFIG_DEBUG_ASSERTIONS=y
< CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y
< CONFIG_DEBUG_FEATURES=y
55d51
< CONFIG_NDEBUG=y
83d78
< CONFIG_DEBUG_FEATURES=n
Saving the new configuration file
rc=1
3. checkkconfig.py against a CMake build dir with several changes,
including an int value:
$ cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
$ ./tools/checkkconfig.py -o build -f build/.config \
-s DEBUG_FEATURES n TASK_NAME_SIZE 16
Setting the value 16 for TASK_NAME_SIZE directly
Change report for config changes
Config Option Old New
----------------------------------------------------------------------
DEBUG_ALERT y n
DEBUG_ASSERTIONS y n
DEBUG_ASSERTIONS_EXPRESSION y n
DEBUG_ASSERTIONS_FILENAME y n
DEBUG_ERROR y n
DEBUG_FEATURES y n
DEBUG_INFO y n
DEBUG_WARN y n
SCHED_DUMP_TASKS y n
STACKCHECK_MARGIN -1
<unset>
TASK_NAME_SIZE 31 16
4. checkkconfig.py in-tree (Make flow, no `-o`) still works:
$ ./tools/checkkconfig.py -f
boards/sim/sim/sim/configs/nsh/defconfig \
-s DEBUG_FEATURES n
...
DEBUG_FEATURES y n
5. Odd number of `-s` arguments is rejected:
$ ./tools/checkkconfig.py -o build -f build/.config -s
DEBUG_FEATURES
ERROR: -s/--set requires an even number of arguments (config-value
pairs)
6. ./tools/checkpatch.sh -m -g HEAD~2..HEAD: All checks pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]