Remove private headers from modulemaps generated by objc_ targets -- MOS_MIGRATED_REVID=140498934
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 efa6b1d..3722572 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
@@ -452,15 +452,14 @@ Optional<CompilationArtifacts> compilationArtifacts) { // TODO(bazel-team): Include textual headers in the module map when Xcode 6 support is // dropped. + // TODO(b/32225593): Include private headers in the module map. Iterable<Artifact> publicHeaders = attributes.hdrs(); - Iterable<Artifact> privateHeaders = ImmutableList.of(); if (compilationArtifacts.isPresent()) { CompilationArtifacts artifacts = compilationArtifacts.get(); publicHeaders = Iterables.concat(publicHeaders, artifacts.getAdditionalHdrs()); - privateHeaders = Iterables.concat(privateHeaders, artifacts.getPrivateHdrs()); } CppModuleMap moduleMap = intermediateArtifacts.moduleMap(); - registerGenerateModuleMapAction(moduleMap, publicHeaders, privateHeaders); + registerGenerateModuleMapAction(moduleMap, publicHeaders); return this; } @@ -869,20 +868,17 @@ /** * Registers an action that will generate a clang module map. - * * @param moduleMap the module map to generate * @param publicHeaders the headers that should be directly accessible by dependers - * @param privateHeaders the headers that should only be directly accessible by this module */ private void registerGenerateModuleMapAction( - CppModuleMap moduleMap, Iterable<Artifact> publicHeaders, Iterable<Artifact> privateHeaders) { + CppModuleMap moduleMap, Iterable<Artifact> publicHeaders) { publicHeaders = Iterables.filter(publicHeaders, MODULE_MAP_HEADER); - privateHeaders = Iterables.filter(privateHeaders, MODULE_MAP_HEADER); ruleContext.registerAction( new CppModuleMapAction( ruleContext.getActionOwner(), moduleMap, - privateHeaders, + ImmutableList.<Artifact>of(), publicHeaders, attributes.moduleMapsForDirectDeps(), ImmutableList.<PathFragment>of(),
diff --git a/src/test/shell/bazel/apple/bazel_apple_test.sh b/src/test/shell/bazel/apple/bazel_apple_test.sh index 4a9b245..1cabd28 100755 --- a/src/test/shell/bazel/apple/bazel_apple_test.sh +++ b/src/test/shell/bazel/apple/bazel_apple_test.sh
@@ -809,4 +809,29 @@ expect_log "ios/top.swift:1:1: error: expressions are not allowed at the top level" } +# Test that it's possible to import Clang module of a target that contains private headers. +function test_import_module_with_private_hdrs() { + rm -rf ios + mkdir -p ios + touch ios/Foo.h ios/Foo_Private.h + +cat >ios/main.swift <<EOF +import ios_lib +EOF + +cat >ios/BUILD <<EOF +load("//tools/build_defs/apple:swift.bzl", "swift_library") + +objc_library(name = "lib", + srcs = ["Foo_Private.h"], + hdrs = ["Foo.h"]) + +swift_library(name = "swiftmodule", + srcs = ["main.swift"], + deps = [":lib"]) +EOF + bazel build --verbose_failures --xcode_version=$XCODE_VERSION \ + //ios:swiftmodule >$TEST_log 2>&1 || fail "should build" +} + run_suite "apple_tests"