From 2351eacb19faed3867903e1ddfa2992f7a787d02 Mon Sep 17 00:00:00 2001 From: Sam Delmerico Date: Tue, 24 May 2022 17:10:02 +0000 Subject: 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 --- java/java_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'java/java_test.go') diff --git a/java/java_test.go b/java/java_test.go index bfd97eb0d..7f0cea718 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -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) + } +} -- cgit v1.2.3-59-g8ed1b