From 5e01fe050a750eabbcb09af9d64e98ce17e50042 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Mon, 26 Jul 2021 15:50:40 +0800 Subject: [PATCH] arch/sim: Copy include/nuttx/config.h to the local folder so the source code compiled by host environment can include config.h directly and then avoid pass Kconfig option through Makefile manually Signed-off-by: Xiang Xiao Change-Id: Ic9fe6f846082cef2d0808dc717df8ae6ed929edf --- arch/sim/src/.gitignore | 1 + arch/sim/src/Makefile | 33 +++++++--------------------- arch/sim/src/sim/up_hcisocket.c | 5 +---- arch/sim/src/sim/up_hostfs.c | 1 - arch/sim/src/sim/up_hosttime.c | 2 ++ arch/sim/src/sim/up_i2cbus.h | 4 ++++ arch/sim/src/sim/up_internal.h | 12 +++++----- arch/sim/src/sim/up_netdriver.c | 5 +---- arch/sim/src/sim/up_sigdeliver.c | 1 + arch/sim/src/sim/up_simuart.c | 6 +++-- arch/sim/src/sim/up_tapdev.c | 6 +---- arch/sim/src/sim/up_testset.c | 5 ++--- arch/sim/src/sim/up_wpcap.c | 5 ++++- arch/sim/src/sim/up_x11framebuffer.c | 7 +++--- boards/sim/sim/sim/scripts/Make.defs | 2 +- include/nuttx/fs/hostfs.h | 1 + 16 files changed, 41 insertions(+), 55 deletions(-) diff --git a/arch/sim/src/.gitignore b/arch/sim/src/.gitignore index 685f6995fd..0caf7f6d09 100644 --- a/arch/sim/src/.gitignore +++ b/arch/sim/src/.gitignore @@ -1,5 +1,6 @@ /nuttx-names.dat /nuttx.ld +/config.h /hostfs.h /chip /board diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index dbcb0c40a3..48663a62fe 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -75,7 +75,6 @@ ifeq ($(CONFIG_HOST_MACOS),y) HOSTCFLAGS += -Wno-deprecated-declarations endif -HOSTCFLAGS += -DCONFIG_USEC_PER_TICK=$(CONFIG_USEC_PER_TICK) HOSTSRCS = up_hostirq.c up_hostmemory.c up_hosttime.c up_simuart.c STDLIBS += -lpthread ifeq ($(CONFIG_HOST_MACOS),y) @@ -97,7 +96,6 @@ endif ifeq ($(CONFIG_SMP),y) CSRCS += up_smpsignal.c up_cpuidlestack.c REQUIREDOBJS += up_smpsignal$(OBJEXT) - HOSTCFLAGS += -DCONFIG_SMP=1 -DCONFIG_SMP_NCPUS=$(CONFIG_SMP_NCPUS) HOSTSRCS += up_simsmp.c endif @@ -118,22 +116,16 @@ else endif ifeq ($(CONFIG_SIM_X11FB),y) -ifeq ($(CONFIG_SIM_X11NOSHM),y) - HOSTCFLAGS += -DCONFIG_SIM_X11NOSHM=1 -endif HOSTSRCS += up_x11framebuffer.c STDLIBS += -lX11 -lXext ifeq ($(CONFIG_SIM_TOUCHSCREEN),y) CSRCS += up_touchscreen.c REQUIREDOBJS += up_touchscreen$(OBJEXT) - HOSTCFLAGS += -DCONFIG_SIM_TOUCHSCREEN=1 HOSTSRCS += up_x11eventloop.c else ifeq ($(CONFIG_SIM_AJOYSTICK),y) CSRCS += up_ajoystick.c - HOSTCFLAGS += -DCONFIG_SIM_AJOYSTICK=1 HOSTSRCS += up_x11eventloop.c else ifeq ($(CONFIG_SIM_BUTTONS),y) - HOSTCFLAGS += -DCONFIG_SIM_BUTTONS=1 HOSTSRCS += up_x11eventloop.c endif endif @@ -165,23 +157,14 @@ endif ifeq ($(CONFIG_SIM_NETDEV_TAP),y) CSRCS += up_netdriver.c - HOSTCFLAGS += -DNETDEV_BUFSIZE=$(CONFIG_NET_ETH_PKTSIZE) ifneq ($(CONFIG_WINDOWS_CYGWIN),y) HOSTSRCS += up_tapdev.c -ifeq ($(CONFIG_SIM_NET_BRIDGE),y) - HOSTCFLAGS += -DCONFIG_SIM_NET_BRIDGE - HOSTCFLAGS += -DCONFIG_SIM_NET_BRIDGE_DEVICE=\"$(CONFIG_SIM_NET_BRIDGE_DEVICE)\" -endif -ifeq ($(CONFIG_SIM_NET_HOST_ROUTE),y) - HOSTCFLAGS += -DCONFIG_SIM_NET_HOST_ROUTE -endif else # CONFIG_WINDOWS_CYGWIN != y HOSTSRCS += up_wpcap.c STDLIBS = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a endif # CONFIG_WINDOWS_CYGWIN != y else ifeq ($(CONFIG_SIM_NETDEV_VPNKIT),y) CSRCS += up_netdriver.c - HOSTCFLAGS += -DCONFIG_SIM_NETDEV_VPNKIT_PATH=\"$(CONFIG_SIM_NETDEV_VPNKIT_PATH)\" HOSTSRCS += up_vpnkit.c VPATH += :sim/vpnkit HOSTSRCS += protocol.c negotiate.c @@ -192,10 +175,6 @@ ifeq ($(CONFIG_SIM_HCISOCKET),y) CSRCS += up_hcisocket.c endif -ifeq ($(CONFIG_I2C_RESET),y) - HOSTCFLAGS += -DCONFIG_I2C_RESET=1 -endif - ifeq ($(CONFIG_SIM_I2CBUS_LINUX),y) HOSTSRCS += up_i2cbuslinux.c endif @@ -212,13 +191,12 @@ endif ifeq ($(CONFIG_FS_HOSTFS),y) ifneq ($(CONFIG_FS_HOSTFS_RPMSG),y) HOSTSRCS += up_hostfs.c - HOSTCFLAGS += -DCONFIG_NAME_MAX=$(CONFIG_NAME_MAX) - -up_hostfs.c: hostfs.h hostfs.h: $(TOPDIR)/include/nuttx/fs/hostfs.h @echo "CP: $<" $(Q) cp $< $@ + +up_hostfs.c: hostfs.h endif endif @@ -325,7 +303,11 @@ makedepfile: $(CSRCS:.c=.ddc) $(ASRCS:.S=.dds) $(HOSTSRCS:.c=.ddh) $(call CATFILE, Make.dep, $^) $(call DELFILE, $^) -.depend: Makefile $(SRCS) $(TOPDIR)$(DELIM).config +config.h: $(TOPDIR)/include/nuttx/config.h + @echo "CP: $<" + $(Q) cp $< $@ + +.depend: Makefile config.h $(SRCS) $(TOPDIR)$(DELIM).config $(Q) if [ -e board/Makefile ]; then \ $(MAKE) -C board depend ; \ fi @@ -352,6 +334,7 @@ distclean:: clean fi $(call DELFILE, Make.dep) $(call DELFILE, .depend) + $(call DELFILE, config.h) $(call DELFILE, hostfs.h) -include Make.dep diff --git a/arch/sim/src/sim/up_hcisocket.c b/arch/sim/src/sim/up_hcisocket.c index 6d777ce903..9159fe248f 100644 --- a/arch/sim/src/sim/up_hcisocket.c +++ b/arch/sim/src/sim/up_hcisocket.c @@ -40,10 +40,7 @@ #include #include #include - -#if defined(CONFIG_UART_BTH4) - #include -#endif +#include #include "up_internal.h" #include "up_hcisocket_host.h" diff --git a/arch/sim/src/sim/up_hostfs.c b/arch/sim/src/sim/up_hostfs.c index e54a2f3bc9..a0333ba2ff 100644 --- a/arch/sim/src/sim/up_hostfs.c +++ b/arch/sim/src/sim/up_hostfs.c @@ -34,7 +34,6 @@ #include #include -#define __SIM__ 1 #include "hostfs.h" /**************************************************************************** diff --git a/arch/sim/src/sim/up_hosttime.c b/arch/sim/src/sim/up_hosttime.c index 9d1fb5e8f5..4e6e0dbb53 100644 --- a/arch/sim/src/sim/up_hosttime.c +++ b/arch/sim/src/sim/up_hosttime.c @@ -30,6 +30,8 @@ #include #include +#include "up_internal.h" + /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/sim/src/sim/up_i2cbus.h b/arch/sim/src/sim/up_i2cbus.h index f899b75473..5921eabc71 100644 --- a/arch/sim/src/sim/up_i2cbus.h +++ b/arch/sim/src/sim/up_i2cbus.h @@ -25,6 +25,10 @@ * Included Files ****************************************************************************/ +#ifdef __SIM__ +#include "config.h" +#endif + #include /**************************************************************************** diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h index 5629b15759..3a73afa062 100644 --- a/arch/sim/src/sim/up_internal.h +++ b/arch/sim/src/sim/up_internal.h @@ -25,9 +25,11 @@ * Included Files ****************************************************************************/ -#ifdef __ASSEMBLY__ -# include -#else +#ifdef __SIM__ +#include "config.h" +#endif + +#ifndef __ASSEMBLY__ # include # include # include @@ -89,6 +91,7 @@ ****************************************************************************/ struct tcb_s; +struct foc_dev_s; struct spi_dev_s; struct qspi_dev_s; struct ioexpander_dev_s; @@ -353,8 +356,7 @@ void up_stack_color(void *stackbase, size_t nbytes); /* up_foc.c *****************************************************************/ #ifdef CONFIG_MOTOR_FOC -struct foc_dev_s; -FAR struct foc_dev_s *sim_foc_initialize(int inst); +struct foc_dev_s *sim_foc_initialize(int inst); void sim_foc_update(void); #endif diff --git a/arch/sim/src/sim/up_netdriver.c b/arch/sim/src/sim/up_netdriver.c index 62036afa1d..6432262435 100644 --- a/arch/sim/src/sim/up_netdriver.c +++ b/arch/sim/src/sim/up_netdriver.c @@ -53,10 +53,7 @@ #include #include #include - -#ifdef CONFIG_NET_PKT -# include -#endif +#include #include "up_internal.h" diff --git a/arch/sim/src/sim/up_sigdeliver.c b/arch/sim/src/sim/up_sigdeliver.c index ac8544fa9c..efb15549ad 100644 --- a/arch/sim/src/sim/up_sigdeliver.c +++ b/arch/sim/src/sim/up_sigdeliver.c @@ -33,6 +33,7 @@ #include #include "sched/sched.h" +#include "up_internal.h" /**************************************************************************** * Public Functions diff --git a/arch/sim/src/sim/up_simuart.c b/arch/sim/src/sim/up_simuart.c index 577fff3403..5e2aa56db5 100644 --- a/arch/sim/src/sim/up_simuart.c +++ b/arch/sim/src/sim/up_simuart.c @@ -31,6 +31,8 @@ #include #include +#include "up_internal.h" + /**************************************************************************** * Private Data ****************************************************************************/ @@ -154,7 +156,7 @@ int simuart_getc(int fd) * Name: simuart_getcflag ****************************************************************************/ -int simuart_getcflag(int fd, tcflag_t *cflag) +int simuart_getcflag(int fd, unsigned int *cflag) { struct termios t; int ret; @@ -176,7 +178,7 @@ int simuart_getcflag(int fd, tcflag_t *cflag) * Name: simuart_setcflag ****************************************************************************/ -int simuart_setcflag(int fd, tcflag_t cflag) +int simuart_setcflag(int fd, unsigned int cflag) { struct termios t; int ret; diff --git a/arch/sim/src/sim/up_tapdev.c b/arch/sim/src/sim/up_tapdev.c index 36fa520de2..7f67aaddb8 100644 --- a/arch/sim/src/sim/up_tapdev.c +++ b/arch/sim/src/sim/up_tapdev.c @@ -56,11 +56,7 @@ #include #include #include - -#ifdef CONFIG_SIM_NET_HOST_ROUTE -# include -#endif - +#include #include #include #include diff --git a/arch/sim/src/sim/up_testset.c b/arch/sim/src/sim/up_testset.c index c6bdd50500..18140990d7 100644 --- a/arch/sim/src/sim/up_testset.c +++ b/arch/sim/src/sim/up_testset.c @@ -23,10 +23,9 @@ ****************************************************************************/ #include +#include -#ifdef CONFIG_SMP -# include -#endif +#include "up_internal.h" /**************************************************************************** * Public Functions diff --git a/arch/sim/src/sim/up_wpcap.c b/arch/sim/src/sim/up_wpcap.c index 2ec463c1d6..948ef34cad 100644 --- a/arch/sim/src/sim/up_wpcap.c +++ b/arch/sim/src/sim/up_wpcap.c @@ -54,6 +54,8 @@ #include #include +#include "up_internal.h" + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -174,7 +176,8 @@ static void init_pcap(struct in_addr addr) error_exit("No interface found with IP address"); } - pcap = pcap_open_live(interfaces->name, NETDEV_BUFSIZE, 0, -1, error); + pcap = pcap_open_live(interfaces->name, + CONFIG_NET_ETH_PKTSIZE, 0, -1, error); if (pcap == NULL) { error_exit(error); diff --git a/arch/sim/src/sim/up_x11framebuffer.c b/arch/sim/src/sim/up_x11framebuffer.c index f132b09ae5..9bd994eb81 100644 --- a/arch/sim/src/sim/up_x11framebuffer.c +++ b/arch/sim/src/sim/up_x11framebuffer.c @@ -29,11 +29,10 @@ #include #include #include +#include +#include -#ifndef CONFIG_SIM_X11NOSHM -# include -# include -#endif +#include "up_internal.h" /**************************************************************************** * Public Data diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index def290af59..d2d1e7cb29 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -198,6 +198,6 @@ ifeq ($(CONFIG_SIM_SANITIZE),y) endif HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \ - $(ARCHCPUFLAGS) $(HOSTINCLUDES) $(EXTRAFLAGS) -pipe + $(ARCHCPUFLAGS) $(HOSTINCLUDES) $(EXTRAFLAGS) -D__SIM__ -pipe LDLINKFLAGS += -nostartfiles -nodefaultlibs diff --git a/include/nuttx/fs/hostfs.h b/include/nuttx/fs/hostfs.h index fa9ea09a79..df22e36b5b 100644 --- a/include/nuttx/fs/hostfs.h +++ b/include/nuttx/fs/hostfs.h @@ -32,6 +32,7 @@ # include # include #else +# include # include #endif