forked from ros2/ros1_bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create package whitelist from package.xml
The prior mechanism to generate an ignore/include list was to use a static file at the workspace root. This doesn't play very well with our build system so instead use package.xml. Any <build_depend> package will now be included in the ros1_bridge build. This is done using a simple python script to parse package.xml which is then called by cmake (stdout of the script is the list). We then feed that list into a modified filter_packages() function that takes a list of include/ignore packages rather than using the static list.
- Loading branch information
Showing
3 changed files
with
49 additions
and
62 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
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,16 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
from catkin_pkg.package import parse_package | ||
|
||
def main(argv=sys.argv[1:]): | ||
pkg = parse_package("package.xml") | ||
packages = [] | ||
|
||
for depend in pkg["build_depends"]: | ||
packages.append(depend.name) | ||
|
||
print(';'.join(packages), end='') | ||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
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 |
---|---|---|
@@ -1,68 +1,26 @@ | ||
# Module/Package resp. message ignores and includes | ||
# | ||
# Finds lists of ROS modules/packages resp. messages that shall | ||
# be included resp. ignored by the ROS bridge according to the | ||
# following rules: | ||
# - Include lists over ignore lists. I.e. if an include list is | ||
# present, the ignore list will be ... well, ignored.) | ||
function(filter_packages) | ||
set(options "") | ||
set(oneValueArgs PKG_LIST) | ||
set(multiValueArgs INCLUDE IGNORE) | ||
|
||
set(USE_PKG_IGNORE OFF) | ||
set(USE_PKG_INCLUDE OFF) | ||
set(USE_MSG_IGNORE OFF) | ||
set(USE_MSG_INCLUDE OFF) | ||
cmake_parse_arguments(FILTER_PACKAGES "${options}" | ||
"${oneValueArgs}" "${multiValueArgs}", "${ARGN}") | ||
|
||
set(BRIDGE_IGNORE_PKGS "") | ||
set(BRIDGE_IGNORE_MSGS "") | ||
set(BRIDGE_INCLUDE_PKGS "") | ||
set(BRIDGE_INCLUDE_MSGS "") | ||
|
||
# File with packages to ignore/include in ROS 1 Bridge | ||
set(BRIDGE_PACKAGE_IGNORE "${CMAKE_SOURCE_DIR}/../../../BridgePackageIgnore.List") | ||
set(BRIDGE_PACKAGE_INCLUDE "${CMAKE_SOURCE_DIR}/../../../BridgePackageInclude.List") | ||
|
||
# File with messages to ignore/include in ROS 1 Bridge | ||
set(BRIDGE_MSG_IGNORE "${CMAKE_SOURCE_DIR}/../../../BridgePackageIgnore.List") | ||
set(BRIDGE_MSG_INCLUDE "${CMAKE_SOURCE_DIR}/../../../BridgePackageInclude.List") | ||
|
||
if(EXISTS "${BRIDGE_PACKAGE_INCLUDE}") | ||
set(USE_PKG_INCLUDE ON) | ||
else() # EXISTS "${BRIDGE_PACKAGE_INCLUDE}" | ||
if(EXISTS "${BRIDGE_PACKAGE_IGNORE}") | ||
set(USE_PKG_IGNORE ON) | ||
endif() # EXISTS "${BRIDGE_PACKAGE_IGNORE}" | ||
endif() # EXISTS "${BRIDGE_PACKAGE_INCLUDE}" | ||
|
||
if(${USE_PKG_INCLUDE}) | ||
FILE(READ "${BRIDGE_PACKAGE_INCLUDE}" BRIDGE_INCLUDE_PKGS) | ||
STRING(REGEX REPLACE ";" "\\\\;" BRIDGE_INCLUDE_PKGS "${BRIDGE_INCLUDE_PKGS}") | ||
STRING(REGEX REPLACE "\n" ";" BRIDGE_INCLUDE_PKGS "${BRIDGE_INCLUDE_PKGS}") | ||
list(REMOVE_DUPLICATES BRIDGE_INCLUDE_PKGS) | ||
message(STATUS "Found package include list, including: ${BRIDGE_INCLUDE_PKGS}") | ||
endif() # USE_PKG_INCLUDE | ||
|
||
if(${USE_PKG_IGNORE}) | ||
FILE(READ "${BRIDGE_PACKAGE_IGNORE}" BRIDGE_IGNORE_PKGS) | ||
STRING(REGEX REPLACE ";" "\\\\;" BRIDGE_IGNORE_PKGS "${BRIDGE_IGNORE_PKGS}") | ||
STRING(REGEX REPLACE "\n" ";" BRIDGE_IGNORE_PKGS "${BRIDGE_IGNORE_PKGS}") | ||
list(REMOVE_DUPLICATES BRIDGE_IGNORE_PKGS) | ||
message(STATUS "Found package ignore list, ignoring: ${BRIDGE_IGNORE_PKGS}") | ||
endif() # USE_PKG_IGNORE | ||
|
||
function(filter_packages pkg_list) | ||
set(ros2_packages ${${pkg_list}}) | ||
if(BRIDGE_INCLUDE_PKGS) | ||
set(ros2_packages ${${FILTER_PACKAGES_PKG_LIST}}) | ||
cmake_print_variables(ros2_packages) | ||
if(FILTER_PACKAGES_INCLUDE) | ||
foreach(pkg ${ros2_packages}) | ||
if(NOT ${pkg} IN_LIST BRIDGE_INCLUDE_PKGS) | ||
if(NOT ${pkg} IN_LIST FILTER_PACKAGES_INCLUDE) | ||
list(REMOVE_ITEM ros2_packages ${pkg}) | ||
endif(NOT ${pkg} IN_LIST BRIDGE_INCLUDE_PKGS) | ||
endif(NOT ${pkg} IN_LIST FILTER_PACKAGES_INCLUDE) | ||
endforeach() | ||
elseif(BRIDGE_IGNORE_PKGS) | ||
elseif(FILTER_PACKAGES_IGNORE) | ||
foreach(pkg ${ros2_packages}) | ||
if(${pkg} IN_LIST BRIDGE_IGNORE_PKGS) | ||
if(${pkg} IN_LIST FILTER_PACKAGES_IGNORE) | ||
list(REMOVE_ITEM ros2_packages ${pkg}) | ||
endif(${pkg} IN_LIST BRIDGE_IGNORE_PKGS) | ||
endif(${pkg} IN_LIST FILTER_PACKAGES_IGNORE) | ||
endforeach() | ||
endif(BRIDGE_INCLUDE_PKGS) | ||
set(${pkg_list} "${ros2_packages}" PARENT_SCOPE) | ||
endif(FILTER_PACKAGES_INCLUDE) | ||
|
||
set(${FILTER_PACKAGES_PKG_LIST} "${ros2_packages}" PARENT_SCOPE) | ||
endfunction(filter_packages ros2_packages) |