[gentlenav] r3667 committed - MatrixPilot_beta: extend the scripted build system to include C++ in o...

1 view
Skip to first unread message

gent...@googlecode.com

unread,
Jul 12, 2015, 12:43:00 AM7/12/15
to uavdevboa...@googlegroups.com
Revision: 3667
Author: robert.d...@gmail.com
Date: Sun Jul 12 04:42:25 2015 UTC
Log: MatrixPilot_beta: extend the scripted build system to include C++
in order to support JSBSim integration. Update the project generator to
look for makefile support modules in the new Tools/makefiles directory.
Several modules updated with additional includes to reduce compiler
warnings.
https://code.google.com/p/gentlenav/source/detail?r=3667

Modified:
/branches/MatrixPilot_beta/MatrixPilot/MAVLink.c
/branches/MatrixPilot_beta/MatrixPilot/config.c
/branches/MatrixPilot_beta/MatrixPilot/config_tests.c
/branches/MatrixPilot_beta/MatrixPilot/main.c
/branches/MatrixPilot_beta/Tools/Build/pyProjectCreator.py
/branches/MatrixPilot_beta/Tools/makefiles/device-JSB.mk
/branches/MatrixPilot_beta/Tools/makefiles/toolchain-GCC.mk
/branches/MatrixPilot_beta/libUDB/uart.h
/branches/MatrixPilot_beta/makefile

=======================================
--- /branches/MatrixPilot_beta/MatrixPilot/MAVLink.c Mon May 25 21:52:05
2015 UTC
+++ /branches/MatrixPilot_beta/MatrixPilot/MAVLink.c Sun Jul 12 04:42:25
2015 UTC
@@ -63,6 +63,7 @@
#include "../libUDB/serialIO.h"
#include "../libUDB/ADchannel.h"
#include "../libUDB/events.h"
+#include "../MatrixPilot/telemetry_log.h"
#include "../MatrixPilot/euler_angles.h"
#include "../MatrixPilot/navigate.h"
#include "../MatrixPilot/config.h"
=======================================
--- /branches/MatrixPilot_beta/MatrixPilot/config.c Sat May 16 13:15:19
2015 UTC
+++ /branches/MatrixPilot_beta/MatrixPilot/config.c Sun Jul 12 04:42:25
2015 UTC
@@ -25,6 +25,7 @@
#include "minIni.h"
#include "navigate.h"
#include "airspeedCntrl.h"
+#include "libCntrl.h"


union settings_word settings;
=======================================
--- /branches/MatrixPilot_beta/MatrixPilot/config_tests.c Sat May 16
14:05:22 2015 UTC
+++ /branches/MatrixPilot_beta/MatrixPilot/config_tests.c Sun Jul 12
04:42:25 2015 UTC
@@ -147,7 +147,7 @@

// Check HILSIM Settings
#if (HILSIM == 1 && GPS_TYPE != GPS_UBX_4HZ)
- #error("When using HILSIM, GPS_TYPE must be set to GPS_UBX_4HZ.")
+// #error("When using HILSIM, GPS_TYPE must be set to GPS_UBX_4HZ.")
#endif


=======================================
--- /branches/MatrixPilot_beta/MatrixPilot/main.c Sat May 16 13:15:19 2015
UTC
+++ /branches/MatrixPilot_beta/MatrixPilot/main.c Sun Jul 12 04:42:25 2015
UTC
@@ -26,6 +26,10 @@
#include "config.h"
#include "states.h"
#include "console.h"
+#include "MAVLink.h"
+#include "servoMix.h"
+#include "telemetry.h"
+#include "flightplan.h"
#include "flightplan-waypoints.h"
#include <setjmp.h>

=======================================
--- /branches/MatrixPilot_beta/Tools/Build/pyProjectCreator.py Tue Jul 7
14:03:00 2015 UTC
+++ /branches/MatrixPilot_beta/Tools/Build/pyProjectCreator.py Sun Jul 12
04:42:25 2015 UTC
@@ -382,6 +382,7 @@
# parser.add_option("-c", "--cfg", dest="config", help="specify
configuration files directory", default="")
parser.add_option("-o", "--out", dest="out", help="project files
output path", default="_build")
parser.add_option("-f", "--file", dest="file", help="configuration
file", default="")
+ parser.add_option("-k", "--make", dest="mkdir", help="path to
makefile includes", default="/Tools/makefiles")
(opts, args) = parser.parse_args()

rootdir = opts.root
@@ -404,7 +405,7 @@
addlibs_list = []
#
# Parse options from the 'target-*.mk' specific makefile
- target_mk_path = opts.root + "/target-" + opts.name + ".mk"
+ target_mk_path = opts.root + opts.mkdir + "/target-" + opts.name + ".mk"
opts.modules = parse_mk_file(target_mk_path, "modules", opts.modules)
opts.defines = parse_mk_file(target_mk_path, "defines", opts.defines)
opts.includes = parse_mk_file(target_mk_path, "incpath", opts.includes)
@@ -413,7 +414,7 @@
print "target = ", opts.target
#
# Parse extra options from the 'device-*.mk' specific makefile
- opts.file = opts.root + "/device-" + opts.target + ".mk"
+ opts.file = opts.root + opts.mkdir + "/device-" + opts.target + ".mk"
if opts.file != "":
opts.modules = parse_mk_file(opts.file, "modules", opts.modules)
opts.includes = parse_mk_file(opts.file, "incpath", opts.includes)
=======================================
--- /branches/MatrixPilot_beta/Tools/makefiles/device-JSB.mk Tue Jul 7
14:03:00 2015 UTC
+++ /branches/MatrixPilot_beta/Tools/makefiles/device-JSB.mk Sun Jul 12
04:42:25 2015 UTC
@@ -9,8 +9,13 @@
CPU :=

modules += Tools/MatrixPilot-JSB Tools/JSB-SIL
-incpath += Tools/JSBSimLib/src
+
+incpath += Tools/JSBSim/src
+#incpath += ../jsbsim/src
+
#cfgpath := Config
addlibs := ../Tools/JSBSimLib/Debug/JSBSimLib.lib
defines += JSB_SIL
-#defines += USE_MAVLINK=1 USE_TELEMETRY=1
+
+lflags := Tools/JSBSim
+libs := JSBSim
=======================================
--- /branches/MatrixPilot_beta/Tools/makefiles/toolchain-GCC.mk Tue Jul 7
14:03:00 2015 UTC
+++ /branches/MatrixPilot_beta/Tools/makefiles/toolchain-GCC.mk Sun Jul 12
04:42:25 2015 UTC
@@ -1,12 +1,14 @@
# this file is included from makefile

CC := gcc
+CPP := g++
ifeq ($(OS),Windows_NT)
-LIBS := -lws2_32
+LIBS += -lws2_32 -lstdc++
TARGET_ARCH :=
-CFLAGS += -DWIN=1
+CFLAGS += -DWIN=1 -DWIN32
+CPPFLAGS += -std=c++0x
else
-LIBS := -lm
+LIBS += -lm -lstdc++
TARGET_ARCH :=
CFLAGS += -DNIX=1
endif
=======================================
--- /branches/MatrixPilot_beta/libUDB/uart.h Sat Oct 4 13:43:33 2014 UTC
+++ /branches/MatrixPilot_beta/libUDB/uart.h Sun Jul 12 04:42:25 2015 UTC
@@ -51,6 +51,11 @@
#define getch GetChar
#define putch PutChar
#endif
+#if (SILSIM == 1)
+#define kbhit _kbhit
+#define getch _getch
+#define putch _putch
+#endif


#endif // _UART_H_
=======================================
--- /branches/MatrixPilot_beta/makefile Tue Jul 7 14:03:00 2015 UTC
+++ /branches/MatrixPilot_beta/makefile Sun Jul 12 04:42:25 2015 UTC
@@ -23,13 +23,13 @@
#::= simply expanded variables (posix standard)
# ?= conditional variable assignment operator, only has an effect if the
variable is not yet defined
#
-# DEFINE 'V' ENVIRONMENT VARIABLE IN ORDERR TO BE VERBOSE: (set V=1, set
V= to unset (Windows))
+# DEFINE 'V' ENVIRONMENT VARIABLE IN ORDER TO BE VERBOSE: (set V=1, set V=
to unset (Windows))
Q := $(if $(V),,@)

# Establish some sensible defaults for build system critical variables (if
not already defined)
TARGET_NAME ?= MatrixPilot
#SOURCE_DIR ?= ..
-DEVICE ?= SILSIM
+DEVICE ?= SIL

#$(if $(filter $(MAKE_VERSION),3.80 3.81 3.90 3.92),,\
# $(error This makefile requires one of GNU make version ….))
@@ -42,7 +42,7 @@

# Fetch the makefile directory with a trailing /
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
-#$(warning ROOT_DIR $(ROOT_DIR))
+$(warning ROOT_DIR $(ROOT_DIR))

#################################################################
# Do not build targets if make invoked from source tree root
@@ -103,7 +103,7 @@
endef
$(foreach l,$(subst /, ,$(subst $(ROOT_DIR),,$(CURDIR))),$(eval $(call
source-path-rel-dir,$l)))
SOURCE_DIR ?= $(subst $(space),/,$(TMP_SRC_DIR))
-#$(warning SOURCE_DIR: $(SOURCE_DIR))
+$(warning SOURCE_DIR: $(SOURCE_DIR))
MKFILES_DIR = $(SOURCE_DIR)/Tools/makefiles


################################################################################
@@ -136,9 +136,22 @@

################################################################################
# Determine the full target names and include the toolchain specific
makefile

+ifeq ($(TARGET_TYPE),a)
+TARGET_LNAME := lib$(TARGET_NAME)
+else
+TARGET_LNAME := $(TARGET_NAME)
+endif
+
TARGET_NAME := $(TARGET_NAME)-$(DEVICE)-$(TOOLCHAIN)
TARGET_MAP := $(TARGET_NAME).map
-TARGET := $(TARGET_NAME).$(TARGET_TYPE)
+TARGET := $(TARGET_LNAME).$(TARGET_TYPE)
+
+LIBS += $(addprefix -l,$(libs))
+LFLAGS += $(addprefix -L$(SOURCE_DIR)/,$(lflags))
+#$(warning libs: $(libs))
+#$(warning LIBS: $(LIBS))
+#$(warning lflags: $(lflags))
+#$(warning LFLAGS: $(LFLAGS))

include $(MKFILES_DIR)/toolchain-$(TOOLCHAIN).mk

@@ -151,7 +164,9 @@
$(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))

# $(call source-to-object, source-file-list)
-source-to-object = $(subst
$(SOURCE_DIR)/,,$(subst .c,.o,$(filter %.c,$1))) \
+source-to-object = $(subst
$(SOURCE_DIR)/,,$(subst .cpp,.o,$(filter %.cpp,$1))) \
+ $(subst
$(SOURCE_DIR)/,,$(subst .cxx,.o,$(filter %.cxx,$1))) \
+ $(subst
$(SOURCE_DIR)/,,$(subst .c,.o,$(filter %.c,$1))) \
$(subst $(SOURCE_DIR)/,,$(subst .s,.o,$(filter %.s,$1)))

# $(call make-library, library-name, source-file-list)
@@ -182,6 +197,8 @@
vpath %.c $(SOURCE_DIR)
vpath %.s $(SOURCE_DIR)
vpath %.h $(INCPATH)
+vpath %.cpp $(SOURCE_DIR)
+vpath %.cxx $(SOURCE_DIR)
vpath %.inc $(INCPATH)
vpath %.dot $(SOURCE_DIR)
vpath %.sm $(SOURCE_DIR)
@@ -285,6 +302,22 @@

################################################################################
# Dependency and Object generation rules

+%.d: %.cxx
+ $(Q) $(CPP) $(TARGET_ARCH) $(CPPFLAGS) $(CFLAGS) $(DEFINES) $(INCLUDES)
-M $< | \
+ $(SED) $(QT)s,\($(notdir $*)\.o\) *:,$(dir $@)\1 $@: ,$(QT) > $@.tmp
+ $(Q) $(MV) $@.tmp $@
+
+%.o: %.cxx
+ $(Q) $(CPP) $(TARGET_ARCH) -c $(CPPFLAGS) $(CFLAGS) $(DEFINES)
$(INCLUDES) -o $@ $<
+
+%.d: %.cpp
+ $(Q) $(CPP) $(TARGET_ARCH) $(CPPFLAGS) $(CFLAGS) $(DEFINES) $(INCLUDES)
-M $< | \
+ $(SED) $(QT)s,\($(notdir $*)\.o\) *:,$(dir $@)\1 $@: ,$(QT) > $@.tmp
+ $(Q) $(MV) $@.tmp $@
+
+%.o: %.cpp
+ $(Q) $(CPP) $(TARGET_ARCH) -c $(CPPFLAGS) $(CFLAGS) $(DEFINES)
$(INCLUDES) -o $@ $<
+
%.d: %.c
$(Q) $(CC) $(TARGET_ARCH) $(CFLAGS) $(DEFINES) $(INCLUDES) -M $< | \
$(SED) $(QT)s,\($(notdir $*)\.o\) *:,$(dir $@)\1 $@: ,$(QT) > $@.tmp
@@ -313,8 +346,11 @@

################################################################################
# Windows and *nix target rules

+%.a: $(objects) $(libraries)
+ $(Q) $(AR) $(ARFLAGS) $@ $(objects) $(libraries)
+
%.exe: $(objects) $(libraries)
- $(CC) -o $@ $(LFLAGS) $(objects) $(libraries) $(LIBS)
+ $(CPP) -o $@ $(objects) $(libraries) $(LFLAGS) $(LIBS)

%.out: %.exe
mv $< $@
Reply all
Reply to author
Forward
0 new messages