Add makefile magic to simplify maintenance.

This commit is contained in:
James Goppert 2015-09-10 21:15:55 -04:00
parent 2238c09b74
commit 2c33f4921c
3 changed files with 84 additions and 54 deletions

View File

@ -240,7 +240,7 @@ foreach(module ${config_modules})
add_subdirectory(src/${module})
px4_mangle_name(${module} mangled_name)
list(APPEND module_libraries ${mangled_name})
message(STATUS "adding module: ${module}")
#message(STATUS "adding module: ${module}")
endforeach()
add_subdirectory(src/firmware/${OS})

134
Makefile
View File

@ -1,64 +1,94 @@
d=$(PWD)
all: nuttx_px4fmu-v2_default
#----------------------------------------------------------------------------
# OS: nuttx BOARD: px4fmu-v2 LABEL: simple
############################################################################
#
nuttx_px4fmu-v2_simple:
mkdir -p $d/build_$@ && cd $d/build_$@ && \
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/Toolchain-arm-none-eabi.cmake \
-DOS=nuttx -DBOARD=px4fmu-v2 -DLABEL=simple && \
make -s && ctest -V && cpack -G ZIP
nuttx_px4fmu-v2_simple_upload: nuttx_px4fmu-v2_simple
make -C build_$< upload
nuttx_px4fmu-v2_simple_test: nuttx_px4fmu-v2_simple
make -C build_$< test
#----------------------------------------------------------------------------
# OS: nuttx BOARD: px4fmu-v2 LABEL: default
# Copyright (c) 2015 PX4 Development Team. All rights reserved.
#
nuttx_px4fmu-v2_default:
mkdir -p $d/build_$@ && cd $d/build_$@ && \
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/Toolchain-arm-none-eabi.cmake \
-DOS=nuttx -DBOARD=px4fmu-v2 -DLABEL=default && \
make -s && ctest -V && cpack -G ZIP
nuttx_px4fmu-v2_default_upload: nuttx_px4fmu-v2_default
make -C build_$< upload
nuttx_px4fmu-v2_default_test: nuttx_px4fmu-v2_default
make -C build_$< test
#----------------------------------------------------------------------------
# OS: nuttx BOARD: sim LABEL: simple
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
# Help
# --------------------------------------------------------------------
# Don't be afraid of this makefile, it is just passing
# arguments to cmake to allow us to keep the wiki pages etc.
# that describe how to build the px4 firmware
# the same even when using cmake instead of make.
#
# Example usage:
#
# make px4fmu-v2_default (builds)
# make px4fmu-v2_default upload (builds and uploads)
# make px4fmu-v2_default test (builds and tests)
#
# This tells cmake to build the nuttx px4fmu-v2 default config in the
# directory build_nuttx_px4fmu-v2_default and then call make
# in that directory with the target upload.
# Parsing
# --------------------------------------------------------------------
# assume 1st argument passed is the main target, the
# rest are arguments to pass to the makefile generated
# by cmake in the subdirectory
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# Functions
# --------------------------------------------------------------------
# define a make function to describe how to build a cmake config
define cmake-build
mkdir -p $(PWD)/build_$@ && cd $(PWD)/build_$@ && \
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/$(1).cmake \
-DOS=$(2) -DBOARD=$(3) -DLABEL=$(4) && \
make -s $(ARGS)
endef
# ADD CONFIGS HERE
# --------------------------------------------------------------------
px4fmu-v2_default:
$(call cmake-build,Toolchain-arm-none-eabi,nuttx,px4fmu-v2,default)
px4fmu-v2_simple:
$(call cmake-build,Toolchain-arm-none-eabi,nuttx,px4fmu-v2,default)
nuttx_sim_simple:
mkdir -p $d/build_$@ && cd $d/build_$@ && \
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/Toolchain-native.cmake \
-DOS=nuttx -DBOARD=sim -DLABEL=simple && \
make -s && ctest -V && cpack -G ZIP
$(call cmake-build,Toolchain-native,nuttx,sim,default)
#----------------------------------------------------------------------------
# OS: posix BOARD: sitl LABEL: simple
#
posix_sitl_simple:
mkdir -p $d/build_$@ && cd $d/build_$@ && \
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/Toolchain-posix-clang-native.cmake \
-DOS=posix -DBOARD=sitl -DLABEL=simple && \
make -s && ctest -V && cpack -G ZIP
$(call cmake-build,Toolchain-posix-clang-native,posix,sitl,simple)
#----------------------------------------------------------------------------
# OS: qurt BOARD: hil LABEL: simple
#
qurt_eagle_travis:
mkdir -p $d/build_$@ && cd $d/build_$@ && \
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/Toolchain-hexagon.cmake \
-DOS=qurt -DBOARD=eagle -DLABEL=travis && \
make -s && ctest -V && cpack -G ZIP
$(call cmake-build,Toolchain-hexagon,qurt,eagle,travis)
# Other targets
# --------------------------------------------------------------------
# explicity set default build target
all: px4fmu-v2_default
#----------------------------------------------------------------------------
# misc targets
#
clean:
rm -rf build_*/

View File

@ -148,7 +148,7 @@ function(px4_nuttx_generate_builtin_commands)
set(builtin_apps_decl_string)
set(command_count 0)
foreach(module ${MODULE_LIST})
message("generating builtin for: ${module}")
#message("generating builtin for: ${module}")
# default
set(MAIN_DEFAULT MAIN-NOTFOUND)
set(STACK_DEFAULT 1024)