Fall back to compiling header-only libraries with --compile_one_dependency.

In toolchains that support parse_headers, this is the desired action. For
other toolchains, this change makes blaze try to build a header-only library
which creates the error that the header only library is not a supported target
kind. Seems like either error message is not useful/actionable.

In theory, it would be better to actually analyze whether a parse_headers is
activated, but that requires refactoring a lot of code that is currently C++
specific.

--
MOS_MIGRATED_REVID=135554761
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformer.java b/src/main/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformer.java
index 9eff869..ac54a67 100644
--- a/src/main/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformer.java
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformer.java
@@ -184,9 +184,8 @@
         }
       }
     }
-
-    throw new TargetParsingException(
-        "Couldn't find dependency on target '" + target.getLabel() + "'");
+    
+    return result;
   }
 
   /** Returns all labels that are contained in direct compile time inputs of {@code rule}. */
diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformerTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformerTest.java
index e8888d0..7ac30ba 100644
--- a/src/test/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/pkgcache/CompileOneDependencyTransformerTest.java
@@ -342,4 +342,12 @@
     assertThat(parseListCompileOneDep("a/a.cc"))
         .containsExactlyElementsIn(labels("//a:foo_select"));
   }
+
+  @Test
+  public void testFallBackToHeaderOnlyLibrary() throws Exception {
+    scratch.file(
+        "a/BUILD",
+        "cc_library(name = 'h', hdrs = ['a.h'], features = ['parse_headers'])");
+    assertThat(parseListCompileOneDep("a/a.h")).containsExactlyElementsIn(labels("//a:h"));
+  }
 }