Skip to content

Commit

Permalink
Fix cmake formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Flova committed Feb 6, 2025
1 parent d6bc1d6 commit d6338e8
Showing 1 changed file with 27 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ find_package(ament_cmake_python REQUIRED)
find_package(bitbots_docs REQUIRED)
find_package(Protobuf REQUIRED)

add_custom_target(${PROJECT_NAME}_generate_proto ALL)
add_custom_target(
${PROJECT_NAME}_generate_proto ALL
COMMENT "Generating protobuf python interface including stubs")

set(PROTO_FILES
bitbots_team_communication/RobocupProtocol/robocup_extension.proto)

add_custom_command(
TARGET ${PROJECT_NAME}_generate_proto
COMMAND protoc
--pyi_out ${CMAKE_SOURCE_DIR}/bitbots_team_communication/
--python_out ${CMAKE_SOURCE_DIR}/bitbots_team_communication/
--proto_path ${CMAKE_SOURCE_DIR}/bitbots_team_communication/RobocupProtocol
${CMAKE_SOURCE_DIR}/bitbots_team_communication/RobocupProtocol/robocup_extension.proto
COMMAND
protoc --pyi_out ${CMAKE_SOURCE_DIR}/bitbots_team_communication/
--python_out ${CMAKE_SOURCE_DIR}/bitbots_team_communication/ --proto_path
${CMAKE_SOURCE_DIR}/bitbots_team_communication/RobocupProtocol
${CMAKE_SOURCE_DIR}/${PROTO_FILES}
COMMENT "Generating protobuf python interface including stubs")

enable_bitbots_docs()
Expand Down Expand Up @@ -48,33 +53,31 @@ if(BUILD_TESTING)

find_package(ament_cmake_mypy REQUIRED)

# The following logic for manually filtering out the files can be removed if
# https://github.com/ament/ament_lint/pull/516 is merged and released in our
# ROS distro

# The following logic for manually filtering out the files can be removed if
# https://github.com/ament/ament_lint/pull/516 is merged and released in our ROS distro

# Collect all .py and .pyi files
file(GLOB_RECURSE PY_FILES "${CMAKE_CURRENT_LIST_DIR}/**/*.py")
file(GLOB_RECURSE PYI_FILES "${CMAKE_CURRENT_LIST_DIR}/**/*.pyi")

# Filter out .py files if a corresponding .pyi file exists
foreach(py_file IN LISTS PY_FILES)
# Get the directory and basename (without extension)
get_filename_component(py_dir "${py_file}" DIRECTORY)
get_filename_component(py_basename "${py_file}" NAME_WE)

# Construct the corresponding .pyi file path
set(pyi_file "${py_dir}/${py_basename}.pyi")
# If a corresponding .pyi file exists, remove the .py file from the list
if(EXISTS "${pyi_file}")
list(REMOVE_ITEM PY_FILES "${py_file}")
endif()
# Get the directory and basename (without extension)
get_filename_component(py_dir "${py_file}" DIRECTORY)
get_filename_component(py_basename "${py_file}" NAME_WE)

# Construct the corresponding .pyi file path
set(PYI_FILE "${py_dir}/${py_basename}.pyi")

# If a corresponding .pyi file exists, remove the .py file from the list
if(EXISTS "${PYI_FILE}")
list(REMOVE_ITEM PY_FILES "${py_file}")
endif()
endforeach()

ament_mypy(
CONFIG_FILE "${CMAKE_CURRENT_LIST_DIR}/mypy.ini"
${PY_FILES} ${PYI_FILES}
)
ament_mypy(CONFIG_FILE "${CMAKE_CURRENT_LIST_DIR}/mypy.ini" ${PY_FILES}
${PYI_FILES})
endif()

ament_package()

0 comments on commit d6338e8

Please sign in to comment.