diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-10-10 16:30:18 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-10-10 16:30:18 +0000 |
commit | 216fd260df8bc4dc8cb40492ef14b1d65f96758e (patch) | |
tree | 29921145a5d40e82de160f2a9e34e4bb111ffd5d | |
parent | 1a53fd409df0cb25d71c4fda5966d3bb3153e728 (diff) | |
parent | 1e488ac0e226d243f841e6febe5432cff3f91655 (diff) | |
download | aidl-android13-mainline-tzdata4-release.tar.gz |
Snap for 9157479 from 1e488ac0e226d243f841e6febe5432cff3f91655 to mainline-tzdata4-releaseaml_tz4_332714070aml_tz4_332714050aml_tz4_332714010aml_tz4_331910000aml_tz4_331314030aml_tz4_331314020aml_tz4_331314010android13-mainline-tzdata4-releaseaml_tz4_332714010
Change-Id: I819498a1ee4d060bd51498b57207289f1c725165
-rw-r--r-- | build/Android.bp | 1 | ||||
-rw-r--r-- | build/aidl_api.go | 10 | ||||
-rw-r--r-- | build/aidl_gen_rule.go | 5 | ||||
-rw-r--r-- | build/aidl_interface.go | 24 | ||||
-rw-r--r-- | build/aidl_interface_backends.go | 3 | ||||
-rw-r--r-- | build/aidl_interface_headers.go | 69 | ||||
-rw-r--r-- | build/aidl_test.go | 18 |
7 files changed, 124 insertions, 6 deletions
diff --git a/build/Android.bp b/build/Android.bp index 24b4a93e..5fe0892c 100644 --- a/build/Android.bp +++ b/build/Android.bp @@ -40,6 +40,7 @@ bootstrap_go_package { "aidl_api.go", "aidl_gen_rule.go", "aidl_interface_backends.go", + "aidl_interface_headers.go", "aidl_interface_metadata_singleton.go", "aidl_mapping.go", "aidl_rust_source_provider.go", diff --git a/build/aidl_api.go b/build/aidl_api.go index 1fc4474f..fe821a6c 100644 --- a/build/aidl_api.go +++ b/build/aidl_api.go @@ -55,6 +55,7 @@ type aidlApiProperties struct { AidlRoot string // base directory for the input aidl file Stability *string Imports []string + Headers []string Versions []string Dumpapi DumpApiProperties } @@ -340,6 +341,14 @@ func getDeps(ctx android.ModuleContext, versionedImports map[string]string) deps // add imported module's checkapiTimestamps as implicits to make sure that imported apiDump is up-to-date deps.implicits = append(deps.implicits, api.checkApiTimestamps.Paths()...) deps.implicits = append(deps.implicits, api.checkHashTimestamps.Paths()...) + case interfaceHeadersDepTag: + headerInfo, ok := ctx.OtherModuleProvider(dep, AidlInterfaceHeadersProvider).(AidlInterfaceHeadersInfo) + if !ok { + ctx.PropertyErrorf("headers", "module %v does not provide AidlInterfaceHeadersInfo", dep.Name()) + return + } + deps.implicits = append(deps.implicits, headerInfo.Srcs...) + deps.imports = append(deps.imports, headerInfo.IncludeDir) } }) return deps @@ -578,6 +587,7 @@ func addApiModule(mctx android.LoadHookContext, i *aidlInterface) string { AidlRoot: aidlRoot, Stability: i.properties.Stability, Imports: i.properties.Imports, + Headers: i.properties.Headers, Versions: i.getVersions(), Dumpapi: i.properties.Dumpapi, }) diff --git a/build/aidl_gen_rule.go b/build/aidl_gen_rule.go index 3dd0fde5..6a326d16 100644 --- a/build/aidl_gen_rule.go +++ b/build/aidl_gen_rule.go @@ -66,6 +66,7 @@ type aidlGenProperties struct { Srcs []string `android:"path"` AidlRoot string // base directory for the input aidl file Imports []string + Headers []string Stability *string Min_sdk_version *string Platform_apis bool @@ -114,12 +115,12 @@ func (g *aidlGenRule) getImports(ctx android.ModuleContext) map[string]string { func (g *aidlGenRule) GenerateAndroidBuildActions(ctx android.ModuleContext) { srcs, imports := getPaths(ctx, g.properties.Srcs, g.properties.AidlRoot) + g.deps = getDeps(ctx, g.getImports(ctx)) + if ctx.Failed() { return } - g.deps = getDeps(ctx, g.getImports(ctx)) - genDirTimestamp := android.PathForModuleGen(ctx, "timestamp") // $out/gen/timestamp g.implicitInputs = append(g.implicitInputs, genDirTimestamp) g.implicitInputs = append(g.implicitInputs, g.deps.implicits...) diff --git a/build/aidl_interface.go b/build/aidl_interface.go index 36527e4e..e853c243 100644 --- a/build/aidl_interface.go +++ b/build/aidl_interface.go @@ -406,6 +406,10 @@ type aidlInterfaceProperties struct { // --dumpapi options Dumpapi DumpApiProperties + + // List of aidl_interface_headers modules that provide include dependencies + // for the AIDL tool. + Headers []string } type aidlInterface struct { @@ -490,6 +494,10 @@ type interfaceDepTag struct { blueprint.BaseDependencyTag } +type interfaceHeadersDepTag struct { + blueprint.BaseDependencyTag +} + var ( // Dep from *-source (aidlGenRule) to *-api (aidlApi) apiDep = apiDepTag{name: "api"} @@ -497,6 +505,8 @@ var ( importApiDep = apiDepTag{name: "imported-api"} // Dep to original *-interface (aidlInterface) interfaceDep = interfaceDepTag{} + // Dep for a header interface + interfaceHeadersDep = interfaceHeadersDepTag{} ) func addImportedInterfaceDeps(ctx android.BottomUpMutatorContext, imports []string) { @@ -529,6 +539,10 @@ func addInterfaceDeps(mctx android.BottomUpMutatorContext) { return } addImportedInterfaceDeps(mctx, i.properties.Imports) + + for _, header := range i.properties.Headers { + mctx.AddDependency(i, interfaceHeadersDep, header) + } case *aidlImplementationGenerator: mctx.AddDependency(i, interfaceDep, i.properties.AidlInterfaceName+aidlInterfaceSuffix) addImportedInterfaceDeps(mctx, i.properties.Imports) @@ -547,6 +561,9 @@ func addInterfaceDeps(mctx android.BottomUpMutatorContext) { name, _ := parseModuleWithVersion(anImport) mctx.AddDependency(i, importApiDep, name+aidlApiSuffix) } + for _, header := range i.properties.Headers { + mctx.AddDependency(i, interfaceHeadersDep, header) + } case *aidlGenRule: mctx.AddDependency(i, interfaceDep, i.properties.BaseName+aidlInterfaceSuffix) addImportedInterfaceDeps(mctx, i.properties.Imports) @@ -554,6 +571,9 @@ func addInterfaceDeps(mctx android.BottomUpMutatorContext) { // for checkapi timestamps mctx.AddDependency(i, apiDep, i.properties.BaseName+aidlApiSuffix) } + for _, header := range i.properties.Headers { + mctx.AddDependency(i, interfaceHeadersDep, header) + } } } @@ -936,6 +956,8 @@ func (i *aidlInterface) buildPreprocessed(ctx android.ModuleContext, version str } paths, imports := getPaths(ctx, srcs, root_dir) + imports = append(imports, deps.imports...) + imports = append(imports, i.properties.Include_dirs...) preprocessCommand := rb.Command().BuiltTool("aidl"). FlagWithOutput("--preprocess ", preprocessed). @@ -944,7 +966,7 @@ func (i *aidlInterface) buildPreprocessed(ctx android.ModuleContext, version str preprocessCommand.FlagWithArg("--stability ", *i.properties.Stability) } preprocessCommand.FlagForEachInput("-p", deps.preprocessed) - preprocessCommand.FlagForEachArg("-I", concat(imports, i.properties.Include_dirs)) + preprocessCommand.FlagForEachArg("-I", imports) preprocessCommand.Inputs(paths) name := i.BaseModuleName() if version != "" { diff --git a/build/aidl_interface_backends.go b/build/aidl_interface_backends.go index 62a167ce..54948ce1 100644 --- a/build/aidl_interface_backends.go +++ b/build/aidl_interface_backends.go @@ -76,6 +76,7 @@ func addCppLibrary(mctx android.LoadHookContext, i *aidlInterface, version strin Srcs: srcs, AidlRoot: aidlRoot, Imports: i.getImportsForVersion(version), + Headers: i.properties.Headers, Stability: i.properties.Stability, Min_sdk_version: i.minSdkVersion(lang), Lang: lang, @@ -224,6 +225,7 @@ func addJavaLibrary(mctx android.LoadHookContext, i *aidlInterface, version stri Srcs: srcs, AidlRoot: aidlRoot, Imports: i.getImportsForVersion(version), + Headers: i.properties.Headers, Stability: i.properties.Stability, Min_sdk_version: minSdkVersion, Platform_apis: proptools.Bool(i.properties.Backend.Java.Platform_apis), @@ -276,6 +278,7 @@ func addRustLibrary(mctx android.LoadHookContext, i *aidlInterface, version stri Srcs: srcs, AidlRoot: aidlRoot, Imports: i.getImportsForVersion(version), + Headers: i.properties.Headers, Stability: i.properties.Stability, Min_sdk_version: i.minSdkVersion(langRust), Lang: langRust, diff --git a/build/aidl_interface_headers.go b/build/aidl_interface_headers.go new file mode 100644 index 00000000..0d59c4d7 --- /dev/null +++ b/build/aidl_interface_headers.go @@ -0,0 +1,69 @@ +// Copyright (C) 2022 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aidl + +import ( + "path/filepath" + + "android/soong/android" + + "github.com/google/blueprint" + "github.com/google/blueprint/proptools" +) + +func init() { + android.RegisterModuleType("aidl_interface_headers", aidlInterfaceHeadersFactory) +} + +type AidlInterfaceHeadersInfo struct { + Srcs android.Paths + IncludeDir string +} + +var AidlInterfaceHeadersProvider = blueprint.NewProvider(AidlInterfaceHeadersInfo{}) + +type aidlInterfaceHeadersProperties struct { + // List of .aidl files which compose this interface. + Srcs []string `android:"path"` + + // Relative path for includes. assumes AIDL path is relative to current directory. + Include_dir *string +} + +type aidlInterfaceHeaders struct { + android.ModuleBase + + properties aidlInterfaceHeadersProperties + + srcs android.Paths +} + +// Modules which provide AIDL sources that are only used to provide "-I" flags to the +// aidl tool. No language bindings are generated from these modules. Typically this will +// be used to provide includes for UnstructuredParcelable AIDL definitions such as those +// coming from framework modules. +func aidlInterfaceHeadersFactory() android.Module { + i := &aidlInterfaceHeaders{} + i.AddProperties(&i.properties) + android.InitAndroidModule(i) + return i +} + +func (i *aidlInterfaceHeaders) GenerateAndroidBuildActions(ctx android.ModuleContext) { + ctx.SetProvider(AidlInterfaceHeadersProvider, AidlInterfaceHeadersInfo{ + Srcs: android.PathsForModuleSrc(ctx, i.properties.Srcs), + IncludeDir: filepath.Join(ctx.ModuleDir(), proptools.String(i.properties.Include_dir)), + }) +} diff --git a/build/aidl_test.go b/build/aidl_test.go index 8c258dbd..11f8dd94 100644 --- a/build/aidl_test.go +++ b/build/aidl_test.go @@ -175,6 +175,7 @@ func _testAidl(t *testing.T, bp string, customizers ...android.FixturePreparer) android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { ctx.RegisterModuleType("aidl_interface", aidlInterfaceFactory) ctx.RegisterModuleType("aidl_interfaces_metadata", aidlInterfacesMetadataSingletonFactory) + ctx.RegisterModuleType("aidl_interface_headers", aidlInterfaceHeadersFactory) ctx.RegisterModuleType("rust_defaults", func() android.Module { return rust.DefaultsFactory() }) @@ -1097,6 +1098,7 @@ func TestAidlImportFlagsForImportedModules(t *testing.T) { srcs: ["a/Foo.aidl"], imports: ["bar-iface-V2"], versions: ["1"], + headers: ["boq-iface-headers"], } `), "foo/a/Foo.aidl": nil, @@ -1129,13 +1131,21 @@ func TestAidlImportFlagsForImportedModules(t *testing.T) { "baz/aidl_api/baz-iface/current/b/Baz.aidl": nil, "baz/aidl_api/baz-iface/1/b/Baz.aidl": nil, "baz/aidl_api/baz-iface/1/.hash": nil, + + "boq/Android.bp": []byte(` + aidl_interface_headers { + name: "boq-iface-headers", + srcs: ["b/Boq.aidl"], + } + `), + "boq/b/Baz.aidl": nil, }) ctx, _ := testAidl(t, ``, customizer) // checkapidump rule is to compare "compatibility" between ToT(dump) and "current" { rule := ctx.ModuleForTests("foo-iface-api", "").Output("checkapi_dump.timestamp") - android.AssertStringEquals(t, "checkapi(dump == current) imports", "", rule.Args["imports"]) + android.AssertStringEquals(t, "checkapi(dump == current) imports", "-Iboq", rule.Args["imports"]) android.AssertStringDoesContain(t, "checkapi(dump == current) optionalFlags", rule.Args["optionalFlags"], "-pout/soong/.intermediates/bar/bar-iface_interface/2/preprocessed.aidl") @@ -1153,7 +1163,9 @@ func TestAidlImportFlagsForImportedModules(t *testing.T) { // compile (v1) { rule := ctx.ModuleForTests("foo-iface-V1-cpp-source", "").Output("a/Foo.cpp") - android.AssertStringEquals(t, "compile(old=1) should import aidl_api/1", "-Ifoo/aidl_api/foo-iface/1", rule.Args["imports"]) + android.AssertStringEquals(t, "compile(old=1) should import aidl_api/1", + "-Ifoo/aidl_api/foo-iface/1 -Iboq", + rule.Args["imports"]) android.AssertStringDoesContain(t, "compile(old=1) should import bar.preprocessed", rule.Args["optionalFlags"], "-pout/soong/.intermediates/bar/bar-iface_interface/2/preprocessed.aidl") @@ -1161,7 +1173,7 @@ func TestAidlImportFlagsForImportedModules(t *testing.T) { // compile ToT(v2) { rule := ctx.ModuleForTests("foo-iface-V2-cpp-source", "").Output("a/Foo.cpp") - android.AssertStringEquals(t, "compile(tot=2) should import base dirs of srcs", "-Ifoo", rule.Args["imports"]) + android.AssertStringEquals(t, "compile(tot=2) should import base dirs of srcs", "-Ifoo -Iboq", rule.Args["imports"]) android.AssertStringDoesContain(t, "compile(tot=2) should import bar.preprocessed", rule.Args["optionalFlags"], "-pout/soong/.intermediates/bar/bar-iface_interface/2/preprocessed.aidl") |