コード例 #1
0
def create_cmakelists(package_template, rosdistro, meta=False):
    """
    :param package_template: contains the required information
    :returns: file contents as string
    """
    if meta:
        template_path = get_metapackage_cmake_template_path()
        temp_dict = {
            'name': package_template.name,
            'metapackage_arguments': ''
        }
        return configure_file(template_path, temp_dict)
    else:
        cmakelists_txt_template = read_template_file('CMakeLists.txt',
                                                     rosdistro)
        ctemp = CatkinTemplate(cmakelists_txt_template)
        if package_template.catkin_deps == []:
            components = ''
        else:
            components = ' COMPONENTS\n  %s\n' % '\n  '.join(
                package_template.catkin_deps)
        boost_find_package = \
            ('' if not package_template.boost_comps
             else ('find_package(Boost REQUIRED COMPONENTS %s)\n' %
                   ' '.join(package_template.boost_comps)))
        system_find_package = ''
        for sysdep in package_template.system_deps:
            if sysdep == 'boost':
                continue
            if sysdep.startswith('python-'):
                system_find_package += '# '
            system_find_package += 'find_package(%s REQUIRED)\n' % sysdep
        # provide dummy values
        catkin_depends = (''.join('#     %s\n' % dep
                                  for dep in package_template.catkin_deps)[:-1]
                          if package_template.catkin_deps else
                          '#     other_catkin_pkg')
        system_depends = (''.join(
            '#     %s\n' % dep for dep in package_template.system_deps)[:-1] if
                          package_template.system_deps else '#     system_lib')
        message_pkgs = [
            pkg for pkg in package_template.catkin_deps
            if pkg.endswith('_msgs')
        ]
        if message_pkgs:
            message_depends = '#   %s' % '\n#   '.join(message_pkgs)
        else:
            message_depends = '#   packages containing msgs'
        temp_dict = {
            'name': package_template.name,
            'components': components,
            'include_directories': _create_include_macro(package_template),
            'boost_find': boost_find_package,
            'systems_find': system_find_package,
            'catkin_depends': catkin_depends,
            'system_depends': system_depends,
            'target_libraries': _create_targetlib_args(package_template),
            'message_dependencies': message_depends
        }
        return ctemp.substitute(temp_dict)
コード例 #2
0
def create_cmakelists(package_template, rosdistro, meta=False):
    """
    :param package_template: contains the required information
    :returns: file contents as string
    """
    if meta:
        template_path = get_metapackage_cmake_template_path()
        temp_dict = {"name": package_template.name, "metapackage_arguments": ""}
        return configure_file(template_path, temp_dict)
    else:
        cmakelists_txt_template = read_template_file("CMakeLists.txt", rosdistro)
        ctemp = CatkinTemplate(cmakelists_txt_template)
        if package_template.catkin_deps == []:
            components = ""
        else:
            components = " COMPONENTS\n  %s\n" % "\n  ".join(package_template.catkin_deps)
        boost_find_package = (
            ""
            if not package_template.boost_comps
            else ("find_package(Boost REQUIRED COMPONENTS %s)\n" % " ".join(package_template.boost_comps))
        )
        system_find_package = ""
        for sysdep in package_template.system_deps:
            if sysdep == "boost":
                continue
            if sysdep.startswith("python-"):
                system_find_package += "# "
            system_find_package += "find_package(%s REQUIRED)\n" % sysdep
        # provide dummy values
        catkin_depends = (
            "".join("#     %s\n" % dep for dep in package_template.catkin_deps)[:-1]
            if package_template.catkin_deps
            else "#     other_catkin_pkg"
        )
        system_depends = (
            "".join("#     %s\n" % dep for dep in package_template.system_deps)[:-1]
            if package_template.system_deps
            else "#     system_lib"
        )
        message_pkgs = [pkg for pkg in package_template.catkin_deps if pkg.endswith("_msgs")]
        if message_pkgs:
            message_depends = "#   %s" % "\n#   ".join(message_pkgs)
        else:
            message_depends = "#   packages containing msgs"
        temp_dict = {
            "name": package_template.name,
            "components": components,
            "include_directories": _create_include_macro(package_template),
            "boost_find": boost_find_package,
            "systems_find": system_find_package,
            "catkin_depends": catkin_depends,
            "system_depends": system_depends,
            "target_libraries": _create_targetlib_args(package_template),
            "message_dependencies": message_depends,
        }
        return ctemp.substitute(temp_dict)
コード例 #3
0
ファイル: metapackage.py プロジェクト: 05050830/catkin_ws
def get_expected_cmakelists_txt(metapackage_name):
    """
    Return the expected boilerplate CMakeLists.txt file for a metapackage.

    :param metapackage_name: name of the metapackage
    :type metapackage_name: str
    :returns: expected CMakeLists.txt file
    :rtype: str
    """
    env = {'name': metapackage_name, 'metapackage_arguments': ''}
    return configure_file(get_metapackage_cmake_template_path(), env)
コード例 #4
0
def create_cmakelists(package_template, rosdistro, meta=False):
    """Create CMake file contents from the template.

    :param package_template: contains the required information
    :returns: file contents as string
    """
    if meta:
        template_path = get_metapackage_cmake_template_path()
        temp_dict = {
            'name': package_template.name,
            'metapackage_arguments': '',
        }
        return configure_file(template_path, temp_dict)
    else:
        cmakelists_txt_template = read_template_file('CMakeLists.txt', rosdistro)
        ctemp = CatkinTemplate(cmakelists_txt_template)
        if package_template.catkin_deps == []:
            components = ''
        else:
            components = ' COMPONENTS\n  %s\n' % '\n  '.join(package_template.catkin_deps)
        boost_find_package = \
            ('' if not package_template.boost_comps
             else ('find_package(Boost REQUIRED COMPONENTS %s)\n' %
                   ' '.join(package_template.boost_comps)))
        system_find_package = ''
        for sysdep in package_template.system_deps:
            if sysdep == 'boost':
                continue
            if sysdep.startswith('python-'):
                system_find_package += '# '
            system_find_package += 'find_package(%s REQUIRED)\n' % sysdep
        # provide dummy values
        catkin_depends = (' '.join(package_template.catkin_deps)
                          if package_template.catkin_deps
                          else 'other_catkin_pkg')
        system_depends = (' '.join(package_template.system_deps)
                          if package_template.system_deps
                          else 'system_lib')
        message_pkgs = [pkg for pkg in package_template.catkin_deps if pkg.endswith('_msgs')]
        if message_pkgs:
            message_depends = '#   %s' % '#   '.join(message_pkgs)
        else:
            message_depends = '#   std_msgs  # Or other packages containing msgs'
        temp_dict = {'name': package_template.name,
                     'components': components,
                     'include_directories': _create_include_macro(package_template),
                     'boost_find': boost_find_package,
                     'systems_find': system_find_package,
                     'catkin_depends': catkin_depends,
                     'system_depends': system_depends,
                     'target_libraries': _create_targetlib_args(package_template),
                     'message_dependencies': message_depends
                     }
        return ctemp.substitute(temp_dict)
コード例 #5
0
ファイル: metapackage.py プロジェクト: 130s/catkin_pkg
def get_expected_cmakelists_txt(metapackage_name):
    """
    Returns the expected boilerplate CMakeLists.txt file for a metapackage

    :param metapackage_name: name of the metapackage
    :type metapackage_name: str
    :returns: expected CMakeLists.txt file
    :rtype: str
    """
    env = {
        'name': metapackage_name,
        'metapackage_arguments': ''
    }
    return configure_file(get_metapackage_cmake_template_path(), env)
コード例 #6
0
ファイル: common.py プロジェクト: po1/bloom
def check_metapackage_for_valid_cmake(name):
    if not os.path.exists('CMakeLists.txt'):
        warning("See: http://ros.org/reps/rep-0127.html#metapackage")
        error("Metapackage '{0}' does not have a CMakeLists.txt, refusing to release."
              .format(name),
              exit=True)
    template_path = get_metapackage_cmake_template_path()
    env = {'name': name, 'metapackage_arguments': ''}
    expected_cmake = configure_file(template_path, env)
    with open('CMakeLists.txt', 'r') as f:
        actual_cmake = f.read()
    if expected_cmake != actual_cmake:
        error("Metapackage '{0}' has a non-compliant CMakeLists.txt, expected:"
              .format(name))
        for line in expected_cmake.splitlines():
            info("  " + line)
        error("But got instead:")
        for line in actual_cmake.splitlines():
            info("  " + line)
        warning("See: http://ros.org/reps/rep-0127.html#metapackage")
        error("Metapackage '{0}' has a non-compliant CMakeLists.txt".format(name),
              exit=True)
コード例 #7
0
ファイル: builder.py プロジェクト: datemitumasa/Robocup
def build_catkin_package(path,
                         package,
                         workspace,
                         buildspace,
                         develspace,
                         installspace,
                         install,
                         force_cmake,
                         quiet,
                         last_env,
                         cmake_args,
                         make_args,
                         destdir=None,
                         use_ninja=False):
    cprint("Processing @{cf}catkin@| package: '@!@{bf}" + package.name + "@|'")

    # Make the build dir
    build_dir = _check_build_dir(package.name, workspace, buildspace)

    # Check last_env
    if last_env is not None:
        cprint(blue_arrow + " Building with env: " + "'{0}'".format(last_env))

    # Check for Makefile and maybe call cmake
    if not use_ninja:
        makefile_name = 'Makefile'
    else:
        makefile_name = 'build.ninja'
    makefile = os.path.join(build_dir, makefile_name)
    if not os.path.exists(makefile) or force_cmake:
        package_dir = os.path.dirname(package.filename)
        if not os.path.exists(os.path.join(package_dir, 'CMakeLists.txt')):
            export_tags = [e.tagname for e in package.exports]
            if 'metapackage' not in export_tags:
                print(
                    colorize_line(
                        'Error: Package "%s" does not have a CMakeLists.txt file'
                        % package.name))
                sys.exit(
                    'Can not build catkin package without CMakeLists.txt file')
            # generate CMakeLists.txt for metpackages without one
            print(
                colorize_line(
                    'Warning: metapackage "%s" should have a CMakeLists.txt file'
                    % package.name))
            cmake_code = configure_file(
                get_metapackage_cmake_template_path(), {
                    'name': package.name,
                    'metapackage_arguments': 'DIRECTORY "%s"' % package_dir
                })
            cmakelists_txt = os.path.join(build_dir, 'CMakeLists.txt')
            with open(cmakelists_txt, 'w') as f:
                f.write(cmake_code)
            package_dir = build_dir

        # Run cmake
        cmake_cmd = [
            'cmake', package_dir, '-DCATKIN_DEVEL_PREFIX=' + develspace,
            '-DCMAKE_INSTALL_PREFIX=' + installspace
        ]
        cmake_cmd.extend(cmake_args)
        add_env = get_additional_environment(install, destdir, installspace)
        isolation_print_command(' '.join(cmake_cmd),
                                build_dir,
                                add_env=add_env)
        if last_env is not None:
            cmake_cmd = [last_env] + cmake_cmd
        try:
            run_command_colorized(cmake_cmd, build_dir, quiet, add_env=add_env)
        except subprocess.CalledProcessError as e:
            if os.path.exists(makefile):
                # remove Makefile to force CMake invocation next time
                os.remove(makefile)
            raise
    else:
        print('%s exists, skipping explicit cmake invocation...' %
              makefile_name)
        # Check to see if cmake needs to be run via make
        if not use_ninja:
            make_check_cmake_cmd = ['make', 'cmake_check_build_system']
        else:
            make_check_cmake_cmd = ['ninja', 'build.ninja']
        add_env = get_additional_environment(install, destdir, installspace)
        isolation_print_command(' '.join(make_check_cmake_cmd),
                                build_dir,
                                add_env=add_env)
        if last_env is not None:
            make_check_cmake_cmd = [last_env] + make_check_cmake_cmd
        run_command_colorized(make_check_cmake_cmd,
                              build_dir,
                              quiet,
                              add_env=add_env)

    # Run make
    if not use_ninja:
        make_executable = 'make'
    else:
        make_executable = 'ninja'
    make_cmd = [make_executable]
    make_cmd.extend(handle_make_arguments(make_args))
    isolation_print_command(' '.join(make_cmd), build_dir)
    if last_env is not None:
        make_cmd = [last_env] + make_cmd
    run_command(make_cmd, build_dir, quiet)

    # Make install
    if install:
        if has_make_target(build_dir, 'install', use_ninja=use_ninja):
            make_install_cmd = [make_executable, 'install']
            isolation_print_command(' '.join(make_install_cmd), build_dir)
            if last_env is not None:
                make_install_cmd = [last_env] + make_install_cmd
            run_command(make_install_cmd, build_dir, quiet)
        else:
            print(
                fmt('@{yf}Package has no "@{boldon}install@{boldoff}" target, skipping "%s install" invocation...'
                    % make_executable))
コード例 #8
0
ファイル: builder.py プロジェクト: fqez/common
def build_catkin_package(
    path, package,
    workspace, buildspace, develspace, installspace,
    install, force_cmake, quiet, last_env, cmake_args, make_args,
    destdir=None, use_ninja=False, use_nmake=False
):
    cprint(
        "Processing @{cf}catkin@| package: '@!@{bf}" +
        package.name + "@|'"
    )

    # Make the build dir
    build_dir = _check_build_dir(package.name, workspace, buildspace)

    # Check last_env
    if last_env is not None:
        cprint(
            blue_arrow + " Building with env: " +
            "'{0}'".format(last_env)
        )

    # Check for Makefile and maybe call cmake
    if not use_ninja:
        makefile_name = 'Makefile'
    else:
        makefile_name = 'build.ninja'
    makefile = os.path.join(build_dir, makefile_name)
    if not os.path.exists(makefile) or force_cmake:
        package_dir = os.path.dirname(package.filename)
        if not os.path.exists(os.path.join(package_dir, 'CMakeLists.txt')):
            export_tags = [e.tagname for e in package.exports]
            if 'metapackage' not in export_tags:
                print(colorize_line('Error: Package "%s" does not have a CMakeLists.txt file' % package.name))
                sys.exit('Can not build catkin package without CMakeLists.txt file')
            # generate CMakeLists.txt for metpackages without one
            print(colorize_line('Warning: metapackage "%s" should have a CMakeLists.txt file' % package.name))
            cmake_code = configure_file(
                get_metapackage_cmake_template_path(),
                {'name': package.name, 'metapackage_arguments': 'DIRECTORY "%s"' % package_dir})
            cmakelists_txt = os.path.join(build_dir, 'CMakeLists.txt')
            with open(cmakelists_txt, 'w') as f:
                f.write(cmake_code)
            package_dir = build_dir

        # Run cmake
        cmake_cmd = [
            'cmake',
            package_dir,
            '-DCATKIN_DEVEL_PREFIX=' + develspace,
            '-DCMAKE_INSTALL_PREFIX=' + installspace
        ]
        cmake_cmd.extend(cmake_args)
        add_env = get_additional_environment(install, destdir, installspace)
        isolation_print_command(' '.join(cmake_cmd), build_dir, add_env=add_env)
        if last_env is not None:
            cmake_cmd = [last_env] + cmake_cmd
        try:
            run_command_colorized(cmake_cmd, build_dir, quiet, add_env=add_env)
        except subprocess.CalledProcessError as e:
            if os.path.exists(makefile):
                # remove Makefile to force CMake invocation next time
                os.remove(makefile)
            raise
    else:
        print('%s exists, skipping explicit cmake invocation...' % makefile_name)
        # Check to see if cmake needs to be run via make
        if use_ninja:
            make_check_cmake_cmd = ['ninja', 'build.ninja']
        elif use_nmake:
            make_check_cmake_cmd = ['nmake', 'cmake_check_build_system']
        else:
            make_check_cmake_cmd = ['make', 'cmake_check_build_system']

        add_env = get_additional_environment(install, destdir, installspace)
        isolation_print_command(' '.join(make_check_cmake_cmd), build_dir, add_env=add_env)
        if last_env is not None:
            make_check_cmake_cmd = [last_env] + make_check_cmake_cmd
        run_command_colorized(
            make_check_cmake_cmd, build_dir, quiet, add_env=add_env
        )

    # Run make
    if use_ninja:
        make_executable = 'ninja'
    elif use_nmake:
        make_executable = 'nmake'
    else:
        make_executable = 'make'

    make_cmd = [make_executable]
    make_cmd.extend(handle_make_arguments(make_args))
    isolation_print_command(' '.join(make_cmd), build_dir)
    if last_env is not None:
        make_cmd = [last_env] + make_cmd
    run_command(make_cmd, build_dir, quiet)

    # Make install
    # NMake doesn't have an option to list target so try it anyway
    if install or use_nmake:
        if has_make_target(build_dir, 'install', use_ninja=use_ninja):
            make_install_cmd = [make_executable, 'install']
            isolation_print_command(' '.join(make_install_cmd), build_dir)
            if last_env is not None:
                make_install_cmd = [last_env] + make_install_cmd
            run_command(make_install_cmd, build_dir, quiet)
        else:
            print(fmt(
                '@{yf}Package has no "@{boldon}install@{boldoff}" target, skipping "%s install" invocation...'
                % make_executable))
コード例 #9
0
def build_catkin_package(
    path, package,
    workspace, buildspace, develspace, installspace,
    install, jobs, force_cmake, quiet, cmake_args, make_args,
    catkin_python_path
):
    cprint(
        "Processing @{cf}catkin@| package: '@!@{bf}" +
        package.name + "@|'"
    )

    # Make the build dir
    build_dir = _check_build_dir(package.name, workspace, buildspace)

    # Help find catkin cmake and python
    env = os.environ.copy()
    try:
        env['PYTHONPATH'] = env['PYTHONPATH'] + os.pathsep + catkin_python_path
    except KeyError:
        env['PYTHONPATH'] = catkin_python_path

    # Check for Makefile and maybe call cmake
    makefile = os.path.join(build_dir, 'Makefile')
    # check if toolchain.cmake, config.cmake exist
    toolchain_cmd = "-DCMAKE_TOOLCHAIN_FILE=%s" % os.path.join(workspace, 'toolchain.cmake') if os.path.isfile(os.path.join(workspace, 'toolchain.cmake')) else None
    config_cmd = "-C%s" % os.path.join(workspace, 'config.cmake') if os.path.isfile(os.path.join(workspace, 'config.cmake')) else None
    if not os.path.exists(makefile) or force_cmake:
        package_dir = os.path.dirname(package.filename)
        if not os.path.exists(os.path.join(package_dir, 'CMakeLists.txt')):
            export_tags = [e.tagname for e in package.exports]
            if 'metapackage' not in export_tags:
                print(colorize_line('Error: Package "%s" does not have a CMakeLists.txt file' % package.name))
                raise RuntimeError('Can not build catkin package without CMakeLists.txt file')
            # generate CMakeLists.txt for metpackages without one
            print(colorize_line('Warning: metapackage "%s" should have a CMakeLists.txt file' % package.name))
            cmake_code = configure_file(
                get_metapackage_cmake_template_path(),
                {'name': package.name, 'metapackage_arguments': 'DIRECTORY "%s"' % package_dir})
            cmakelists_txt = os.path.join(build_dir, 'CMakeLists.txt')
            with open(cmakelists_txt, 'w') as f:
                f.write(cmake_code)
            package_dir = build_dir

        # Run cmake
        cmake_cmd = [
            'cmake',
            package_dir,
        ]
        if toolchain_cmd:
            cmake_cmd.append(toolchain_cmd)
        if config_cmd:
            cmake_cmd.append(config_cmd)
        cmake_cmd.extend(cmake_args)
        isolation_print_command(' '.join(cmake_cmd))
        #if last_env is not None:
        #    cmake_cmd = [last_env] + cmake_cmd
        try:
            run_command_colorized(cmake_cmd, build_dir, quiet, env=env)
        except subprocess.CalledProcessError as e:
            # remove Makefile to force CMake invocation next time
            os.remove(makefile)
            raise
    else:
        print('Makefile exists, skipping explicit cmake invocation...')
        # Check to see if cmake needs to be run via make
        make_check_cmake_cmd = ['make', 'cmake_check_build_system']
        isolation_print_command(' '.join(make_check_cmake_cmd), build_dir)
        #if last_env is not None:
        #    make_check_cmake_cmd = [last_env] + make_check_cmake_cmd
        run_command_colorized(
            make_check_cmake_cmd, build_dir, quiet, env=env
        )

    # Run make
    make_cmd = ['make', '-j' + str(jobs), '-l' + str(jobs)]
    make_cmd.extend(make_args)
    isolation_print_command(' '.join(make_cmd), build_dir)
    #if last_env is not None:
    #    make_cmd = [last_env] + make_cmd
    run_command(make_cmd, build_dir, quiet, env=env)

    # Make install
    if install:
        make_install_cmd = ['make', 'install']
        isolation_print_command(' '.join(make_install_cmd), build_dir)
        #if last_env is not None:
        #    make_install_cmd = [last_env] + make_install_cmd
        run_command(make_install_cmd, build_dir, quiet)
コード例 #10
0
ファイル: builder.py プロジェクト: akshararai/HERMES_qp
def build_catkin_package(
    path,
    package,
    workspace,
    buildspace,
    develspace,
    installspace,
    install,
    force_cmake,
    quiet,
    last_env,
    cmake_args,
    make_args,
    destdir=None,
):
    cprint("Processing @{cf}catkin@| package: '@!@{bf}" + package.name + "@|'")

    # Make the build dir
    build_dir = _check_build_dir(package.name, workspace, buildspace)

    # Check last_env
    if last_env is not None:
        cprint(blue_arrow + " Building with env: " + "'{0}'".format(last_env))

    # Check for Makefile and maybe call cmake
    makefile = os.path.join(build_dir, "Makefile")
    if not os.path.exists(makefile) or force_cmake:
        package_dir = os.path.dirname(package.filename)
        if not os.path.exists(os.path.join(package_dir, "CMakeLists.txt")):
            export_tags = [e.tagname for e in package.exports]
            if "metapackage" not in export_tags:
                print(colorize_line('Error: Package "%s" does not have a CMakeLists.txt file' % package.name))
                sys.exit("Can not build catkin package without CMakeLists.txt file")
            # generate CMakeLists.txt for metpackages without one
            print(colorize_line('Warning: metapackage "%s" should have a CMakeLists.txt file' % package.name))
            cmake_code = configure_file(
                get_metapackage_cmake_template_path(),
                {"name": package.name, "metapackage_arguments": 'DIRECTORY "%s"' % package_dir},
            )
            cmakelists_txt = os.path.join(build_dir, "CMakeLists.txt")
            with open(cmakelists_txt, "w") as f:
                f.write(cmake_code)
            package_dir = build_dir

        # Run cmake
        cmake_cmd = [
            "cmake",
            package_dir,
            "-DCATKIN_DEVEL_PREFIX=" + develspace,
            "-DCMAKE_INSTALL_PREFIX=" + installspace,
        ]
        cmake_cmd.extend(cmake_args)
        add_env = get_additional_environment(install, destdir, installspace)
        isolation_print_command(" ".join(cmake_cmd), build_dir, add_env=add_env)
        if last_env is not None:
            cmake_cmd = [last_env] + cmake_cmd
        try:
            run_command_colorized(cmake_cmd, build_dir, quiet, add_env=add_env)
        except subprocess.CalledProcessError as e:
            if os.path.exists(makefile):
                # remove Makefile to force CMake invocation next time
                os.remove(makefile)
            raise
    else:
        print("Makefile exists, skipping explicit cmake invocation...")
        # Check to see if cmake needs to be run via make
        make_check_cmake_cmd = ["make", "cmake_check_build_system"]
        add_env = get_additional_environment(install, destdir, installspace)
        isolation_print_command(" ".join(make_check_cmake_cmd), build_dir, add_env=add_env)
        if last_env is not None:
            make_check_cmake_cmd = [last_env] + make_check_cmake_cmd
        run_command_colorized(make_check_cmake_cmd, build_dir, quiet, add_env=add_env)

    # Run make
    make_cmd = ["make"]
    make_cmd.extend(handle_make_arguments(make_args, force_single_threaded_when_running_tests=True))
    isolation_print_command(" ".join(make_cmd), build_dir)
    if last_env is not None:
        make_cmd = [last_env] + make_cmd
    run_command(make_cmd, build_dir, quiet)

    # Make install
    if install:
        if has_make_target(build_dir, "install"):
            make_install_cmd = ["make", "install"]
            isolation_print_command(" ".join(make_install_cmd), build_dir)
            if last_env is not None:
                make_install_cmd = [last_env] + make_install_cmd
            run_command(make_install_cmd, build_dir, quiet)
        else:
            print(fmt('@{yf}Package has no "@{boldon}install@{boldoff}" target, skipping "make install" invocation...'))
コード例 #11
0
def build_catkin_package(path, package, workspace, buildspace, develspace,
                         installspace, install, jobs, force_cmake, quiet,
                         cmake_args, make_args, catkin_python_path):
    cprint("Processing @{cf}catkin@| package: '@!@{bf}" + package.name + "@|'")

    # Make the build dir
    build_dir = _check_build_dir(package.name, workspace, buildspace)

    # Help find catkin cmake and python
    env = os.environ.copy()
    try:
        env['PYTHONPATH'] = env['PYTHONPATH'] + os.pathsep + catkin_python_path
    except KeyError:
        env['PYTHONPATH'] = catkin_python_path

    # Check for Makefile and maybe call cmake
    makefile = os.path.join(build_dir, 'Makefile')
    # check if toolchain.cmake, config.cmake exist
    toolchain_cmd = "-DCMAKE_TOOLCHAIN_FILE=%s" % os.path.join(
        workspace, 'toolchain.cmake') if os.path.isfile(
            os.path.join(workspace, 'toolchain.cmake')) else None
    config_cmd = "-C%s" % os.path.join(
        workspace, 'config.cmake') if os.path.isfile(
            os.path.join(workspace, 'config.cmake')) else None
    if not os.path.exists(makefile) or force_cmake:
        package_dir = os.path.dirname(package.filename)
        if not os.path.exists(os.path.join(package_dir, 'CMakeLists.txt')):
            export_tags = [e.tagname for e in package.exports]
            if 'metapackage' not in export_tags:
                print(
                    colorize_line(
                        'Error: Package "%s" does not have a CMakeLists.txt file'
                        % package.name))
                raise RuntimeError(
                    'Can not build catkin package without CMakeLists.txt file')
            # generate CMakeLists.txt for metpackages without one
            print(
                colorize_line(
                    'Warning: metapackage "%s" should have a CMakeLists.txt file'
                    % package.name))
            cmake_code = configure_file(
                get_metapackage_cmake_template_path(), {
                    'name': package.name,
                    'metapackage_arguments': 'DIRECTORY "%s"' % package_dir
                })
            cmakelists_txt = os.path.join(build_dir, 'CMakeLists.txt')
            with open(cmakelists_txt, 'w') as f:
                f.write(cmake_code)
            package_dir = build_dir

        # Run cmake
        cmake_cmd = [
            'cmake',
            package_dir,
        ]
        if toolchain_cmd:
            cmake_cmd.append(toolchain_cmd)
        if config_cmd:
            cmake_cmd.append(config_cmd)
        cmake_cmd.extend(cmake_args)
        isolation_print_command(' '.join(cmake_cmd))
        #if last_env is not None:
        #    cmake_cmd = [last_env] + cmake_cmd
        try:
            run_command_colorized(cmake_cmd, build_dir, quiet, env=env)
        except subprocess.CalledProcessError as e:
            # remove Makefile to force CMake invocation next time
            os.remove(makefile)
            raise
    else:
        print('Makefile exists, skipping explicit cmake invocation...')
        # Check to see if cmake needs to be run via make
        make_check_cmake_cmd = ['make', 'cmake_check_build_system']
        isolation_print_command(' '.join(make_check_cmake_cmd), build_dir)
        #if last_env is not None:
        #    make_check_cmake_cmd = [last_env] + make_check_cmake_cmd
        run_command_colorized(make_check_cmake_cmd, build_dir, quiet, env=env)

    # Run make
    make_cmd = ['make', '-j' + str(jobs), '-l' + str(jobs)]
    make_cmd.extend(make_args)
    isolation_print_command(' '.join(make_cmd), build_dir)
    #if last_env is not None:
    #    make_cmd = [last_env] + make_cmd
    run_command(make_cmd, build_dir, quiet, env=env)

    # Make install
    if install:
        make_install_cmd = ['make', 'install']
        isolation_print_command(' '.join(make_install_cmd), build_dir)
        #if last_env is not None:
        #    make_install_cmd = [last_env] + make_install_cmd
        run_command(make_install_cmd, build_dir, quiet)