summaryrefslogtreecommitdiff
path: root/utils/llvm-build/llvmbuild/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils/llvm-build/llvmbuild/main.py')
-rw-r--r--utils/llvm-build/llvmbuild/main.py45
1 files changed, 34 insertions, 11 deletions
diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py
index 36bca872e5f1..baecc6d89965 100644
--- a/utils/llvm-build/llvmbuild/main.py
+++ b/utils/llvm-build/llvmbuild/main.py
@@ -312,15 +312,26 @@ subdirectories = %s
f.close()
- def write_library_table(self, output_path):
+ def write_library_table(self, output_path, enabled_optional_components):
# Write out the mapping from component names to required libraries.
#
# We do this in topological order so that we know we can append the
# dependencies for added library groups.
entries = {}
for c in self.ordered_component_infos:
+ # Skip optional components which are not enabled.
+ if c.type_name == 'OptionalLibrary' \
+ and c.name not in enabled_optional_components:
+ continue
+
+ # Skip target groups which are not enabled.
+ tg = c.get_parent_target_group()
+ if tg and not tg.enabled:
+ continue
+
# Only certain components are in the table.
- if c.type_name not in ('Library', 'LibraryGroup', 'TargetGroup'):
+ if c.type_name not in ('Library', 'OptionalLibrary', \
+ 'LibraryGroup', 'TargetGroup'):
continue
# Compute the llvm-config "component name". For historical reasons,
@@ -328,10 +339,12 @@ subdirectories = %s
llvmconfig_component_name = c.get_llvmconfig_component_name()
# Get the library name, or None for LibraryGroups.
- if c.type_name == 'Library':
+ if c.type_name == 'Library' or c.type_name == 'OptionalLibrary':
library_name = c.get_prefixed_library_name()
+ is_installed = c.installed
else:
library_name = None
+ is_installed = True
# Get the component names of all the required libraries.
required_llvmconfig_component_names = [
@@ -344,7 +357,8 @@ subdirectories = %s
# Add the entry.
entries[c.name] = (llvmconfig_component_name, library_name,
- required_llvmconfig_component_names)
+ required_llvmconfig_component_names,
+ is_installed)
# Convert to a list of entries and sort by name.
entries = entries.values()
@@ -352,16 +366,16 @@ subdirectories = %s
# Create an 'all' pseudo component. We keep the dependency list small by
# only listing entries that have no other dependents.
root_entries = set(e[0] for e in entries)
- for _,_,deps in entries:
+ for _,_,deps,_ in entries:
root_entries -= set(deps)
- entries.append(('all', None, root_entries))
+ entries.append(('all', None, root_entries, True))
entries.sort()
# Compute the maximum number of required libraries, plus one so there is
# always a sentinel.
max_required_libraries = max(len(deps)
- for _,_,deps in entries) + 1
+ for _,_,deps,_ in entries) + 1
# Write out the library table.
make_install_dir(os.path.dirname(output_path))
@@ -382,18 +396,21 @@ subdirectories = %s
print >>f, ' /// The name of the library for this component (or NULL).'
print >>f, ' const char *Library;'
print >>f, ''
+ print >>f, ' /// Whether the component is installed.'
+ print >>f, ' bool IsInstalled;'
+ print >>f, ''
print >>f, '\
/// The list of libraries required when linking this component.'
print >>f, ' const char *RequiredLibraries[%d];' % (
max_required_libraries)
print >>f, '} AvailableComponents[%d] = {' % len(entries)
- for name,library_name,required_names in entries:
+ for name,library_name,required_names,is_installed in entries:
if library_name is None:
library_name_as_cstr = '0'
else:
library_name_as_cstr = '"lib%s.a"' % library_name
- print >>f, ' { "%s", %s, { %s } },' % (
- name, library_name_as_cstr,
+ print >>f, ' { "%s", %s, %d, { %s } },' % (
+ name, library_name_as_cstr, is_installed,
', '.join('"%s"' % dep
for dep in required_names))
print >>f, '};'
@@ -778,6 +795,11 @@ given by --build-root) at the same SUBPATH""",
help=("Enable the given space or semi-colon separated "
"list of targets, or all targets if not present"),
action="store", default=None)
+ group.add_option("", "--enable-optional-components",
+ dest="optional_components", metavar="NAMES",
+ help=("Enable the given space or semi-colon separated "
+ "list of optional components"),
+ action="store", default=None)
parser.add_option_group(group)
(opts, args) = parser.parse_args()
@@ -819,7 +841,8 @@ given by --build-root) at the same SUBPATH""",
# Write out the required library table, if requested.
if opts.write_library_table:
- project_info.write_library_table(opts.write_library_table)
+ project_info.write_library_table(opts.write_library_table,
+ opts.optional_components)
# Write out the make fragment, if requested.
if opts.write_make_fragment: