From 31214a42e31e85d005bb40e96ec28e96dcd195d7 Mon Sep 17 00:00:00 2001 From: Cal Peyser Date: Thu, 9 Feb 2017 16:41:04 +0000 Subject: Generated files directory is passed to dependers as a user header search path. In the process, rename and replace the incorrectly named ObjcCommon.Builder#addUserHeaderSearchPaths -- PiperOrigin-RevId: 147038434 MOS_MIGRATED_REVID=147038434 --- .../build/lib/rules/objc/CompilationSupport.java | 6 ++- .../build/lib/rules/objc/J2ObjcAspect.java | 2 +- .../lib/rules/objc/LegacyCompilationSupport.java | 3 +- .../devtools/build/lib/rules/objc/ObjcCommon.java | 51 ++++++++++++++-------- .../build/lib/rules/objc/ObjcProvider.java | 8 ++++ .../build/lib/rules/objc/ProtobufSupport.java | 10 ++--- .../lib/rules/objc/ProtocolBuffers2Support.java | 6 +-- 7 files changed, 55 insertions(+), 31 deletions(-) (limited to 'src/main/java/com/google/devtools') diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java index cbe8ce3b1d..b9e28b4ffb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java @@ -597,8 +597,10 @@ public abstract class CompilationSupport { xcodeProviderBuilder .addHeaders(attributes.hdrs()) .addHeaders(attributes.textualHdrs()) - .addUserHeaderSearchPaths(ObjcCommon.userHeaderSearchPaths(buildConfiguration)) - .addHeaderSearchPaths("$(WORKSPACE_ROOT)", + .addUserHeaderSearchPaths( + ObjcCommon.userHeaderSearchPaths(common.getObjcProvider(), buildConfiguration)) + .addHeaderSearchPaths( + "$(WORKSPACE_ROOT)", attributes.headerSearchPaths(buildConfiguration.getGenfilesFragment())) .addHeaderSearchPaths("$(WORKSPACE_ROOT)", includeSystemPaths) .addHeaderSearchPaths("$(SDKROOT)/usr/include", attributes.sdkIncludes()) diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java index d25be99408..89cd3339ab 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java @@ -759,7 +759,7 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF } return builder - .addUserHeaderSearchPaths(headerSearchPaths) + .addIncludes(headerSearchPaths) .setIntermediateArtifacts(intermediateArtifacts) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java index b8fc926967..b22a7ec94c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java @@ -287,7 +287,8 @@ public class LegacyCompilationSupport extends CompilationSupport { .add(compileFlagsForClang(appleConfiguration)) .add(commonLinkAndCompileFlagsForClang(objcProvider, objcConfiguration, appleConfiguration)) .add(objcConfiguration.getCoptsForCompilationMode()) - .addBeforeEachPath("-iquote", ObjcCommon.userHeaderSearchPaths(buildConfiguration)) + .addBeforeEachPath( + "-iquote", ObjcCommon.userHeaderSearchPaths(objcProvider, buildConfiguration)) .addBeforeEachExecPath("-include", pchFile.asSet()) .addBeforeEachPath("-I", priorityHeaders) .addBeforeEachPath("-I", objcProvider.get(INCLUDE)) diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java index 9a47734630..ad677f6a89 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java @@ -35,6 +35,7 @@ import static com.google.devtools.build.lib.rules.objc.ObjcProvider.HEADER; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.IMPORTED_LIBRARY; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.INCLUDE; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.INCLUDE_SYSTEM; +import static com.google.devtools.build.lib.rules.objc.ObjcProvider.IQUOTE; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.J2OBJC_LIBRARY; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.LIBRARY; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.LINKED_BINARY; @@ -158,8 +159,9 @@ public final class ObjcCommon { private Iterable directDepObjcProviders = ImmutableList.of(); private Iterable runtimeDepObjcProviders = ImmutableList.of(); private Iterable defines = ImmutableList.of(); + private Iterable includes = ImmutableList.of(); + private Iterable directDependencyIncludes = ImmutableList.of(); private Iterable userHeaderSearchPaths = ImmutableList.of(); - private Iterable directDependencyHeaderSearchPaths = ImmutableList.of(); private IntermediateArtifacts intermediateArtifacts; private boolean alwayslink; private boolean hasModuleMap; @@ -318,20 +320,23 @@ public final class ObjcCommon { return this; } - public Builder addUserHeaderSearchPaths(Iterable userHeaderSearchPaths) { - this.userHeaderSearchPaths = - Iterables.concat(this.userHeaderSearchPaths, userHeaderSearchPaths); + /** Adds includes to be passed into compile actions with {@code -I}. */ + public Builder addIncludes(Iterable includes) { + this.includes = Iterables.concat(this.includes, includes); return this; } - /** - * Adds header search paths that will only be visible by strict dependents of the provider. - */ - public Builder addDirectDependencyHeaderSearchPaths( - Iterable directDependencyHeaderSearchPaths) { - this.directDependencyHeaderSearchPaths = - Iterables.concat( - this.directDependencyHeaderSearchPaths, directDependencyHeaderSearchPaths); + /** Adds header search paths that will only be visible by strict dependents of the provider. */ + public Builder addDirectDependencyIncludes(Iterable directDependencyIncludes) { + this.directDependencyIncludes = + Iterables.concat(this.directDependencyIncludes, directDependencyIncludes); + return this; + } + + /** Adds user header search paths to be passed into compile actions with {@code -iquote}. */ + public Builder addUserHeaderSearchPaths(Iterable userHeaderSearchPaths) { + this.userHeaderSearchPaths = + Iterables.concat(this.userHeaderSearchPaths, userHeaderSearchPaths); return this; } @@ -394,6 +399,7 @@ public final class ObjcCommon { } ObjcCommon build() { + Iterable bundleImports = BundleableFile.bundleImportsFromRule(context); ObjcProvider.Builder objcProvider = @@ -409,12 +415,16 @@ public final class ObjcCommon { .addAll(SDK_DYLIB, extraSdkDylibs) .addAll(STATIC_FRAMEWORK_FILE, staticFrameworkImports) .addAll(DYNAMIC_FRAMEWORK_FILE, dynamicFrameworkImports) - .addAll(STATIC_FRAMEWORK_DIR, + .addAll( + STATIC_FRAMEWORK_DIR, uniqueContainers(staticFrameworkImports, FRAMEWORK_CONTAINER_TYPE)) - .addAll(DYNAMIC_FRAMEWORK_DIR, + .addAll( + DYNAMIC_FRAMEWORK_DIR, uniqueContainers(dynamicFrameworkImports, FRAMEWORK_CONTAINER_TYPE)) - .addAll(INCLUDE, userHeaderSearchPaths) - .addAllForDirectDependents(INCLUDE, directDependencyHeaderSearchPaths) + .addAll(INCLUDE, includes) + .addAll(IQUOTE, userHeaderSearchPaths) + .add(IQUOTE, buildConfiguration.getGenfilesFragment()) + .addAllForDirectDependents(INCLUDE, directDependencyIncludes) .addAll(DEFINE, defines) .addTransitiveAndPropagate(depObjcProviders) .addTransitiveWithoutPropagating(directDepObjcProviders); @@ -673,8 +683,13 @@ public final class ObjcCommon { return false; } - static ImmutableList userHeaderSearchPaths(BuildConfiguration configuration) { - return ImmutableList.of(new PathFragment("."), configuration.getGenfilesFragment()); + static ImmutableSet userHeaderSearchPaths( + ObjcProvider provider, BuildConfiguration config) { + return ImmutableSet.builder() + .add(new PathFragment(".")) + .add(config.getGenfilesFragment()) + .addAll(provider.get(IQUOTE)) + .build(); } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java index 0b7dddbeb3..c16a1052e6 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java @@ -158,6 +158,13 @@ public final class ObjcProvider extends SkylarkClassObject implements Transitive public static final Key INCLUDE = new Key<>(LINK_ORDER, "include", PathFragment.class); + /** + * Include search paths specified with {@code -iquote} on the command line. Also known as user + * header search paths. + */ + public static final Key IQUOTE = + new Key<>(LINK_ORDER, "iquote", PathFragment.class); + /** * Include search paths specified with {@code -isystem} on the command line. */ @@ -411,6 +418,7 @@ public final class ObjcProvider extends SkylarkClassObject implements Transitive IMPORTED_LIBRARY, INCLUDE, INCLUDE_SYSTEM, + IQUOTE, J2OBJC_LIBRARY, JRE_LIBRARY, LIBRARY, diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java index 3c62f07a36..455ee70391 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java @@ -39,7 +39,6 @@ import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory. import com.google.devtools.build.lib.rules.proto.ProtoSourcesProvider; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.PathFragment; - import java.util.HashMap; import java.util.Set; @@ -238,8 +237,7 @@ final class ProtobufSupport { return Optional.absent(); } - Iterable userHeaderSearchPaths = - ImmutableList.of(getWorkspaceRelativeOutputDir()); + Iterable includes = ImmutableList.of(getWorkspaceRelativeOutputDir()); ObjcCommon.Builder commonBuilder = new ObjcCommon.Builder(ruleContext); if (!isLinkingTarget()) { @@ -260,9 +258,9 @@ final class ProtobufSupport { } if (isLinkingTarget()) { - commonBuilder.addUserHeaderSearchPaths(userHeaderSearchPaths); + commonBuilder.addIncludes(includes); } else { - commonBuilder.addDirectDependencyHeaderSearchPaths(userHeaderSearchPaths); + commonBuilder.addDirectDependencyIncludes(includes); } return Optional.of(commonBuilder.build().getObjcProvider()); @@ -453,7 +451,7 @@ final class ProtobufSupport { .setIntermediateArtifacts(intermediateArtifacts) .setCompilationArtifacts(compilationArtifacts); if (isLinkingTarget()) { - commonBuilder.addUserHeaderSearchPaths(getProtobufHeaderSearchPaths()); + commonBuilder.addIncludes(getProtobufHeaderSearchPaths()); } else { commonBuilder.addDepObjcProviders( ruleContext.getPrerequisites( diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtocolBuffers2Support.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtocolBuffers2Support.java index da7f0dfcaa..54d8904492 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtocolBuffers2Support.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtocolBuffers2Support.java @@ -121,7 +121,7 @@ final class ProtocolBuffers2Support { public XcodeProvider getXcodeProvider() { XcodeProvider.Builder xcodeProviderBuilder = new XcodeProvider.Builder() - .addUserHeaderSearchPaths(getUserHeaderSearchPaths()) + .addUserHeaderSearchPaths(getIncludes()) .setCompilationArtifacts(getCompilationArtifacts()); new XcodeSupport(ruleContext) @@ -145,7 +145,7 @@ final class ProtocolBuffers2Support { .setIntermediateArtifacts(new IntermediateArtifacts(ruleContext, "")) .setHasModuleMap() .setCompilationArtifacts(getCompilationArtifacts()) - .addUserHeaderSearchPaths(getUserHeaderSearchPaths()) + .addIncludes(getIncludes()) .addDepObjcProviders( ruleContext.getPrerequisites( ObjcRuleClasses.PROTO_LIB_ATTR, Mode.TARGET, ObjcProvider.class)) @@ -198,7 +198,7 @@ final class ProtocolBuffers2Support { return commandLineBuilder.build(); } - public ImmutableSet getUserHeaderSearchPaths() { + public ImmutableSet getIncludes() { ImmutableSet.Builder searchPathEntriesBuilder = new ImmutableSet.Builder().add(getWorkspaceRelativeOutputDir()); -- cgit v1.2.3