From 437825418297c1ff43681acc6cf870e2f51d1dcb Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Fri, 23 Oct 2020 14:48:45 +0200 Subject: [PATCH] Fix NuttX build under Cygwin after NuttX 9.1.0+ upgrade #15139 --- platforms/nuttx/NuttX/Make.defs.in | 39 +++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/platforms/nuttx/NuttX/Make.defs.in b/platforms/nuttx/NuttX/Make.defs.in index 57f7cc277b..5299325b46 100644 --- a/platforms/nuttx/NuttX/Make.defs.in +++ b/platforms/nuttx/NuttX/Make.defs.in @@ -33,19 +33,45 @@ # ############################################################################ +# Set flags for the NuttX build system for Cygwin +# They are already used by Config.mk +ifneq (, $(findstring CYGWIN, $(shell uname))) + CONFIG_HOST_CYGWIN := y + CONFIG_WINDOWS_CYGWIN := y + CONFIG_CYGWIN_WINTOOL := y +endif + include $(TOPDIR)/.config include $(TOPDIR)/tools/Config.mk +# Replace each space separated word in the string that contains "cygdrive" +# with the windows path and escaped backslashes +# e.g. [hello -I /cygdrive/c -I/cygdrive/c] -> [hello -I C:\\ ] +define cygwin_to_windows_paths +$(subst \,\\,$(foreach word,$(1),$(shell \ +if [[ "$(word)" == *"cygdrive"* ]]; then \ + cygpath -w "$(word)"; \ +else \ + echo $(word); \ +fi \ +))) +endef + CINCPATH := $(shell $(INCDIR) -s "$(CC)" $(TOPDIR)$(DELIM)include) CXXINCPATH := $(shell $(INCDIR) -s "$(CC)" $(TOPDIR)$(DELIM)include$(DELIM)cxx) ARCHINCLUDES += $(CINCPATH) ARCHXXINCLUDES += $(CINCPATH) $(CXXINCPATH) +ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld -ifeq ($(CONFIG_CYGWIN_WINTOOL),y) - ARCHSCRIPT = -T "$(shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld)" -else - ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld +ifeq ($(CONFIG_BOARD_USE_PROBES),y) + ARCHINCLUDES += -I $(TOPDIR)/arch/$(CONFIG_ARCH)/src/$(CONFIG_ARCH_CHIP) -I $(TOPDIR)/arch/$(CONFIG_ARCH)/src/common + ARCHXXINCLUDES += -I $(TOPDIR)/arch/$(CONFIG_ARCH)/src/$(CONFIG_ARCH_CHIP) -I $(TOPDIR)/arch/$(CONFIG_ARCH)/src/common +endif + +ifneq (, $(findstring CYGWIN, $(shell uname))) + ARCHINCLUDES := $(call cygwin_to_windows_paths,$(ARCHINCLUDES)) + ARCHXXINCLUDES := $(call cygwin_to_windows_paths,$(ARCHXXINCLUDES)) endif CC = ${CMAKE_C_COMPILER} @@ -61,11 +87,6 @@ OBJDUMP = ${CMAKE_OBJDUMP} ARCHCCVERSION = $(shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q') ARCHCCMAJOR = $(shell echo $(ARCHCCVERSION) | cut -d'.' -f1) -ifeq ($(CONFIG_BOARD_USE_PROBES),y) - ARCHINCLUDES += -I$(TOPDIR)/arch/$(CONFIG_ARCH)/src/$(CONFIG_ARCH_CHIP) -I$(TOPDIR)/arch/$(CONFIG_ARCH)/src/common - ARCHXXINCLUDES += -I$(TOPDIR)/arch/$(CONFIG_ARCH)/src/$(CONFIG_ARCH_CHIP) -I$(TOPDIR)/arch/$(CONFIG_ARCH)/src/common -endif - ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION = $(CONFIG_DEBUG_OPTLEVEL) else