diff options
author | Steven Moreland <smoreland@google.com> | 2024-01-04 03:09:48 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2024-01-04 03:09:48 +0000 |
commit | b55ee9ffa56fb63175b34fc2ba4ceeb1035f6a2b (patch) | |
tree | f700d819747e818f970e39b0e9b40badcb97324e | |
parent | dfc4ec6c27649668c0a67a8d948b6240884ab8a2 (diff) | |
parent | a321d69f900360c948653be5d3374fae5249c453 (diff) | |
download | aidl-b55ee9ffa56fb63175b34fc2ba4ceeb1035f6a2b.tar.gz |
always_allow_unfrozen am: 5c3d46d304 am: aa38b59585 am: a321d69f90
Original change: https://android-review.googlesource.com/c/platform/system/tools/aidl/+/2889272
Change-Id: I0d5206cad65709eeb118eb936b4506564f94a6ec
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | build/Android.bp | 30 | ||||
-rw-r--r-- | build/aidl_api/tests-unfrozen-vendor/1/.hash | 1 | ||||
-rw-r--r-- | build/aidl_api/tests-unfrozen-vendor/1/vendor/IFoo.aidl | 22 | ||||
-rw-r--r-- | build/aidl_api/tests-unfrozen-vendor/current/vendor/IFoo.aidl | 23 | ||||
-rw-r--r-- | build/aidl_gen_rule.go | 16 | ||||
-rw-r--r-- | build/aidl_interface.go | 36 | ||||
-rw-r--r-- | build/aidl_interface_backends.go | 4 | ||||
-rw-r--r-- | build/aidl_interface_metadata_singleton.go | 11 | ||||
-rw-r--r-- | build/test_unfrozen_iface.cpp | 19 | ||||
-rw-r--r-- | build/tests_unfrozen_vendor/vendor/IFoo.aidl | 6 | ||||
-rw-r--r-- | metadata/include/aidl/metadata.h | 4 | ||||
-rw-r--r-- | metadata/parser.cpp | 1 | ||||
-rw-r--r-- | metadata/test.cpp | 5 |
13 files changed, 163 insertions, 15 deletions
diff --git a/build/Android.bp b/build/Android.bp index 836a7763..c5b32177 100644 --- a/build/Android.bp +++ b/build/Android.bp @@ -390,6 +390,36 @@ aidl_interface { ], } +aidl_interface { + name: "tests-unfrozen-vendor", + owner: "google", + local_include_dir: "tests_unfrozen_vendor", + srcs: ["tests_unfrozen_vendor/vendor/IFoo.aidl"], + vendor_available: true, + backend: { + rust: { + enabled: true, + }, + }, + frozen: false, + always_use_unfrozen: true, + versions_with_info: [ + { + version: "1", + imports: [], + }, + ], + +} + +cc_library { + name: "build_test_aidl_always_use_unfrozen", + srcs: ["test_unfrozen_iface.cpp"], + shared_libs: [ + "tests-unfrozen-vendor-V2-cpp", + ], +} + // These test that a parcel imported from A->B->C will have the required dependencies to link in // all backends (C++ backends need to link direclty against the constructor of the parcelable // in order to work) diff --git a/build/aidl_api/tests-unfrozen-vendor/1/.hash b/build/aidl_api/tests-unfrozen-vendor/1/.hash new file mode 100644 index 00000000..f948d9ab --- /dev/null +++ b/build/aidl_api/tests-unfrozen-vendor/1/.hash @@ -0,0 +1 @@ +4c1abd625626228b3aa4a015e3745cd08752ddb6 diff --git a/build/aidl_api/tests-unfrozen-vendor/1/vendor/IFoo.aidl b/build/aidl_api/tests-unfrozen-vendor/1/vendor/IFoo.aidl new file mode 100644 index 00000000..74eaf385 --- /dev/null +++ b/build/aidl_api/tests-unfrozen-vendor/1/vendor/IFoo.aidl @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package vendor; +interface IFoo { + void foo(); +} diff --git a/build/aidl_api/tests-unfrozen-vendor/current/vendor/IFoo.aidl b/build/aidl_api/tests-unfrozen-vendor/current/vendor/IFoo.aidl new file mode 100644 index 00000000..9a014420 --- /dev/null +++ b/build/aidl_api/tests-unfrozen-vendor/current/vendor/IFoo.aidl @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package vendor; +interface IFoo { + void foo(); + void bar(); +} diff --git a/build/aidl_gen_rule.go b/build/aidl_gen_rule.go index ae329509..b9890e34 100644 --- a/build/aidl_gen_rule.go +++ b/build/aidl_gen_rule.go @@ -92,6 +92,7 @@ type aidlGenProperties struct { RequireFrozenReason string Visibility []string Flags []string + UseUnfrozen bool } type aidlGenRule struct { @@ -232,23 +233,10 @@ func (g *aidlGenRule) generateBuildActionsForSingleAidl(ctx android.ModuleContex } optionalFlags = append(optionalFlags, wrap("-p", g.deps.preprocessed.Strings(), "")...) - unfrozen_override := ctx.Config().Getenv("AIDL_USE_UNFROZEN_OVERRIDE") - var use_unfrozen bool - if unfrozen_override != "" { - if unfrozen_override == "true" { - use_unfrozen = true - } else if unfrozen_override == "false" { - use_unfrozen = false - } else { - ctx.PropertyErrorf("AIDL_USE_UNFROZEN_OVERRIDE has unexpected value of \"%s\". Should be \"true\" or \"false\".", unfrozen_override) - } - } else { - use_unfrozen = ctx.DeviceConfig().Release_aidl_use_unfrozen() - } // If this is an unfrozen version of a previously frozen interface, we want (1) the location // of the previously frozen source and (2) the previously frozen hash so the generated // library can behave like both versions at run time. - if !use_unfrozen && previousVersion != "" && + if !g.properties.UseUnfrozen && previousVersion != "" && !proptools.Bool(g.properties.Unstable) && g.hashFile == nil { apiDirPath := android.ExistentPathForSource(ctx, previousApiDir) if apiDirPath.Valid() { diff --git a/build/aidl_interface.go b/build/aidl_interface.go index db476d03..9b3affa7 100644 --- a/build/aidl_interface.go +++ b/build/aidl_interface.go @@ -334,6 +334,17 @@ type aidlInterfaceProperties struct { // List of .aidl files which compose this interface. Srcs []string `android:"path"` + // Normally, in release configurations, such as next, unfrozen AIDL + // interfaces may be disabled. However, for some partners developing + // on Android, they may prefer to use the release configuration + // while making a small amount of changes for development. In this + // case, the VTS test vts_treble_vintf_vendor_test would still fail. + // However, the build would be unblocked. + // + // Note: this will not work for AOSP android.* interfaces because they + // will not be available in the compatibility matrix. + Always_use_unfrozen *bool + // List of aidl_interface modules that this uses. If one of your AIDL interfaces uses an // interface or parcelable from another aidl_interface, you should put its name here. // It could be an aidl_interface solely or with version(such as -V1) @@ -490,6 +501,31 @@ func (i *aidlInterface) shouldGenerateRustBackend() bool { return i.properties.Backend.Rust.Enabled != nil && *i.properties.Backend.Rust.Enabled } +func (i *aidlInterface) useUnfrozen(ctx android.EarlyModuleContext) bool { + var use_unfrozen bool + + unfrozen_override := ctx.Config().Getenv("AIDL_USE_UNFROZEN_OVERRIDE") + if unfrozen_override != "" { + if unfrozen_override == "true" { + use_unfrozen = true + } else if unfrozen_override == "false" { + use_unfrozen = false + } else { + ctx.PropertyErrorf("AIDL_USE_UNFROZEN_OVERRIDE has unexpected value of \"%s\". Should be \"true\" or \"false\".", unfrozen_override) + } + } else { + use_unfrozen = ctx.DeviceConfig().Release_aidl_use_unfrozen() + } + + // could check this earlier and return, but make sure we always verify + // environmental variables + if proptools.Bool(i.properties.Always_use_unfrozen) { + use_unfrozen = true + } + + return use_unfrozen +} + func (i *aidlInterface) minSdkVersion(lang string) *string { var ver *string switch lang { diff --git a/build/aidl_interface_backends.go b/build/aidl_interface_backends.go index a7653d68..8f515aa7 100644 --- a/build/aidl_interface_backends.go +++ b/build/aidl_interface_backends.go @@ -94,6 +94,7 @@ func addCppLibrary(mctx android.DefaultableHookContext, i *aidlInterface, versio NotFrozen: notFrozen, RequireFrozenReason: requireFrozenReason, Flags: i.flagsForAidlGenRule(version), + UseUnfrozen: i.useUnfrozen(mctx), }, ) @@ -237,6 +238,7 @@ func addCppAnalyzerLibrary(mctx android.DefaultableHookContext, i *aidlInterface NotFrozen: notFrozen, RequireFrozenReason: requireFrozenReason, Flags: i.flagsForAidlGenRule(version), + UseUnfrozen: i.useUnfrozen(mctx), }) importExportDependencies := []string{} @@ -337,6 +339,7 @@ func addJavaLibrary(mctx android.DefaultableHookContext, i *aidlInterface, versi NotFrozen: notFrozen, RequireFrozenReason: requireFrozenReason, Flags: i.flagsForAidlGenRule(version), + UseUnfrozen: i.useUnfrozen(mctx), }) mctx.CreateModule(aidlImplementationGeneratorFactory, &nameProperties{ @@ -392,6 +395,7 @@ func addRustLibrary(mctx android.DefaultableHookContext, i *aidlInterface, versi NotFrozen: notFrozen, RequireFrozenReason: requireFrozenReason, Flags: i.flagsForAidlGenRule(version), + UseUnfrozen: i.useUnfrozen(mctx), }) versionedRustName := fixRustName(i.versionedName(version)) diff --git a/build/aidl_interface_metadata_singleton.go b/build/aidl_interface_metadata_singleton.go index ef3af3c8..cab183a3 100644 --- a/build/aidl_interface_metadata_singleton.go +++ b/build/aidl_interface_metadata_singleton.go @@ -33,11 +33,12 @@ var ( `echo "\"types\": [${types}]," && ` + `echo "\"hashes\": [${hashes}]," && ` + `echo "\"has_development\": ${has_development}," && ` + + `echo "\"use_unfrozen\": ${use_unfrozen}," && ` + `echo "\"versions\": [${versions}]" && ` + `echo '}' ` + `;} >> ${out}`, Description: "AIDL metadata: ${out}", - }, "name", "stability", "types", "hashes", "has_development", "versions") + }, "name", "stability", "types", "hashes", "has_development", "use_unfrozen", "versions") joinJsonObjectsToArrayRule = pctx.StaticRule("joinJsonObjectsToArrayRule", blueprint.RuleParams{ Rspfile: "$out.rsp", @@ -84,6 +85,7 @@ func (m *aidlInterfacesMetadataSingleton) GenerateAndroidBuildActions(ctx androi ComputedTypes []string HashFiles []string HasDevelopment android.WritablePath + UseUnfrozen bool Versions []string } @@ -100,6 +102,7 @@ func (m *aidlInterfacesMetadataSingleton) GenerateAndroidBuildActions(ctx androi info.Stability = proptools.StringDefault(t.properties.Stability, "") info.ComputedTypes = t.computedTypes info.Versions = t.getVersions() + info.UseUnfrozen = t.useUnfrozen(ctx) moduleInfos[t.ModuleBase.Name()] = info case *aidlGenRule: info := moduleInfos[t.properties.BaseName] @@ -138,6 +141,11 @@ func (m *aidlInterfacesMetadataSingleton) GenerateAndroidBuildActions(ctx androi ")\" = \"1\" ]; then echo true; else echo false; fi)" } + useUnfrozenValue := "false" + if info.UseUnfrozen { + useUnfrozenValue = "true" + } + ctx.Build(pctx, android.BuildParams{ Rule: aidlMetadataRule, Implicits: implicits, @@ -149,6 +157,7 @@ func (m *aidlInterfacesMetadataSingleton) GenerateAndroidBuildActions(ctx androi "types": strings.Join(wrap(`\"`, info.ComputedTypes, `\"`), ", "), "hashes": readHashes, "has_development": hasDevelopmentValue, + "use_unfrozen": useUnfrozenValue, "versions": strings.Join(info.Versions, ", "), }, }) diff --git a/build/test_unfrozen_iface.cpp b/build/test_unfrozen_iface.cpp new file mode 100644 index 00000000..a0b313c9 --- /dev/null +++ b/build/test_unfrozen_iface.cpp @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2023 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. + */ + +#include <vendor/IFoo.h> + +static_assert(vendor::IFoo::VERSION == 2, "version must always be 2"); diff --git a/build/tests_unfrozen_vendor/vendor/IFoo.aidl b/build/tests_unfrozen_vendor/vendor/IFoo.aidl new file mode 100644 index 00000000..48539408 --- /dev/null +++ b/build/tests_unfrozen_vendor/vendor/IFoo.aidl @@ -0,0 +1,6 @@ +package vendor; + +interface IFoo { + void foo(); // V1 + void bar(); // V2 ** UNFROZEN ** +} diff --git a/metadata/include/aidl/metadata.h b/metadata/include/aidl/metadata.h index 09c60ba3..fe602c4b 100644 --- a/metadata/include/aidl/metadata.h +++ b/metadata/include/aidl/metadata.h @@ -37,6 +37,10 @@ struct AidlInterfaceMetadata { // true if the interface is different from the last frozen version bool has_development; + // true if the unfrozen interface is allowed to be used at runtime + // in this build configuration + bool use_unfrozen; + // list of all frozen versions std::vector<size_t> versions; diff --git a/metadata/parser.cpp b/metadata/parser.cpp index 646a77b4..e457e937 100644 --- a/metadata/parser.cpp +++ b/metadata/parser.cpp @@ -57,6 +57,7 @@ int main(int argc, char** argv) { } std::cout << "}," << std::endl; std::cout << entry["has_development"].asString() << "," << std::endl; + std::cout << entry["use_unfrozen"].asString() << "," << std::endl; std::cout << "std::vector<size_t>{" << std::endl; for (const Json::Value& intf : entry["versions"]) { std::cout << intf.asString() << "," << std::endl; diff --git a/metadata/test.cpp b/metadata/test.cpp index 7d7d3313..4df5082e 100644 --- a/metadata/test.cpp +++ b/metadata/test.cpp @@ -55,3 +55,8 @@ TEST(AidlMetadata, HasTestInstancesNoDevelopment) { EXPECT_THAT(info->versions, ElementsAre(1)); EXPECT_EQ(info->has_development, false); } + +TEST(AidlMetadata, UseUnfrozen) { + const auto& info = metadataForModule("tests-unfrozen-vendor"); + EXPECT_TRUE(info->use_unfrozen); +} |