You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2021/07/26 22:44:42 UTC
[incubator-nuttx] 02/02: arch/sim: Copy include/nuttx/config.h to
the local folder
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 5e01fe050a750eabbcb09af9d64e98ce17e50042
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Jul 26 15:50:40 2021 +0800
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 <xi...@xiaomi.com>
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 685f699..0caf7f6 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 dbcb0c4..48663a6 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 6d777ce..9159fe2 100644
--- a/arch/sim/src/sim/up_hcisocket.c
+++ b/arch/sim/src/sim/up_hcisocket.c
@@ -40,10 +40,7 @@
#include <nuttx/net/bluetooth.h>
#include <nuttx/wireless/bluetooth/bt_driver.h>
#include <nuttx/wireless/bluetooth/bt_uart.h>
-
-#if defined(CONFIG_UART_BTH4)
- #include <nuttx/serial/uart_bth4.h>
-#endif
+#include <nuttx/serial/uart_bth4.h>
#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 e54a2f3..a0333ba 100644
--- a/arch/sim/src/sim/up_hostfs.c
+++ b/arch/sim/src/sim/up_hostfs.c
@@ -34,7 +34,6 @@
#include <fcntl.h>
#include <errno.h>
-#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 9d1fb5e..4e6e0db 100644
--- a/arch/sim/src/sim/up_hosttime.c
+++ b/arch/sim/src/sim/up_hosttime.c
@@ -30,6 +30,8 @@
#include <time.h>
#include <unistd.h>
+#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 f899b75..5921eab 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 <stdint.h>
/****************************************************************************
diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h
index 5629b15..3a73afa 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 <nuttx/config.h>
-#else
+#ifdef __SIM__
+#include "config.h"
+#endif
+
+#ifndef __ASSEMBLY__
# include <sys/types.h>
# include <stdbool.h>
# include <netinet/in.h>
@@ -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 62036af..6432262 100644
--- a/arch/sim/src/sim/up_netdriver.c
+++ b/arch/sim/src/sim/up_netdriver.c
@@ -53,10 +53,7 @@
#include <nuttx/net/net.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/arp.h>
-
-#ifdef CONFIG_NET_PKT
-# include <nuttx/net/pkt.h>
-#endif
+#include <nuttx/net/pkt.h>
#include "up_internal.h"
diff --git a/arch/sim/src/sim/up_sigdeliver.c b/arch/sim/src/sim/up_sigdeliver.c
index ac8544f..efb1554 100644
--- a/arch/sim/src/sim/up_sigdeliver.c
+++ b/arch/sim/src/sim/up_sigdeliver.c
@@ -33,6 +33,7 @@
#include <nuttx/arch.h>
#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 577fff3..5e2aa56 100644
--- a/arch/sim/src/sim/up_simuart.c
+++ b/arch/sim/src/sim/up_simuart.c
@@ -31,6 +31,8 @@
#include <poll.h>
#include <errno.h>
+#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 36fa520..7f67aad 100644
--- a/arch/sim/src/sim/up_tapdev.c
+++ b/arch/sim/src/sim/up_tapdev.c
@@ -56,11 +56,7 @@
#include <string.h>
#include <syslog.h>
#include <time.h>
-
-#ifdef CONFIG_SIM_NET_HOST_ROUTE
-# include <net/route.h>
-#endif
-
+#include <net/route.h>
#include <net/if.h>
#include <linux/sockios.h>
#include <linux/if_tun.h>
diff --git a/arch/sim/src/sim/up_testset.c b/arch/sim/src/sim/up_testset.c
index c6bdd50..1814099 100644
--- a/arch/sim/src/sim/up_testset.c
+++ b/arch/sim/src/sim/up_testset.c
@@ -23,10 +23,9 @@
****************************************************************************/
#include <stdint.h>
+#include <stdatomic.h>
-#ifdef CONFIG_SMP
-# include <stdatomic.h>
-#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 2ec463c..948ef34 100644
--- a/arch/sim/src/sim/up_wpcap.c
+++ b/arch/sim/src/sim/up_wpcap.c
@@ -54,6 +54,8 @@
#include <syslog.h>
#include <malloc.h>
+#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 f132b09..9bd994e 100644
--- a/arch/sim/src/sim/up_x11framebuffer.c
+++ b/arch/sim/src/sim/up_x11framebuffer.c
@@ -29,11 +29,10 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
-#ifndef CONFIG_SIM_X11NOSHM
-# include <sys/shm.h>
-# include <X11/extensions/XShm.h>
-#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 def290a..d2d1e7c 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 fa9ea09..df22e36 100644
--- a/include/nuttx/fs/hostfs.h
+++ b/include/nuttx/fs/hostfs.h
@@ -32,6 +32,7 @@
# include <dirent.h>
# include <time.h>
#else
+# include <config.h>
# include <stdint.h>
#endif