This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit a67e87961a594be5408e7fb9818eba34d8115f27
Author: wangjianyu3 <[email protected]>
AuthorDate: Sun Nov 22 10:41:09 2026 +0800

    system/toybox: pin KCONFIG_CONFIG to toybox's own config file
    
    When the surrounding build exports KCONFIG_CONFIG, toybox genconfig
    writes its own .config over the outer build's .config and corrupts it.
    Pin KCONFIG_CONFIG to toybox-owned files for those steps: .config in
    TOYBOX_BINARY_DIR for CMake (the FetchContent binary dir, created up
    front since FetchContent is skipped once the source is unpacked) and
    the unpacked tree's .config for Make.
    
    Assisted-by: OpenCode:mimo-v2.6-pro
    Co-authored-by: multica-agent <[email protected]>
    Signed-off-by: wangjianyu3 <[email protected]>
---
 system/toybox/CMakeLists.txt | 16 ++++++++++------
 system/toybox/Makefile       |  2 ++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/system/toybox/CMakeLists.txt b/system/toybox/CMakeLists.txt
index 4bd90c478..7254d38e1 100644
--- a/system/toybox/CMakeLists.txt
+++ b/system/toybox/CMakeLists.txt
@@ -25,6 +25,7 @@ if(CONFIG_SYSTEM_TOYBOX)
   set(TOYBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/toybox)
   set(TOYBOX_VERSION "${CONFIG_SYSTEM_TOYBOX_VERSION}")
   set(TOYBOX_STAMP ${TOYBOX_DIR}/.nuttx_patched-${TOYBOX_VERSION})
+  set(TOYBOX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/toybox)
 
   # 
############################################################################
   # Download and patch the pinned release
@@ -44,7 +45,7 @@ if(CONFIG_SYSTEM_TOYBOX)
             SOURCE_DIR
             ${TOYBOX_DIR}
             BINARY_DIR
-            ${NUTTX_BINARY_DIR}/apps/system/toybox/toybox
+            ${TOYBOX_BINARY_DIR}
             SUBBUILD_DIR
             ${TOYBOX_SUBBUILD_DIR}
         DOWNLOAD_NO_PROGRESS true
@@ -126,6 +127,8 @@ if(CONFIG_SYSTEM_TOYBOX)
   if(TOYBOX_REGENERATE)
     file(WRITE ${TOYBOX_ALLCONFIG} ${TOYBOX_ALLCONFIG_TEXT})
 
+    file(MAKE_DIRECTORY ${TOYBOX_BINARY_DIR})
+
     find_program(TOYBOX_HOSTCC NAMES cc gcc REQUIRED)
 
     message(STATUS "Generating Toybox headers for NuttX (${TOYBOX_VERSION})")
@@ -133,8 +136,8 @@ if(CONFIG_SYSTEM_TOYBOX)
     execute_process(
       COMMAND
         ${CMAKE_COMMAND} -E env "KCONFIG_ALLCONFIG=${TOYBOX_ALLCONFIG}"
-        "CC=${TOYBOX_HOSTCC}" "HOSTCC=${TOYBOX_HOSTCC}" "CROSS_COMPILE=" bash
-        scripts/genconfig.sh -n
+        "KCONFIG_CONFIG=${TOYBOX_BINARY_DIR}/.config" "CC=${TOYBOX_HOSTCC}"
+        "HOSTCC=${TOYBOX_HOSTCC}" "CROSS_COMPILE=" bash scripts/genconfig.sh -n
       WORKING_DIRECTORY ${TOYBOX_DIR}
       RESULT_VARIABLE TOYBOX_GENCONFIG_RESULT)
 
@@ -149,9 +152,10 @@ if(CONFIG_SYSTEM_TOYBOX)
 
     execute_process(
       COMMAND
-        ${CMAKE_COMMAND} -E env "CC=${TOYBOX_HOSTCC}" "HOSTCC=${TOYBOX_HOSTCC}"
-        "CROSS_COMPILE=" "NOBUILD=1"
-        "NUTTX_TOYBOX_MULTIPLEX_NAME=toybox_multiplex" bash scripts/make.sh
+        ${CMAKE_COMMAND} -E env "KCONFIG_CONFIG=${TOYBOX_BINARY_DIR}/.config"
+        "CC=${TOYBOX_HOSTCC}" "HOSTCC=${TOYBOX_HOSTCC}" "CROSS_COMPILE="
+        "NOBUILD=1" "NUTTX_TOYBOX_MULTIPLEX_NAME=toybox_multiplex" bash
+        scripts/make.sh
       WORKING_DIRECTORY ${TOYBOX_DIR}
       RESULT_VARIABLE TOYBOX_MAKESH_RESULT)
 
diff --git a/system/toybox/Makefile b/system/toybox/Makefile
index 74a9b3408..83dc282be 100644
--- a/system/toybox/Makefile
+++ b/system/toybox/Makefile
@@ -103,6 +103,7 @@ endif
        $(Q) cd $(TOYBOX_UNPACKNAME) && \
                CC="$(HOSTCC)" HOSTCC="$(HOSTCC)" CROSS_COMPILE= \
                KCONFIG_ALLCONFIG=$(WD)$(DELIM).toybox_allconfig \
+               KCONFIG_CONFIG=$(WD)$(DELIM)$(TOYBOX_UNPACKNAME)$(DELIM).config 
\
                bash scripts/genconfig.sh -n
        # scripts/make.sh *appends* its "FILES=..." build recipe to
        # generated/build.sh instead of overwriting it (upstream only expects
@@ -114,6 +115,7 @@ endif
        $(Q) rm -f $(TOYBOX_UNPACKNAME)$(DELIM)generated$(DELIM)build.sh
        $(Q) cd $(TOYBOX_UNPACKNAME) && \
                CC="$(HOSTCC)" HOSTCC="$(HOSTCC)" CROSS_COMPILE= NOBUILD=1 \
+               KCONFIG_CONFIG=$(WD)$(DELIM)$(TOYBOX_UNPACKNAME)$(DELIM).config 
\
                NUTTX_TOYBOX_MULTIPLEX_NAME=toybox_multiplex \
                bash scripts/make.sh
        $(Q) awk '/^FILES="/{sub(/^FILES="/,""); if ($$0!="") print; f=1; next} 
\

Reply via email to