@@ -41,7 +41,7 @@ def mk_quote_string_for_target(value):
41
41
"""
42
42
mk_quote_string_for_target(target_name) -> str
43
43
44
- Return a quoted form of the given target_name suitable for including in a
44
+ Return a quoted form of the given target_name suitable for including in a
45
45
Makefile as a target name.
46
46
"""
47
47
@@ -340,7 +340,7 @@ def write_library_table(self, output_path, enabled_optional_components):
340
340
# Compute the llvm-config "component name". For historical reasons,
341
341
# this is lowercased based on the library name.
342
342
llvmconfig_component_name = c .get_llvmconfig_component_name ()
343
-
343
+
344
344
# Get the library name, or None for LibraryGroups.
345
345
if c .type_name == 'Library' or c .type_name == 'OptionalLibrary' :
346
346
library_name = c .get_prefixed_library_name ()
@@ -430,14 +430,14 @@ def get_required_libraries_for_component(self, ci, traverse_groups = False):
430
430
traversed to include their required libraries.
431
431
"""
432
432
433
- assert ci .type_name in ('Library' , 'LibraryGroup' , 'TargetGroup' )
433
+ assert ci .type_name in ('Library' , 'OptionalLibrary' , ' LibraryGroup' , 'TargetGroup' )
434
434
435
435
for name in ci .required_libraries :
436
436
# Get the dependency info.
437
437
dep = self .component_info_map [name ]
438
438
439
439
# If it is a library, yield it.
440
- if dep .type_name == 'Library' :
440
+ if dep .type_name == 'Library' or dep . type_name == 'OptionalLibrary' :
441
441
yield dep
442
442
continue
443
443
@@ -492,7 +492,7 @@ def get_fragment_dependencies(self):
492
492
if (path .startswith (self .source_root ) and os .path .exists (path )):
493
493
yield path
494
494
495
- def write_cmake_fragment (self , output_path ):
495
+ def write_cmake_fragment (self , output_path , enabled_optional_components ):
496
496
"""
497
497
write_cmake_fragment(output_path) -> None
498
498
@@ -561,8 +561,13 @@ def write_cmake_fragment(self, output_path):
561
561
# names to required libraries, in a way that is easily accessed from CMake.
562
562
""" )
563
563
for ci in self .ordered_component_infos :
564
- # We only write the information for libraries currently.
565
- if ci .type_name != 'Library' :
564
+ # Skip optional components which are not enabled.
565
+ if ci .type_name == 'OptionalLibrary' \
566
+ and ci .name not in enabled_optional_components :
567
+ continue
568
+
569
+ # We only write the information for certain components currently.
570
+ if ci .type_name not in ('Library' , 'OptionalLibrary' ):
566
571
continue
567
572
568
573
f .write ("""\
@@ -573,7 +578,7 @@ def write_cmake_fragment(self, output_path):
573
578
574
579
f .close ()
575
580
576
- def write_cmake_exports_fragment (self , output_path ):
581
+ def write_cmake_exports_fragment (self , output_path , enabled_optional_components ):
577
582
"""
578
583
write_cmake_exports_fragment(output_path) -> None
579
584
@@ -595,8 +600,13 @@ def write_cmake_exports_fragment(self, output_path):
595
600
# dependencies of libraries imported from LLVM.
596
601
""" )
597
602
for ci in self .ordered_component_infos :
603
+ # Skip optional components which are not enabled.
604
+ if ci .type_name == 'OptionalLibrary' \
605
+ and ci .name not in enabled_optional_components :
606
+ continue
607
+
598
608
# We only write the information for libraries currently.
599
- if ci .type_name != 'Library' :
609
+ if ci .type_name not in ( 'Library' , 'OptionalLibrary' ) :
600
610
continue
601
611
602
612
# Skip disabled targets.
@@ -905,9 +915,11 @@ def main():
905
915
906
916
# Write out the cmake fragment, if requested.
907
917
if opts .write_cmake_fragment :
908
- project_info .write_cmake_fragment (opts .write_cmake_fragment )
918
+ project_info .write_cmake_fragment (opts .write_cmake_fragment ,
919
+ opts .optional_components )
909
920
if opts .write_cmake_exports_fragment :
910
- project_info .write_cmake_exports_fragment (opts .write_cmake_exports_fragment )
921
+ project_info .write_cmake_exports_fragment (opts .write_cmake_exports_fragment ,
922
+ opts .optional_components )
911
923
912
924
# Configure target definition files, if requested.
913
925
if opts .configure_target_def_files :
0 commit comments