def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description="Invoke 'catkin_make_isolated' on a workspace while "
                    "enabling and running the tests")
    parser.add_argument(
        '--rosdistro-name',
        required=True,
        help='The name of the ROS distro to identify the setup file to be '
             'sourced (if available)')
    parser.add_argument(
        '--workspace-root',
        required=True,
        help='The root path of the workspace to compile')
    parser.add_argument(
        '--parent-result-space',
        help='The path of the parent result space')
    parser.add_argument(
        '--clean-before',
        action='store_true',
        help='The flag if the workspace should be cleaned before the '
             'invocation')
    parser.add_argument(
        '--clean-after',
        action='store_true',
        help='The flag if the workspace should be cleaned after the '
             'invocation')
    args = parser.parse_args(argv)

    ensure_workspace_exists(args.workspace_root)

    if args.clean_before:
        clean_workspace(args.workspace_root)

    try:
        test_results_dir = os.path.join(args.workspace_root, 'test_results')
        arguments = [
            '--cmake-args', '-DCATKIN_ENABLE_TESTING=1',
            '-DCATKIN_SKIP_TESTING=0',
            '-DCATKIN_TEST_RESULTS_DIR=%s' % test_results_dir,
            '--catkin-make-args', '-j1']
        rc = call_catkin_make_isolated(
            args.rosdistro_name, args.workspace_root,
            arguments,
            parent_result_space=args.parent_result_space)
        if not rc:
            rc = call_catkin_make_isolated(
                args.rosdistro_name, args.workspace_root,
                arguments + ['tests'],
                parent_result_space=args.parent_result_space)
            if not rc:
                rc = call_catkin_make_isolated(
                    args.rosdistro_name, args.workspace_root,
                    arguments + ['run_tests'],
                    parent_result_space=args.parent_result_space)
    finally:
        if args.clean_after:
            clean_workspace(args.workspace_root)

    return rc
def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description="Invoke 'catkin_make_isolated --install' on a workspace")
    parser.add_argument(
        '--rosdistro-name',
        required=True,
        help='The name of the ROS distro to identify the setup file to be '
             'sourced (if available)')
    parser.add_argument(
        '--workspace-root',
        required=True,
        help='The root path of the workspace to compile')
    parser.add_argument(
        '--parent-result-space', nargs='*',
        help='The paths of the parent result spaces')
    parser.add_argument(
        '--clean-before',
        action='store_true',
        help='The flag if the workspace should be cleaned before the '
             'invocation')
    parser.add_argument(
        '--clean-after',
        action='store_true',
        help='The flag if the workspace should be cleaned after the '
             'invocation')
    args = parser.parse_args(argv)

    ensure_workspace_exists(args.workspace_root)

    if args.clean_before:
        clean_workspace(args.workspace_root)

    try:
        with Scope('SUBSECTION', 'build workspace in isolation and install'):
            parent_result_spaces = None
            if args.parent_result_space:
                parent_result_spaces = args.parent_result_space
            rc = call_catkin_make_isolated(
                args.rosdistro_name, args.workspace_root,
                ['--install', '--cmake-args', '-DCATKIN_SKIP_TESTING=1',
                 '--catkin-make-args', '-j1'],
                parent_result_spaces=parent_result_spaces)
    finally:
        if args.clean_after:
            clean_workspace(args.workspace_root)

    return rc
Example #3
0
def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description="Invoke 'catkin_make_isolated --install' on a workspace")
    parser.add_argument(
        '--rosdistro-name',
        required=True,
        help='The name of the ROS distro to identify the setup file to be '
        'sourced (if available)')
    parser.add_argument('--workspace-root',
                        required=True,
                        help='The root path of the workspace to compile')
    parser.add_argument('--parent-result-space',
                        help='The path of the parent result space')
    parser.add_argument(
        '--clean-before',
        action='store_true',
        help='The flag if the workspace should be cleaned before the '
        'invocation')
    parser.add_argument(
        '--clean-after',
        action='store_true',
        help='The flag if the workspace should be cleaned after the '
        'invocation')
    args = parser.parse_args(argv)

    ensure_workspace_exists(args.workspace_root)

    if args.clean_before:
        clean_workspace(args.workspace_root)

    try:
        rc = call_catkin_make_isolated(
            args.rosdistro_name,
            args.workspace_root, [
                '--install', '--cmake-args', '-DCATKIN_SKIP_TESTING=1',
                '--catkin-make-args', '-j1'
            ],
            parent_result_space=args.parent_result_space)
    finally:
        if args.clean_after:
            clean_workspace(args.workspace_root)

    return rc
Example #4
0
def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description="Invoke 'rosdoc_lite' on each package of a workspace")
    parser.add_argument(
        '--rosdistro-name',
        required=True,
        help='The name of the ROS distro to identify the setup file to be '
             'sourced (if available)')
    parser.add_argument(
        '--os-code-name',
        required=True,
        help="The OS code name (e.g. 'trusty')")
    parser.add_argument(
        '--arch',
        required=True,
        help="The architecture (e.g. 'amd64')")
    parser.add_argument(
        '--workspace-root',
        required=True,
        help='The root path of the workspace to compile')
    parser.add_argument(
        '--rosdoc-lite-dir',
        required=True,
        help='The root path of the rosdoc_lite repository')
    parser.add_argument(
        '--catkin-sphinx-dir',
        required=True,
        help='The root path of the catkin-sphinx repository')
    parser.add_argument(
        '--rosdoc-index-dir',
        required=True,
        help='The root path of the rosdoc_index folder')
    parser.add_argument(
        '--canonical-base-url',
        help='The canonical base URL to add to all generated HTML files')
    parser.add_argument(
        'pkg_tuples',
        nargs='*',
        help='A list of package tuples in topological order, each containing '
             'the name, the relative path and optionally the package-relative '
             'path of the rosdoc config file separated by a colon')
    add_argument_output_dir(parser, required=True)
    args = parser.parse_args(argv)

    ensure_workspace_exists(args.workspace_root)
    clean_workspace(args.workspace_root)

    with Scope('SUBSECTION', 'build workspace in isolation and install'):
        rc = call_catkin_make_isolated(
            args.rosdistro_name, args.workspace_root,
            ['--install', '--cmake-args', '-DCATKIN_SKIP_TESTING=1',
             '--catkin-make-args', '-j1'])
    # TODO compile error should still allow to generate doc from static parts
    if rc:
        return rc

    rosdoc_index = RosdocIndex([
        os.path.join(args.output_dir, args.rosdistro_name),
        os.path.join(args.rosdoc_index_dir, args.rosdistro_name)])

    source_space = os.path.join(args.workspace_root, 'src')
    for pkg_tuple in args.pkg_tuples:
        pkg_name, pkg_subfolder, pkg_rosdoc_config = pkg_tuple.split(':', 2)
        with Scope('SUBSECTION', 'rosdoc_lite - %s' % pkg_name):
            pkg_path = os.path.join(source_space, pkg_subfolder)

            pkg_doc_path = os.path.join(
                args.output_dir, 'api_rosdoc', pkg_name)
            pkg_tag_path = os.path.join(
                args.output_dir, 'symbols', '%s.tag' % pkg_name)

            source_cmd = [
                # for workspaces with only plain cmake packages the setup files
                # generated by cmi won't implicitly source the underlays
                '.', '/opt/ros/%s/setup.sh' % args.rosdistro_name,
                '&&',
                '.', os.path.join(
                    args.workspace_root, 'install_isolated', 'setup.sh'),
            ]
            rosdoc_lite_cmd = [
                os.path.join(args.rosdoc_lite_dir, 'scripts', 'rosdoc_lite'),
                pkg_path,
                '-o', pkg_doc_path,
                '-g', pkg_tag_path,
                '-t', os.path.join(
                    args.output_dir, 'rosdoc_tags', '%s.yaml' % pkg_name),
            ]
            print("Invoking `rosdoc_lite` for package '%s': %s" %
                  (pkg_name, ' '.join(rosdoc_lite_cmd)))
            pkg_rc = subprocess.call(
                [
                    'sh', '-c',
                    ' '.join(source_cmd) +
                    ' && ' +
                    'PYTHONPATH=%s/src:%s/src:$PYTHONPATH ' % (
                        args.rosdoc_lite_dir, args.catkin_sphinx_dir) +
                    ' '.join(rosdoc_lite_cmd)
                ], stderr=subprocess.STDOUT, cwd=pkg_path)
            if pkg_rc:
                rc = pkg_rc

            # only if rosdoc runs generates a symbol file
            # create the corresponding location file
            if os.path.exists(pkg_tag_path):
                data = {
                    'docs_url': '../../../api/%s/html' % pkg_name,
                    'location': '%s/symbols/%s.tag' %
                    (args.rosdistro_name, pkg_name),
                    'package': pkg_name,
                }

                # fetch generator specific output folders from rosdoc_lite
                if pkg_rosdoc_config:
                    output_folders = get_generator_output_folders(
                        pkg_rosdoc_config, pkg_name)
                    for generator, output_folder in output_folders.items():
                        data['%s_output_folder' % generator] = output_folder

                rosdoc_index.locations[pkg_name] = [data]

            if args.canonical_base_url:
                add_canonical_link(
                    pkg_doc_path, '%s/%s/api/%s' %
                    (args.canonical_base_url, args.rosdistro_name, pkg_name))

            # merge manifest.yaml files
            rosdoc_manifest_yaml_file = os.path.join(
                pkg_doc_path, 'manifest.yaml')
            job_manifest_yaml_file = os.path.join(
                args.output_dir, 'manifests', pkg_name, 'manifest.yaml')
            with open(rosdoc_manifest_yaml_file, 'r') as h:
                rosdoc_data = yaml.load(h)
            with open(job_manifest_yaml_file, 'r') as h:
                job_data = yaml.load(h)
            rosdoc_data.update(job_data)
            with open(rosdoc_manifest_yaml_file, 'w') as h:
                yaml.safe_dump(rosdoc_data, h, default_flow_style=False)

    rosdoc_index.write_modified_data(
        args.output_dir, ['locations'])

    return rc
Example #5
0
def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description="Invoke 'rosdoc_lite' on each package of a workspace")
    parser.add_argument(
        '--rosdistro-name',
        required=True,
        help='The name of the ROS distro to identify the setup file to be '
        'sourced (if available)')
    parser.add_argument('--os-code-name',
                        required=True,
                        help="The OS code name (e.g. 'xenial')")
    parser.add_argument('--arch',
                        required=True,
                        help="The architecture (e.g. 'amd64')")
    parser.add_argument('--workspace-root',
                        required=True,
                        help='The root path of the workspace to compile')
    parser.add_argument('--rosdoc-lite-dir',
                        required=True,
                        help='The root path of the rosdoc_lite repository')
    parser.add_argument('--catkin-sphinx-dir',
                        required=True,
                        help='The root path of the catkin-sphinx repository')
    parser.add_argument('--rosdoc-index-dir',
                        required=True,
                        help='The root path of the rosdoc_index folder')
    parser.add_argument(
        '--canonical-base-url',
        help='The canonical base URL to add to all generated HTML files')
    parser.add_argument(
        'pkg_tuples',
        nargs='*',
        help='A list of package tuples in topological order, each containing '
        'the name, the relative path and optionally the package-relative '
        'path of the rosdoc config file separated by a colon')
    add_argument_output_dir(parser, required=True)
    args = parser.parse_args(argv)

    ensure_workspace_exists(args.workspace_root)
    clean_workspace(args.workspace_root)

    with Scope('SUBSECTION', 'build workspace in isolation and install'):
        rc = call_catkin_make_isolated(
            args.rosdistro_name, args.workspace_root, [
                '--install', '--cmake-args', '-DCATKIN_SKIP_TESTING=1',
                '--catkin-make-args', '-j1'
            ])
    # TODO compile error should still allow to generate doc from static parts
    if rc:
        return rc

    rosdoc_index = RosdocIndex([
        os.path.join(args.output_dir, args.rosdistro_name),
        os.path.join(args.rosdoc_index_dir, args.rosdistro_name)
    ])

    source_space = os.path.join(args.workspace_root, 'src')
    for pkg_tuple in args.pkg_tuples:
        pkg_name, pkg_subfolder, pkg_rosdoc_config = pkg_tuple.split(':', 2)
        with Scope('SUBSECTION', 'rosdoc_lite - %s' % pkg_name):
            pkg_path = os.path.join(source_space, pkg_subfolder)

            pkg_doc_path = os.path.join(args.output_dir, 'api_rosdoc',
                                        pkg_name)
            pkg_tag_path = os.path.join(args.output_dir, 'symbols',
                                        '%s.tag' % pkg_name)

            source_cmd = [
                '.',
                os.path.join(args.workspace_root, 'install_isolated',
                             'setup.sh'),
            ]
            # for workspaces with only plain cmake packages the setup files
            # generated by cmi won't implicitly source the underlays
            setup_file = '/opt/ros/%s/setup.sh' % args.rosdistro_name
            if os.path.exists(setup_file):
                source_cmd = ['.', setup_file, '&&'] + source_cmd
            rosdoc_lite_cmd = [
                os.path.join(args.rosdoc_lite_dir, 'scripts', 'rosdoc_lite'),
                pkg_path,
                '-o',
                pkg_doc_path,
                '-g',
                pkg_tag_path,
                '-t',
                os.path.join(args.output_dir, 'rosdoc_tags',
                             '%s.yaml' % pkg_name),
            ]
            print("Invoking `rosdoc_lite` for package '%s': %s" %
                  (pkg_name, ' '.join(rosdoc_lite_cmd)))
            pkg_rc = subprocess.call([
                'sh', '-c', ' '.join(source_cmd) + ' && ' +
                'PYTHONPATH=%s/src:%s/src:$PYTHONPATH ' %
                (args.rosdoc_lite_dir, args.catkin_sphinx_dir) +
                ' '.join(rosdoc_lite_cmd)
            ],
                                     stderr=subprocess.STDOUT,
                                     cwd=pkg_path)
            if pkg_rc:
                rc = pkg_rc

            # only if rosdoc runs generates a symbol file
            # create the corresponding location file
            if os.path.exists(pkg_tag_path):
                data = {
                    'docs_url':
                    '../../../api/%s/html' % pkg_name,
                    'location':
                    '%s/symbols/%s.tag' % (args.rosdistro_name, pkg_name),
                    'package':
                    pkg_name,
                }

                # fetch generator specific output folders from rosdoc_lite
                if pkg_rosdoc_config:
                    output_folders = get_generator_output_folders(
                        pkg_rosdoc_config, pkg_name)
                    for generator, output_folder in output_folders.items():
                        data['%s_output_folder' % generator] = output_folder

                rosdoc_index.locations[pkg_name] = [data]

            if args.canonical_base_url:
                add_canonical_link(
                    pkg_doc_path, '%s/%s/api/%s' %
                    (args.canonical_base_url, args.rosdistro_name, pkg_name))

            # merge manifest.yaml files
            rosdoc_manifest_yaml_file = os.path.join(pkg_doc_path,
                                                     'manifest.yaml')
            job_manifest_yaml_file = os.path.join(args.output_dir, 'manifests',
                                                  pkg_name, 'manifest.yaml')
            if os.path.exists(rosdoc_manifest_yaml_file):
                with open(rosdoc_manifest_yaml_file, 'r') as h:
                    rosdoc_data = yaml.load(h)
            else:
                # if rosdoc_lite failed to generate the file
                rosdoc_data = {}
            with open(job_manifest_yaml_file, 'r') as h:
                job_data = yaml.load(h)
            rosdoc_data.update(job_data)
            with open(rosdoc_manifest_yaml_file, 'w') as h:
                yaml.safe_dump(rosdoc_data, h, default_flow_style=False)

    rosdoc_index.write_modified_data(args.output_dir, ['locations'])

    return rc
def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description="Invoke 'catkin_make_isolated' on a workspace while "
                    "enabling and running the tests")
    parser.add_argument(
        '--rosdistro-name',
        required=True,
        help='The name of the ROS distro to identify the setup file to be '
             'sourced (if available)')
    parser.add_argument(
        '--workspace-root',
        required=True,
        help='The root path of the workspace to compile')
    parser.add_argument(
        '--parent-result-space', nargs='*',
        help='The paths of the parent result spaces')
    parser.add_argument(
        '--clean-before',
        action='store_true',
        help='The flag if the workspace should be cleaned before the '
             'invocation')
    parser.add_argument(
        '--clean-after',
        action='store_true',
        help='The flag if the workspace should be cleaned after the '
             'invocation')
    args = parser.parse_args(argv)

    ensure_workspace_exists(args.workspace_root)

    if args.clean_before:
        clean_workspace(args.workspace_root)

    parent_result_spaces = None
    if args.parent_result_space:
        parent_result_spaces = args.parent_result_space

    try:
        with Scope('SUBSECTION', 'build workspace in isolation'):
            test_results_dir = os.path.join(
                args.workspace_root, 'test_results')
            arguments = [
                '--cmake-args', '-DCATKIN_ENABLE_TESTING=1',
                '-DCATKIN_SKIP_TESTING=0',
                '-DCATKIN_TEST_RESULTS_DIR=%s' % test_results_dir,
                '--catkin-make-args', '-j1']
            rc = call_catkin_make_isolated(
                args.rosdistro_name, args.workspace_root,
                arguments,
                parent_result_spaces=parent_result_spaces)
        if not rc:
            with Scope('SUBSECTION', 'build tests'):
                rc = call_catkin_make_isolated(
                    args.rosdistro_name, args.workspace_root,
                    arguments + ['tests'],
                    parent_result_spaces=parent_result_spaces)
            if not rc:
                # for workspaces with only plain cmake packages the setup files
                # generated by cmi won't implicitly source the underlays
                if parent_result_spaces is None:
                    parent_result_spaces = ['/opt/ros/%s' % args.rosdistro_name]
                devel_space = os.path.join(
                    args.workspace_root, 'devel_isolated')
                parent_result_spaces.append(devel_space)
                # since catkin_make_isolated doesn't provide a custom
                # environment to run tests this needs to source the devel space
                # and force a CMake run ro use the new environment
                with Scope('SUBSECTION', 'run tests'):
                    rc = call_catkin_make_isolated(
                        args.rosdistro_name, args.workspace_root,
                        ['--force-cmake'] + arguments + ['run_tests'],
                        parent_result_spaces=parent_result_spaces)
    finally:
        if args.clean_after:
            clean_workspace(args.workspace_root)

    return rc
def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description="Invoke 'catkin_make_isolated' on a workspace while "
        "enabling and running the tests")
    parser.add_argument(
        '--rosdistro-name',
        required=True,
        help='The name of the ROS distro to identify the setup file to be '
        'sourced (if available)')
    parser.add_argument('--workspace-root',
                        required=True,
                        help='The root path of the workspace to compile')
    parser.add_argument('--parent-result-space',
                        help='The path of the parent result space')
    parser.add_argument(
        '--clean-before',
        action='store_true',
        help='The flag if the workspace should be cleaned before the '
        'invocation')
    parser.add_argument(
        '--clean-after',
        action='store_true',
        help='The flag if the workspace should be cleaned after the '
        'invocation')
    args = parser.parse_args(argv)

    ensure_workspace_exists(args.workspace_root)

    if args.clean_before:
        clean_workspace(args.workspace_root)

    try:
        test_results_dir = os.path.join(args.workspace_root, 'test_results')
        arguments = [
            '--cmake-args', '-DCATKIN_ENABLE_TESTING=1',
            '-DCATKIN_SKIP_TESTING=0',
            '-DCATKIN_TEST_RESULTS_DIR=%s' % test_results_dir,
            '--catkin-make-args', '-j1'
        ]
        rc = call_catkin_make_isolated(
            args.rosdistro_name,
            args.workspace_root,
            arguments,
            parent_result_space=args.parent_result_space)
        if not rc:
            rc = call_catkin_make_isolated(
                args.rosdistro_name,
                args.workspace_root,
                arguments + ['tests'],
                parent_result_space=args.parent_result_space)
            if not rc:
                rc = call_catkin_make_isolated(
                    args.rosdistro_name,
                    args.workspace_root,
                    arguments + ['run_tests'],
                    parent_result_space=args.parent_result_space)
    finally:
        if args.clean_after:
            clean_workspace(args.workspace_root)

    return rc
Example #8
0
def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description="Invoke 'catkin_make_isolated' on a workspace while "
        "enabling and running the tests")
    parser.add_argument(
        '--rosdistro-name',
        required=True,
        help='The name of the ROS distro to identify the setup file to be '
        'sourced (if available)')
    parser.add_argument('--workspace-root',
                        required=True,
                        help='The root path of the workspace to compile')
    parser.add_argument('--parent-result-space',
                        nargs='*',
                        help='The paths of the parent result spaces')
    parser.add_argument(
        '--clean-before',
        action='store_true',
        help='The flag if the workspace should be cleaned before the '
        'invocation')
    parser.add_argument(
        '--clean-after',
        action='store_true',
        help='The flag if the workspace should be cleaned after the '
        'invocation')
    args = parser.parse_args(argv)

    ensure_workspace_exists(args.workspace_root)

    if args.clean_before:
        clean_workspace(args.workspace_root)

    parent_result_spaces = None
    if args.parent_result_space:
        parent_result_spaces = args.parent_result_space

    try:
        with Scope('SUBSECTION', 'build workspace in isolation'):
            test_results_dir = os.path.join(args.workspace_root,
                                            'test_results')
            arguments = [
                '--cmake-args', '-DCATKIN_ENABLE_TESTING=1',
                '-DCATKIN_SKIP_TESTING=0',
                '-DCATKIN_TEST_RESULTS_DIR=%s' % test_results_dir,
                '--catkin-make-args', '-j1'
            ]
            rc = call_catkin_make_isolated(
                args.rosdistro_name,
                args.workspace_root,
                arguments,
                parent_result_spaces=parent_result_spaces)
        if not rc:
            with Scope('SUBSECTION', 'build tests'):
                rc = call_catkin_make_isolated(
                    args.rosdistro_name,
                    args.workspace_root,
                    arguments + ['tests'],
                    parent_result_spaces=parent_result_spaces)
            if not rc:
                # for workspaces with only plain cmake packages the setup files
                # generated by cmi won't implicitly source the underlays
                if parent_result_spaces is None:
                    parent_result_spaces = [
                        '/opt/ros/%s' % args.rosdistro_name
                    ]
                devel_space = os.path.join(args.workspace_root,
                                           'devel_isolated')
                parent_result_spaces.append(devel_space)
                # since catkin_make_isolated doesn't provide a custom
                # environment to run tests this needs to source the devel space
                # and force a CMake run ro use the new environment
                with Scope('SUBSECTION', 'run tests'):
                    rc = call_catkin_make_isolated(
                        args.rosdistro_name,
                        args.workspace_root,
                        ['--force-cmake'] + arguments + ['run_tests'],
                        parent_result_spaces=parent_result_spaces)
    finally:
        if args.clean_after:
            clean_workspace(args.workspace_root)

    return rc