Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bazel_ros2_rules/ros2/resources/cmake_tools/file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ def __init__(self, target_file: Path):
if fragment['role'] == 'flags':
self.link_flags.append(fragment['fragment'])
elif fragment['role'] == 'libraries':
self.link_libraries.append(fragment['fragment'])
# In the generated JSON a library can be in quotes, in
# order to escape some characters.
# This escaping creates problem down the line,
# "/usr/lib/libfoo.so" is *not* a path.
# We remove the escaping here so they can be treated normally
link_library = fragment['fragment']
if link_library.startswith('"') and \
link_library.endswith('"'):
link_library = link_library.strip('"')
self.link_libraries.append(link_library)
elif fragment['role'] == 'libraryPath':
self.link_search_paths.append(fragment['fragment'])
elif fragment['role'] == 'frameworkPath':
Expand Down
17 changes: 17 additions & 0 deletions bazel_ros2_rules/ros2/resources/ros2bzl/scraping/metadata.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import os
import xml.etree.ElementTree as ET

# Remove elements that have a condition attribute on ROS1
def remove_ros1_elements(root):
ros1_condition_value = '$ROS_VERSION == 1'
elements_to_remove = []

for parent in root.iter():
for child in list(parent):
if 'condition' in child.attrib:
if child.get('condition') == ros1_condition_value:
elements_to_remove.append((parent, child))
else:
child.attrib.pop('condition')

for parent, child in elements_to_remove:
parent.remove(child)

def parse_package_xml(path_to_package_xml):
tree = ET.parse(path_to_package_xml)

remove_ros1_elements(tree.getroot())

depends = set([
tag.text for tag in tree.findall('./depend')
])
Expand Down
5 changes: 4 additions & 1 deletion bazel_ros2_rules/ros2/resources/ros2bzl/scraping/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def find_package(name: str) -> Tuple[str, str]:
dist = importlib.metadata.distribution(name)
top_level = dist.read_text('top_level.txt')
packages = top_level.splitlines()
assert len(packages) == 1
assert len(packages) >= 1
if len(packages) > 1:
print(f"Multiple top level entries where found in {name}. "
"Only the first one will be considered")
return str(dist._path), str(dist.locate_file(packages[0]))


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
cc_library(
name = @name@,
srcs = @srcs@,
hdrs = glob(["{}/**/*.h*".format(x) for x in @headers@], allow_empty = True),
hdrs = glob(
["{}/**/*.h*".format(x) for x in @headers@] +
["{}/**/*.inc".format(x) for x in @headers@],
allow_empty = True,
),
includes = @includes@,
copts = @copts@,
defines = @defines@,
Expand Down
Loading