From 7f2a7166cfd4a765e86d9cae9685530d512838fa Mon Sep 17 00:00:00 2001 From: Martin Jansa Date: Sat, 5 Dec 2020 04:44:11 -0800 Subject: [PATCH] bitbake: simplify unresolved dependencies handling * use DEPENDENCY instead of PLATFORM_PKG in UNRESOLVED_* variables in some cases as documented in previous commit the unresolved dependency might be ROS package which just happens to be missing in pkg_names, so it's considered as external/system/platform package * parse dependency name by skipping whole UNRESOLVED_DEPENDENCY_REF_PREFIX instead of relying on last underscore separated string Signed-off-by: Martin Jansa --- superflore/generators/bitbake/yocto_recipe.py | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/superflore/generators/bitbake/yocto_recipe.py b/superflore/generators/bitbake/yocto_recipe.py index 968b9a7c..d2cfe039 100644 --- a/superflore/generators/bitbake/yocto_recipe.py +++ b/superflore/generators/bitbake/yocto_recipe.py @@ -42,8 +42,8 @@ from superflore.utils import resolve_dep import yaml -UNRESOLVED_PLATFORM_PKG_PREFIX = 'ROS_UNRESOLVED_PLATFORM_PKG_' -UNRESOLVED_PLATFORM_PKG_REFERENCE_PREFIX = '${'+UNRESOLVED_PLATFORM_PKG_PREFIX +UNRESOLVED_DEPENDENCY_PREFIX = 'ROS_UNRESOLVED_PLATFORM_PKG_' +UNRESOLVED_DEPENDENCY_REF_PREFIX = '${'+UNRESOLVED_DEPENDENCY_PREFIX class yoctoRecipe(object): @@ -285,7 +285,7 @@ def modify_name_if_native(dep, is_native): If the name is for an unresolved platform package, move the "-native" inside the "}" so that it's part of the variable name. """ - if dep.startswith(UNRESOLVED_PLATFORM_PKG_REFERENCE_PREFIX): + if dep.startswith(UNRESOLVED_DEPENDENCY_REF_PREFIX): return dep[0:-len('}')] + ('-native}' if is_native else '}') else: return dep + ('-native' if is_native else '') @@ -374,13 +374,13 @@ def get_dependencies( info('External dependency add: ' + recipe) except UnresolvedDependency: oe_dep = self.convert_to_oe_name(dep, is_native) - recipe = UNRESOLVED_PLATFORM_PKG_REFERENCE_PREFIX\ + recipe = UNRESOLVED_DEPENDENCY_REF_PREFIX\ + oe_dep + '}' dependencies.add(recipe) system_dependencies.add(recipe) # Never add -native. rosdep_dep = self.convert_to_oe_name(dep, False) - rosdep_name = UNRESOLVED_PLATFORM_PKG_REFERENCE_PREFIX\ + rosdep_name = UNRESOLVED_DEPENDENCY_REF_PREFIX\ + rosdep_dep + '}' yoctoRecipe.rosdep_cache[dep].add(rosdep_name) info('Unresolved external dependency add: ' + recipe) @@ -685,21 +685,17 @@ def generate_ros_distro_inc( + ' they are added, override\n# the settings in' + ' ros-distro.inc .\n') """ - Drop trailing "}" so that "..._foo-native" sorts after - "..._foo". + Drop UNRESOLVED_DEPENDENCY_REF_PREFIX and trailing "}" + so that "..._foo-native" sorts after "..._foo". """ - unresolved = [p[0:-1] for p in yoctoRecipe.platform_deps - if p.startswith( - UNRESOLVED_PLATFORM_PKG_REFERENCE_PREFIX)] - for p in sorted(unresolved): - """ - PN is last underscore-separated field. NB the trailing '}' - has already been removed. - """ - pn = p.split('_')[-1] + unresolved = [ + p[len(UNRESOLVED_DEPENDENCY_REF_PREFIX):-1] + for p in yoctoRecipe.platform_deps if p.startswith( + UNRESOLVED_DEPENDENCY_REF_PREFIX)] + for dep in sorted(unresolved): conf_file.write( - UNRESOLVED_PLATFORM_PKG_PREFIX + pn + ' = "UNRESOLVED-' - + pn + '"\n') + UNRESOLVED_DEPENDENCY_PREFIX + dep + ' = "UNRESOLVED-' + + dep + '"\n') ok('Wrote {0}'.format(conf_path)) except OSError as e: