Skip to content

Commit

Permalink
Add flag for generating build dep for exported dep
Browse files Browse the repository at this point in the history
Superflore generates a runtime-dependency for elements that depend on a
ROS package that defines packages as build-exports-depends or
buildtool-export-depend. This generates valid buildstream elements.
However, some tooling struggles to consume such dependency graph.

This commit adds a flag to additional generate a runtime-dependency for
elements that depend on a ROS package that defines packages as
build-exports-depends or buildtool-export-depend.
  • Loading branch information
harrysarson committed Feb 3, 2025
1 parent e5818da commit 22e9728
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
12 changes: 10 additions & 2 deletions superflore/generators/buildstream/bst_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(
srcrev_cache, skip_keys, repo_dir, external_repos,
*,
exclude_source,
exported_dependencies_as_build_dependencies,
):
self.repo_dir = repo_dir
self.external_repos = external_repos
Expand Down Expand Up @@ -87,6 +88,7 @@ def __init__(
self.srcrev = srcrev_cache[self.src_uri]
self.skip_keys = skip_keys
self.exclude_source = exclude_source
self.exported_dependencies_as_build_dependencies = exported_dependencies_as_build_dependencies

def get_license_line(self):
self.license_line = ''
Expand Down Expand Up @@ -313,9 +315,15 @@ def get_element_text(self, distributor):
exec_deps, sys_deps = self.get_dependencies(
self.rdepends, self.rdepends_external)

element["build-depends"] = buildstack + sorted(deps | buildtool_native_deps)
build_deps = deps | buildtool_native_deps
runtime_deps = deps | export_deps | buildtool_export_native_deps | exec_deps

element["runtime-depends"] = [base] + sorted(deps | export_deps | buildtool_export_native_deps | exec_deps)
if self.exported_dependencies_as_build_dependencies:
build_deps |= runtime_deps

element["build-depends"] = buildstack + sorted(build_deps)

element["runtime-depends"] = [base] + sorted(runtime_deps)

variables = {}
if self.build_type == "ament_cmake":
Expand Down
6 changes: 6 additions & 0 deletions superflore/generators/buildstream/gen_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def regenerate_pkg(
overlay, pkg, rosdistro, preserve_existing, srcrev_cache,
skip_keys, external_repos, generated_elements_dir = "elements/generated",
exclude_source=False,
exported_dependencies_as_build_dependencies=False,
):
pkg_names = get_package_names(rosdistro)[0]
if pkg not in pkg_names:
Expand Down Expand Up @@ -99,6 +100,7 @@ def regenerate_pkg(
current = bst_element(
rosdistro, pkg, srcrev_cache, skip_keys, repo_dir, external_repos,
exclude_source=exclude_source,
exported_dependencies_as_build_dependencies=exported_dependencies_as_build_dependencies,
)
except InvalidPackage as e:
err('Invalid package: ' + str(e))
Expand Down Expand Up @@ -146,6 +148,7 @@ def _gen_element_for_package(
pkg_rosinstall, srcrev_cache, skip_keys, repo_dir, external_repos,
*,
exclude_source,
exported_dependencies_as_build_dependencies,
):
pkg_names = get_package_names(rosdistro)
pkg_dep_walker = DependencyWalker(rosdistro)
Expand Down Expand Up @@ -175,6 +178,7 @@ def _gen_element_for_package(
repo_dir,
external_repos,
exclude_source=exclude_source,
exported_dependencies_as_build_dependencies=exported_dependencies_as_build_dependencies,
)
# add build dependencies
for bdep in pkg_build_deps:
Expand Down Expand Up @@ -204,6 +208,7 @@ def __init__(
self, rosdistro, pkg_name, srcrev_cache, skip_keys, repo_dir, external_repos,
*,
exclude_source,
exported_dependencies_as_build_dependencies,
):
pkg = rosdistro.release_packages[pkg_name]
repo = rosdistro.repositories[pkg.repository_name].release_repository
Expand All @@ -217,6 +222,7 @@ def __init__(
rosdistro, pkg_name, pkg, repo, ros_pkg, pkg_rosinstall,
srcrev_cache, skip_keys, repo_dir, external_repos,
exclude_source=exclude_source,
exported_dependencies_as_build_dependencies=exported_dependencies_as_build_dependencies,
)

def element_text(self):
Expand Down
9 changes: 8 additions & 1 deletion superflore/generators/buildstream/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def main():
default="elements/generated",
help='directory for generated bst elements',
type=str)
parser.add_argument(
'--exported-dependencies-as-build-dependencies',
default=False,
action='store_true',
help='Generate a build-dependency for exported dependencies as well as a runtime-dependency')
parser.add_argument(
'--exclude-sources-for',
default=[],
Expand Down Expand Up @@ -153,6 +158,7 @@ def main():
distro = get_distro(args.ros_distro)
packages = args.only
exclude_sources_for = args.exclude_sources_for
exported_dependencies_as_build_dependencies = args.exported_dependencies_as_build_dependencies
include_dependencies = True
if include_dependencies:
packages = set(packages) | \
Expand All @@ -172,7 +178,8 @@ def main():
srcrev_cache,
skip_keys=skip_keys,
external_repos=external_repos,
exclude_source=pkg in exclude_sources_for
exclude_source=pkg in exclude_sources_for,
exported_dependencies_as_build_dependencies=exported_dependencies_as_build_dependencies,
)
except KeyError:
err("No package to satisfy key '%s' available "
Expand Down

0 comments on commit 22e9728

Please sign in to comment.