Of course, everyone has their own development workflow, but first
experiments with Claude CLI show that all the individual steps make it
easy for it to get lost in the weeds.

Add a development mode that is enabled via passing -d/-D to MAKEALL,
which enables a more AI-friendly building experience with -d:

  - Generate compile_commands.json on every successful build, so LSP can
    be used (doesn't 100% work yet for me, but that's not barebox'
    fault)

  - implies -i, so old build directories aren't wiped

  - Use build/ as name for the build directory as clangd will look
    there automatically if the file is not found in the source
    directory[1]. Support for multiple build directories can be handled
    via git worktrees still.

The -D goes on and adds some more things, that may falsify results in
some cases:

  - Output missing firmware warnings that may be expected with
    defconfigs and no firmware on stdout, no stderr, so MAKEALL output
    is cleaner

  - Enable sanitizers. This will affect binary size.

[1]: 
https://github.com/llvm/llvm-project/blob/263802c56b4d/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp#L151

Signed-off-by: Ahmad Fatoum <[email protected]>
---
 MAKEALL                                 | 17 ++++++++++++++++-
 common/boards/configs/devel.config      |  2 ++
 common/boards/configs/sanitizers.config |  6 ++++++
 3 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 common/boards/configs/devel.config
 create mode 100644 common/boards/configs/sanitizers.config

diff --git a/MAKEALL b/MAKEALL
index bfc0f917aca8..1e6d0c97b868 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -60,6 +60,8 @@ usage() {
        echo "TARGET      -t      Makefile target"
        echo "V           -v      verbosity"
        echo "INCREMENTAL -i"
+       echo "            -d      (iterative development mode)"
+       echo "            -D      (extended iterative development mode)"
        echo ""
 }
 
@@ -189,6 +191,9 @@ do_build_defconfig() {
                report "Compile: " ${defconfig}
 
                if [ "$compile_result" = "0" ]; then
+                       if [ "$DEVEL" = "1" ]; then
+                               ${MAKE} $silent_flag compile_commands.json
+                       fi
                        report "OK     \n"
                else
                        report "FAILED \n"
@@ -288,7 +293,7 @@ do_build_all() {
        return $nbuilds
 }
 
-while getopts "hc:j:O:l:a:e:k:t:v:i" Option
+while getopts "hc:j:O:l:a:e:k:t:v:idD" Option
 do
 case $Option in
        a )
@@ -321,6 +326,16 @@ case $Option in
        i )
                INCREMENTAL=1
                ;;
+       d | D)
+               DEVEL=1
+               INCREMENTAL=1
+               KCONFIG_ADD="${KCONFIG_ADD} common/boards/configs/devel.config"
+               BUILDDIR="build"
+               if [ "$Option" = D ]; then
+                       KCONFIG_ADD="${KCONFIG_ADD} 
common/boards/configs/sanitizers.config"
+                       export NO_MISSING_FIRMWARE_WARNING=1
+               fi
+               ;;
        h )
                usage
                exit 0
diff --git a/common/boards/configs/devel.config 
b/common/boards/configs/devel.config
new file mode 100644
index 000000000000..fd046c9ab08e
--- /dev/null
+++ b/common/boards/configs/devel.config
@@ -0,0 +1,2 @@
+CONFIG_WERROR=y
+CONFIG_PANIC_POWEROFF=y
diff --git a/common/boards/configs/sanitizers.config 
b/common/boards/configs/sanitizers.config
new file mode 100644
index 000000000000..7e6cffd67874
--- /dev/null
+++ b/common/boards/configs/sanitizers.config
@@ -0,0 +1,6 @@
+CONFIG_KASAN=y
+CONFIG_ASAN=y
+CONFIG_UBSAN=y
+CONFIG_DEBUG_LIST=y
+CONFIG_BUG_ON_DATA_CORRUPTION=y
+CONFIG_STACKPROTECTOR_STRONG=y
-- 
2.47.3


Reply via email to