Makefile add clang-check and clang-tidy helpers

This commit is contained in:
Daniel Agar 2017-01-02 00:56:48 -05:00 committed by Lorenz Meier
parent 28971caaf3
commit 34b2fb55e6
3 changed files with 32 additions and 30 deletions

View File

@ -296,10 +296,18 @@ test_startup_shutdown:
@$(call PX4_RUN,$(MAKE) --no-print-directory posix_sitl_test gazebo_standard_vtol HEADLESS=1 MEMORY_DEBUG=1)
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 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
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:
@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
package_firmware:
@zip --junk-paths Firmware.zip `find Binaries/. -name \*.px4`

View File

@ -746,13 +746,6 @@ function(px4_add_common_flags)
set(max_optimization -O0)
endif()
if (NOT ${CMAKE_C_COMPILER_ID} MATCHES ".*Clang.*")
list(APPEND _optimization_flags
-fno-strength-reduce
-fno-builtin-printf
)
endif()
set(c_warnings
-Wbad-function-cast
-Wstrict-prototypes
@ -760,13 +753,6 @@ function(px4_add_common_flags)
-Wnested-externs
)
if (NOT ${CMAKE_C_COMPILER_ID} MATCHES ".*Clang.*")
list(APPEND c_warnings
-Wold-style-declaration
-Wmissing-parameter-type
)
endif()
set(c_compile_flags
-g
-std=gnu99
@ -787,7 +773,18 @@ function(px4_add_common_flags)
-D__CUSTOM_FILE_IO__
)
if (NOT (${CMAKE_C_COMPILER_ID} MATCHES ".*Clang.*"))
# clang
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# force color for clang (needed for clang + ccache)
list(APPEND _optimization_flags
-fcolor-diagnostics
)
else()
list(APPEND _optimization_flags
-fno-strength-reduce
-fno-builtin-printf
)
# -fcheck-new is a no-op for Clang in general
# and has no effect, but can generate a compile
# error for some OS
@ -821,21 +818,18 @@ function(px4_add_common_flags)
)
set(added_include_dirs
${PX4_SOURCE_DIR}/src
${PX4_BINARY_DIR}
${PX4_BINARY_DIR}/src
${PX4_SOURCE_DIR}/src/modules
${PX4_BINARY_DIR}/src/modules
${PX4_BINARY_DIR}/src/modules/px4_messages
${PX4_SOURCE_DIR}/mavlink/include/mavlink
${PX4_SOURCE_DIR}/src
${PX4_SOURCE_DIR}/src/drivers/boards/${BOARD}
${PX4_SOURCE_DIR}/src/include
${PX4_SOURCE_DIR}/src/lib
${PX4_SOURCE_DIR}/src/platforms
# TODO Build/versioning was in Makefile,
# do we need this, how does it work with cmake
${PX4_SOURCE_DIR}/src/drivers/boards/${BOARD}
${PX4_BINARY_DIR}
${PX4_BINARY_DIR}/src/modules/px4_messages
${PX4_BINARY_DIR}/src/modules
${PX4_SOURCE_DIR}/mavlink/include/mavlink
${PX4_SOURCE_DIR}/src/lib/DriverFramework/framework/include
${PX4_SOURCE_DIR}/src/modules
${PX4_SOURCE_DIR}/src/platforms
)
list(APPEND added_include_dirs

View File

@ -393,7 +393,7 @@ int sdlog2_main(int argc, char *argv[])
return 0;
}
if (!strcmp(argv[1], "on")) {
if (!strncmp(argv[1], "on", 2)) {
struct vehicle_command_s cmd;
cmd.command = VEHICLE_CMD_PREFLIGHT_STORAGE;
cmd.param1 = -1;