Exemple #1
0
    def generate_ros_distro_inc(basepath,
                                distro,
                                version,
                                platforms,
                                skip_keys=[]):
        conf_dir = '{0}/meta-ros{1}-{2}/conf/ros-distro/include/{2}/' \
                    'generated/'.format(
                        basepath, yoctoRecipe._get_ros_version(distro), distro)
        conf_file_name = 'superflore-ros-distro.inc'
        conf_path = '{}{}'.format(conf_dir, conf_file_name)
        try:
            make_dir(conf_dir)
            with open(conf_path, 'w') as conf_file:
                conf_file.write('# {}/generated/{}\n'.format(
                    distro, conf_file_name))
                conf_file.write('# Generated by superflore -- DO NOT EDIT')
                conf_file.write(
                    ' (except ROS_DISTRO_METADATA_VERSION_REVISION)\n#\n')
                conf_file.write(
                    '# Copyright Open Source Robotics Foundation\n\n')
                conf_file.write(
                    '# Increment every time meta-ros is released because of ' +
                    'a manually created change, ie, NOT as a result of a ' +
                    'superflore run (which\n# resets it to "0").')
                conf_file.write(
                    '\nROS_DISTRO_METADATA_VERSION_REVISION = "0"\n')
                conf_file.write(
                    '\nROS_SUPERFLORE_PROGRAM_VERSION = "{}"\n'.format(
                        get_superflore_version()))
                conf_file.write('ROS_SUPERFLORE_GENERATION_SCHEME = "2"\n')
                ros_version = yoctoRecipe._get_ros_version(distro)
                conf_file.write(
                    '\nROS_DISTRO_TYPE = "ros{}"\n'.format(ros_version))
                conf_file.write('ROS_VERSION = "{}"\n'.format(ros_version))
                conf_file.write('# DO NOT OVERRIDE ROS_PYTHON_VERSION\n')
                ros_python_version = 3
                if ros_version == 1:
                    ros_python_version = 2
                conf_file.write(
                    'ROS_PYTHON_VERSION = "{}"\n\n'.format(ros_python_version))
                oe_skip_keys = map(
                    lambda skip_key: yoctoRecipe.convert_to_oe_name(skip_key),
                    skip_keys)
                conf_file.write(
                    yoctoRecipe.generate_multiline_variable(
                        'ROS_SUPERFLORE_GENERATION_SKIP_LIST', oe_skip_keys) +
                    '\n')
                conf_file.write(
                    '# Superflore was unable to generate recipes for these ' +
                    'packages, eg, because their repositories are not on ' +
                    'GitHub.\n')
                conf_file.write(
                    yoctoRecipe.generate_multiline_variable(
                        'ROS_SUPERFLORE_GENERATION_NOT_POSSIBLE',
                        yoctoRecipe.not_generated_recipes) + '\n')
                conf_file.write(
                    '# Number of commits that will be returned by '
                    '"git log meta-ros{0}-{1}/files/{1}/generated/'
                    'cache.yaml" when the\n# generated files are committed. '
                    'This is used for the fourth version field of '
                    'DISTRO_VERSION.\n'.format(
                        yoctoRecipe._get_ros_version(distro), distro))
                version = 1 if not version else len(version.splitlines()) + 1
                conf_file.write(
                    'ROS_NUM_CACHE_YAML_COMMITS = "{}"'.format(version) +
                    '\n\n')
                conf_file.write(
                    '# Iterated values of ' +
                    'ROS_DISTRO-cache.distribution_file.release_platforms.' +
                    '<LINUX-DISTRO>.[ <NAME> ... ] .\n')
                release_platforms = []
                for p in sorted(platforms.items()):
                    for release in p[1]:
                        release_platforms.append(p[0] + '-' + release)
                conf_file.write(
                    yoctoRecipe.generate_multiline_variable(
                        'ROS_DISTRO_RELEASE_PLATFORMS', release_platforms) +
                    '\n')
                conf_file.write(
                    yoctoRecipe.generate_multiline_variable(
                        'ROS_SUPERFLORE_GENERATED_RECIPES',
                        yoctoRecipe.generated_recipes.keys()) + '\n')
                conf_file.write(
                    yoctoRecipe.generate_multiline_variable(
                        'ROS_SUPERFLORE_GENERATED_RECIPE_BASENAMES_WITH_COMPONENT',
                        [(yoctoRecipe.max_component_name - len(component)) *
                         ' ' + component + '/' + recipe + '_' + version
                         for recipe, (version, component) in
                         yoctoRecipe.generated_recipes.items()],
                        key=lambda recipe: recipe.split('/')[1].split('_')[0]))
                conf_file.write(
                    '\n# What\'s built by packagegroup-ros-world. Does not ' +
                    'include packages that appear solely in ' +
                    'ROS_SUPERFLORE_GENERATED_BUILDTOOLS\n# (with a -native' +
                    ' suffix) or ROS_SUPERFLORE_GENERATED_TESTS.\n')
                recipes_set = set(yoctoRecipe.generated_recipes.keys())
                test_deps = set(
                    map(
                        lambda test_dep: yoctoRecipe.convert_to_oe_name(
                            test_dep), yoctoRecipe.generated_test_deps -
                        yoctoRecipe.generated_non_test_deps))
                conf_file.write(
                    yoctoRecipe.generate_multiline_variable(
                        'ROS_SUPERFLORE_GENERATED_WORLD_PACKAGES',
                        recipes_set - yoctoRecipe.generated_native_recipes -
                        test_deps))
                conf_file.write(
                    '\n# Packages found in the <buildtool_depend> and ' +
                    '<buildtool_export_depend> items, ie, ones for which a ' +
                    '-native is built. Does not\n# include those found in ' +
                    'the ROS_EXEC_DEPENDS values in the recipes of build ' +
                    'tools.\n')
                conf_file.write(
                    yoctoRecipe.generate_multiline_variable(
                        'ROS_SUPERFLORE_GENERATED_BUILDTOOLS_%s' %
                        distro.upper(), yoctoRecipe.generated_native_recipes) +
                    '\n')
                conf_file.write('ROS_SUPERFLORE_GENERATED_BUILDTOOLS_append ='
                                ' " ${ROS_SUPERFLORE_GENERATED_BUILDTOOLS_%s}"'
                                '\n\n' % distro.upper())
                conf_file.write(
                    yoctoRecipe.generate_multiline_variable(
                        'ROS_SUPERFLORE_GENERATED_PLATFORM_PACKAGE_DEPENDENCIES',
                        yoctoRecipe.platform_deps))
                conf_file.write(
                    '\n# Packages found only in <test_depend> items. Does not'
                    + ' include those found only in the ROS_*_DEPENDS of ' +
                    'recipes of tests.\n')
                conf_file.write(
                    yoctoRecipe.generate_multiline_variable(
                        'ROS_SUPERFLORE_GENERATED_TESTS', test_deps) + '\n')
                conf_file.write(
                    yoctoRecipe.generate_multiline_variable(
                        'ROS_SUPERFLORE_GENERATED_RECIPES_FOR_COMPONENTS',
                        yoctoRecipe.generated_components))
                conf_file.write(
                    '\n# Platform packages without a OE-RECIPE@OE-LAYER' +
                    ' mapping in base.yaml, python.yaml, or ruby.yaml. Until' +
                    ' they are added, override\n# the settings in' +
                    ' ros-distro.inc .\n')
                """
                Drop 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]
                    conf_file.write(UNRESOLVED_PLATFORM_PKG_PREFIX + pn +
                                    ' = "UNRESOLVED-' + pn + '"\n')

                ok('Wrote {0}'.format(conf_path))
        except OSError as e:
            err('Failed to write conf {} to disk! {}'.format(conf_path, e))
            raise e
Exemple #2
0
 def test_get_superflore_version(self):
     """Test get SuperFlore version"""
     if __version__ != 'unset':
         self.assertGreaterEqual(parse_version(get_superflore_version()),
                                 parse_version('0.2.1'))
 def generate_rosdistro_conf(
         basepath, distro, version, platforms, skip_keys=[]):
     conf_dir = '{}/conf/ros-distro/include/{}/'.format(basepath, distro)
     conf_file_name = 'generated-ros-distro.inc'
     conf_path = '{}{}'.format(conf_dir, conf_file_name)
     try:
         make_dir(conf_dir)
         with open(conf_path, 'w') as conf_file:
             conf_file.write('# {}/{}\n'.format(distro, conf_file_name))
             conf_file.write('# Generated by superflore -- DO NOT EDIT')
             conf_file.write(
                 ' (except ROS_DISTRO_METADATA_VERSION_REVISION)\n#\n')
             conf_file.write(
                 '# Copyright ' + strftime("%Y", gmtime())
                 + ' Open Source Robotics Foundation\n\n')
             conf_file.write(
                 '# Increment every time meta-ros is released because of '
                 + 'a manually created change, ie, NOT as a result of a '
                 + 'superflore run (which\n# resets it to "0").')
             conf_file.write(
                 '\nROS_DISTRO_METADATA_VERSION_REVISION = "0"\n')
             conf_file.write(
                 '\nROS_SUPERFLORE_PROGRAM_VERSION = "{}"\n'
                 .format(get_superflore_version()))
             conf_file.write('ROS_SUPERFLORE_GENERATION_SCHEME = "1"\n')
             ros_version = yoctoRecipe._get_ros_version(distro)
             conf_file.write(
                 '\nROS_DISTRO_TYPE = "ros{}"\n'.format(ros_version))
             conf_file.write('ROS_VERSION = "{}"\n'.format(ros_version))
             conf_file.write('# DO NOT OVERRIDE ROS_PYTHON_VERSION\n')
             ros_python_version = 3
             if ros_version == 1:
                 ros_python_version = 2
             conf_file.write(
                 'ROS_PYTHON_VERSION = "{}"\n\n'.format(ros_python_version))
             oe_skip_keys = map(
                 lambda skip_key: yoctoRecipe.convert_to_oe_name(skip_key),
                 skip_keys
             )
             conf_file.write(yoctoRecipe.generate_multiline_variable(
                 'ROS_SUPERFLORE_GENERATION_SKIP_LIST', oe_skip_keys)
                 + '\n')
             conf_file.write(
                 '# Superflore was unable to generate recipes for these '
                 + 'packages, eg, because their repositories are not on '
                 + 'GitHub.\n')
             conf_file.write(yoctoRecipe.generate_multiline_variable(
                 'ROS_SUPERFLORE_GENERATION_NOT_POSSIBLE',
                 yoctoRecipe.not_generated_recipes) + '\n')
             conf_file.write(
                 '# Number of commits that will be returned by'
                 + ' "git log files/ROS_DISTRO-cache.yaml" when the '
                 + 'generated files are committed. This is\n# used for the'
                 + ' third version field of DISTRO_VERSION.\n')
             version = 1 if not version else len(version.splitlines()) + 1
             conf_file.write(
                 'ROS_NUM_CACHE_YAML_COMMITS = "{}"'.format(version)
                 + '\n\n')
             conf_file.write(
                 '# Iterated values of '
                 + 'ROS_DISTRO-cache.distribution_file.release_platforms.'
                 + '<LINUX-DISTRO>.[ <NAME> ... ] .\n')
             release_platforms = []
             for p in sorted(platforms.items()):
                 for release in p[1]:
                     release_platforms.append(p[0] + '-' + release)
             conf_file.write(yoctoRecipe.generate_multiline_variable(
                 'ROS_DISTRO_RELEASE_PLATFORMS', release_platforms) + '\n')
             conf_file.write(yoctoRecipe.generate_multiline_variable(
                 'ROS_SUPERFLORE_GENERATED_RECIPES',
                 yoctoRecipe.generated_recipes.keys()) + '\n')
             conf_file.write(yoctoRecipe.generate_multiline_variable(
                 'ROS_SUPERFLORE_GENERATED_RECIPE_BASENAMES_WITH_COMPONENT',
                 [(yoctoRecipe.max_component_name - len(component)) * ' '
                  + component + '/' + recipe + '_' + version
                  for recipe, (version, component)
                  in yoctoRecipe.generated_recipes.items()],
                 key=lambda recipe: recipe.split('/')[1].split('_')[0]))
             conf_file.write(
                 '\n# What\'s built by packagegroup-ros-world. Does not '
                 + 'include packages that appear solely in '
                 + 'ROS_SUPERFLORE_GENERATED_BUILDTOOLS\n# (with a -native'
                 + ' suffix) or ROS_SUPERFLORE_GENERATED_TESTS.\n')
             recipes_set = set(yoctoRecipe.generated_recipes.keys())
             test_deps = set(map(
                 lambda test_dep: yoctoRecipe.convert_to_oe_name(test_dep),
                 yoctoRecipe.generated_test_deps
                 - yoctoRecipe.generated_non_test_deps
             ))
             conf_file.write(yoctoRecipe.generate_multiline_variable(
                 'ROS_SUPERFLORE_GENERATED_WORLD_PACKAGES', recipes_set
                 - yoctoRecipe.generated_native_recipes - test_deps))
             conf_file.write(
                 '\n# Packages found in the <buildtool_depend> and '
                 + '<buildtool_export_depend> items, ie, ones for which a '
                 + '-native is built. Does not\n# include those found in '
                 + 'the ROS_EXEC_DEPENDS values in the recipes of build '
                 + 'tools.\n')
             conf_file.write(
                 yoctoRecipe.generate_multiline_variable(
                     'ROS_SUPERFLORE_GENERATED_BUILDTOOLS',
                     yoctoRecipe.generated_native_recipes) + '\n')
             conf_file.write(yoctoRecipe.generate_multiline_variable(
                 'ROS_SUPERFLORE_GENERATED_PLATFORM_PACKAGE_DEPENDENCIES',
                 yoctoRecipe.platform_deps))
             conf_file.write(
                 '\n# Packages found only in <test_depend> items. Does not'
                 + ' include those found only in the ROS_*_DEPENDS of '
                 + 'recipes of tests.\n')
             conf_file.write(
                 yoctoRecipe.generate_multiline_variable(
                     'ROS_SUPERFLORE_GENERATED_TESTS',
                     test_deps) + '\n')
             conf_file.write(
                 yoctoRecipe.generate_multiline_variable(
                     'ROS_SUPERFLORE_GENERATED_RECIPES_FOR_COMPONENTS',
                     yoctoRecipe.generated_components))
             ok('Wrote {0}'.format(conf_path))
     except OSError as e:
         err('Failed to write conf {} to disk! {}'.format(conf_path, e))
         raise e