aboutsummaryrefslogtreecommitdiff
path: root/build/aidl_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'build/aidl_test.go')
-rw-r--r--build/aidl_test.go182
1 files changed, 179 insertions, 3 deletions
diff --git a/build/aidl_test.go b/build/aidl_test.go
index 9eb42cc8..3b12469a 100644
--- a/build/aidl_test.go
+++ b/build/aidl_test.go
@@ -27,6 +27,7 @@ import (
"android/soong/android"
"android/soong/apex"
"android/soong/cc"
+ "android/soong/genrule"
"android/soong/java"
"android/soong/rust"
)
@@ -61,6 +62,7 @@ func _testAidl(t *testing.T, bp string, customizers ...android.FixturePreparer)
preparers = append(preparers,
cc.PrepareForTestWithCcDefaultModules,
java.PrepareForTestWithJavaDefaultModules,
+ genrule.PrepareForTestWithGenRuleBuildComponents,
)
bp = bp + `
@@ -126,12 +128,15 @@ func _testAidl(t *testing.T, bp string, customizers ...android.FixturePreparer)
crate_name: "binder",
srcs: [""],
}
- aidl_interfaces_metadata {
- name: "aidl_metadata_json",
- }
`
preparers = append(preparers, android.FixtureWithRootAndroidBp(bp))
+ preparers = append(preparers, android.FixtureAddTextFile("system/tools/aidl/build/Android.bp", `
+ aidl_interfaces_metadata {
+ name: "aidl_metadata_json",
+ visibility: ["//system/tools/aidl:__subpackages__"],
+ }
+ `))
preparers = append(preparers, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
// To keep tests stable, fix Platform_sdk_codename and Platform_sdk_final
@@ -970,6 +975,177 @@ func TestRustDuplicateNames(t *testing.T) {
`)
}
+func TestAidlImportFlagsForIncludeDirs(t *testing.T) {
+ customizer := withFiles(map[string][]byte{
+ "foo/Android.bp": []byte(`
+ aidl_interface {
+ name: "foo-iface",
+ local_include_dir: "src",
+ include_dirs: [
+ "path1",
+ "path2/sub",
+ ],
+ srcs: [
+ "src/foo/Foo.aidl",
+ ],
+ imports: [
+ "bar-iface",
+ ],
+ versions: ["1", "2"],
+ }
+ aidl_interface {
+ name: "bar-iface",
+ local_include_dir: "src",
+ srcs: [
+ "src/bar/Bar.aidl",
+ ],
+ }
+ `),
+ "foo/src/foo/Foo.aidl": nil,
+ "foo/src/bar/Bar.aidl": nil,
+ "foo/aidl_api/foo-iface/current/foo/Foo.aidl": nil,
+ "foo/aidl_api/foo-iface/1/foo/Foo.aidl": nil,
+ "foo/aidl_api/foo-iface/1/.hash": nil,
+ "foo/aidl_api/foo-iface/2/foo/Foo.aidl": nil,
+ "foo/aidl_api/foo-iface/2/.hash": nil,
+ })
+ ctx, _ := testAidl(t, ``, customizer)
+
+ // compile for older version
+ {
+ rule := ctx.ModuleForTests("foo-iface-V1-cpp-source", "").Output("foo/Foo.cpp")
+ imports := strings.Split(rule.Args["imports"], " ")
+ android.AssertArrayString(t, "should import foo/1(target) and bar/current(imported)", []string{
+ "-Ifoo/aidl_api/foo-iface/1",
+ "-Ipath1",
+ "-Ipath2/sub",
+ "-Ifoo/aidl_api/bar-iface/current",
+ }, imports)
+ }
+ // compile for tot version
+ {
+ rule := ctx.ModuleForTests("foo-iface-V3-cpp-source", "").Output("foo/Foo.cpp")
+ imports := strings.Split(rule.Args["imports"], " ")
+ android.AssertArrayString(t, "aidlCompile should import ToT", []string{
+ "-Ifoo/src",
+ "-Ipath1",
+ "-Ipath2/sub",
+ "-Ifoo/src",
+ }, imports)
+ }
+}
+
+func TestSupportsGenruleAndFilegroup(t *testing.T) {
+ customizer := withFiles(map[string][]byte{
+ "foo/Android.bp": []byte(`
+ aidl_interface {
+ name: "foo-iface",
+ local_include_dir: "src",
+ include_dirs: [
+ "path1",
+ "path2/sub",
+ ],
+ srcs: [
+ "src/foo/Foo.aidl",
+ ":filegroup1",
+ ":gen1",
+ ],
+ imports: [
+ "bar-iface",
+ ],
+ versions: ["1"],
+ }
+ filegroup {
+ name: "filegroup1",
+ path: "filegroup/sub",
+ srcs: [
+ "filegroup/sub/pkg/Bar.aidl",
+ ],
+ }
+ genrule {
+ name: "gen1",
+ cmd: "generate baz/Baz.aidl",
+ out: [
+ "baz/Baz.aidl",
+ ]
+ }
+ aidl_interface {
+ name: "bar-iface",
+ local_include_dir: "src",
+ srcs: [
+ "src/bar/Bar.aidl",
+ ],
+ }
+ `),
+ "foo/aidl_api/foo-iface/1/foo/Foo.aidl": nil,
+ "foo/aidl_api/foo-iface/1/.hash": nil,
+ "foo/filegroup/sub/pkg/Bar.aidl": nil,
+ "foo/src/foo/Foo.aidl": nil,
+ })
+ ctx, _ := testAidl(t, ``, customizer)
+
+ // aidlCompile for snapshots (v1)
+ {
+ rule := ctx.ModuleForTests("foo-iface-V1-cpp-source", "").Output("foo/Foo.cpp")
+ imports := strings.Split(rule.Args["imports"], " ")
+ android.AssertArrayString(t, "aidlCompile should import filegroup/genrule as well", []string{
+ "-Ifoo/aidl_api/foo-iface/1",
+ "-Ipath1",
+ "-Ipath2/sub",
+ "-Ifoo/aidl_api/bar-iface/current",
+ }, imports)
+ }
+ // aidlCompile for ToT (v2)
+ {
+ rule := ctx.ModuleForTests("foo-iface-V2-cpp-source", "").Output("foo/Foo.cpp")
+ imports := strings.Split(rule.Args["imports"], " ")
+ android.AssertArrayString(t, "aidlCompile should import filegroup/genrule as well", []string{
+ "-Ifoo/src",
+ "-Ifoo/filegroup/sub",
+ "-Iout/soong/.intermediates/foo/gen1/gen",
+ "-Ipath1",
+ "-Ipath2/sub",
+ "-Ifoo/src",
+ }, imports)
+ }
+
+ // dumpapi
+ {
+ rule := ctx.ModuleForTests("foo-iface-api", "").Rule("aidlDumpApiRule")
+ android.AssertPathsRelativeToTopEquals(t, "dumpapi should dump srcs/filegroups/genrules", []string{
+ "foo/src/foo/Foo.aidl",
+ "foo/filegroup/sub/pkg/Bar.aidl",
+ "out/soong/.intermediates/foo/gen1/gen/baz/Baz.aidl",
+ }, rule.Inputs)
+
+ dumpDir := "out/soong/.intermediates/foo/foo-iface-api/dump"
+ android.AssertPathsRelativeToTopEquals(t, "dumpapi should dump with rel paths", []string{
+ dumpDir + "/foo/Foo.aidl",
+ dumpDir + "/pkg/Bar.aidl",
+ dumpDir + "/baz/Baz.aidl",
+ dumpDir + "/.hash",
+ }, rule.Outputs.Paths())
+
+ imports := strings.Split(rule.Args["imports"], " ")
+ android.AssertArrayString(t, "dumpapi should import filegroup/genrule as well", []string{
+ // these are from foo-iface.srcs
+ "-Ifoo/src",
+ "-Ifoo/filegroup/sub",
+ "-Iout/soong/.intermediates/foo/gen1/gen",
+
+ // this is from bar-iface.srcs
+ "-Ifoo/src",
+
+ // this is from foo-iface.Local_include_dir
+ "-Ifoo/src",
+
+ // these are from foo-iface.include_dirs
+ "-Ipath1",
+ "-Ipath2/sub",
+ }, imports)
+ }
+}
+
func TestAidlFlags(t *testing.T) {
ctx, _ := testAidl(t, `
aidl_interface {