AIDL source generation accounts for Bazel paths
The AIDL source generation rule sets include flags based on the relative
path of .aidl sources. For .aidl sources provided by Bazel targets, e.g.
in a filegroup, the same directory could be added to the include path
twice. Instead we need to ensure that if a Bazel source provides the
include path, that we don't add it again from a Soong source.
Bug: 229251008
Test: USE_BAZEL_ANALYSIS=1 m api-stubs-docs-non-updatable
Change-Id: I4997039003242b43e0e52ccf41729acb4ad11324
diff --git a/java/java_test.go b/java/java_test.go
index bfd97eb..7f0cea7 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1747,3 +1747,37 @@
android.AssertDeepEquals(t, "Implementation/Resources JARs are produced", expectedOutputFiles, android.NormalizePathsForTesting(javaInfo.ImplementationAndResourcesJars))
android.AssertDeepEquals(t, "Implementation JARs are produced", expectedOutputFiles, android.NormalizePathsForTesting(javaInfo.ImplementationJars))
}
+
+func TestGenAidlIncludeFlagsForMixedBuilds(t *testing.T) {
+ bazelOutputBaseDir := filepath.Join("out", "bazel")
+ result := android.GroupFixturePreparers(
+ PrepareForIntegrationTestWithJava,
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.BazelContext = android.MockBazelContext{
+ OutputBaseDir: bazelOutputBaseDir,
+ }
+ }),
+ ).RunTest(t)
+
+ ctx := &android.TestPathContext{TestResult: result}
+
+ srcDirectory := filepath.Join("frameworks", "base")
+ srcDirectoryAlreadyIncluded := filepath.Join("frameworks", "base", "core", "java")
+ bazelSrcDirectory := android.PathForBazelOut(ctx, srcDirectory)
+ bazelSrcDirectoryAlreadyIncluded := android.PathForBazelOut(ctx, srcDirectoryAlreadyIncluded)
+ srcs := android.Paths{
+ android.PathForTestingWithRel(bazelSrcDirectory.String(), "bazelAidl.aidl"),
+ android.PathForTestingWithRel(bazelSrcDirectory.String(), "bazelAidl2.aidl"),
+ android.PathForTestingWithRel(bazelSrcDirectoryAlreadyIncluded.String(), "bazelAidlExclude.aidl"),
+ android.PathForTestingWithRel(bazelSrcDirectoryAlreadyIncluded.String(), "bazelAidl2Exclude.aidl"),
+ }
+ dirsAlreadyIncluded := android.Paths{
+ android.PathForTesting(srcDirectoryAlreadyIncluded),
+ }
+
+ expectedFlags := " -Iout/bazel/execroot/__main__/frameworks/base"
+ flags := genAidlIncludeFlags(ctx, srcs, dirsAlreadyIncluded)
+ if flags != expectedFlags {
+ t.Errorf("expected flags to be %q; was %q", expectedFlags, flags)
+ }
+}