From 463217a5f96a737a9644bafd03bfe534ea626525 Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Sun, 21 Jan 2018 05:26:12 +0100 Subject: [PATCH] Cygwin: repair NuttX build (#8737) * Cygwin: repaired NuttX build after 1f63d85869b3495f3f66a3300b365c57469f1020 all the NuttX specific WINTOOL define handling was skiped in cmake Make.defs generation The Nuttx build is makfile based and needs its cygwin treatment Additionally the ${PX4_SOURCE_DIR}/src/include which was added through cmake needs path conversion The two root causes for the special handling are: - ARM GCC for Windows doesn't support cygwin paths passed as an argument so they need to be either relative or converted via cypath tool - Symbolic links are totally different under Windows and because NuttX uses them extensively it has special handling scripts that need to be fed with the correct defines * Cygwin: NuttX include paths all converted in Make.defs.in differentiate between WINTOOL define (MSYS & cygwin) and cygwin using uname command: - MSYS needs symbolic link handling for ARM GCC but no path conversion - Cygwin needs both --- .../toolchains/Toolchain-arm-none-eabi.cmake | 2 +- platforms/nuttx/nuttx-configs/Make.defs.in | 23 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/cmake/toolchains/Toolchain-arm-none-eabi.cmake b/cmake/toolchains/Toolchain-arm-none-eabi.cmake index 72b3abee8d..6e01bc9fb8 100644 --- a/cmake/toolchains/Toolchain-arm-none-eabi.cmake +++ b/cmake/toolchains/Toolchain-arm-none-eabi.cmake @@ -20,7 +20,7 @@ include(CMakeForceCompiler) # this one is important set(CMAKE_SYSTEM_NAME Generic) -#this one not so much +# this one not so much set(CMAKE_SYSTEM_VERSION 1) # specify the cross compiler diff --git a/platforms/nuttx/nuttx-configs/Make.defs.in b/platforms/nuttx/nuttx-configs/Make.defs.in index e5b86c8b22..c3bd7a476b 100644 --- a/platforms/nuttx/nuttx-configs/Make.defs.in +++ b/platforms/nuttx/nuttx-configs/Make.defs.in @@ -45,7 +45,26 @@ NM = ${CMAKE_NM} OBJCOPY = ${CMAKE_OBJCOPY} OBJDUMP = ${CMAKE_OBJDUMP} -CFLAGS = -Os -g2 -I${PX4_SOURCE_DIR}/src/include ${CMAKE_C_FLAGS} -I. -isystem $(TOPDIR)/include \ +# Include paths with Cygwin path conversion +ifneq (, $(findstring CYGWIN, $(shell uname))) + WINTOOL = y + PX4INCLUDES = -I"$(shell cygpath -w ${PX4_SOURCE_DIR}/src/include)" + ARCHINCLUDES = $(PX4INCLUDES) -I. -isystem "$(shell cygpath -w $(TOPDIR)/include)" + ARCHXXINCLUDES = $(ARCHINCLUDES) -isystem "$(shell cygpath -w $(TOPDIR)/include/cxx)" +else + PX4INCLUDES = -I${PX4_SOURCE_DIR}/src/include + ARCHINCLUDES = $(PX4INCLUDES) -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = $(ARCHINCLUDES) -isystem $(TOPDIR)/include/cxx +endif + +# Windows toolchain (MSYS & Cygwin) symbolic link handling +ifeq ($(WINTOOL),y) + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mknulldeps.sh +endif + +CFLAGS = -Os -g2 ${CMAKE_C_FLAGS} $(ARCHINCLUDES) \ -Wno-bad-function-cast \ -Wno-cpp \ -Wno-float-equal \ @@ -62,7 +81,7 @@ CFLAGS = -Os -g2 -I${PX4_SOURCE_DIR}/src/include ${CMAKE_C_FLAGS} -I. -isystem $ -Wno-sign-compare \ -Wno-type-limits -CXXFLAGS = -Os -g2 -I${PX4_SOURCE_DIR}/src/include ${CMAKE_CXX_FLAGS} -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx \ +CXXFLAGS = -Os -g2 ${CMAKE_CXX_FLAGS} $(ARCHXXINCLUDES) \ -fcheck-new \ -fno-builtin \ -Wno-double-promotion \