Exemple #1
0
def main(action, resolve_deps, eclipse, debug, release, verbose, warnings,
         no_warnings, default_yes, catkin_args):
    """ A wrapper for catkin. """
    org_dir = os.getcwd()
    ws = Workspace()
    ws.cd_root()

    build_eclipse = False
    if action == "build":
        if debug:
            catkin_args = ("-DCMAKE_BUILD_TYPE=Debug", ) + catkin_args
        elif release:
            catkin_args = ("-DCMAKE_BUILD_TYPE=RelWithDebInfo", ) + catkin_args
        else:
            catkin_args = ("-DCMAKE_BUILD_TYPE={}".format(
                user_settings['Catkin']['DEFAULT_BUILD_TYPE']), ) + catkin_args

        if (user_settings['Catkin']['SHOW_WARNINGS_DURING_COMPILATION']
                or warnings) and not no_warnings:
            catkin_args = ("-DCMAKE_CXX_FLAGS=-Wall", ) + (
                "-DCMAKE_CXX_FLAGS=-Wextra", ) + catkin_args

        if eclipse:
            build_eclipse = True
            catkin_args = ("--force-cmake", ) + catkin_args
            catkin_args = ("-GEclipse CDT4 - Unix Makefiles", ) + catkin_args

        if verbose:
            catkin_args += ("-v", )
            catkin_args += ("--make-args VERBOSE=1 --", )

    if resolve_deps:
        ws.resolve_dependencies(default_yes=default_yes)

    os.chdir(org_dir)
    process = subprocess.Popen(["catkin", action] + list(catkin_args))
    process.wait()  # Wait for process to finish and set returncode

    if build_eclipse:
        set_eclipse_project_setting(ws.root)

    sys.exit(process.returncode)
Exemple #2
0
def create(name):
    """Create a snapshot of the current workspace."""
    suffix = "_" + time.strftime("%y%m%d")
    snapshot_name = name + suffix + user_settings['Snapshot']['FILE_ENDING']
    filename = os.path.join(os.getcwd(), snapshot_name)

    # First test whether it's safe to create a snapshot
    ws = Workspace()
    ws.test_for_changes(prompt="Are you sure you want to continue? These changes won't be included in the snapshot!")

    # Create snapshot of rosinstall
    ws.cd_root()
    ws.snapshot(filename=".rosinstall")

    # Create archive
    with open(user_settings['Snapshot']['VERSION_FILE'], "w") as f:
        f.write(user_settings['Snapshot']['SNAPSHOT_VERSION'])
    files = [('.rosinstall', 'src/.rosinstall'), '.catkin_tools', user_settings['Snapshot']['VERSION_FILE']]
    files += [os.path.join(dp, f) for dp, dn, fn in os.walk(".catkin_tools") for f in fn]
    zip_files(files, filename)
    os.remove(".rosinstall")
    os.remove(user_settings['Snapshot']['VERSION_FILE'])
    click.secho("Wrote snapshot to " + filename, fg="green")