aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar Cal Peyser <cpeyser@google.com>2017-02-09 16:41:04 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-02-09 19:27:38 +0000
commit31214a42e31e85d005bb40e96ec28e96dcd195d7 (patch)
tree8dc69821e6f65016d777952b40c7bf3f3399d890 /src/main/java/com/google
parent321fc56f5f9f11b3971fcea811ad91c200c12005 (diff)
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
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java51
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ProtocolBuffers2Support.java6
7 files changed, 55 insertions, 31 deletions
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<ObjcProvider> directDepObjcProviders = ImmutableList.of();
private Iterable<ObjcProvider> runtimeDepObjcProviders = ImmutableList.of();
private Iterable<String> defines = ImmutableList.of();
+ private Iterable<PathFragment> includes = ImmutableList.of();
+ private Iterable<PathFragment> directDependencyIncludes = ImmutableList.of();
private Iterable<PathFragment> userHeaderSearchPaths = ImmutableList.of();
- private Iterable<PathFragment> 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<PathFragment> userHeaderSearchPaths) {
- this.userHeaderSearchPaths =
- Iterables.concat(this.userHeaderSearchPaths, userHeaderSearchPaths);
+ /** Adds includes to be passed into compile actions with {@code -I}. */
+ public Builder addIncludes(Iterable<PathFragment> 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<PathFragment> 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<PathFragment> 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<PathFragment> userHeaderSearchPaths) {
+ this.userHeaderSearchPaths =
+ Iterables.concat(this.userHeaderSearchPaths, userHeaderSearchPaths);
return this;
}
@@ -394,6 +399,7 @@ public final class ObjcCommon {
}
ObjcCommon build() {
+
Iterable<BundleableFile> 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<PathFragment> userHeaderSearchPaths(BuildConfiguration configuration) {
- return ImmutableList.of(new PathFragment("."), configuration.getGenfilesFragment());
+ static ImmutableSet<PathFragment> userHeaderSearchPaths(
+ ObjcProvider provider, BuildConfiguration config) {
+ return ImmutableSet.<PathFragment>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
@@ -159,6 +159,13 @@ public final class ObjcProvider extends SkylarkClassObject implements Transitive
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<PathFragment> IQUOTE =
+ new Key<>(LINK_ORDER, "iquote", PathFragment.class);
+
+ /**
* Include search paths specified with {@code -isystem} on the command line.
*/
public static final Key<PathFragment> INCLUDE_SYSTEM =
@@ -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<PathFragment> userHeaderSearchPaths =
- ImmutableList.of(getWorkspaceRelativeOutputDir());
+ Iterable<PathFragment> 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<PathFragment> getUserHeaderSearchPaths() {
+ public ImmutableSet<PathFragment> getIncludes() {
ImmutableSet.Builder<PathFragment> searchPathEntriesBuilder =
new ImmutableSet.Builder<PathFragment>().add(getWorkspaceRelativeOutputDir());