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
This commit is contained in:
Sam Delmerico
2022-05-24 17:10:02 +00:00
parent 97bd127457
commit 2351eacb19
6 changed files with 97 additions and 15 deletions

View File

@@ -1747,3 +1747,37 @@ func TestImportMixedBuild(t *testing.T) {
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)
}
}