@@ -116,12 +116,11 @@ class HeaderSearchPaths {
116116 private final ProjectSourcePathResolver projectSourcePathResolver ;
117117 private final PathRelativizer pathRelativizer ;
118118 private final SwiftAttributeParser swiftAttributeParser ;
119- private final ImmutableSet <String > swiftLabels ;
120- private final boolean indexViaBuildFlags ;
121119 private final ProjectFilesystem projectFilesystem ;
122120 private final BuildContext buildContext ;
123121 private final UnresolvedCxxPlatform unresolvedCxxPlatform ;
124122 private final boolean indexViaCompileArgs ;
123+ private final AppleConfig appleConfig ;
125124
126125 private static final LoadingCache <ActionGraphBuilder , Map <UnflavoredBuildTarget , Set <BuildRule >>>
127126 mappingCache =
@@ -160,10 +159,9 @@ class HeaderSearchPaths {
160159 this .projectSourcePathResolver = projectSourcePathResolver ;
161160 this .pathRelativizer = pathRelativizer ;
162161 this .swiftAttributeParser = swiftAttributeParser ;
163- this .swiftLabels = ImmutableSet .copyOf (appleConfig .getProjectGeneratorSwiftLabels ());
164- this .indexViaBuildFlags = appleConfig .getProjectGeneratorIndexViaBuildFlags ();
165162 this .indexViaCompileArgs = appleConfig .getProjectGeneratorIndexViaCompileArgs ();
166163 this .projectFilesystem = projectCell .getFilesystem ();
164+ this .appleConfig = appleConfig ;
167165 }
168166
169167 /** Derives header search path attributes for the {@code targetNode}. */
@@ -207,7 +205,7 @@ HeaderSearchPathAttributes getHeaderSearchPathAttributes(
207205 ImmutableSet <Path > swiftIncludePaths = collectRecursiveSwiftIncludePaths (targetNode );
208206 builder .setSwiftIncludePaths (swiftIncludePaths );
209207
210- if (indexViaBuildFlags ) {
208+ if (Utils . getShouldIndexViaBuildFlagsForTargetNode ( targetNode , appleConfig ) ) {
211209 getIncludeFlags (targetNode , builder );
212210 }
213211 }
@@ -522,7 +520,7 @@ private void addPrivateHeaderIncludes(
522520 requiredBuildTargets .add (buildTarget );
523521
524522 // If the module is mixed then we need to import the VFS overlay and the -Swift.h header hmap
525- if (targetNodeContainsSwift (targetNode )
523+ if (Utils . targetNodeContainsSwift (targetNode , appleConfig )
526524 && !targetNode .getConstructorArg ().getExportedHeaders ().isEmpty ()) {
527525 BuildTarget privateSwiftHeaderMapTarget =
528526 targetNode
@@ -584,7 +582,7 @@ private void addPublicHeaderIncludes(
584582 includeFlags .add ("-I" + targetFilesystem .resolve (includePath ));
585583 requiredBuildTargets .add (buildTarget );
586584
587- if (targetNodeContainsSwift (targetNode )) {
585+ if (Utils . targetNodeContainsSwift (targetNode , appleConfig )) {
588586 // Swift libraries also need to include their dependent libraries swiftmodule files
589587 BuildTarget swiftCompileTarget =
590588 targetNode
@@ -872,7 +870,7 @@ private ImmutableSortedMap<Path, SourcePath> getPrivateCxxHeaders(
872870 SourceSortedSet .ofNamedSources (ImmutableSortedMap .of ())));
873871 }
874872
875- if (targetNodeContainsSwift (targetNode )) {
873+ if (Utils . targetNodeContainsSwift (targetNode , appleConfig )) {
876874 // Mixed libraries need to see their -Swift.h header. This is exposed through the module,
877875 // but is also expected to be available in unprefixed form internally.
878876 String moduleName =
@@ -1118,7 +1116,7 @@ private ImmutableSet<Path> collectRecursiveHeaderSearchPaths(
11181116 // but to do it right, it's likely that we'll need to add that. When that happens, we can also
11191117 // update this "if" statement. If, long-term, we move towards using modules for all Objective-C
11201118 // code, the merged header map will no longer work at all.
1121- if (targetNodeContainsSwift (targetNode )) {
1119+ if (Utils . targetNodeContainsSwift (targetNode , appleConfig )) {
11221120 Flavor defaultPlatformFlavor =
11231121 targetNode .getConstructorArg ().getDefaultPlatform ().orElse (cxxPlatform .getFlavor ());
11241122
@@ -1180,7 +1178,7 @@ private ImmutableSet<Path> collectRecursiveSwiftIncludePaths(
11801178 // we do need to add the paths to .swiftmodule files for dependencies.
11811179 if (nativeNode != targetNode
11821180 && headerVisibility .equals (HeaderVisibility .PUBLIC )
1183- && targetNodeContainsSwift (nativeNode )) {
1181+ && Utils . targetNodeContainsSwift (nativeNode , appleConfig )) {
11841182 BuildTarget flavoredSwiftCompileTarget =
11851183 NodeHelper .getSwiftModuleTarget (nativeNode , defaultPlatformFlavor );
11861184
@@ -1193,19 +1191,6 @@ && targetNodeContainsSwift(nativeNode)) {
11931191 return builder .build ();
11941192 }
11951193
1196- private boolean targetNodeContainsSwift (
1197- TargetNode <? extends CxxLibraryDescription .CommonArg > targetNode ) {
1198- // Codegen libraries will have empty srcs so we cannot only rely on target inputs.
1199- // We first check for any of the labels specified in apple.project_generator_swift_labels
1200- // to know if this target is specified as Swift in the build rules.
1201- for (String label : targetNode .getConstructorArg ().getLabels ()) {
1202- if (swiftLabels .contains (label )) {
1203- return true ;
1204- }
1205- }
1206- return AppleDescriptions .targetNodeContainsSwiftSourceCode (targetNode );
1207- }
1208-
12091194 /** Adds the set of headers defined by headerVisibility to the merged header maps. */
12101195 private void addToMergedHeaderMap (
12111196 TargetNode <? extends CxxLibraryDescription .CommonArg > targetNode ,
0 commit comments