From 652e4f41c1088318f0a5931ee982172282d8674c Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Fri, 25 Jun 2021 11:48:59 +0200 Subject: [PATCH] cpp: Use modules for cpp and libstdcpp Also add better error message when kconfig or make includes a .cpp without cpp module. --- Makefile.base | 9 +++++++-- Makefile.dep | 8 +++++++- Makefile.include | 2 +- makefiles/pseudomodules.inc.mk | 2 ++ sys/Kconfig | 12 ++++++++++++ sys/arduino/Kconfig | 2 ++ 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Makefile.base b/Makefile.base index 88cb367043..58124cc1e5 100644 --- a/Makefile.base +++ b/Makefile.base @@ -67,9 +67,14 @@ ifeq ($(strip $(ASSMSRC))$(NO_AUTO_SRC),) ASSMSRC := $(wildcard *.S) endif + ifneq (,$(SRCXX)) - ifeq (,$(filter cpp,$(FEATURES_USED))) - $(error Found C++ source, but feature "cpp" is not used. Add "FEATURES_REQUIRED += cpp") + ifeq (,$(filter cpp,$(USEMODULE))) + ifneq (1,$(TEST_KCONFIG)) + $(error Found C++ source, but feature "cpp" is not used. Add "FEATURES_REQUIRED += cpp") + else + $(error Found C++ source, but "cpp" module is not used. Enable the MODULE_CPP in Kconfig) + endif endif endif diff --git a/Makefile.dep b/Makefile.dep index 4c57278ff1..8a8adb2116 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -104,7 +104,13 @@ FEATURES_OPTIONAL += no_idle_thread ifneq (,$(filter libstdcpp,$(FEATURES_USED))) # Also use C++ if libstdc++ is used - FEATURES_REQUIRED += cpp + USEMODULE += cpp + USEMODULE += libstdcpp +endif + +ifneq (,$(filter cpp,$(FEATURES_USED))) + # Also use C++ if libstdc++ is used + USEMODULE += cpp endif ifneq (,$(filter test_utils_interactive_sync,$(USEMODULE))) diff --git a/Makefile.include b/Makefile.include index fe01d56056..365a3a32df 100644 --- a/Makefile.include +++ b/Makefile.include @@ -623,7 +623,7 @@ else endif # variables used to compile and link c++ -ifneq (,$(filter cpp,$(FEATURES_USED))) +ifneq (,$(filter cpp,$(USEMODULE))) CPPMIX ?= 1 endif diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 05c8fe7ee7..7340f2b864 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -20,6 +20,7 @@ PSEUDOMODULES += cord_ep_standalone PSEUDOMODULES += core_% PSEUDOMODULES += cortexm_fpu PSEUDOMODULES += cortexm_svc +PSEUDOMODULES += cpp PSEUDOMODULES += cpu_check_address PSEUDOMODULES += dbgpin PSEUDOMODULES += devfs_% @@ -75,6 +76,7 @@ PSEUDOMODULES += ieee802154_submac PSEUDOMODULES += ina3221_alerts PSEUDOMODULES += l2filter_blacklist PSEUDOMODULES += l2filter_whitelist +PSEUDOMODULES += libstdcpp PSEUDOMODULES += lis2dh12_i2c PSEUDOMODULES += lis2dh12_int PSEUDOMODULES += lis2dh12_spi diff --git a/sys/Kconfig b/sys/Kconfig index 3c768062d6..94626af3b9 100644 --- a/sys/Kconfig +++ b/sys/Kconfig @@ -58,6 +58,18 @@ rsource "usb/Kconfig" rsource "xtimer/Kconfig" rsource "ztimer/Kconfig" +config MODULE_CPP + bool "Use CPP compiler" + depends on TEST_KCONFIG + depends on HAS_CPP + +config MODULE_LIBSTDCPP + bool "Use the CPP standard library" + depends on TEST_KCONFIG + depends on HAS_LIBSTDCPP + depends on HAS_CPP + select MODULE_CPP + config MODULE_SYS bool default y diff --git a/sys/arduino/Kconfig b/sys/arduino/Kconfig index 9f1ae34981..876b852313 100644 --- a/sys/arduino/Kconfig +++ b/sys/arduino/Kconfig @@ -16,8 +16,10 @@ menuconfig MODULE_ARDUINO imply MODULE_PERIPH_SPI depends on HAS_ARDUINO depends on HAS_PERIPH_GPIO + depends on HAS_CPP depends on TEST_KCONFIG select MODULE_PERIPH_GPIO + select MODULE_CPP select MODULE_ARDUINO_SKETCHES select MODULE_FMT select MODULE_ZTIMER