Skip to content

Commit

Permalink
Allow custom config file for ament_uncrustify (#200)
Browse files Browse the repository at this point in the history
* parse arguements for CONFIG_FILE and append to cmd

Signed-off-by: Yadunund Vijay <yadunund@gmail.com>

* removed newline

Signed-off-by: Yadunund <yadunund@openrobotics.org>

* fixed description

Signed-off-by: Yadunund <yadunund@openrobotics.org>
Signed-off-by: Yadunund Vijay <yadunund@gmail.com>

* corrected location of default configuration file in docblock

Signed-off-by: Yadunund <yadunund@openrobotics.org>

* fixed alignment in docblock

Signed-off-by: Yadunund <yadunund@openrobotics.org>

* reverted deletion of empty line after copyright header

Signed-off-by: Yadunund <yadunund@openrobotics.org>
  • Loading branch information
Yadunund authored and dirk-thomas committed Nov 15, 2019
1 parent abe70a3 commit 2066aae
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ament_cmake_uncrustify/cmake/ament_uncrustify.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@
#
# Add a test to check the code for compliance with uncrustify.
#
# The default configuration file used for uncrustify is located at
# configuration/ament_code_style.cfg within the ament_uncrustify directory.
# The default configuration file can be overridden by the
# argument 'CONFIG_FILE'.
#
# :param TESTNAME: the name of the test, default: "uncrustify"
# :type TESTNAME: string
# :param CONFIG_FILE: the path of the configuration file for
# uncrustify to consider
# :type CONFIG_FILE: string
# :param MAX_LINE_LENGTH: override the maximum line length,
# the default is defined in ament_uncrustify
# :type MAX_LINE_LENGTH: integer
Expand All @@ -26,7 +34,7 @@
# @public
#
function(ament_uncrustify)
cmake_parse_arguments(ARG "" "MAX_LINE_LENGTH;TESTNAME" "" ${ARGN})
cmake_parse_arguments(ARG "" "MAX_LINE_LENGTH;TESTNAME;CONFIG_FILE" "" ${ARGN})
if(NOT ARG_TESTNAME)
set(ARG_TESTNAME "uncrustify")
endif()
Expand All @@ -41,6 +49,9 @@ function(ament_uncrustify)
if(DEFINED ARG_MAX_LINE_LENGTH)
list(APPEND cmd "--linelength" "${ARG_MAX_LINE_LENGTH}")
endif()
if(ARG_CONFIG_FILE)
list(APPEND cmd "-c" "${ARG_CONFIG_FILE}")
endif()
list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS})

file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_uncrustify")
Expand Down

0 comments on commit 2066aae

Please sign in to comment.