Ejemplo n.º 1
0
 def __init__(self, library_path, bru_modules_path):
     # different module_versions may end up with different sets if
     # #include files, so which modules should we search here? All?
     # Only the latest known version of each module? All modules
     # whose tar.gz was downloaded already anyway?
     self.include2modules = {} 
     library = get_library()
     for module in get_all_modules(library_path):
         print('scanning #includes for', module)
         for version in library.get_all_versions(module):
             formula = library.load_formula(module, version)
             brulib.module_downloader.get_urls(library, formula, bru_modules_path)
             includes = [two_component_path.path 
                 for two_component_path in collect_includes(formula)]
             includes.sort()
             #print("includes for ", module, ": ", includes)
             self._remember_includes(module, includes)
Ejemplo n.º 2
0
 def __init__(self, library_path, bru_modules_path):
     # different module_versions may end up with different sets if
     # #include files, so which modules should we search here? All?
     # Only the latest known version of each module? All modules
     # whose tar.gz was downloaded already anyway?
     self.include2modules = {}
     library = get_library()
     for module in get_all_modules(library_path):
         print('scanning #includes for', module)
         for version in library.get_all_versions(module):
             formula = library.load_formula(module, version)
             brulib.module_downloader.get_urls(library, formula,
                                               bru_modules_path)
             includes = [
                 two_component_path.path
                 for two_component_path in collect_includes(formula)
             ]
             includes.sort()
             #print("includes for ", module, ": ", includes)
             self._remember_includes(module, includes)
Ejemplo n.º 3
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)
Ejemplo n.º 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)