def relocate_deps_linux(target_src, target_dst, config):
    """
  See relocate_deps(). Linux implementation.
  """
    NEW_RPATH = '$ORIGIN/../lib'

    # Make sure we have the chrpath command available in the Linux build.
    check_for_command('chrpath')

    # Copy the linked libraries.
    dep_extractor = DependencyExtractor()
    dep_extractor.set_library_filter(
        lambda path: False if PAT_LINUX_LIB_EXCLUDE.search(path) else True)
    libs = dep_extractor.extract_deps(target_src)
    for lib_src in libs:
        lib_dst = os.path.join(config[ARTIFACT_LIB_DIR],
                               os.path.basename(lib_src))
        copy_file(lib_src, lib_dst)
        # We have to set the RUNPATH of the shared objects as well for transitive
        # dependencies to be properly resolved. $ORIGIN is always relative to the
        # running executable.
        chrpath(lib_dst, NEW_RPATH)

    # We must also update the RUNPATH of the executable itself to look for its
    # dependencies in a relative location.
    chrpath(target_dst, NEW_RPATH)
def get_resolved_deps(target):
    """
  Return a list of resolved library dependencies for the given target.
  """
    if IS_LINUX:
        return DependencyExtractor().extract_deps(target)
    if IS_MACOS:
        return get_resolved_dep_library_paths_macos(target).values()
    raise NotImplementedError("not implemented")
Exemplo n.º 3
0
def create_dependency_extractor():
    dep_extractor = DependencyExtractor()
    dep_extractor.set_library_filter(is_lib_whitelisted)
    dep_extractor.set_expand_symlinks(True)
    return dep_extractor