summaryrefslogtreecommitdiff
path: root/android/filegroup_test.go
diff options
context:
space:
mode:
author Vinh Tran <vinhdaitran@google.com> 2022-08-16 16:45:44 -0400
committer Vinh Tran <vinhdaitran@google.com> 2022-08-18 13:59:06 -0400
commit16fe8e1cf108c95ee48776121c4e2d45d9e3fd50 (patch)
tree0adc0c909c922dec5646f14365f4ab748377f163 /android/filegroup_test.go
parent63e738ffe0cb7328d75e288ee0356da5e521c455 (diff)
Fix ProcessBazelQueryResponse of filegroup
In mixed builds currently, filegroup doesn't use path prop when creating the paths to the srcs. It defaults to ModuleDir. Hence, when java.genAidlIncludeFlags [1] calls srcFile.Rel() to eventually create the AIDL include dir for AIDL flags, srcFile.Rel() returns the filepath relative to the module directory instead. This CL appends path prop to module dir when creating relativeRoot. This fixes the bridge between converted filegroup that set path prop (e.g. libbinder_aidl) to unconverted module (for example, droidstubs). The fix is needed for the child CL aosp/2186599 to convert libbinder_aidl to Bazel. Without this fix, module-lib-api-stubs-docs-non-updatable (unconverted module that depends on libbinder_aidl) can't be built in mixed builds. [1]: https://cs.android.com/android/platform/superproject/+/master:build/soong/java/gen.go;l=123?q=java%2Fgen.go Test: go test Bug: 243010121 Change-Id: Ic2dd2ab9199c62010303a5b8c611d722f4a4118d
Diffstat (limited to 'android/filegroup_test.go')
-rw-r--r--android/filegroup_test.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/android/filegroup_test.go b/android/filegroup_test.go
new file mode 100644
index 000000000..a7ea8054c
--- /dev/null
+++ b/android/filegroup_test.go
@@ -0,0 +1,58 @@
+package android
+
+import (
+ "path/filepath"
+ "testing"
+)
+
+func TestFileGroupWithPathProp(t *testing.T) {
+ outBaseDir := "outputbase"
+ pathPrefix := outBaseDir + "/execroot/__main__"
+ expectedOutputfile := filepath.Join(pathPrefix, "a/b/c/d/test.aidl")
+
+ testCases := []struct {
+ bp string
+ rel string
+ }{
+ {
+ bp: `
+ filegroup {
+ name: "baz",
+ srcs: ["a/b/c/d/test.aidl"],
+ path: "a/b",
+ bazel_module: { label: "//:baz" },
+ }
+`,
+ rel: "c/d/test.aidl",
+ },
+ {
+ bp: `
+ filegroup {
+ name: "baz",
+ srcs: ["a/b/c/d/test.aidl"],
+ bazel_module: { label: "//:baz" },
+ }
+`,
+ rel: "a/b/c/d/test.aidl",
+ },
+ }
+
+ for _, testCase := range testCases {
+ outBaseDir := "outputbase"
+ result := GroupFixturePreparers(
+ PrepareForTestWithFilegroup,
+ FixtureModifyConfig(func(config Config) {
+ config.BazelContext = MockBazelContext{
+ OutputBaseDir: outBaseDir,
+ LabelToOutputFiles: map[string][]string{
+ "//:baz": []string{"a/b/c/d/test.aidl"},
+ },
+ }
+ }),
+ ).RunTestWithBp(t, testCase.bp)
+
+ fg := result.Module("baz", "").(*fileGroup)
+ AssertStringEquals(t, "src relativeRoot", testCase.rel, fg.srcs[0].Rel())
+ AssertStringEquals(t, "src full path", expectedOutputfile, fg.srcs[0].String())
+ }
+}