diff options
author | 2015-05-20 20:03:26 +0000 | |
---|---|---|
committer | 2015-05-21 09:50:21 +0000 | |
commit | b66898e44d79ef67f856eaeae711bb461564a3c1 (patch) | |
tree | 5adcd55d38a04f5111118e9776317bbfc8e1a914 /src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java | |
parent | 9208259df169e46cabdf1102bfc529a915a1581d (diff) |
Allow objc_{library,binary} to depend on cc_library.
This is an early version of support for this feature, likely still missing
a number of edge cases. However the basic functionality should work.
To allow a dependency from objc to cc, the following flags will have to be
passed to bazel:
--experimental_enable_objc_cc_deps --experimental_disable_java --cpu=ios_i386 --crosstool_top=//tools/objc/crosstool:crosstool
The feature is also compatible with --ios_multi_cpus, with the familiar
values for --ios_cpu (i386, x86_64, armv7, arm64). However, using this
crosstool and any CPU defined in it (legal values are ios_i386, ios_x86_64,
ios_armv7, ios_arm64) will make it impossible to use genrules with java make
variables in the same build: Obviously they require java support and no that
is not available for iOS CPUs.
The new flag --experimental_disable_java has not been tested in any
circumstances but the one enabled by this CL so use it with caution.
This CL does not contain any Xcode support for CC dependencies yet, they
will just not show up in the generated Xcode project.
--
MOS_MIGRATED_REVID=94116942
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java | 30 |
1 files changed, 30 insertions, 0 deletions
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 e3ed076467..e311bc3473 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 @@ -18,6 +18,7 @@ import static com.google.devtools.build.lib.rules.objc.ObjcProvider.ASSET_CATALO import static com.google.devtools.build.lib.rules.objc.ObjcProvider.BREAKPAD_FILE; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.BUNDLE_FILE; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.BUNDLE_IMPORT_DIR; +import static com.google.devtools.build.lib.rules.objc.ObjcProvider.CC_LIBRARY; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.DEFINE; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FLAG; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FORCE_LOAD_FOR_XCODEGEN; @@ -57,6 +58,8 @@ import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.packages.Type; import com.google.devtools.build.lib.rules.cpp.CcCommon; +import com.google.devtools.build.lib.rules.cpp.CcLinkParamsProvider; +import com.google.devtools.build.lib.rules.cpp.CppCompilationContext; import com.google.devtools.build.lib.util.FileType; import com.google.devtools.build.lib.util.RegexFilter; import com.google.devtools.build.lib.vfs.PathFragment; @@ -237,6 +240,8 @@ public final class ObjcCommon { private Iterable<Artifact> extraImportLibraries = ImmutableList.of(); private Optional<Artifact> linkedBinary = Optional.absent(); private Optional<Artifact> breakpadFile = Optional.absent(); + private Iterable<CppCompilationContext> depCcHeaderProviders = ImmutableList.of(); + private Iterable<CcLinkParamsProvider> depCcLinkProviders = ImmutableList.of(); Builder(RuleContext context) { this.context = Preconditions.checkNotNull(context); @@ -354,6 +359,22 @@ public final class ObjcCommon { return this; } + /** + * Sets information from {@code cc_library} dependencies to be used during compilation. + */ + public Builder addDepCcHeaderProviders(Iterable<CppCompilationContext> depCcHeaderProviders) { + this.depCcHeaderProviders = Iterables.concat(this.depCcHeaderProviders, depCcHeaderProviders); + return this; + } + + /** + * Sets information from {@code cc_library} dependencies to be used during linking. + */ + public Builder addDepCcLinkProviders(Iterable<CcLinkParamsProvider> depCcLinkProviders) { + this.depCcLinkProviders = Iterables.concat(this.depCcLinkProviders, depCcLinkProviders); + return this; + } + ObjcCommon build() { Iterable<BundleableFile> bundleImports = BundleableFile.bundleImportsFromRule(context); @@ -373,6 +394,15 @@ public final class ObjcCommon { .addTransitiveAndPropagate(depObjcProviders) .addTransitiveWithoutPropagating(directDepObjcProviders); + for (CppCompilationContext headerProvider : depCcHeaderProviders) { + // TODO(bazel-team): Also account for custom include settings to go into header search paths + objcProvider.addTransitiveAndPropagate(HEADER, headerProvider.getDeclaredIncludeSrcs()); + } + for (CcLinkParamsProvider linkProvider : depCcLinkProviders) { + objcProvider.addTransitiveAndPropagate( + CC_LIBRARY, linkProvider.getCcLinkParams(true, false).getLibraries()); + } + if (compilationAttributes.isPresent()) { CompilationAttributes attributes = compilationAttributes.get(); ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(context); |