示例#1
0
def get_arg_modules(module, version):
    """ returns list of (module,version) tuples given cmdline args.
        If version is None then we pick the latest available version
        of a module
        If module ends with '*' then we glob all matching modules """
    library = get_library()
    if module.endswith('*'):
        lib_dir = './library'
        matching_dirs = glob.glob(os.path.join(lib_dir, module))
        modules = [os.path.relpath(dir, start=lib_dir) for dir in matching_dirs]
        return [(module, version or library.get_latest_version_of(module)) 
                for module in modules]
    else:
        version = version or library.get_latest_version_of(module)
        return [(module, version)]
示例#2
0
def get_arg_modules(module, version):
    """ returns list of (module,version) tuples given cmdline args.
        If version is None then we pick the latest available version
        of a module
        If module ends with '*' then we glob all matching modules """
    library = get_library()
    if module.endswith('*'):
        lib_dir = './library'
        matching_dirs = glob.glob(os.path.join(lib_dir, module))
        modules = [
            os.path.relpath(dir, start=lib_dir) for dir in matching_dirs
        ]
        return [(module, version or library.get_latest_version_of(module))
                for module in modules]
    else:
        version = version or library.get_latest_version_of(module)
        return [(module, version)]
示例#3
0
 def annotate_with_latest_version(modules):
     dependency2version = collections.OrderedDict()
     for module in sorted(modules):
         dependency2version[module] = library.get_latest_version_of(module)
     return dependency2version
示例#4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("module", help = "e.g. boost-asio, or 'boost*'")
    parser.add_argument("--version", '-v', required = False, default = None,
        help = "version of module, e.g. 1.57.0, defaults to latest if unspecified")
    parser.add_argument('--recursive', '-r', action='store_true', 
        help='recursively find dependencies')
    args = parser.parse_args()
    index = IncludeFileIndex('./library', './bru_modules')
    library = get_library()

    todo_module_version = get_arg_modules(args.module, args.version)
    done_modules = set()
    while len(todo_module_version) > 0:
        module, version = todo_module_version.pop()
        if module in done_modules:
            continue
        
        print("scanning module {} version {}".format(module, version))
        formula = library.load_formula(module, version)
        (deps, missing_includes) = scan_deps(formula, index)
        print("dependencies: ")
        for dep in sorted(deps):
            # show for each dep if it was git added alrdy
            print(dep, '' if is_in_scm(os.path.join('library', dep)) else '*')
        if len(missing_includes) > 0:
            print("missing includes: ", missing_includes)

        # now add the computed dependencies to the formula, unless
        # the formula alrdy epxlicitly lists deps:
        if not 'dependencies' in formula:
            def annotate_with_latest_version(modules):
                dependency2version = collections.OrderedDict()
                for module in sorted(modules):
                    dependency2version[module] = library.get_latest_version_of(module)
                return dependency2version

            # remove deps we consider builtin, like C++ stdlib and C lib. 
            # This here is kinda fuzzy and differs between OSs.
            builtin_deps = set([
                'llvm-libcxx'
            ])
            deps = deps.difference(builtin_deps)

            formula['dependencies'] = annotate_with_latest_version(deps)
            print(formula)
            library.save_formula(formula)

        # also add the deps to the gyp in a sloppy & ad-hoc way for now:
        # this works sort of ok for modules with a single target only (e.g.
        # the boost modules after boost_import.py): add the all found
        # deps to the first gyp target's dependencies.
        if len(deps) > 0:
            gyp = library.load_gyp(formula)
            first_target = gyp['targets'][0]
            if not 'dependencies' in first_target:
                # Todo: reconsider the ':*' dependency on all targets in 
                # upstream modules. May wanna exclude test targets from this,
                # which we cannot do here easily though. Maybe bru.py can
                # exclude test targets later on? Test targets give extra
                # confidence that things are wired up fine, but will increase
                # initial compile times after 'bru install'.
                first_target['dependencies'] = [
                    "../{}/{}.gyp:*".format(dep, dep) for dep in deps]
                library.save_gyp(formula, gyp)

        done_modules.add(module)

        if args.recursive:
            direct_dependency_modules = list(item for item in deps)
            todo_module_version += ((module, library.get_latest_version_of(module)) 
                                   for module in direct_dependency_modules)

    if args.recursive:
        print("recursive module dependencies: ", done_modules)
示例#5
0
 def annotate_with_latest_version(modules):
     dependency2version = collections.OrderedDict()
     for module in sorted(modules):
         dependency2version[module] = library.get_latest_version_of(
             module)
     return dependency2version
示例#6
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("module", help="e.g. boost-asio, or 'boost*'")
    parser.add_argument(
        "--version",
        '-v',
        required=False,
        default=None,
        help="version of module, e.g. 1.57.0, defaults to latest if unspecified"
    )
    parser.add_argument('--recursive',
                        '-r',
                        action='store_true',
                        help='recursively find dependencies')
    args = parser.parse_args()
    index = IncludeFileIndex('./library', './bru_modules')
    library = get_library()

    todo_module_version = get_arg_modules(args.module, args.version)
    done_modules = set()
    while len(todo_module_version) > 0:
        module, version = todo_module_version.pop()
        if module in done_modules:
            continue

        print("scanning module {} version {}".format(module, version))
        formula = library.load_formula(module, version)
        (deps, missing_includes) = scan_deps(formula, index)
        print("dependencies: ")
        for dep in sorted(deps):
            # show for each dep if it was git added alrdy
            print(dep, '' if is_in_scm(os.path.join('library', dep)) else '*')
        if len(missing_includes) > 0:
            print("missing includes: ", missing_includes)

        # now add the computed dependencies to the formula, unless
        # the formula alrdy epxlicitly lists deps:
        if not 'dependencies' in formula:

            def annotate_with_latest_version(modules):
                dependency2version = collections.OrderedDict()
                for module in sorted(modules):
                    dependency2version[module] = library.get_latest_version_of(
                        module)
                return dependency2version

            # remove deps we consider builtin, like C++ stdlib and C lib.
            # This here is kinda fuzzy and differs between OSs.
            builtin_deps = set(['llvm-libcxx'])
            deps = deps.difference(builtin_deps)

            formula['dependencies'] = annotate_with_latest_version(deps)
            print(formula)
            library.save_formula(formula)

        # also add the deps to the gyp in a sloppy & ad-hoc way for now:
        # this works sort of ok for modules with a single target only (e.g.
        # the boost modules after boost_import.py): add the all found
        # deps to the first gyp target's dependencies.
        if len(deps) > 0:
            gyp = library.load_gyp(formula)
            first_target = gyp['targets'][0]
            if not 'dependencies' in first_target:
                # Todo: reconsider the ':*' dependency on all targets in
                # upstream modules. May wanna exclude test targets from this,
                # which we cannot do here easily though. Maybe bru.py can
                # exclude test targets later on? Test targets give extra
                # confidence that things are wired up fine, but will increase
                # initial compile times after 'bru install'.
                first_target['dependencies'] = [
                    "../{}/{}.gyp:*".format(dep, dep) for dep in deps
                ]
                library.save_gyp(formula, gyp)

        done_modules.add(module)

        if args.recursive:
            direct_dependency_modules = list(item for item in deps)
            todo_module_version += ((module,
                                     library.get_latest_version_of(module))
                                    for module in direct_dependency_modules)

    if args.recursive:
        print("recursive module dependencies: ", done_modules)