forked from Archive/PX4-Autopilot
build system fixes and improvements
- deploy px4 metadata using target - clang scan-build upload output to s3 - clang-tidy properly check headers - add cppcheck helper - force gcc color
This commit is contained in:
parent
723a6bf6ac
commit
ac4a706da0
|
@ -93,7 +93,7 @@ Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,
|
|||
google-runtime-memset,
|
||||
google-runtime-operator,
|
||||
## evaluate # google-runtime-references,
|
||||
llvm-header-guard,
|
||||
#llvm-header-guard,
|
||||
## evaluate # llvm-include-order,
|
||||
#llvm-namespace-comment,
|
||||
misc-argument-comment,
|
||||
|
@ -192,7 +192,6 @@ Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,
|
|||
readability-uniqueptr-delete-release,
|
||||
'
|
||||
WarningsAsErrors: '*'
|
||||
HeaderFilterRegex: '*.h, *.hpp, *.hh, *.hxx'
|
||||
AnalyzeTemporaryDtors: false
|
||||
CheckOptions:
|
||||
- key: cert-dcl59-cpp.HeaderFileExtensions
|
||||
|
|
|
@ -91,3 +91,5 @@ posix-configs/SITL/init/test/*_generated
|
|||
parameters.md
|
||||
airframes.md
|
||||
airframes.xml
|
||||
|
||||
cppcheck-result.xml
|
||||
|
|
16
.travis.yml
16
.travis.yml
|
@ -29,6 +29,11 @@ matrix:
|
|||
services:
|
||||
- docker
|
||||
env: BUILD_TARGET=clang-tidy
|
||||
- os: linux
|
||||
sudo: required
|
||||
services:
|
||||
- docker
|
||||
env: BUILD_TARGET=scan-build
|
||||
- os: linux
|
||||
sudo: required
|
||||
services:
|
||||
|
@ -62,18 +67,25 @@ script:
|
|||
elif [[ "${BUILD_TARGET}" = "px4_metadata" ]]; then
|
||||
./Tools/docker_run.sh 'make px4_metadata';
|
||||
elif [[ "${BUILD_TARGET}" = "clang-tidy" ]]; then
|
||||
./Tools/docker_run.sh 'make clang-tidy-parallel';
|
||||
./Tools/docker_run.sh 'make clang-tidy-quiet';
|
||||
elif [[ "${BUILD_TARGET}" = "scan-build" ]]; then
|
||||
./Tools/docker_run.sh 'make scan-build';
|
||||
fi
|
||||
|
||||
after_success:
|
||||
# s3 deploy individual firmware files (.px4), Firmware.zip, airframe.xml, and param.xml
|
||||
# s3 deploy individual firmware files (.px4), Firmware.zip
|
||||
- if [[ "${BUILD_TARGET}" = "qgc_firmware" && "${TRAVIS_PULL_REQUEST}" == "false" && "${TRAVIS_BRANCH}" != "coverity" ]]; then
|
||||
./Tools/docker_run.sh 'make s3put_firmware AWS_S3_BUCKET="px4-travis/archives/Firmware/${TRAVIS_BRANCH}/${TRAVIS_BUILD_ID}"'
|
||||
&& ./Tools/docker_run.sh 'make s3put_qgc_firmware AWS_S3_BUCKET="px4-travis/Firmware/${TRAVIS_BRANCH}"';
|
||||
fi
|
||||
# s3 deploy airframe and parameter metadata
|
||||
- if [[ "${BUILD_TARGET}" = "px4_metadata" && "${TRAVIS_PULL_REQUEST}" == "false" && "${TRAVIS_BRANCH}" != "coverity" ]]; then
|
||||
./Tools/docker_run.sh 'make s3put_metadata AWS_S3_BUCKET="px4-travis/Firmware/${TRAVIS_BRANCH}"';
|
||||
fi
|
||||
# s3 upload clang scan-build output for master branch
|
||||
- if [[ "${BUILD_TARGET}" = "scan-build" && "${TRAVIS_PULL_REQUEST}" == "false" && "${TRAVIS_BRANCH}" == "master" ]]; then
|
||||
PX4_DOCKER_REPO=px4io/px4-dev-clang:2017-04-22 ./Tools/docker_run.sh 'make s3put_scan-build AWS_S3_BUCKET="px4-travis/scan-build"';
|
||||
fi
|
||||
|
||||
deploy:
|
||||
# on tags deploy Firmware.zip to Github releases
|
||||
|
|
52
Makefile
52
Makefile
|
@ -258,7 +258,7 @@ px4_metadata: parameters_metadata airframe_metadata
|
|||
# AWS_ACCESS_KEY_ID
|
||||
# AWS_SECRET_ACCESS_KEY
|
||||
# AWS_S3_BUCKET
|
||||
.PHONY: s3put_firmware s3put_qgc_firmware
|
||||
.PHONY: s3put_firmware s3put_qgc_firmware s3put_px4_metadata s3put_scan-build
|
||||
|
||||
Firmware.zip:
|
||||
@rm -rf Firmware.zip
|
||||
|
@ -270,12 +270,15 @@ s3put_firmware: Firmware.zip
|
|||
s3put_qgc_firmware: qgc_firmware
|
||||
@find $(SRC_DIR)/build_* -name "*.px4" -exec $(SRC_DIR)/Tools/s3put.sh "{}" \;
|
||||
|
||||
s3put_metadata: px4_metadata
|
||||
s3put_px4_metadata: px4_metadata
|
||||
@$(SRC_DIR)/Tools/s3put.sh airframes.md
|
||||
@$(SRC_DIR)/Tools/s3put.sh airframes.xml
|
||||
@$(SRC_DIR)/Tools/s3put.sh build_posix_sitl_default/parameters.xml
|
||||
@$(SRC_DIR)/Tools/s3put.sh parameters.md
|
||||
|
||||
s3put_scan-build: scan-build
|
||||
$(SRC_DIR)/Tools/s3put.sh `find build_scan-build -mindepth 1 -maxdepth 1 -type d`/
|
||||
|
||||
# Astyle
|
||||
# --------------------------------------------------------------------
|
||||
.PHONY: check_format format
|
||||
|
@ -312,34 +315,37 @@ tests_coverage:
|
|||
@genhtml --legend --show-details --function-coverage --quiet --output-directory coverage-html coverage.info
|
||||
@$(MAKE) --no-print-directory posix_sitl_default test_results_junit
|
||||
|
||||
# Clang analyzers
|
||||
# static analyzers (scan-build, clang-tidy, cppcheck)
|
||||
# --------------------------------------------------------------------
|
||||
.PHONY: scan-build clang-check clang-tidy
|
||||
.PHONY: posix_sitl_default-clang scan-build clang-tidy clang-tidy-fix clang-tidy-quiet cppcheck
|
||||
|
||||
posix_sitl_default-clang:
|
||||
@mkdir -p $(SRC_DIR)/build_posix_sitl_default-clang
|
||||
@cd $(SRC_DIR)/build_posix_sitl_default-clang && cmake .. -GNinja -DCONFIG=posix_sitl_default -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
|
||||
@cd $(SRC_DIR)/build_posix_sitl_default-clang && ninja
|
||||
|
||||
scan-build:
|
||||
@export CCACHE_DISABLE=1
|
||||
@mkdir -p $(SRC_DIR)/build_posix_sitl_default_scan-build
|
||||
@cd $(SRC_DIR)/build_posix_sitl_default_scan-build && scan-build cmake .. -GNinja -DCONFIG=posix_sitl_default
|
||||
@scan-build cmake --build $(SRC_DIR)/build_posix_sitl_default_scan-build
|
||||
@export CCC_CC=clang
|
||||
@export CCC_CXX=clang++
|
||||
@mkdir -p $(SRC_DIR)/build_posix_sitl_default-scan-build
|
||||
@cd $(SRC_DIR)/build_posix_sitl_default-scan-build && scan-build cmake .. -GNinja -DCONFIG=posix_sitl_default
|
||||
@scan-build -o $(SRC_DIR)/build_scan-build cmake --build $(SRC_DIR)/build_posix_sitl_default-scan-build
|
||||
|
||||
clang-check:
|
||||
@CC=clang CXX=clang++ $(MAKE) --no-print-directory posix_sitl_default
|
||||
@$(SRC_DIR)/Tools/clang-tool.sh -b build_posix_sitl_default -t clang-check
|
||||
clang-tidy: posix_sitl_default-clang
|
||||
@cd build_posix_sitl_default-clang && run-clang-tidy-4.0.py -header-filter=".*\.hpp" -j$(j) -p .
|
||||
|
||||
clang-tidy:
|
||||
rm -rf $(SRC_DIR)/build_posix_sitl_default
|
||||
@CC=clang CXX=clang++ $(MAKE) --no-print-directory posix_sitl_default
|
||||
@$(SRC_DIR)/Tools/clang-tool.sh -b build_posix_sitl_default -t clang-tidy
|
||||
# to automatically fix a single check at a time, eg modernize-redundant-void-arg
|
||||
# % run-clang-tidy-4.0.py -fix -j4 -checks=-\*,modernize-redundant-void-arg -p .
|
||||
clang-tidy-fix: posix_sitl_default-clang
|
||||
@cd build_posix_sitl_default-clang && run-clang-tidy-4.0.py -header-filter=".*\.hpp" -j$(j) -fix -p .
|
||||
|
||||
clang-tidy-parallel:
|
||||
rm -rf $(SRC_DIR)/build_posix_sitl_default
|
||||
@CC=clang CXX=clang++ $(MAKE) --no-print-directory posix_sitl_default
|
||||
@$(SRC_DIR)/Tools/run-clang-tidy.py -j$(j) -p $(SRC_DIR)/build_posix_sitl_default
|
||||
# modified version of run-clang-tidy.py to return error codes and only output relevant results
|
||||
clang-tidy-quiet: posix_sitl_default-clang
|
||||
@cd build_posix_sitl_default-clang && $(SRC_DIR)/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j) -p .
|
||||
|
||||
clang-tidy-fix:
|
||||
rm -rf $(SRC_DIR)/build_posix_sitl_default
|
||||
@CC=clang CXX=clang++ $(MAKE) --no-print-directory posix_sitl_default
|
||||
@run-clang-tidy.py -fix -j$(j) -p $(SRC_DIR)/build_posix_sitl_default
|
||||
cppcheck: posix_sitl_default-clang
|
||||
@cppcheck --enable=all --project=build_posix_sitl_default-clang/compile_commands.json --xml-version=2 2> cppcheck-result.xml
|
||||
@cppcheck-htmlreport --file=cppcheck-result.xml --report-dir=build_cppcheck-htmlreport --source-dir=$(SRC_DIR)/src/
|
||||
|
||||
# Cleanup
|
||||
# --------------------------------------------------------------------
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
while getopts "b:t:" opt; do
|
||||
case "${opt}" in
|
||||
b)
|
||||
builddir=$OPTARG
|
||||
;;
|
||||
t)
|
||||
tool=$OPTARG
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "builddir = ${builddir}, tool = ${tool}"
|
||||
|
||||
case "${builddir}" in
|
||||
"build_posix_rpi_cross")
|
||||
CXX_INC=$(cd ${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/include/c++/*; pwd)
|
||||
EXTRA_ARG1=-I${CXX_INC}
|
||||
EXTRA_ARG2=-I${CXX_INC}/arm-linux-gnueabihf
|
||||
EXTRA_ARG3=-I${CXX_INC}/backward
|
||||
extra_args="--extra-arg=-I${CXX_INC} --extra-arg=-I${CXX_INC}/arm-linux-gnueabihf --extra-arg=-I${CXX_INC}/backward"
|
||||
;;
|
||||
"build_posix_sitl_default")
|
||||
;;
|
||||
*)
|
||||
echo "unknown build dir: ${builddir}"
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPILE_DB=$(/bin/pwd)/${builddir}
|
||||
if [[ ! -f ${COMPILE_DB}/compile_commands.json ]]; then
|
||||
echo "compile_commands.json not found in ${COMPILE_DB}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "${tool}" in
|
||||
"clang-check")
|
||||
command=clang-check;
|
||||
option=-analyze;
|
||||
;;
|
||||
"clang-tidy")
|
||||
command=clang-tidy
|
||||
#option=-fix
|
||||
;;
|
||||
esac
|
||||
|
||||
failed=0
|
||||
while read line; do
|
||||
file_line=$(echo $line | grep \"file\")
|
||||
if [ $? -eq 0 ]; then
|
||||
file_path=$(echo $file_line | awk '{ print $2; }' | sed 's/\"//g')
|
||||
|
||||
echo ${file_path}
|
||||
${command} ${option} -p ${COMPILE_DB} ${extra_args} ${file_path}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
failed=1
|
||||
fi
|
||||
echo
|
||||
fi
|
||||
done <${COMPILE_DB}/compile_commands.json
|
||||
|
||||
if [ $failed -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
|
@ -11,9 +11,9 @@ filename=${1}
|
|||
[ -z "$AWS_SECRET_ACCESS_KEY" ] && { echo "ERROR: Need to set AWS_SECRET_ACCESS_KEY"; exit 1; }
|
||||
[ -z "$AWS_S3_BUCKET" ] && { echo "ERROR: Need to set AWS_S3_BUCKET"; exit 1; }
|
||||
|
||||
if [ -f ${filename} ]; then
|
||||
if [ -e ${filename} ]; then
|
||||
base_file_name=`basename $filename`
|
||||
s3cmd --access_key=${AWS_ACCESS_KEY_ID} --secret_key=${AWS_SECRET_ACCESS_KEY} put ${filename} s3://${AWS_S3_BUCKET}/${base_file_name}
|
||||
s3cmd --access_key=${AWS_ACCESS_KEY_ID} --secret_key=${AWS_SECRET_ACCESS_KEY} put -r ${filename} s3://${AWS_S3_BUCKET}/${base_file_name}
|
||||
else
|
||||
echo "ERROR: ${file} doesn't exist"
|
||||
exit 1
|
||||
|
|
|
@ -846,6 +846,15 @@ function(px4_add_common_flags)
|
|||
)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
|
||||
# force color for gcc > 4.9
|
||||
list(APPEND _optimization_flags
|
||||
-fdiagnostics-color=always
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(visibility_flags
|
||||
-fvisibility=hidden
|
||||
-include visibility.h
|
||||
|
|
Loading…
Reference in New Issue