示例#1
0
def main():
    parser = CreateOptionParser()
    options, args = parser.parse_args()
    if len(args) != 1:
        Die('Exactly one top-level source file must be specified.')
    start_path = args[0]
    roots = options.roots or DefaultRoots()
    sources = ReadSources(roots=roots, source_files=[start_path])
    start_source = sources[start_path]
    WalkDeps(sources, start_source)
示例#2
0
def CheckChromeVox(changed_files=None):
    if changed_files is not None:
        changed_files_set = frozenset(
            (os.path.relpath(path) for path in changed_files))
        if len(changed_files_set) == 0:
            return (True, '')
    else:
        changed_files_set = None
    ret_success = True
    ret_output = ''
    roots = [
        CVoxPath(),
        CVoxPath('../common'),
        os.path.relpath(
            os.path.join(
                _CHROME_SOURCE_DIR,
                'third_party/chromevox/third_party/closure-library/'
                'closure/goog'))
    ]
    sources = ReadSources(roots,
                          need_source_text=True,
                          exclude=[re.compile('testing')])
    work_pool = pool.Pool(len(_TOP_LEVEL_SCRIPTS))
    try:
        results = []
        for top_level in _TOP_LEVEL_SCRIPTS:
            tl_files, externs = top_level
            bundle = Bundle()
            CalcDeps(bundle, sources, tl_files)
            bundle.Add((sources[name] for name in tl_files))
            ordered_paths = list(bundle.GetInPaths())
            if (changed_files_set is not None
                    and changed_files_set.isdisjoint(ordered_paths + externs)):
                continue
            print 'Compiling %s' % ','.join(tl_files)
            results.append([
                tl_files,
                work_pool.apply_async(_Compile, args=[ordered_paths, externs])
            ])
        for result in results:
            tl_files = result[0]
            success, output = result[1].get()
            if not success:
                ret_output += '\nFrom compiling %s:\n%s\n' % (
                    ','.join(tl_files), output)
                ret_success = False
        work_pool.close()
    except:
        work_pool.terminate()
        raise
    finally:
        work_pool.join()
    return (ret_success, ret_output)