'main command-line entrypoint'

def main(self):

    parser = OptionParser(usage='usage:    %prog    [options]    [PACKAGE]...', description='rosmake    recursively    builds    all    dependencies    before    building    a    package', prog='rosmake')
    parser.add_option('--test-only', dest='test_only', default=False, action='store_true', help='only    run    tests')
    parser.add_option('-t', dest='test', default=False, action='store_true', help='build    and    test    packages')
    parser.add_option('-a', '--all', dest='build_all', default=False, action='store_true', help='select    all    packages')
    parser.add_option('-i', '--mark-installed', dest='mark_installed', default=False, action='store_true', help='On    successful    build,    mark    specified    packages    as    installed    with    ROS_NOBUILD')
    parser.add_option('-u', '--unmark-installed', dest='unmark_installed', default=False, action='store_true', help='Remove    ROS_NOBUILD    from    the    specified    packages.        This    will    not    build    anything.')
    parser.add_option('-v', dest='verbose', default=False, action='store_true', help='display    errored    builds')
    parser.add_option('-r', '-k', '--robust', dest='best_effort', default=False, action='store_true', help='do    not    stop    build    on    error')
    parser.add_option('--build-everything', dest='robust', default=False, action='store_true', help='build    all    packages    regardless    of    errors')
    parser.add_option('-V', dest='full_verbose', default=False, action='store_true', help='display    all    builds')
    parser.add_option('-s', '--specified-only', dest='specified_only', default=False, action='store_true', help='only    build    packages    specified    on    the    command    line')
    parser.add_option('--buildtest', dest='buildtest', action='append', help='package    to    buildtest')
    parser.add_option('--buildtest1', dest='buildtest1', action='append', help='package    to    buildtest1')
    parser.add_option('--output', dest='output_dir', action='store', help='where    to    output    results')
    parser.add_option('--pre-clean', dest='pre_clean', action='store_true', help='run    make    clean    first')
    parser.add_option('--bootstrap', dest='bootstrap', default=False, action='store_true', help='DEPRECATED,    UNUSED')
    parser.add_option('--disable-logging', dest='logging_enabled', default=True, action='store_false', help='turn    off    all    logs')
    parser.add_option('--target', dest='target', action='store', help='run    make    with    this    target')
    parser.add_option('--pjobs', dest='ros_parallel_jobs', type='int', action='store', help='Override    ROS_PARALLEL_JOBS    environment    variable    with    this    number    of    jobs.')
    parser.add_option('--threads', dest='threads', type='int', default=os.environ.get('ROSMAKE_THREADS', parallel_build.num_cpus()), action='store', help='Build    up    to    N    packages    in    parallel')
    parser.add_option('--profile', dest='print_profile', default=False, action='store_true', help='print    time    profile    after    build')
    parser.add_option('--skip-blacklist', dest='skip_blacklist', default=False, action='store_true', help='skip    packages    containing    a    file    called    ROS_BUILD_BLACKLIST    (Default    behavior    will    ignore    the    presence    of    ROS_BUILD_BLACKLIST)')
    parser.add_option('--skip-blacklist-osx', dest='skip_blacklist_osx', default=False, action='store_true', help='deprecated    option.    it    will    do    nothing,    please    use    platform    declarations    and    --require-platform    instead')
    parser.add_option('--status-rate', dest='status_update_rate', action='store', help='How    fast    to    update    the    status    bar    in    Hz.        Default:    5Hz')
    (options, args) = parser.parse_args()
    self.printer.print_all('rosmake    starting...')
    rospack = self.rospack
    rosstack = self.rosstack
    testing = False
    building = True
    if options.test_only:
        testing = True
        building = False
    elif options.test:
        testing = True
    if options.ros_parallel_jobs:
        self.ros_parallel_jobs = options.ros_parallel_jobs
    self.robust_build = options.robust
    self.best_effort = options.best_effort
    self.threads = options.threads
    self.skip_blacklist = options.skip_blacklist
    if options.skip_blacklist_osx:
        self.printer.print_all('Option    --skip-blacklist-osx    is    deprecated.    It    will    do    nothing,    please    use    platform    declarations    and    --require-platform    instead')
    self.logging_enabled = options.logging_enabled
    self.printer.full_verbose = options.full_verbose
    self.printer.verbose = options.verbose
    if options.status_update_rate:
        if (float(options.status_update_rate) > 0):
            self.printer.duration = (1.0 / float(options.status_update_rate))
        else:
            self.printer.duration = 0
    packages = []
    if options.build_all:
        packages = [x for x in rospack.list() if (not self.rospack.get_manifest(x).is_catkin)]
        self.printer.print_all('Building    all    packages')
    else:
        if options.buildtest:
            for p in options.buildtest:
                packages.extend(self.rospack.get_depends_on(p))
                self.printer.print_all(('buildtest    requested    for    package    %s    adding    it    and    all    dependent    packages:    ' % p))
        if options.buildtest1:
            for p in options.buildtest1:
                packages.extend(self.rospack.get_depends_on(p, implicit=False))
                self.printer.print_all(('buildtest1    requested    for    package    %s    adding    it    and    all    depends-on1    packages:    ' % p))
    if ((len(packages) == 0) and (len(args) == 0)):
        p = os.path.basename(os.path.abspath('.'))
        try:
            if os.path.samefile(rospack.get_path(p), '.'):
                packages = [p]
                self.printer.print_all(('No    package    specified.        Building    %s' % packages))
            else:
                self.printer.print_all(("No    package    selected    and    the    current    directory    is    not    the    correct    path    for    package    '%s'." % p))
        except rospkg.ResourceNotFound as ex:
            try:
                stack_dir = rosstack.get_path(p)
                if os.path.samefile(stack_dir, '.'):
                    packages = [p]
                    self.printer.print_all(('No    package    specified.        Building    stack    %s' % packages))
                else:
                    self.printer.print_all(("No    package    or    stack    arguments    and    the    current    directory    is    not    the    correct    path    for    stack    '%s'.    Stack    directory    is:    %s." % (p, rosstack.get_path(p))))
            except:
                self.printer.print_all(("No    package    or    stack    specified.        And    current    directory    '%s'    is    not    a    package    name    or    stack    name." % p))
    else:
        packages.extend(args)
    self.printer.print_all(('Packages    requested    are:    %s' % packages))
    if self.logging_enabled:
        date_time_stamp = ('rosmake_output-' + time.strftime('%Y%m%d-%H%M%S'))
        if options.output_dir:
            self.log_dir = os.path.abspath(options.output_dir)
        else:
            self.log_dir = os.path.join(rospkg.get_ros_home(), 'rosmake', date_time_stamp)
        self.printer.print_all(('Logging    to    directory    %s' % self.log_dir))
        if (os.path.exists(self.log_dir) and (not os.path.isdir(self.log_dir))):
            self.printer.print_all(('Log    destination    %s    is    a    file;    please    remove    it    or    choose    a    new    destination' % self.log_dir))
            sys.exit(1)
        if (not os.path.exists(self.log_dir)):
            self.printer.print_verbose(("%s    doesn't    exist:    creating" % self.log_dir))
            makedirs_with_parent_perms(self.log_dir)
        self.printer.print_verbose('Finished    setting    up    logging')
    stacks_arguments = [s for s in packages if (s in rosstack.list())]
    (self.specified_packages, self.rejected_packages) = rospkg.expand_to_packages(packages, rospack, rosstack)
    self.printer.print_all(('Expanded    args    %s    to:\n%s' % (packages, self.specified_packages)))
    if self.rejected_packages:
        self.printer.print_all(('WARNING:    The    following    args    could    not    be    parsed    as    stacks    or    packages:    %s' % self.rejected_packages))
    if ((len(self.specified_packages) + len(stacks_arguments)) == 0):
        self.printer.print_all('ERROR:    No    arguments    could    be    parsed    into    valid    package    or    stack    names.')
        self.printer.running = False
        return False
    if options.unmark_installed:
        for p in self.specified_packages:
            if self.flag_tracker.remove_nobuild(p):
                self.printer.print_all(('Removed    ROS_NOBUILD    from    %s' % p))
        self.printer.running = False
        return True
    required_packages = self.specified_packages[:]
    for s in stacks_arguments:
        if (not rosstack.packages_of(s)):
            for d in rosstack.get_depends(s, implicit=False):
                try:
                    required_packages.extend(rosstack.packages_of(d))
                except ResourceNotFound:
                    self.printer.print_all(('WARNING:    The    stack    "%s"    was    not    found.    We    will    assume    it    is    using    the    new    buildsystem    and    try    to    continue...' % d))
    required_packages = list(set(required_packages))
    buildable_packages = []
    for p in required_packages:
        (buildable, error, str) = self.flag_tracker.can_build(p, self.skip_blacklist, [], False)
        if buildable:
            buildable_packages.append(p)
    counter = 0
    for p in required_packages:
        counter = (counter + 1)
        self.printer.print_verbose(('Processing    %s    and    all    dependencies(%d    of    %d    requested)' % (p, counter, len(packages))))
        self.build_or_recurse(p)
    if options.specified_only:
        new_list = []
        for pkg in self.build_list:
            if (pkg in self.specified_packages):
                new_list.append(pkg)
                self.dependency_tracker = parallel_build.DependencyTracker(self.specified_packages, rospack=self.rospack)
        self.printer.print_all(('specified-only    option    was    used,    only    building    packages    %s' % new_list))
        self.build_list = new_list
    if options.pre_clean:
        build_queue = parallel_build.BuildQueue(self.build_list, parallel_build.DependencyTracker([], rospack=self.rospack), robust_build=True)
        self.parallel_build_pkgs(build_queue, 'clean', threads=options.threads)
    build_passed = True
    if building:
        self.printer.print_verbose(('Building    packages    %s' % self.build_list))
        build_queue = parallel_build.BuildQueue(self.build_list, self.dependency_tracker, robust_build=(options.robust or options.best_effort))
        if (None not in self.result.keys()):
            self.result[None] = {}
        build_passed = self.parallel_build_pkgs(build_queue, options.target, threads=options.threads)
    tests_passed = True
    if (build_passed and testing):
        self.printer.print_verbose(('Testing    packages    %s' % packages))
        build_queue = parallel_build.BuildQueue(self.specified_packages, parallel_build.DependencyTracker(self.specified_packages, rospack=self.rospack), robust_build=True)
        tests_passed = self.parallel_build_pkgs(build_queue, 'test', threads=1)
    if options.mark_installed:
        if (build_passed and tests_passed):
            for p in self.specified_packages:
                if self.flag_tracker.add_nobuild(p):
                    self.printer.print_all(('Marking    %s    as    installed    with    a    ROS_NOBUILD    file' % p))
        else:
            self.printer.print_all('All    builds    and    tests    did    not    pass    cannot    mark    packages    as    installed.    ')
    self.finish_time = time.time()
    self.generate_summary_output(self.log_dir)
    if options.print_profile:
        self.printer.print_all(self.get_profile_string())
    self.printer.running = False
    return (build_passed and tests_passed)
