Modify indexer includes to no longer duplicate paths - Pick the workspace root or exec root based on whether or not the path is in the tulsi includes folder PiperOrigin-RevId: 298606243
diff --git a/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl b/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl index dda397f..2d8d4ba 100644 --- a/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl +++ b/src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl
@@ -843,10 +843,12 @@ includes_depsets = [cc_ctx.includes, cc_ctx.quote_includes, cc_ctx.system_includes] if includes_depsets: - target_includes = [ + # Use a depset here to remove duplicates which is possible since + # converting the output path can strip some path information. + target_includes = depset([ _convert_outpath_to_symlink_path(x) for x in depset(transitive = includes_depsets).to_list() - ] + ]).to_list() else: target_includes = []
diff --git a/src/TulsiGenerator/PBXTargetGenerator.swift b/src/TulsiGenerator/PBXTargetGenerator.swift index 2b50d3d..39e5365 100644 --- a/src/TulsiGenerator/PBXTargetGenerator.swift +++ b/src/TulsiGenerator/PBXTargetGenerator.swift
@@ -1226,26 +1226,19 @@ toSet includes: NSMutableOrderedSet) { if let includePaths = ruleEntry.includePaths { let rootedPaths: [String] = includePaths.map() { (path, recursive) in - let rootedPath = "$(\(PBXTargetGenerator.WorkspaceRootVarName))/\(path)" + // Any paths of the tulsi-includes form will only be in the bazel workspace symlink since + // they refer to generated files from a build. + // Otherwise we assume the file exists in the workspace. + let prefixVar = path.hasPrefix(PBXTargetGenerator.tulsiIncludesPath) + ? PBXTargetGenerator.BazelWorkspaceSymlinkVarName + : PBXTargetGenerator.WorkspaceRootVarName + let rootedPath = "$(\(prefixVar))/\(path)" if recursive { return "\(rootedPath)/**" } return rootedPath } includes.addObjects(from: rootedPaths) - - /// Some targets that generate sources also provide header search paths into non-generated - /// sources. Using workspace root is needed for the former, but the latter has to be - /// included via the Bazel workspace root. - /// TODO(tulsi-team): See if we can merge the two locations to just Bazel workspace. - let bazelWorkspaceRootedPaths: [String] = includePaths.map() { (path, recursive) in - let rootedPath = "$(\(PBXTargetGenerator.BazelWorkspaceSymlinkVarName))/\(path)" - if recursive { - return "\(rootedPath)/**" - } - return rootedPath - } - includes.addObjects(from: bazelWorkspaceRootedPaths) } // TODO(rdar://36107040): Once Xcode supports indexing with multiple -fmodule-map-file