diff --git a/mk/board_qflight.mk b/mk/board_qflight.mk index 0dcb1640ac..965efbdbdc 100644 --- a/mk/board_qflight.mk +++ b/mk/board_qflight.mk @@ -64,7 +64,7 @@ LIBSKETCH_SKEL_SO = $(BUILDROOT)/libqflight_skel.so .SUFFIXES: .o .c .cpp .so .do # build DSP object from C file -$(BUILDROOT)/libraries/%.do: $(SKETCHBOOK)/libraries/%.c +$(BUILDROOT)/libraries/%.do: $(SKETCHBOOK)/libraries/%.c MAV_GEN $(RULEHDR) $(v)$(QURT_CC) $(DSP_FLAGS) -c -o $@ $< diff --git a/mk/build_rules.mk b/mk/build_rules.mk index 4280081e69..6565e75931 100644 --- a/mk/build_rules.mk +++ b/mk/build_rules.mk @@ -3,11 +3,11 @@ # Build sketch objects # -$(BUILDROOT)/%.o: $(BUILDROOT)/%.cpp $(GENERATE_TARGETS) +$(BUILDROOT)/%.o: $(BUILDROOT)/%.cpp $(GENERATE_TARGETS) MAV_GEN $(RULEHDR) $(v)$(CXX) $(CXXFLAGS) -c -o $@ $< $(SKETCH_INCLUDES) -$(BUILDROOT)/%.o: $(BUILDROOT)/make.flags $(SRCROOT)/%.cpp $(GENERATE_TARGETS) +$(BUILDROOT)/%.o: $(BUILDROOT)/make.flags $(SRCROOT)/%.cpp $(GENERATE_TARGETS) MAV_GEN $(RULEHDR) $(v)$(CXX) $(CXXFLAGS) -c -o $@ $*.cpp $(SKETCH_INCLUDES) @@ -23,7 +23,7 @@ $(BUILDROOT)/%.o: $(SRCROOT)/%.S # Build library objects from sources in the sketchbook # -$(BUILDROOT)/libraries/%.o: $(SKETCHBOOK)/libraries/%.cpp $(GENERATE_TARGETS) +$(BUILDROOT)/libraries/%.o: $(SKETCHBOOK)/libraries/%.cpp $(GENERATE_TARGETS) MAV_GEN $(RULEHDR) $(v)$(CXX) $(CXXFLAGS) -c -o $@ $< $(SLIB_INCLUDES) diff --git a/mk/check_modules.sh b/mk/check_modules.sh index 0c070f20cc..5edad928fc 100755 --- a/mk/check_modules.sh +++ b/mk/check_modules.sh @@ -2,7 +2,7 @@ echo "Checking modules" -MODULE_LIST="PX4Firmware PX4NuttX uavcan" +MODULE_LIST="PX4Firmware PX4NuttX uavcan mavlink" NEED_INIT=0 @@ -10,12 +10,12 @@ cd $(dirname "$0")/.. || exit 1 for m in $MODULE_LIST; do [ -d modules/$m ] || { - echo "module/$m missing - need module init" + echo "modules/$m missing - need module init" NEED_INIT=1 break } [ -f modules/$m/.git ] || { - echo "module/$m/.git missing - need module init" + echo "modules/$m/.git missing - need module init" NEED_INIT=1 break } diff --git a/mk/mavgen.mk b/mk/mavgen.mk new file mode 100644 index 0000000000..dd01f39230 --- /dev/null +++ b/mk/mavgen.mk @@ -0,0 +1,15 @@ + +# mavlink header generation +MAVLINK_DIR := $(SKETCHBOOK)/modules/mavlink/ +MESSAGE_DEFINITIONS := $(SKETCHBOOK)/modules/mavlink/message_definitions/v1.0 +MAVLINK_HEADERS := $(BUILDROOT)/libraries/GCS_MAVLink/include/mavlink/v1.0/ + +.PHONY: MAV_GEN + +MAV_GEN: $(MAVLINK_HEADERS) CHECK_MODULES + +$(MAVLINK_HEADERS): $(MESSAGE_DEFINITIONS)/ardupilotmega.xml $(MESSAGE_DEFINITIONS)/common.xml + echo "Generating MAVLink headers..." + #goto mavlink module directory and run the most recent generator script + echo "Generating C code using mavgen.py located at" $(SKETCHBOOK)/modules/mavlink/ + PYTHONPATH=$(MAVLINK_DIR) python $(MAVLINK_DIR)/pymavlink/tools/mavgen.py --lang=C --wire-protocol=1.0 --output=$@ $(MAVLINK_DIR)/message_definitions/v1.0/ardupilotmega.xml \ No newline at end of file diff --git a/mk/modules.mk b/mk/modules.mk index 6d653aff43..29d26d8fd5 100644 --- a/mk/modules.mk +++ b/mk/modules.mk @@ -2,9 +2,7 @@ # git submodule support .PHONY: CHECK_MODULES - -# PX4 build needs submodules -px4-%: CHECK_MODULES +all: CHECK_MODULES CHECK_MODULES: $(v)$(MK_DIR)/check_modules.sh diff --git a/mk/px4_targets.mk b/mk/px4_targets.mk index ae2b3802db..92b0c59c4f 100644 --- a/mk/px4_targets.mk +++ b/mk/px4_targets.mk @@ -81,7 +81,7 @@ module_mk: $(v) cmp $(SKETCHBOOK)/module.mk $(SKETCHBOOK)/module.mk.new 2>/dev/null || mv $(SKETCHBOOK)/module.mk.new $(SKETCHBOOK)/module.mk $(v) rm -f $(SKETCHBOOK)/module.mk.new -px4-v1: $(BUILDROOT)/make.flags CHECK_MODULES $(PX4_ROOT)/Archives/px4fmu-v1.export $(SKETCHCPP) module_mk px4-io-v1 +px4-v1: $(BUILDROOT)/make.flags CHECK_MODULES MAV_GEN $(PX4_ROOT)/Archives/px4fmu-v1.export $(SKETCHCPP) module_mk px4-io-v1 $(RULEHDR) $(v) rm -f $(PX4_ROOT)/makefiles/$(PX4_V1_CONFIG_FILE) $(v) cp $(PX4_V1_CONFIG_FILE) $(PX4_ROOT)/makefiles/nuttx/ @@ -92,7 +92,7 @@ px4-v1: $(BUILDROOT)/make.flags CHECK_MODULES $(PX4_ROOT)/Archives/px4fmu-v1.exp $(v) $(SKETCHBOOK)/Tools/scripts/add_git_hashes.py $(HASHADDER_FLAGS) "$(SKETCH)-v1.px4" "$(SKETCH)-v1.px4" $(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v1.px4" -px4-v2: $(BUILDROOT)/make.flags CHECK_MODULES $(PX4_ROOT)/Archives/px4fmu-v2.export $(SKETCHCPP) module_mk px4-io-v2 +px4-v2: $(BUILDROOT)/make.flags CHECK_MODULES MAV_GEN $(PX4_ROOT)/Archives/px4fmu-v2.export $(SKETCHCPP) module_mk px4-io-v2 $(RULEHDR) $(v) rm -f $(PX4_ROOT)/makefiles/$(PX4_V2_CONFIG_FILE) $(v) cp $(PX4_V2_CONFIG_FILE) $(PX4_ROOT)/makefiles/nuttx/ @@ -103,7 +103,7 @@ px4-v2: $(BUILDROOT)/make.flags CHECK_MODULES $(PX4_ROOT)/Archives/px4fmu-v2.exp $(v) $(SKETCHBOOK)/Tools/scripts/add_git_hashes.py $(HASHADDER_FLAGS) "$(SKETCH)-v2.px4" "$(SKETCH)-v2.px4" $(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v2.px4" -px4-v4: $(BUILDROOT)/make.flags CHECK_MODULES $(PX4_ROOT)/Archives/px4fmu-v4.export $(SKETCHCPP) module_mk +px4-v4: $(BUILDROOT)/make.flags CHECK_MODULES MAV_GEN $(PX4_ROOT)/Archives/px4fmu-v4.export $(SKETCHCPP) module_mk $(RULEHDR) $(v) rm -f $(PX4_ROOT)/makefiles/$(PX4_V4_CONFIG_FILE) $(v) cp $(PX4_V4_CONFIG_FILE) $(PX4_ROOT)/makefiles/nuttx/ diff --git a/mk/sketch_sources.mk b/mk/sketch_sources.mk index 7882cc69ca..07d64f9ea4 100644 --- a/mk/sketch_sources.mk +++ b/mk/sketch_sources.mk @@ -78,7 +78,7 @@ SKETCHLIBNAMES := $(notdir $(SKETCHLIBS)) SKETCHLIBSRCDIRS := $(SKETCHLIBS) $(addsuffix /utility,$(SKETCHLIBS)) SKETCHLIBSRCS := $(wildcard $(foreach suffix,$(SRCSUFFIXES),$(addsuffix /$(suffix),$(SKETCHLIBSRCDIRS)))) SKETCHLIBOBJS := $(addsuffix .o,$(basename $(subst $(SKETCHBOOK),$(BUILDROOT),$(SKETCHLIBSRCS)))) -SKETCHLIBINCLUDES := -I$(SKETCHBOOK)/libraries/ +SKETCHLIBINCLUDES := -I$(SKETCHBOOK)/libraries/ -I$(BUILDROOT)/libraries/ -I$(BUILDROOT)/libraries/GCS_MAVLink/ SKETCHLIBSRCSRELATIVE := $(subst $(SKETCHBOOK)/,,$(SKETCHLIBSRCS)) ifeq ($(VERBOSE),) diff --git a/mk/targets.mk b/mk/targets.mk index 8ebc369dd4..b6b97b650f 100644 --- a/mk/targets.mk +++ b/mk/targets.mk @@ -140,3 +140,4 @@ clean: @rm -fr $(BUILDROOT) include $(MK_DIR)/modules.mk +include $(MK_DIR)/mavgen.mk