-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ament_pclint and ament_cmake_pclint packages
- Loading branch information
Juan Pablo Samper
committed
May 1, 2018
1 parent
5678703
commit 5e5e6b1
Showing
31 changed files
with
7,837 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(ament_cmake_pclint NONE) | ||
|
||
find_package(ament_cmake_core REQUIRED) | ||
find_package(ament_cmake_test REQUIRED) | ||
|
||
ament_package( | ||
CONFIG_EXTRAS "ament_cmake_pclint-extras.cmake" | ||
) | ||
|
||
install( | ||
DIRECTORY cmake | ||
DESTINATION share/${PROJECT_NAME} | ||
) | ||
|
||
if(BUILD_TESTING) | ||
find_package(ament_cmake_copyright REQUIRED) | ||
ament_copyright() | ||
|
||
find_package(ament_cmake_lint_cmake REQUIRED) | ||
ament_lint_cmake() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2017 Apex.AI, Inc. | ||
# | ||
# | ||
# This file contains modified code from the following open source projects | ||
# published under the licenses listed below: | ||
# | ||
# | ||
# # Copyright 2014-2015 Open Source Robotics Foundation, Inc. | ||
# # | ||
# # Licensed under the Apache License, Version 2.0 (the "License"); | ||
# # you may not use this file except in compliance with the License. | ||
# # You may obtain a copy of the License at | ||
# # | ||
# # http://www.apache.org/licenses/LICENSE-2.0 | ||
# # | ||
# # Unless required by applicable law or agreed to in writing, software | ||
# # distributed under the License is distributed on an "AS IS" BASIS, | ||
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# # See the License for the specific language governing permissions and | ||
# # limitations under the License. | ||
|
||
find_package(ament_cmake_test QUIET REQUIRED) | ||
|
||
include("${ament_cmake_pclint_DIR}/ament_pclint.cmake") | ||
|
||
ament_register_extension("ament_lint_auto" "ament_cmake_pclint" | ||
"ament_cmake_pclint_lint_hook.cmake") |
32 changes: 32 additions & 0 deletions
32
ament_cmake_pclint/cmake/ament_cmake_pclint_lint_hook.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2017 Apex.AI, Inc. | ||
# | ||
# | ||
# This file contains modified code from the following open source projects | ||
# published under the licenses listed below: | ||
# | ||
# | ||
# # Copyright 2015 Open Source Robotics Foundation, Inc. | ||
# # | ||
# # Licensed under the Apache License, Version 2.0 (the "License"); | ||
# # you may not use this file except in compliance with the License. | ||
# # You may obtain a copy of the License at | ||
# # | ||
# # http://www.apache.org/licenses/LICENSE-2.0 | ||
# # | ||
# # Unless required by applicable law or agreed to in writing, software | ||
# # distributed under the License is distributed on an "AS IS" BASIS, | ||
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# # See the License for the specific language governing permissions and | ||
# # limitations under the License. | ||
|
||
file(GLOB_RECURSE _source_files FOLLOW_SYMLINKS | ||
"*.c" | ||
"*.cc" | ||
"*.cpp" | ||
"*.cxx" | ||
"*.c++" | ||
) | ||
if(_source_files) | ||
message(STATUS "Added test 'pclint' to perform static code analysis on C / C++ code") | ||
ament_pclint() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# Copyright 2017 Apex.AI, Inc. | ||
# | ||
# | ||
# This file contains modified code from the following open source projects | ||
# published under the licenses listed below: | ||
# | ||
# | ||
# # Copyright 2014-2015 Open Source Robotics Foundation, Inc. | ||
# # | ||
# # Licensed under the Apache License, Version 2.0 (the "License"); | ||
# # you may not use this file except in compliance with the License. | ||
# # You may obtain a copy of the License at | ||
# # | ||
# # http://www.apache.org/licenses/LICENSE-2.0 | ||
# # | ||
# # Unless required by applicable law or agreed to in writing, software | ||
# # distributed under the License is distributed on an "AS IS" BASIS, | ||
# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# # See the License for the specific language governing permissions and | ||
# # limitations under the License. | ||
|
||
# Add a test to perform static code analysis with pclint. | ||
# | ||
# :param TESTNAME: the name of the test, default: "pclint" | ||
# :type TESTNAME: string | ||
# :param LANGUAGE: force analysis to a specific language. Either "c" or "cpp" | ||
# :type LANGUAGE: string | ||
# :param LNT_FILE: Full-path of a custom lnt file. | ||
# :type LNT_FILE: string | ||
# :param ARGN: the files or directories to check | ||
# :type ARGN: list of strings | ||
# | ||
# @public | ||
function(ament_pclint) | ||
cmake_parse_arguments(ARG | ||
"" | ||
"LANGUAGE;TESTNAME;LNT_FILE" | ||
"INCLUDE_DIRS;COMPILE_DEFS" | ||
${ARGN}) | ||
if(NOT ARG_TESTNAME) | ||
set(ARG_TESTNAME "pclint") | ||
endif() | ||
|
||
find_program(ament_pclint_BIN NAMES "ament_pclint") | ||
if(NOT ament_pclint_BIN) | ||
message(FATAL_ERROR "ament_pclint() could not find program 'ament_pclint'") | ||
endif() | ||
|
||
set(cmd "${ament_pclint_BIN}" ${ARG_UNPARSED_ARGUMENTS}) | ||
|
||
get_property(INCLUDED_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) | ||
|
||
if(INCLUDED_DIRS) | ||
list(APPEND cmd "--include-directories" ${INCLUDED_DIRS}) | ||
set(_INCLUDE_DIRS_FLAG_SET "Found") | ||
endif() | ||
|
||
# Include 'include' folders in AMENT_PREFIX_PATH | ||
if(ARG_INCLUDE_DIRS) | ||
if(NOT _INCLUDE_DIRS_FLAG_SET) | ||
list(APPEND cmd "--include-directories") | ||
set(_INCLUDED_DIRS_FLAG_SET "Found") | ||
endif() | ||
foreach(path ${ARG_INCLUDE_DIRS}) | ||
list(APPEND cmd "${path}/include") | ||
endforeach() | ||
endif() | ||
|
||
get_directory_property(COMPILE_DEFS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) | ||
|
||
if(COMPILE_DEFS) | ||
list(APPEND cmd "--compiler-definitions" "${COMPILE_DEFS}") | ||
set(_COMPILE_DEFS_FLAG_SET "Found") | ||
endif() | ||
|
||
# Add user-specificied compiler-definitions | ||
if(ARG_COMPILE_DEFS) | ||
if(NOT _COMPILE_DEFS_FLAG_SET) | ||
list(APPEND cmd "--compiler-definitions") | ||
set(_COMPILE_DEFS_FLAG_SET "Found") | ||
endif() | ||
foreach(def ${ARG_COMPILE_DEFS}) | ||
list(APPEND cmd "${def}") | ||
endforeach() | ||
endif() | ||
|
||
if(ARG_LANGUAGE) | ||
list(APPEND cmd "--language" "${ARG_LANGUAGE}") | ||
endif() | ||
|
||
if(ARG_LNT_FILE) | ||
list(APPEND cmd "--pclint-config-file" ${ARG_LNT_FILE}) | ||
endif() | ||
|
||
set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") | ||
|
||
list(APPEND cmd "--xunit-file" "${result_file}") | ||
|
||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_pclint") | ||
ament_add_test( | ||
"${ARG_TESTNAME}" | ||
COMMAND ${cmd} | ||
OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_pclint/${ARG_TESTNAME}.txt" | ||
RESULT_FILE "${result_file}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
set_tests_properties( | ||
"${ARG_TESTNAME}" | ||
PROPERTIES | ||
LABELS "pclint;linter" | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
ament_pclint | ||
============== | ||
|
||
Performs a static code analysis of C / C++ source files using `PCLint | ||
<http://www.gimpel.com/html/index.htm>`_. | ||
|
||
How to run the check from the command line? | ||
------------------------------------------- | ||
|
||
The command line tool is provided by the package `ament_pclint`_. | ||
|
||
|
||
How to run the check from within a CMake ament package as part of the tests? | ||
---------------------------------------------------------------------------- | ||
|
||
``package.xml``: | ||
|
||
.. code:: xml | ||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<test_depend>ament_cmake_pclint</test_depend> | ||
``CMakeLists.txt``: | ||
|
||
.. code:: cmake | ||
find_package(ament_cmake REQUIRED) | ||
if(BUILD_TESTING) | ||
find_package(ament_cmake_pclint REQUIRED) | ||
ament_pclint() | ||
endif() | ||
When running multiple linters as part of the CMake tests the documentation of | ||
the package `ament_lint_auto <https://github.com/ament/ament_lint>`_ might | ||
contain some useful information. | ||
|
||
The documentation of the package `ament_cmake_test | ||
<https://github.com/ament/ament_cmake>`_ provides more information on testing | ||
in CMake ament packages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="2"> | ||
<name>ament_cmake_pclint</name> | ||
<version>0.4.0</version> | ||
<description> | ||
The CMake API for ament_pclint to perform static code analysis on C/C++ | ||
code using PCLint. | ||
</description> | ||
<maintainer email="jp.samper@apex.ai">Juan Pablo Samper</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake_core</buildtool_depend> | ||
<buildtool_depend>ament_cmake_test</buildtool_depend> | ||
|
||
<buildtool_export_depend>ament_cmake_test</buildtool_export_depend> | ||
<buildtool_export_depend>ament_pclint</buildtool_export_depend> | ||
|
||
<test_depend>ament_cmake_copyright</test_depend> | ||
<test_depend>ament_cmake_lint_cmake</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
Empty file.
Oops, something went wrong.