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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8d4e87240 !testing/cmocka: Compile cmocka as a libary only by default
8d4e87240 is described below

commit 8d4e87240224654bcf59f134d41b677bdfe231bd
Author: Matteo Golin <[email protected]>
AuthorDate: Tue Dec 23 16:40:00 2025 -0500

    !testing/cmocka: Compile cmocka as a libary only by default
    
    BREAKING CHANGE
    
    This commit introduces a Kconfig switch to include the cmocka binary
    built from cmocka_main.c. The default behaviour is now changed so that
    cmocka is built as a library only, which would be the desired behaviour
    for users creating their own cmocka projects.
    
    To restore the old behaviour (where the cmocka program is compiled), add
    CONFIG_TESTING_CMOCKA_PROG=y to your legacy configuration.
    
    Signed-off-by: Matteo Golin <[email protected]>
---
 testing/cmocka/CMakeLists.txt | 32 +++++++++++++++++---------------
 testing/cmocka/Kconfig        | 18 ++++++++++++++++--
 testing/cmocka/Makefile       |  8 +++++---
 3 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/testing/cmocka/CMakeLists.txt b/testing/cmocka/CMakeLists.txt
index 277ee2233..d810aee89 100644
--- a/testing/cmocka/CMakeLists.txt
+++ b/testing/cmocka/CMakeLists.txt
@@ -74,20 +74,22 @@ if(CONFIG_TESTING_CMOCKA)
   target_include_directories(cmocka PRIVATE ${INCDIR})
   target_compile_options(cmocka PRIVATE ${CFLAGS})
 
-  nuttx_add_application(
-    NAME
-    ${CONFIG_TESTING_CMOCKA_PROGNAME}
-    PRIORITY
-    ${CONFIG_TESTING_CMOCKA_PRIORITY}
-    STACKSIZE
-    ${CONFIG_TESTING_CMOCKA_STACKSIZE}
-    MODULE
-    ${CONFIG_TESTING_CMOCKA}
-    INCLUDE_DIRECTORIES
-    ${INCDIR}
-    SRCS
-    cmocka_main.c
-    DEPENDS
-    cmocka)
+  if(CONFIG_TESTING_CMOCKA_PROG)
+    nuttx_add_application(
+      NAME
+      ${CONFIG_TESTING_CMOCKA_PROGNAME}
+      PRIORITY
+      ${CONFIG_TESTING_CMOCKA_PRIORITY}
+      STACKSIZE
+      ${CONFIG_TESTING_CMOCKA_STACKSIZE}
+      MODULE
+      ${CONFIG_TESTING_CMOCKA}
+      INCLUDE_DIRECTORIES
+      ${INCDIR}
+      SRCS
+      cmocka_main.c
+      DEPENDS
+      cmocka)
+  endif()
 
 endif()
diff --git a/testing/cmocka/Kconfig b/testing/cmocka/Kconfig
index 0f5ab51f7..fd1138152 100644
--- a/testing/cmocka/Kconfig
+++ b/testing/cmocka/Kconfig
@@ -4,7 +4,7 @@
 #
 
 config TESTING_CMOCKA
-       tristate "Enable libcmocka"
+       bool "Enable libcmocka"
        depends on LIBC_REGEX
        default n
        ---help---
@@ -12,6 +12,15 @@ config TESTING_CMOCKA
 
 if TESTING_CMOCKA
 
+config TESTING_CMOCKA_PROG
+       tristate "Compile cmocka binary"
+       default n
+       ---help---
+               Instead of just compiling cmocka as a library, the 'cmocka' 
binary is
+               also included.
+
+if TESTING_CMOCKA_PROG
+
 config TESTING_CMOCKA_PROGNAME
        string "Program name"
        default "cmocka"
@@ -27,8 +36,13 @@ config TESTING_CMOCKA_STACKSIZE
        int "cmocka test stack size"
        default DEFAULT_TASK_STACKSIZE
 
+endif # TESTING_CMOCKA_PROG
+
 config TESTING_CMOCKA_LEAKDETECT
-       bool "Memory leaks can be checked using cmocka, please use in local 
environment"
+       bool "Detect leaks"
        default n
+       ---help---
+               Memory leaks can be checked using cmocka, please use in a local
+               environment.
 
 endif
diff --git a/testing/cmocka/Makefile b/testing/cmocka/Makefile
index ac2d177b5..4a21f3ea1 100644
--- a/testing/cmocka/Makefile
+++ b/testing/cmocka/Makefile
@@ -29,12 +29,14 @@ CFLAGS += -DHAVE_CLOCK_REALTIME=1
 CFLAGS += -DHAVE_STRUCT_TIMESPEC=1
 CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/testing/cmocka
 
+MODULE = $(CONFIG_TESTING_CMOCKA_PROG)
+
+ifneq ($(CONFIG_TESTING_CMOCKA_PROG),)
 PROGNAME  = $(CONFIG_TESTING_CMOCKA_PROGNAME)
 PRIORITY  = $(CONFIG_TESTING_CMOCKA_PRIORITY)
 STACKSIZE = $(CONFIG_TESTING_CMOCKA_STACKSIZE)
-MODULE    = $(CONFIG_TESTING_CMOCKA)
-
-MAINSRC = $(CURDIR)/cmocka_main.c
+MAINSRC   = $(CURDIR)/cmocka_main.c
+endif
 
 # Download and unpack tarball if no git repo found
 ifeq ($(wildcard cmocka/.git),)

Reply via email to