build: allow make with BOARD-VEHICLE combination

This commit is contained in:
Andrew Tridgell 2018-11-20 22:13:31 +11:00
parent 646c6f4361
commit 98267b0cd7
1 changed files with 30 additions and 4 deletions

View File

@ -1,11 +1,13 @@
ROOT = $(dir $(lastword $(MAKEFILE_LIST))) ROOT = $(dir $(lastword $(MAKEFILE_LIST)))
WAF_BINARY = $(realpath $(ROOT)/modules/waf/waf-light) WAF_BINARY = $(realpath $(ROOT)/modules/waf/waf-light)
WAF = $(WAF_BINARY) $(WAF_FLAGS) WAF = python $(WAF_BINARY) $(WAF_FLAGS)
EXPLICIT_COMMANDS = check check-all clean list_boards EXPLICIT_COMMANDS = check check-all clean list_boards
VEHICLES = copter plane rover VEHICLES = copter plane rover sub heli
BOARD_LIST := $(shell $(WAF) list_boards | head -1)
all: $(WAF_BINARY) all: $(WAF_BINARY)
@$(WAF) build @$(WAF) build
@ -29,6 +31,12 @@ $(VEHICLES): $(WAF_BINARY)
.DEFAULT: %-configure .DEFAULT: %-configure
@$(WAF) configure --board $@ build @$(WAF) configure --board $@ build
define target_template
$(1)-$(2) : $(1)-configure $(2)
endef
$(foreach board,$(BOARD_LIST),$(foreach vehicle,$(VEHICLES),$(eval $(call target_template,$(board),$(vehicle)))))
help: help:
@echo "Ardupilot Building" @echo "Ardupilot Building"
@echo "==================" @echo "=================="
@ -46,14 +54,19 @@ help:
@echo "" @echo ""
@echo "Boards" @echo "Boards"
@echo "------" @echo "------"
@echo ""
@echo "In order to trigger the build for a board/platform, the name of the board is" @echo "In order to trigger the build for a board/platform, the name of the board is"
@echo "used as the target. Example: make linux" @echo "used as the target. Example: make linux"
@echo "If no target is passed, then the build will be triggered for the last board" @echo "If no target is passed, then the build will be triggered for the last board"
@echo "used. You can suffix the board/platform with '-configure' in order to just " @echo "used. You can suffix the board/platform with '-configure' in order to just "
@echo "configure without triggering a build command." @echo "configure without triggering a build command."
@echo "" @echo ""
@echo "You can get a list of available boards using the command:"
@echo " make list_boards"
@echo ""
@echo "Vehicles" @echo "Vehicles"
@echo "--------" @echo "--------"
@echo ""
@echo "It's possible to build for a specific vehicle by defining the target as one of:" @echo "It's possible to build for a specific vehicle by defining the target as one of:"
@echo " $(VEHICLES)" @echo " $(VEHICLES)"
@echo "" @echo ""
@ -61,26 +74,39 @@ help:
@echo "board/platform, you'll need to configure the build before (e.g" @echo "board/platform, you'll need to configure the build before (e.g"
@echo "make linux-configure)" @echo "make linux-configure)"
@echo "" @echo ""
@echo "Combinations"
@echo "------------"
@echo ""
@echo "It's possible to build for a specific vehicle type and board using"
@echo " make BOARD-VEHICLE"
@echo ""
@echo "For example, to build copter for the Pixracer, use this:"
@echo " make Pixracer-copter"
@echo ""
@echo "Check" @echo "Check"
@echo "-----" @echo "-----"
@echo ""
@echo "Check targets are used for running tests. There are two targets available:" @echo "Check targets are used for running tests. There are two targets available:"
@echo " check: for running tests that are still failing or that are new or" @echo " check: for running tests that are still failing or that are new or"
@echo " have been modified" @echo " have been modified"
@echo " check-all: to run all tests" @echo " check-all: to run all tests"
@echo "" @echo ""
@echo "Waf commands" @echo "Waf commands"
@echo "------------" @echo "------------"
@echo ""
@echo "Waf commands can be explicitly called with targets prefixed by 'waf-'. Example:" @echo "Waf commands can be explicitly called with targets prefixed by 'waf-'. Example:"
@echo " make waf-clean" @echo " make waf-clean"
@echo " make waf-build" @echo " make waf-build"
@echo "" @echo ""
@echo "Common commands" @echo "Common commands"
@echo "---------------" @echo "---------------"
@echo ""
@echo "Some Waf commands can be executed without the need of prefixing the target name" @echo "Some Waf commands can be executed without the need of prefixing the target name"
@echo "with 'waf-'. They are: $(EXPLICIT_COMMANDS)" @echo "with 'waf-'. They are: $(EXPLICIT_COMMANDS)"
@echo "" @echo ""
@echo "Waf flags" @echo "Waf flags"
@echo "---------" @echo "---------"
@echo ""
@echo "The variable WAF_FLAGS can be used to set any waf command line options that" @echo "The variable WAF_FLAGS can be used to set any waf command line options that"
@echo "come to be necessary. Ex: make linux WAF_FLAGS='-c no'" @echo "come to be necessary. Ex: make linux WAF_FLAGS='-c no'"
@echo "" @echo ""