Skip to content

Commit

Permalink
Filter libraries in java_common.collect_native_deps_dirs()
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 494154788
Change-Id: Ic347a256e865d0290fb7887d9f6c71cafc1b67a6
  • Loading branch information
hvadehra authored and copybara-github committed Dec 9, 2022
1 parent 3a14360 commit c150e46
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.google.devtools.build.lib.packages.Provider;
import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
import com.google.devtools.build.lib.rules.cpp.CcInfo;
import com.google.devtools.build.lib.rules.cpp.CppFileTypes;
import com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider.JavaOutput;
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.TransitiveInfoCollectionApi;
Expand Down Expand Up @@ -434,7 +435,23 @@ public Sequence<String> collectNativeLibsDirs(
checkPrivateAccess(thread);
ImmutableList<Artifact> nativeLibs =
JavaCommon.collectNativeLibraries(
Sequence.cast(deps, TransitiveInfoCollection.class, "deps"));
Sequence.cast(deps, TransitiveInfoCollection.class, "deps"))
.stream()
.filter(
nativeLibrary -> {
String name = nativeLibrary.getFilename();
if (CppFileTypes.INTERFACE_SHARED_LIBRARY.matches(name)) {
return false;
}
if (!(CppFileTypes.SHARED_LIBRARY.matches(name)
|| CppFileTypes.VERSIONED_SHARED_LIBRARY.matches(name))) {
throw new IllegalArgumentException(
"not a shared library :" + nativeLibrary.prettyPrint());
}
return true;
})
.collect(toImmutableList());

Set<String> uniqueDirs = new LinkedHashSet<>();
for (Artifact nativeLib : nativeLibs) {
uniqueDirs.add(nativeLib.getRootRelativePath().getParentDirectory().getPathString());
Expand Down

0 comments on commit c150e46

Please sign in to comment.