aboutsummaryrefslogtreecommitdiff
path: root/utils/llvm-build
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-11-29 00:06:50 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-11-29 00:06:50 +0000
commit5086de6f878187f4419351b2b24c766e0d0d25dc (patch)
tree104ce0a260597dc69a9619604cf36bcea93df0da /utils/llvm-build
parent7ca7b53804c75d5c785f89e348f16930e242b973 (diff)
llvmbuild/CMake: Update CMake output fragment to include explicit library
dependency information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145328 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/llvm-build')
-rw-r--r--utils/llvm-build/llvmbuild/componentinfo.py17
-rw-r--r--utils/llvm-build/llvmbuild/main.py49
2 files changed, 66 insertions, 0 deletions
diff --git a/utils/llvm-build/llvmbuild/componentinfo.py b/utils/llvm-build/llvmbuild/componentinfo.py
index b9a2d4f1dc..079102f676 100644
--- a/utils/llvm-build/llvmbuild/componentinfo.py
+++ b/utils/llvm-build/llvmbuild/componentinfo.py
@@ -138,6 +138,23 @@ class LibraryComponentInfo(ComponentInfo):
def get_library_name(self):
return self.library_name or self.name
+ def get_prefixed_library_name(self):
+ """
+ get_prefixed_library_name() -> str
+
+ Return the library name prefixed by the project name. This is generally
+ what the library name will be on disk.
+ """
+
+ basename = self.get_library_name()
+
+ # FIXME: We need to get the prefix information from an explicit project
+ # object, or something.
+ if basename in ('gtest', 'gtest_main'):
+ return basename
+
+ return 'LLVM%s' % basename
+
def get_llvmconfig_component_name(self):
return self.get_library_name().lower()
diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py
index 21cf392882..c77ffcd14b 100644
--- a/utils/llvm-build/llvmbuild/main.py
+++ b/utils/llvm-build/llvmbuild/main.py
@@ -354,6 +354,37 @@ class LLVMProjectInfo(object):
print >>f, '};'
f.close()
+ def get_required_libraries_for_component(self, ci, traverse_groups = False):
+ """
+ get_required_libraries_for_component(component_info) -> iter
+
+ Given a Library component info descriptor, return an iterator over all
+ of the directly required libraries for linking with this component. If
+ traverse_groups is True, then library and target groups will be
+ traversed to include their required libraries.
+ """
+
+ assert ci.type_name in ('Library', 'LibraryGroup', 'TargetGroup')
+
+ for name in ci.required_libraries:
+ # Get the dependency info.
+ dep = self.component_info_map[name]
+
+ # If it is a library, yield it.
+ if dep.type_name == 'Library':
+ yield dep
+ continue
+
+ # Otherwise if it is a group, yield or traverse depending on what
+ # was requested.
+ if dep.type_name in ('LibraryGroup', 'TargetGroup'):
+ if not traverse_groups:
+ yield dep
+ continue
+
+ for res in self.get_required_libraries_for_component(dep, True):
+ yield res
+
def get_fragment_dependencies(self):
"""
get_fragment_dependencies() -> iter
@@ -447,6 +478,24 @@ configure_file(\"%s\"
${CMAKE_CURRENT_BINARY_DIR}/DummyConfigureOutput)""" % (
cmake_quote_path(dep),)
+ # Write the properties we use to encode the required library dependency
+ # information in a form CMake can easily use directly.
+ print >>f, """
+# Explicit library dependency information.
+#
+# The following property assignments effectively create a map from component
+# names to required libraries, in a way that is easily accessed from CMake."""
+ for ci in self.ordered_component_infos:
+ # We only write the information for libraries currently.
+ if ci.type_name != 'Library':
+ continue
+
+ print >>f, """\
+set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_%s %s)""" % (
+ ci.get_prefixed_library_name(), " ".join(sorted(
+ dep.get_prefixed_library_name()
+ for dep in self.get_required_libraries_for_component(ci))))
+
f.close()
def write_make_fragment(self, output_path):