From 6fa44c197335a8bea4f96cce3296f5c92d8dd7e7 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 27 Sep 2022 12:41:52 +0100 Subject: [PATCH 01/67] java_sdk_library_import: Copy all prebuilt properties to child modules Previously, only the prefer property was copied from the java_sdk_library_import module to its child modules which meant that if the use_source_config_var property was used to control the prefer property that the child modules would never be used. That can cause build breakages when building against prebuilts as some parts of the build will use prebuilt files from java_sdk_library_import and some will use source files from the corresponding java_sdk_library. This change copies the use_source_config_var property too. It also adds tests to verify that dependencies on child modules of a java_sdk_library use the prebuilt child modules of the corresponding java_sdk_library_import. That revealed a bug with the handling of stub sources where the prefer property was set after creating the module which has also been fixed. Bug: 249192297 Test: m nothing # Cherry pick into branch broken by previous behavior and make # sure that it fixes it. Change-Id: I5719c257f8457bcb2238bc7965215512a20f1095 (cherry picked from commit on android-review.googlesource.com host: bf4de041de611de4b3ec24c5f261c4293522961a) Merged-In: I5719c257f8457bcb2238bc7965215512a20f1095 (cherry picked from commit 8ab8056a4f9de6cec1fdedc7d49502439ea7aef6) --- android/prebuilt.go | 14 +++++++- java/sdk_library.go | 17 ++++++---- java/sdk_library_test.go | 70 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 91 insertions(+), 10 deletions(-) diff --git a/android/prebuilt.go b/android/prebuilt.go index 584348767..e7f221b6d 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go @@ -56,7 +56,9 @@ func (t prebuiltDependencyTag) ExcludeFromApexContents() {} var _ ExcludeFromVisibilityEnforcementTag = PrebuiltDepTag var _ ExcludeFromApexContentsTag = PrebuiltDepTag -type PrebuiltProperties struct { +// UserSuppliedPrebuiltProperties contains the prebuilt properties that can be specified in an +// Android.bp file. +type UserSuppliedPrebuiltProperties struct { // When prefer is set to true the prebuilt will be used instead of any source module with // a matching name. Prefer *bool `android:"arch_variant"` @@ -70,6 +72,16 @@ type PrebuiltProperties struct { // If specified then the prefer property is ignored in favor of the value of the Soong config // variable. Use_source_config_var *ConfigVarProperties +} + +// CopyUserSuppliedPropertiesFromPrebuilt copies the user supplied prebuilt properties from the +// prebuilt properties. +func (u *UserSuppliedPrebuiltProperties) CopyUserSuppliedPropertiesFromPrebuilt(p *Prebuilt) { + *u = p.properties.UserSuppliedPrebuiltProperties +} + +type PrebuiltProperties struct { + UserSuppliedPrebuiltProperties SourceExists bool `blueprint:"mutated"` UsePrebuilt bool `blueprint:"mutated"` diff --git a/java/sdk_library.go b/java/sdk_library.go index 47ffc6afc..cb4805823 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2119,8 +2119,9 @@ func (module *SdkLibraryImport) createJavaImportForStubs(mctx android.Defaultabl Sdk_version *string Libs []string Jars []string - Prefer *bool Compile_dex *bool + + android.UserSuppliedPrebuiltProperties }{} props.Name = proptools.StringPtr(module.stubsLibraryModuleName(apiScope)) props.Sdk_version = scopeProperties.Sdk_version @@ -2130,7 +2131,7 @@ func (module *SdkLibraryImport) createJavaImportForStubs(mctx android.Defaultabl props.Jars = scopeProperties.Jars // The imports are preferred if the java_sdk_library_import is preferred. - props.Prefer = proptools.BoolPtr(module.prebuilt.Prefer()) + props.CopyUserSuppliedPropertiesFromPrebuilt(&module.prebuilt) // The imports need to be compiled to dex if the java_sdk_library_import requests it. compileDex := module.properties.Compile_dex @@ -2144,16 +2145,18 @@ func (module *SdkLibraryImport) createJavaImportForStubs(mctx android.Defaultabl func (module *SdkLibraryImport) createPrebuiltStubsSources(mctx android.DefaultableHookContext, apiScope *apiScope, scopeProperties *sdkLibraryScopeProperties) { props := struct { - Name *string - Srcs []string - Prefer *bool + Name *string + Srcs []string + + android.UserSuppliedPrebuiltProperties }{} props.Name = proptools.StringPtr(module.stubsSourceModuleName(apiScope)) props.Srcs = scopeProperties.Stub_srcs - mctx.CreateModule(PrebuiltStubsSourcesFactory, &props) // The stubs source is preferred if the java_sdk_library_import is preferred. - props.Prefer = proptools.BoolPtr(module.prebuilt.Prefer()) + props.CopyUserSuppliedPropertiesFromPrebuilt(&module.prebuilt) + + mctx.CreateModule(PrebuiltStubsSourcesFactory, &props) } // Add the dependencies on the child module in the component deps mutator so that it diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 3500c84d2..ec971a8fe 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -867,11 +867,12 @@ func TestJavaSdkLibraryImport_WithSource(t *testing.T) { }) } -func TestJavaSdkLibraryImport_Preferred(t *testing.T) { +func testJavaSdkLibraryImport_Preferred(t *testing.T, prefer string, preparer android.FixturePreparer) { result := android.GroupFixturePreparers( prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("sdklib"), + preparer, ).RunTestWithBp(t, ` java_sdk_library { name: "sdklib", @@ -885,11 +886,37 @@ func TestJavaSdkLibraryImport_Preferred(t *testing.T) { java_sdk_library_import { name: "sdklib", - prefer: true, + `+prefer+` public: { jars: ["a.jar"], + stub_srcs: ["a.java"], + current_api: "current.txt", + removed_api: "removed.txt", + annotations: "annotations.zip", }, } + + java_library { + name: "combined", + static_libs: [ + "sdklib.stubs", + ], + java_resources: [ + ":sdklib.stubs.source", + ":sdklib{.public.api.txt}", + ":sdklib{.public.removed-api.txt}", + ":sdklib{.public.annotations.zip}", + ], + sdk_version: "none", + system_modules: "none", + } + + java_library { + name: "public", + srcs: ["a.java"], + libs: ["sdklib"], + sdk_version: "current", + } `) CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{ @@ -903,9 +930,48 @@ func TestJavaSdkLibraryImport_Preferred(t *testing.T) { CheckModuleDependencies(t, result.TestContext, "prebuilt_sdklib", "android_common", []string{ `dex2oatd`, `prebuilt_sdklib.stubs`, + `prebuilt_sdklib.stubs.source`, `sdklib.impl`, `sdklib.xml`, }) + + // Make sure that dependencies on child modules use the prebuilt when preferred. + CheckModuleDependencies(t, result.TestContext, "combined", "android_common", []string{ + // Each use of :sdklib{...} adds a dependency onto prebuilt_sdklib. + `prebuilt_sdklib`, + `prebuilt_sdklib`, + `prebuilt_sdklib`, + `prebuilt_sdklib.stubs`, + `prebuilt_sdklib.stubs.source`, + }) + + // Make sure that dependencies on sdklib that resolve to one of the child libraries use the + // prebuilt library. + public := result.ModuleForTests("public", "android_common") + rule := public.Output("javac/public.jar") + inputs := rule.Implicits.Strings() + expected := "out/soong/.intermediates/prebuilt_sdklib.stubs/android_common/combined/sdklib.stubs.jar" + if !android.InList(expected, inputs) { + t.Errorf("expected %q to contain %q", inputs, expected) + } +} + +func TestJavaSdkLibraryImport_Preferred(t *testing.T) { + t.Run("prefer", func(t *testing.T) { + testJavaSdkLibraryImport_Preferred(t, "prefer: true,", android.NullFixturePreparer) + }) + + t.Run("use_source_config_var", func(t *testing.T) { + testJavaSdkLibraryImport_Preferred(t, + "use_source_config_var: {config_namespace: \"acme\", var_name: \"use_source\"},", + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.VendorVars = map[string]map[string]string{ + "acme": { + "use_source": "false", + }, + } + })) + }) } func TestJavaSdkLibraryEnforce(t *testing.T) { From 521fdf5b647bbbb6523d26a93723b4c3136b902d Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 1 Sep 2023 16:11:47 -0700 Subject: [PATCH 02/67] Add install_symlink soong module type This can be used to install symlinks to arbitrary locations/targets on the device. Used to replace a make-built symlink. Bug: 205632228 Test: built and ran the emulator observed the /system/bin/hwservicemanager symlink is still there (cherry picked from https://android-review.googlesource.com/q/commit:dff9c14148de93502b3880d9f9943054c2eeb392) Merged-In: I6df922c8d919e6d56fa79702815a89c98f4d65ed Change-Id: I6df922c8d919e6d56fa79702815a89c98f4d65ed --- etc/Android.bp | 2 + etc/install_symlink.go | 92 ++++++++++++++++++++++++ etc/install_symlink_test.go | 135 ++++++++++++++++++++++++++++++++++++ etc/prebuilt_etc_test.go | 2 +- 4 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 etc/install_symlink.go create mode 100644 etc/install_symlink_test.go diff --git a/etc/Android.bp b/etc/Android.bp index c67023679..cefd717aa 100644 --- a/etc/Android.bp +++ b/etc/Android.bp @@ -14,10 +14,12 @@ bootstrap_go_package { srcs: [ "prebuilt_etc.go", "snapshot_etc.go", + "install_symlink.go", ], testSrcs: [ "prebuilt_etc_test.go", "snapshot_etc_test.go", + "install_symlink_test.go", ], pluginFor: ["soong_build"], } diff --git a/etc/install_symlink.go b/etc/install_symlink.go new file mode 100644 index 000000000..2182b8669 --- /dev/null +++ b/etc/install_symlink.go @@ -0,0 +1,92 @@ +// Copyright 2023 Google Inc. All rights reserved. +// +// 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 etc + +import ( + "android/soong/android" + "path/filepath" + "strings" +) + +func init() { + RegisterInstallSymlinkBuildComponents(android.InitRegistrationContext) +} + +func RegisterInstallSymlinkBuildComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("install_symlink", InstallSymlinkFactory) +} + +// install_symlink can be used to install an symlink with an arbitrary target to an arbitrary path +// on the device. +func InstallSymlinkFactory() android.Module { + module := &InstallSymlink{} + module.AddProperties(&module.properties) + android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) + return module +} + +type InstallSymlinkProperties struct { + // Where to install this symlink, relative to the partition it's installed on. + // Which partition it's installed on can be controlled by the vendor, system_ext, ramdisk, etc. + // properties. + Installed_location string + // The target of the symlink, aka where the symlink points. + Symlink_target string +} + +type InstallSymlink struct { + android.ModuleBase + properties InstallSymlinkProperties + + output android.Path + installedPath android.InstallPath +} + +func (m *InstallSymlink) GenerateAndroidBuildActions(ctx android.ModuleContext) { + if filepath.Clean(m.properties.Symlink_target) != m.properties.Symlink_target { + ctx.PropertyErrorf("symlink_target", "Should be a clean filepath") + return + } + if filepath.Clean(m.properties.Installed_location) != m.properties.Installed_location { + ctx.PropertyErrorf("installed_location", "Should be a clean filepath") + return + } + if strings.HasPrefix(m.properties.Installed_location, "../") || strings.HasPrefix(m.properties.Installed_location, "/") { + ctx.PropertyErrorf("installed_location", "Should not start with / or ../") + return + } + + out := android.PathForModuleOut(ctx, "out.txt") + android.WriteFileRuleVerbatim(ctx, out, "") + m.output = out + + name := filepath.Base(m.properties.Installed_location) + installDir := android.PathForModuleInstall(ctx, filepath.Dir(m.properties.Installed_location)) + m.installedPath = ctx.InstallAbsoluteSymlink(installDir, name, m.properties.Symlink_target) +} + +func (m *InstallSymlink) AndroidMkEntries() []android.AndroidMkEntries { + return []android.AndroidMkEntries{{ + Class: "FAKE", + // Need at least one output file in order for this to take effect. + OutputFile: android.OptionalPathForPath(m.output), + Include: "$(BUILD_PHONY_PACKAGE)", + ExtraEntries: []android.AndroidMkExtraEntriesFunc{ + func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { + entries.AddStrings("LOCAL_SOONG_INSTALL_SYMLINKS", m.installedPath.String()) + }, + }, + }} +} diff --git a/etc/install_symlink_test.go b/etc/install_symlink_test.go new file mode 100644 index 000000000..d7165e5de --- /dev/null +++ b/etc/install_symlink_test.go @@ -0,0 +1,135 @@ +// Copyright 2023 Google Inc. All rights reserved. +// +// 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 etc + +import ( + "android/soong/android" + "strings" + "testing" +) + +var prepareForInstallSymlinkTest = android.GroupFixturePreparers( + android.PrepareForTestWithArchMutator, + android.FixtureRegisterWithContext(RegisterInstallSymlinkBuildComponents), +) + +func TestInstallSymlinkBasic(t *testing.T) { + result := prepareForInstallSymlinkTest.RunTestWithBp(t, ` + install_symlink { + name: "foo", + installed_location: "bin/foo", + symlink_target: "/system/system_ext/bin/foo", + } + `) + + foo_variants := result.ModuleVariantsForTests("foo") + if len(foo_variants) != 1 { + t.Fatalf("expected 1 variant, got %#v", foo_variants) + } + + foo := result.ModuleForTests("foo", "android_common").Module() + androidMkEntries := android.AndroidMkEntriesForTest(t, result.TestContext, foo) + if len(androidMkEntries) != 1 { + t.Fatalf("expected 1 androidmkentry, got %d", len(androidMkEntries)) + } + + symlinks := androidMkEntries[0].EntryMap["LOCAL_SOONG_INSTALL_SYMLINKS"] + if len(symlinks) != 1 { + t.Fatalf("Expected 1 symlink, got %d", len(symlinks)) + } + + if !strings.HasSuffix(symlinks[0], "system/bin/foo") { + t.Fatalf("Expected symlink install path to end in system/bin/foo, got: %s", symlinks[0]) + } +} + +func TestInstallSymlinkToRecovery(t *testing.T) { + result := prepareForInstallSymlinkTest.RunTestWithBp(t, ` + install_symlink { + name: "foo", + installed_location: "bin/foo", + symlink_target: "/system/system_ext/bin/foo", + recovery: true, + } + `) + + foo_variants := result.ModuleVariantsForTests("foo") + if len(foo_variants) != 1 { + t.Fatalf("expected 1 variant, got %#v", foo_variants) + } + + foo := result.ModuleForTests("foo", "android_common").Module() + androidMkEntries := android.AndroidMkEntriesForTest(t, result.TestContext, foo) + if len(androidMkEntries) != 1 { + t.Fatalf("expected 1 androidmkentry, got %d", len(androidMkEntries)) + } + + symlinks := androidMkEntries[0].EntryMap["LOCAL_SOONG_INSTALL_SYMLINKS"] + if len(symlinks) != 1 { + t.Fatalf("Expected 1 symlink, got %d", len(symlinks)) + } + + if !strings.HasSuffix(symlinks[0], "recovery/root/system/bin/foo") { + t.Fatalf("Expected symlink install path to end in recovery/root/system/bin/foo, got: %s", symlinks[0]) + } +} + +func TestErrorOnNonCleanTarget(t *testing.T) { + prepareForInstallSymlinkTest. + ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Should be a clean filepath")). + RunTestWithBp(t, ` + install_symlink { + name: "foo", + installed_location: "bin/foo", + symlink_target: "/system/system_ext/../bin/foo", + } + `) +} + +func TestErrorOnNonCleanInstalledLocation(t *testing.T) { + prepareForInstallSymlinkTest. + ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Should be a clean filepath")). + RunTestWithBp(t, ` + install_symlink { + name: "foo", + installed_location: "bin/../foo", + symlink_target: "/system/system_ext/bin/foo", + } + `) +} + +func TestErrorOnInstalledPathStartingWithDotDot(t *testing.T) { + prepareForInstallSymlinkTest. + ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Should not start with / or \\.\\./")). + RunTestWithBp(t, ` + install_symlink { + name: "foo", + installed_location: "../bin/foo", + symlink_target: "/system/system_ext/bin/foo", + } + `) +} + +func TestErrorOnInstalledPathStartingWithSlash(t *testing.T) { + prepareForInstallSymlinkTest. + ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Should not start with / or \\.\\./")). + RunTestWithBp(t, ` + install_symlink { + name: "foo", + installed_location: "/bin/foo", + symlink_target: "/system/system_ext/bin/foo", + } + `) +} diff --git a/etc/prebuilt_etc_test.go b/etc/prebuilt_etc_test.go index 0d44c31ef..df117097e 100644 --- a/etc/prebuilt_etc_test.go +++ b/etc/prebuilt_etc_test.go @@ -82,7 +82,7 @@ func TestPrebuiltEtcVariants(t *testing.T) { baz_variants := result.ModuleVariantsForTests("baz.conf") if len(baz_variants) != 1 { - t.Errorf("expected 1, got %#v", bar_variants) + t.Errorf("expected 1, got %#v", baz_variants) } } From 4f8b68116962c891f6c7c4ca403aa6db5a875a1f Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Mon, 17 Jul 2023 09:58:50 -0400 Subject: [PATCH 03/67] Make genrule export_include_dirs more consistent Previously, genrule export_include_dirs always added ModuleDir to exported include dirs when export_include_dirs is set but not when export_include_dirs is not set. Now when export_include_dirs is set, we also export the directory without the additional ModuleDir subdir. Test: genrule go tests Test: set export_include_dirs and test (cherry picked from https://android-review.googlesource.com/q/commit:d38c87c035ee267a76e1cf1a32d76756346e5679) Merged-In: I46e860b2c20c1a96bddd14367d7fa737d901994d Change-Id: I46e860b2c20c1a96bddd14367d7fa737d901994d --- genrule/genrule.go | 3 +++ genrule/genrule_test.go | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/genrule/genrule.go b/genrule/genrule.go index f532297f7..cf85a365b 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -292,6 +292,9 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { for _, dir := range g.properties.Export_include_dirs { g.exportedIncludeDirs = append(g.exportedIncludeDirs, android.PathForModuleGen(ctx, g.subDir, ctx.ModuleDir(), dir)) + // Also export without ModuleDir for consistency with Export_include_dirs not being set + g.exportedIncludeDirs = append(g.exportedIncludeDirs, + android.PathForModuleGen(ctx, g.subDir, dir)) } } else { g.exportedIncludeDirs = append(g.exportedIncludeDirs, android.PathForModuleGen(ctx, g.subDir)) diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go index 63f8fa9b8..216cbc1e6 100644 --- a/genrule/genrule_test.go +++ b/genrule/genrule_test.go @@ -790,6 +790,49 @@ func TestGenruleOutputFiles(t *testing.T) { result.ModuleForTests("gen_all", "").Module().(*useSource).srcs) } +func TestGenruleInterface(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForGenRuleTest, + android.FixtureMergeMockFs(android.MockFS{ + "package-dir/Android.bp": []byte(` + genrule { + name: "module-name", + cmd: "mkdir -p $(genDir) && cat $(in) >> $(genDir)/$(out)", + srcs: [ + "src/foo.proto", + ], + out: ["proto.h", "bar/proto.h"], + export_include_dirs: [".", "bar"], + } + `), + }), + ).RunTest(t) + + exportedIncludeDirs := []string{ + "out/soong/.intermediates/package-dir/module-name/gen/package-dir", + "out/soong/.intermediates/package-dir/module-name/gen", + "out/soong/.intermediates/package-dir/module-name/gen/package-dir/bar", + "out/soong/.intermediates/package-dir/module-name/gen/bar", + } + gen := result.Module("module-name", "").(*Module) + + android.AssertPathsRelativeToTopEquals( + t, + "include path", + exportedIncludeDirs, + gen.GeneratedHeaderDirs(), + ) + android.AssertPathsRelativeToTopEquals( + t, + "files", + []string{ + "out/soong/.intermediates/package-dir/module-name/gen/proto.h", + "out/soong/.intermediates/package-dir/module-name/gen/bar/proto.h", + }, + gen.GeneratedSourceFiles(), + ) +} + func TestGenSrcsWithNonRootAndroidBpOutputFiles(t *testing.T) { result := android.GroupFixturePreparers( prepareForGenRuleTest, From 17f01d976acd757cb6afabba3f3606a6b25d0ecf Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Tue, 5 Mar 2024 16:12:20 +0000 Subject: [PATCH 04/67] Revert "Generate runtime stubs in droidstubs" Revert submission 2929615 Reason for revert: b/328225000 Reverted changes: /q/submissionid:2929615 Change-Id: Ifbec11417103c96b37a4da18dfc9fda73f654d8f --- java/droiddoc.go | 2 -- java/droidstubs.go | 56 +++-------------------------------------- java/droidstubs_test.go | 36 +++++--------------------- 3 files changed, 9 insertions(+), 85 deletions(-) diff --git a/java/droiddoc.go b/java/droiddoc.go index df40d016c..6a66f45ec 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -222,8 +222,6 @@ type Javadoc struct { stubsSrcJar android.WritablePath exportableStubsSrcJar android.WritablePath - - runtimeStubsSrcJar android.WritablePath } func (j *Javadoc) OutputFiles(tag string) (android.Paths, error) { diff --git a/java/droidstubs.go b/java/droidstubs.go index f4bcaca15..e506ee6d1 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -227,7 +227,6 @@ type currentApiTimestampProvider interface { type annotationFlagsParams struct { migratingNullability bool validatingNullability bool - extractAnnotations bool nullabilityWarningsFile android.WritablePath annotationsZip android.WritablePath } @@ -255,7 +254,6 @@ type stubsCommandConfigParams struct { validatingNullability bool annotationsEnabled bool apiLevelsAnnotationsEnabled bool - extractAnnotations bool } // droidstubs passes sources files through Metalava to generate stub .java files that only contain the API to be @@ -540,9 +538,7 @@ func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.Ru cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile) } - if params.extractAnnotations { - cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip) - } + cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip) if len(d.properties.Merge_annotations_dirs) != 0 { d.mergeAnnoDirFlags(ctx, cmd) @@ -588,9 +584,7 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a } else if stubsType == Exportable { apiVersions = s.exportableArtifacts.apiVersionsXml } else { - // if the stubs type does not generate api-versions.xml file, default to using the - // everything artifacts - apiVersions = s.everythingArtifacts.apiVersionsXml + ctx.ModuleErrorf("%s stubs type does not generate api-versions.xml file", stubsType.String()) } } else { ctx.PropertyErrorf("api_levels_module", @@ -824,7 +818,6 @@ func (d *Droidstubs) commonMetalavaStubCmd(ctx android.ModuleContext, rule *andr annotationParams := annotationFlagsParams{ migratingNullability: params.stubConfig.migratingNullability, validatingNullability: params.stubConfig.validatingNullability, - extractAnnotations: params.stubConfig.extractAnnotations, nullabilityWarningsFile: params.nullabilityWarningsFile, annotationsZip: params.annotationsZip, } @@ -1073,38 +1066,6 @@ func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCo d.optionalStubCmd(ctx, optionalCmdParams) } -// Sandbox rule for generating runtime stubs -func (d *Droidstubs) runtimeStubCmd(ctx android.ModuleContext, params stubsCommandConfigParams) { - - // We are only interested in generating the stubs srcjar, - // not other artifacts for the runtime stubs - params.checkApi = false - params.writeSdkValues = false - params.validatingNullability = false - params.extractAnnotations = false - params.apiLevelsAnnotationsEnabled = false - - optionalCmdParams := stubsCommandParams{ - stubConfig: params, - } - - d.Javadoc.runtimeStubsSrcJar = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-"+"stubs.srcjar") - optionalCmdParams.stubsSrcJar = d.Javadoc.runtimeStubsSrcJar - - // If aconfig_declarations property is not defined, all flagged apis symbols are stripped - // as no aconfig flags are enabled. In such case, the runtime stubs are identical to the - // exportable stubs, thus no additional metalava invocation is needed. - if len(d.properties.Aconfig_declarations) == 0 { - rule := android.NewRuleBuilder(pctx, ctx) - rule.Command(). - Text("cp").Flag("-f"). - Input(d.exportableStubsSrcJar).Output(d.runtimeStubsSrcJar) - rule.Build(fmt.Sprintf("metalava_%s", params.stubsType.String()), "metalava merged") - } else { - d.optionalStubCmd(ctx, optionalCmdParams) - } -} - func (d *Droidstubs) optionalStubCmd(ctx android.ModuleContext, params stubsCommandParams) { params.srcJarDir = android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "srcjars") @@ -1176,8 +1137,6 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) { annotationsEnabled := Bool(d.properties.Annotations_enabled) - extractAnnotations := annotationsEnabled - migratingNullability := annotationsEnabled && String(d.properties.Previous_api) != "" validatingNullability := annotationsEnabled && (strings.Contains(String(d.Javadoc.properties.Args), "--validate-nullability-from-merged-stubs") || String(d.properties.Validate_nullability_from_list) != "") @@ -1199,26 +1158,17 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) { validatingNullability: validatingNullability, annotationsEnabled: annotationsEnabled, apiLevelsAnnotationsEnabled: apiLevelsAnnotationsEnabled, - extractAnnotations: extractAnnotations, } stubCmdParams.stubsType = Everything // Create default (i.e. "everything" stubs) rule for metalava d.everythingStubCmd(ctx, stubCmdParams) - // The module generates "exportable" stubs regardless of whether + // The module generates "exportable" (and "runtime" eventually) stubs regardless of whether // aconfig_declarations property is defined or not. If the property is not defined, the module simply // strips all flagged apis to generate the "exportable" stubs stubCmdParams.stubsType = Exportable d.exportableStubCmd(ctx, stubCmdParams) - // "runtime" stubs do not generate any other artifacts than the stubs. - // Therefore, metalava does not have to run for "runtime" configuration - // when the module does not generate stubs. - if stubCmdParams.generateStubs { - stubCmdParams.stubsType = Runtime - d.runtimeStubCmd(ctx, stubCmdParams) - } - if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") { if len(d.Javadoc.properties.Out) > 0 { diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go index c86e8bf0f..8da695f08 100644 --- a/java/droidstubs_test.go +++ b/java/droidstubs_test.go @@ -397,47 +397,23 @@ func TestAconfigDeclarations(t *testing.T) { "bar", ], } - droidstubs { - name: "baz", - srcs: ["a/A.java"], - api_surface: "public", - check_api: { - current: { - api_file: "a/current.txt", - removed_api_file: "a/removed.txt", - } - }, - } `) // Check that droidstubs depend on aconfig_declarations android.AssertBoolEquals(t, "foo expected to depend on bar", CheckModuleHasDependency(t, result.TestContext, "foo", "android_common", "bar"), true) - fooModule := result.ModuleForTests("foo", "android_common") + m := result.ModuleForTests("foo", "android_common") android.AssertStringDoesContain(t, "foo generates revert annotations file", - strings.Join(fooModule.AllOutputs(), ""), "revert-annotations-exportable.txt") + strings.Join(m.AllOutputs(), ""), "revert-annotations-exportable.txt") // revert-annotations.txt passed to exportable stubs generation metalava command - exportableManifest := fooModule.Output("metalava_exportable.sbox.textproto") - exportableCmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, exportableManifest).Commands[0].Command) - android.AssertStringDoesContain(t, "flagged api hide command not included", exportableCmdline, "revert-annotations-exportable.txt") + manifest := m.Output("metalava_exportable.sbox.textproto") + cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command) + android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "revert-annotations-exportable.txt") android.AssertStringDoesContain(t, "foo generates exportable stubs jar", - strings.Join(fooModule.AllOutputs(), ""), "exportable/foo-stubs.srcjar") - - // revert-annotations.txt passed to runtime stubs generation metalava command - runtimeManifest := fooModule.Output("metalava_runtime.sbox.textproto") - runtimeCmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, runtimeManifest).Commands[0].Command) - android.AssertStringDoesContain(t, "flagged api hide command not included", runtimeCmdline, "revert-annotations-runtime.txt") - - android.AssertStringDoesContain(t, "foo generates runtime stubs jar", - strings.Join(fooModule.AllOutputs(), ""), "runtime/foo-stubs.srcjar") - - // If aconfig_declarations property is not defined, the runtime stubs is a copy of the exportable stubs - bazModule := result.ModuleForTests("baz", "android_common") - bazRuntimeCmdline := bazModule.Rule("metalava_runtime").RuleParams.Command - android.AssertStringDoesContain(t, "copy command should include the input stub", bazRuntimeCmdline, "exportable/baz-stubs.srcjar") + strings.Join(m.AllOutputs(), ""), "exportable/foo-stubs.srcjar") } func TestReleaseExportRuntimeApis(t *testing.T) { From de57c7a324b405fbbfe887b2512afa1845083f2d Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Tue, 5 Mar 2024 16:12:20 +0000 Subject: [PATCH 05/67] Revert "Additional cleanup prior to adding the runtime stubs" Revert submission 2929615 Reason for revert: b/328225000 Reverted changes: /q/submissionid:2929615 Change-Id: I29c605adb9401c9cb8b58646f2ae7b53b9a758e9 --- java/droidstubs.go | 106 +++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 57 deletions(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index e506ee6d1..76c8d8890 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -242,18 +242,16 @@ type stubsCommandParams struct { stubConfig stubsCommandConfigParams } type stubsCommandConfigParams struct { - stubsType StubsType - javaVersion javaVersion - deps deps - checkApi bool - generateStubs bool - doApiLint bool - doCheckReleased bool - writeSdkValues bool - migratingNullability bool - validatingNullability bool - annotationsEnabled bool - apiLevelsAnnotationsEnabled bool + stubsType StubsType + javaVersion javaVersion + deps deps + checkApi bool + generateStubs bool + doApiLint bool + doCheckReleased bool + writeSdkValues bool + migratingNullability bool + validatingNullability bool } // droidstubs passes sources files through Metalava to generate stub .java files that only contain the API to be @@ -523,28 +521,30 @@ func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuil } func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, params annotationFlagsParams) { - cmd.Flag(config.MetalavaAnnotationsFlags) + if Bool(d.properties.Annotations_enabled) { + cmd.Flag(config.MetalavaAnnotationsFlags) - if params.migratingNullability { - previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api)) - cmd.FlagWithInput("--migrate-nullness ", previousApi) + if params.migratingNullability { + previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api)) + cmd.FlagWithInput("--migrate-nullness ", previousApi) + } + + if s := String(d.properties.Validate_nullability_from_list); s != "" { + cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s)) + } + + if params.validatingNullability { + cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile) + } + + cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip) + + if len(d.properties.Merge_annotations_dirs) != 0 { + d.mergeAnnoDirFlags(ctx, cmd) + } + + cmd.Flag(config.MetalavaAnnotationsWarningsFlags) } - - if s := String(d.properties.Validate_nullability_from_list); s != "" { - cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s)) - } - - if params.validatingNullability { - cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile) - } - - cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip) - - if len(d.properties.Merge_annotations_dirs) != 0 { - d.mergeAnnoDirFlags(ctx, cmd) - } - - cmd.Flag(config.MetalavaAnnotationsWarningsFlags) } func (d *Droidstubs) mergeAnnoDirFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) { @@ -569,11 +569,9 @@ func (d *Droidstubs) inclusionAnnotationsFlags(ctx android.ModuleContext, cmd *a }) } -func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, params stubsCommandParams) { +func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) { var apiVersions android.Path - stubsType := params.stubConfig.stubsType - apiVersionsXml := params.apiVersionsXml - if params.stubConfig.apiLevelsAnnotationsEnabled { + if proptools.Bool(d.properties.Api_levels_annotations_enabled) { d.apiLevelsGenerationFlags(ctx, cmd, stubsType, apiVersionsXml) apiVersions = apiVersionsXml } else { @@ -822,11 +820,9 @@ func (d *Droidstubs) commonMetalavaStubCmd(ctx android.ModuleContext, rule *andr annotationsZip: params.annotationsZip, } - if params.stubConfig.annotationsEnabled { - d.annotationsFlags(ctx, cmd, annotationParams) - } + d.annotationsFlags(ctx, cmd, annotationParams) d.inclusionAnnotationsFlags(ctx, cmd) - d.apiLevelsAnnotationsFlags(ctx, cmd, params) + d.apiLevelsAnnotationsFlags(ctx, cmd, params.stubConfig.stubsType, params.apiVersionsXml) d.expandArgs(ctx, cmd) @@ -856,13 +852,13 @@ func (d *Droidstubs) everythingStubCmd(ctx android.ModuleContext, params stubsCo d.everythingArtifacts.metadataZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"-metadata.zip") } - if params.annotationsEnabled { + if Bool(d.properties.Annotations_enabled) { if params.validatingNullability { d.everythingArtifacts.nullabilityWarningsFile = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_nullability_warnings.txt") } d.everythingArtifacts.annotationsZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_annotations.zip") } - if params.apiLevelsAnnotationsEnabled { + if Bool(d.properties.Api_levels_annotations_enabled) { d.everythingArtifacts.apiVersionsXml = android.PathForModuleOut(ctx, Everything.String(), "api-versions.xml") } @@ -1040,7 +1036,7 @@ func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCo optionalCmdParams.metadataDir = d.exportableArtifacts.metadataDir } - if params.annotationsEnabled { + if Bool(d.properties.Annotations_enabled) { if params.validatingNullability { d.exportableArtifacts.nullabilityWarningsFile = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_nullability_warnings.txt") optionalCmdParams.nullabilityWarningsFile = d.exportableArtifacts.nullabilityWarningsFile @@ -1048,7 +1044,7 @@ func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCo d.exportableArtifacts.annotationsZip = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_annotations.zip") optionalCmdParams.annotationsZip = d.exportableArtifacts.annotationsZip } - if params.apiLevelsAnnotationsEnabled { + if Bool(d.properties.Api_levels_annotations_enabled) { d.exportableArtifacts.apiVersionsXml = android.PathForModuleOut(ctx, params.stubsType.String(), "api-versions.xml") optionalCmdParams.apiVersionsXml = d.exportableArtifacts.apiVersionsXml } @@ -1144,20 +1140,16 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) { checkApi := apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") || apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") - apiLevelsAnnotationsEnabled := proptools.Bool(d.properties.Api_levels_annotations_enabled) - stubCmdParams := stubsCommandConfigParams{ - javaVersion: javaVersion, - deps: deps, - checkApi: checkApi, - generateStubs: generateStubs, - doApiLint: doApiLint, - doCheckReleased: doCheckReleased, - writeSdkValues: writeSdkValues, - migratingNullability: migratingNullability, - validatingNullability: validatingNullability, - annotationsEnabled: annotationsEnabled, - apiLevelsAnnotationsEnabled: apiLevelsAnnotationsEnabled, + javaVersion: javaVersion, + deps: deps, + checkApi: checkApi, + generateStubs: generateStubs, + doApiLint: doApiLint, + doCheckReleased: doCheckReleased, + writeSdkValues: writeSdkValues, + migratingNullability: migratingNullability, + validatingNullability: validatingNullability, } stubCmdParams.stubsType = Everything // Create default (i.e. "everything" stubs) rule for metalava From a90cd1e4b89dd2cd9041a767ce88e57f794ba6bf Mon Sep 17 00:00:00 2001 From: yangfan deng Date: Tue, 5 Sep 2023 23:52:49 +0000 Subject: [PATCH 06/67] Add wear-sdk.impl to the InstrumentFrameworkModule list so that classes for wear-sdk.impl library can be exported inside jacoco-report-classes-all.jar Ignore-AOSP-First: internal-only projects Test: http://go/forrest-run/L55500030002341444 Bug: 298469315 Change-Id: Ib0943e8d472ee3005a6e240c83462b054c72f199 (cherry picked from commit 8e5dfaa98985a267278f17cf1600e3fb3668cfc5) --- java/config/config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/java/config/config.go b/java/config/config.go index 83c27d309..cabfa013d 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -52,6 +52,7 @@ var ( "core-icu4j", "core-oj", "core-libart", + "wear-sdk.impl", } ) From 6c47e664cc1a9f26e966ece7819aa1dca489bb66 Mon Sep 17 00:00:00 2001 From: Sorin Basca Date: Mon, 11 Mar 2024 17:23:06 +0000 Subject: [PATCH 07/67] Revert^2 "Switch to JDK 21" This reverts commit b832ae19d84132ffe8d780009e772f6602d6b027. Reason for revert: Reland Switch to JDK 21 when related issues are resolved. Bug: 313924276 Change-Id: Ibb5031d9892d1ddc5bc4d2af9885c3192b8ac8ad Test: TH --- java/config/config.go | 7 +------ ui/build/config.go | 13 ++++++------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/java/config/config.go b/java/config/config.go index 2f0240c2a..3159a05de 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -132,12 +132,7 @@ func init() { if override := ctx.Config().Getenv("OVERRIDE_JLINK_VERSION_NUMBER"); override != "" { return override } - switch ctx.Config().Getenv("EXPERIMENTAL_USE_OPENJDK21_TOOLCHAIN") { - case "true": - return "21" - default: - return "17" - } + return "21" }) pctx.SourcePathVariable("JavaToolchain", "${JavaHome}/bin") diff --git a/ui/build/config.go b/ui/build/config.go index 1a2539793..3143b6b0d 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -386,22 +386,21 @@ func NewConfig(ctx Context, args ...string) Config { // Configure Java-related variables, including adding it to $PATH java8Home := filepath.Join("prebuilts/jdk/jdk8", ret.HostPrebuiltTag()) - java17Home := filepath.Join("prebuilts/jdk/jdk17", ret.HostPrebuiltTag()) java21Home := filepath.Join("prebuilts/jdk/jdk21", ret.HostPrebuiltTag()) javaHome := func() string { if override, ok := ret.environ.Get("OVERRIDE_ANDROID_JAVA_HOME"); ok { return override } - if ret.environ.IsEnvTrue("EXPERIMENTAL_USE_OPENJDK21_TOOLCHAIN") { - return java21Home - } if toolchain11, ok := ret.environ.Get("EXPERIMENTAL_USE_OPENJDK11_TOOLCHAIN"); ok && toolchain11 != "true" { - ctx.Fatalln("The environment variable EXPERIMENTAL_USE_OPENJDK11_TOOLCHAIN is no longer supported. An OpenJDK 11 toolchain is now the global default.") + ctx.Fatalln("The environment variable EXPERIMENTAL_USE_OPENJDK11_TOOLCHAIN is no longer supported. An OpenJDK 21 toolchain is now the global default.") } if toolchain17, ok := ret.environ.Get("EXPERIMENTAL_USE_OPENJDK17_TOOLCHAIN"); ok && toolchain17 != "true" { - ctx.Fatalln("The environment variable EXPERIMENTAL_USE_OPENJDK17_TOOLCHAIN is no longer supported. An OpenJDK 17 toolchain is now the global default.") + ctx.Fatalln("The environment variable EXPERIMENTAL_USE_OPENJDK17_TOOLCHAIN is no longer supported. An OpenJDK 21 toolchain is now the global default.") } - return java17Home + if toolchain21, ok := ret.environ.Get("EXPERIMENTAL_USE_OPENJDK21_TOOLCHAIN"); ok && toolchain21 != "true" { + ctx.Fatalln("The environment variable EXPERIMENTAL_USE_OPENJDK21_TOOLCHAIN is no longer supported. An OpenJDK 21 toolchain is now the global default.") + } + return java21Home }() absJavaHome := absPath(ctx, javaHome) From eb80e2b9eb12b87093868707a17a44cf38fcf946 Mon Sep 17 00:00:00 2001 From: Harshit Mahajan Date: Wed, 13 Mar 2024 10:21:28 +0000 Subject: [PATCH 08/67] Add VanillaIceCream to the releases for which snapshots can be built Bug: 289203818 Change-Id: I9d9caeb38cacbd3b3f3fd05617a914fa9fb5e1d3 Test: m Ignore-AOSP-First: Merge conflicts aosp/3000881, will cherry-pick this. --- sdk/build_release.go | 1 + sdk/build_release_test.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/build_release.go b/sdk/build_release.go index 6bb05a36d..1b1b47b7f 100644 --- a/sdk/build_release.go +++ b/sdk/build_release.go @@ -101,6 +101,7 @@ var ( buildReleaseS = initBuildRelease("S") buildReleaseT = initBuildRelease("Tiramisu") buildReleaseU = initBuildRelease("UpsideDownCake") + buildReleaseV = initBuildRelease("VanillaIceCream") // Add the current build release which is always treated as being more recent than any other // build release, including those added in tests. diff --git a/sdk/build_release_test.go b/sdk/build_release_test.go index 5bf57b553..b8a274f5b 100644 --- a/sdk/build_release_test.go +++ b/sdk/build_release_test.go @@ -42,7 +42,7 @@ func TestNameToRelease(t *testing.T) { android.AssertDeepEquals(t, "release", (*buildRelease)(nil), release) // Uses a wildcard in the error message to allow for additional build releases to be added to // the supported set without breaking this test. - android.FailIfNoMatchingErrors(t, `unknown release "A", expected one of \[S,Tiramisu,UpsideDownCake,F1,F2,current\]`, []error{err}) + android.FailIfNoMatchingErrors(t, `unknown release "A", expected one of \[S,Tiramisu,UpsideDownCake,VanillaIceCream,F1,F2,current\]`, []error{err}) }) } @@ -60,7 +60,7 @@ func TestParseBuildReleaseSet(t *testing.T) { t.Run("closed range", func(t *testing.T) { set, err := parseBuildReleaseSet("S-F1") android.AssertDeepEquals(t, "errors", nil, err) - android.AssertStringEquals(t, "set", "[S,Tiramisu,UpsideDownCake,F1]", set.String()) + android.AssertStringEquals(t, "set", "[S,Tiramisu,UpsideDownCake,VanillaIceCream,F1]", set.String()) }) invalidAReleaseMessage := `unknown release "A", expected one of ` + allBuildReleaseSet.String() t.Run("invalid release", func(t *testing.T) { From 2c4312b3e7aca00b36ee5cb14f724847f1227262 Mon Sep 17 00:00:00 2001 From: Priyanka Advani Date: Wed, 13 Mar 2024 17:37:29 +0000 Subject: [PATCH 09/67] Revert "Add VanillaIceCream to the releases for which snapshots ..." Revert submission 26563706-CrSdk Reason for revert: Droidmonitored triggered revert for build breakages in b/329449481 Reverted changes: /q/submissionid:26563706-CrSdk Change-Id: Ie38cc3b6229d857a90e401fdee92b0a62bb72c3b --- sdk/build_release.go | 1 - sdk/build_release_test.go | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sdk/build_release.go b/sdk/build_release.go index 1b1b47b7f..6bb05a36d 100644 --- a/sdk/build_release.go +++ b/sdk/build_release.go @@ -101,7 +101,6 @@ var ( buildReleaseS = initBuildRelease("S") buildReleaseT = initBuildRelease("Tiramisu") buildReleaseU = initBuildRelease("UpsideDownCake") - buildReleaseV = initBuildRelease("VanillaIceCream") // Add the current build release which is always treated as being more recent than any other // build release, including those added in tests. diff --git a/sdk/build_release_test.go b/sdk/build_release_test.go index b8a274f5b..5bf57b553 100644 --- a/sdk/build_release_test.go +++ b/sdk/build_release_test.go @@ -42,7 +42,7 @@ func TestNameToRelease(t *testing.T) { android.AssertDeepEquals(t, "release", (*buildRelease)(nil), release) // Uses a wildcard in the error message to allow for additional build releases to be added to // the supported set without breaking this test. - android.FailIfNoMatchingErrors(t, `unknown release "A", expected one of \[S,Tiramisu,UpsideDownCake,VanillaIceCream,F1,F2,current\]`, []error{err}) + android.FailIfNoMatchingErrors(t, `unknown release "A", expected one of \[S,Tiramisu,UpsideDownCake,F1,F2,current\]`, []error{err}) }) } @@ -60,7 +60,7 @@ func TestParseBuildReleaseSet(t *testing.T) { t.Run("closed range", func(t *testing.T) { set, err := parseBuildReleaseSet("S-F1") android.AssertDeepEquals(t, "errors", nil, err) - android.AssertStringEquals(t, "set", "[S,Tiramisu,UpsideDownCake,VanillaIceCream,F1]", set.String()) + android.AssertStringEquals(t, "set", "[S,Tiramisu,UpsideDownCake,F1]", set.String()) }) invalidAReleaseMessage := `unknown release "A", expected one of ` + allBuildReleaseSet.String() t.Run("invalid release", func(t *testing.T) { From f5bf51a85c3450dcb1c8ccb8efeb5ed96340d8b7 Mon Sep 17 00:00:00 2001 From: David Fu Date: Wed, 26 Apr 2023 20:25:30 +0000 Subject: [PATCH 10/67] Changed assignee to triage_assignee in fuzzconfig Merged-In: Ifdf4e8a3d855c414c906d249674411f4f4b88396 Change-Id: Ifdf4e8a3d855c414c906d249674411f4f4b88396 --- fuzz/fuzz_common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fuzz/fuzz_common.go b/fuzz/fuzz_common.go index 79d241279..f76529d31 100644 --- a/fuzz/fuzz_common.go +++ b/fuzz/fuzz_common.go @@ -339,7 +339,7 @@ type FuzzConfig struct { // List of modules for monitoring coverage drops in directories (e.g. "libicu") Target_modules []string `json:"target_modules,omitempty"` // Specifies a bug assignee to replace default ISE assignment - Assignee string `json:"assignee,omitempty"` + Triage_assignee string `json:"triage_assignee,omitempty"` } type FuzzFrameworks struct { From b75ed0f2d8c4d13924573fd065c9706475aac17b Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Tue, 12 Mar 2024 22:22:30 +0000 Subject: [PATCH 11/67] Pass "--container" to aconfig create-cache Bug: 328823994 Test: unit tests and manual tests locally. Ignore-AOSP-First: It is easier to detect all the mismatch in internal master. Change-Id: I096877015b78786639376b279a9be5d07594d92e --- aconfig/aconfig_declarations.go | 18 ++++++++------ aconfig/aconfig_declarations_test.go | 35 ++++++++++++++++++++++++++++ aconfig/init.go | 3 ++- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go index 392e8193a..d29e3122d 100644 --- a/aconfig/aconfig_declarations.go +++ b/aconfig/aconfig_declarations.go @@ -137,18 +137,22 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module inputFiles := make([]android.Path, len(declarationFiles)) copy(inputFiles, declarationFiles) inputFiles = append(inputFiles, valuesFiles...) + args := map[string]string{ + "release_version": ctx.Config().ReleaseVersion(), + "package": module.properties.Package, + "declarations": android.JoinPathsWithPrefix(declarationFiles, "--declarations "), + "values": joinAndPrefix(" --values ", module.properties.Values), + "default-permission": optionalVariable(" --default-permission ", defaultPermission), + } + if len(module.properties.Container) > 0 { + args["container"] = "--container " + module.properties.Container + } ctx.Build(pctx, android.BuildParams{ Rule: aconfigRule, Output: intermediateCacheFilePath, Inputs: inputFiles, Description: "aconfig_declarations", - Args: map[string]string{ - "release_version": ctx.Config().ReleaseVersion(), - "package": module.properties.Package, - "declarations": android.JoinPathsWithPrefix(declarationFiles, "--declarations "), - "values": joinAndPrefix(" --values ", module.properties.Values), - "default-permission": optionalVariable(" --default-permission ", defaultPermission), - }, + Args: args, }) intermediateDumpFilePath := android.PathForModuleOut(ctx, "intermediate.txt") diff --git a/aconfig/aconfig_declarations_test.go b/aconfig/aconfig_declarations_test.go index 1fe3c862a..5201fedb1 100644 --- a/aconfig/aconfig_declarations_test.go +++ b/aconfig/aconfig_declarations_test.go @@ -69,3 +69,38 @@ func TestAconfigDeclarationsWithExportableUnset(t *testing.T) { depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey) android.AssertBoolEquals(t, "exportable", depData.Exportable, false) } + +func TestAconfigDeclarationsWithContainer(t *testing.T) { + bp := ` + aconfig_declarations { + name: "module_name", + package: "com.example.package", + container: "com.android.foo", + srcs: [ + "foo.aconfig", + ], + } + ` + result := runTest(t, android.FixtureExpectsNoErrors, bp) + + module := result.ModuleForTests("module_name", "") + rule := module.Rule("aconfig") + android.AssertStringEquals(t, "rule must contain container", rule.Args["container"], "--container com.android.foo") +} + +func TestAconfigDeclarationsWithoutContainer(t *testing.T) { + bp := ` + aconfig_declarations { + name: "module_name", + package: "com.example.package", + srcs: [ + "foo.aconfig", + ], + } + ` + result := runTest(t, android.FixtureExpectsNoErrors, bp) + + module := result.ModuleForTests("module_name", "") + rule := module.Rule("aconfig") + android.AssertIntEquals(t, "rule must not contain container", len(rule.Args["container"]), 0) +} diff --git a/aconfig/init.go b/aconfig/init.go index e64429fb9..4a61b6759 100644 --- a/aconfig/init.go +++ b/aconfig/init.go @@ -42,6 +42,7 @@ var ( blueprint.RuleParams{ Command: `${aconfig} create-cache` + ` --package ${package}` + + ` ${container}` + ` ${declarations}` + ` ${values}` + ` ${default-permission}` + @@ -52,7 +53,7 @@ var ( "${aconfig}", }, Restat: true, - }, "release_version", "package", "declarations", "values", "default-permission") + }, "release_version", "package", "container", "declarations", "values", "default-permission") // For create-device-config-sysprops: Generate aconfig flag value map text file aconfigTextRule = pctx.AndroidStaticRule("aconfig_text", From 584f0bc1a6fcc56edb221a9cecb50a33aa979517 Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Tue, 5 Mar 2024 16:12:20 +0000 Subject: [PATCH 12/67] Revert "Generate runtime stubs in droidstubs" Revert submission 2929615 Reason for revert: b/328225000 Reverted changes: /q/submissionid:2929615 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:17f01d976acd757cb6afabba3f3606a6b25d0ecf) Merged-In: Ifbec11417103c96b37a4da18dfc9fda73f654d8f Change-Id: Ifbec11417103c96b37a4da18dfc9fda73f654d8f 24D1-dev is based on 24Q2-release. Therefore, we merged this CL to 24D1-dev. --- java/droiddoc.go | 2 -- java/droidstubs.go | 56 +++-------------------------------------- java/droidstubs_test.go | 36 +++++--------------------- 3 files changed, 9 insertions(+), 85 deletions(-) diff --git a/java/droiddoc.go b/java/droiddoc.go index df40d016c..6a66f45ec 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -222,8 +222,6 @@ type Javadoc struct { stubsSrcJar android.WritablePath exportableStubsSrcJar android.WritablePath - - runtimeStubsSrcJar android.WritablePath } func (j *Javadoc) OutputFiles(tag string) (android.Paths, error) { diff --git a/java/droidstubs.go b/java/droidstubs.go index f4bcaca15..e506ee6d1 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -227,7 +227,6 @@ type currentApiTimestampProvider interface { type annotationFlagsParams struct { migratingNullability bool validatingNullability bool - extractAnnotations bool nullabilityWarningsFile android.WritablePath annotationsZip android.WritablePath } @@ -255,7 +254,6 @@ type stubsCommandConfigParams struct { validatingNullability bool annotationsEnabled bool apiLevelsAnnotationsEnabled bool - extractAnnotations bool } // droidstubs passes sources files through Metalava to generate stub .java files that only contain the API to be @@ -540,9 +538,7 @@ func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.Ru cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile) } - if params.extractAnnotations { - cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip) - } + cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip) if len(d.properties.Merge_annotations_dirs) != 0 { d.mergeAnnoDirFlags(ctx, cmd) @@ -588,9 +584,7 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a } else if stubsType == Exportable { apiVersions = s.exportableArtifacts.apiVersionsXml } else { - // if the stubs type does not generate api-versions.xml file, default to using the - // everything artifacts - apiVersions = s.everythingArtifacts.apiVersionsXml + ctx.ModuleErrorf("%s stubs type does not generate api-versions.xml file", stubsType.String()) } } else { ctx.PropertyErrorf("api_levels_module", @@ -824,7 +818,6 @@ func (d *Droidstubs) commonMetalavaStubCmd(ctx android.ModuleContext, rule *andr annotationParams := annotationFlagsParams{ migratingNullability: params.stubConfig.migratingNullability, validatingNullability: params.stubConfig.validatingNullability, - extractAnnotations: params.stubConfig.extractAnnotations, nullabilityWarningsFile: params.nullabilityWarningsFile, annotationsZip: params.annotationsZip, } @@ -1073,38 +1066,6 @@ func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCo d.optionalStubCmd(ctx, optionalCmdParams) } -// Sandbox rule for generating runtime stubs -func (d *Droidstubs) runtimeStubCmd(ctx android.ModuleContext, params stubsCommandConfigParams) { - - // We are only interested in generating the stubs srcjar, - // not other artifacts for the runtime stubs - params.checkApi = false - params.writeSdkValues = false - params.validatingNullability = false - params.extractAnnotations = false - params.apiLevelsAnnotationsEnabled = false - - optionalCmdParams := stubsCommandParams{ - stubConfig: params, - } - - d.Javadoc.runtimeStubsSrcJar = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-"+"stubs.srcjar") - optionalCmdParams.stubsSrcJar = d.Javadoc.runtimeStubsSrcJar - - // If aconfig_declarations property is not defined, all flagged apis symbols are stripped - // as no aconfig flags are enabled. In such case, the runtime stubs are identical to the - // exportable stubs, thus no additional metalava invocation is needed. - if len(d.properties.Aconfig_declarations) == 0 { - rule := android.NewRuleBuilder(pctx, ctx) - rule.Command(). - Text("cp").Flag("-f"). - Input(d.exportableStubsSrcJar).Output(d.runtimeStubsSrcJar) - rule.Build(fmt.Sprintf("metalava_%s", params.stubsType.String()), "metalava merged") - } else { - d.optionalStubCmd(ctx, optionalCmdParams) - } -} - func (d *Droidstubs) optionalStubCmd(ctx android.ModuleContext, params stubsCommandParams) { params.srcJarDir = android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "srcjars") @@ -1176,8 +1137,6 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) { annotationsEnabled := Bool(d.properties.Annotations_enabled) - extractAnnotations := annotationsEnabled - migratingNullability := annotationsEnabled && String(d.properties.Previous_api) != "" validatingNullability := annotationsEnabled && (strings.Contains(String(d.Javadoc.properties.Args), "--validate-nullability-from-merged-stubs") || String(d.properties.Validate_nullability_from_list) != "") @@ -1199,26 +1158,17 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) { validatingNullability: validatingNullability, annotationsEnabled: annotationsEnabled, apiLevelsAnnotationsEnabled: apiLevelsAnnotationsEnabled, - extractAnnotations: extractAnnotations, } stubCmdParams.stubsType = Everything // Create default (i.e. "everything" stubs) rule for metalava d.everythingStubCmd(ctx, stubCmdParams) - // The module generates "exportable" stubs regardless of whether + // The module generates "exportable" (and "runtime" eventually) stubs regardless of whether // aconfig_declarations property is defined or not. If the property is not defined, the module simply // strips all flagged apis to generate the "exportable" stubs stubCmdParams.stubsType = Exportable d.exportableStubCmd(ctx, stubCmdParams) - // "runtime" stubs do not generate any other artifacts than the stubs. - // Therefore, metalava does not have to run for "runtime" configuration - // when the module does not generate stubs. - if stubCmdParams.generateStubs { - stubCmdParams.stubsType = Runtime - d.runtimeStubCmd(ctx, stubCmdParams) - } - if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") { if len(d.Javadoc.properties.Out) > 0 { diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go index c86e8bf0f..8da695f08 100644 --- a/java/droidstubs_test.go +++ b/java/droidstubs_test.go @@ -397,47 +397,23 @@ func TestAconfigDeclarations(t *testing.T) { "bar", ], } - droidstubs { - name: "baz", - srcs: ["a/A.java"], - api_surface: "public", - check_api: { - current: { - api_file: "a/current.txt", - removed_api_file: "a/removed.txt", - } - }, - } `) // Check that droidstubs depend on aconfig_declarations android.AssertBoolEquals(t, "foo expected to depend on bar", CheckModuleHasDependency(t, result.TestContext, "foo", "android_common", "bar"), true) - fooModule := result.ModuleForTests("foo", "android_common") + m := result.ModuleForTests("foo", "android_common") android.AssertStringDoesContain(t, "foo generates revert annotations file", - strings.Join(fooModule.AllOutputs(), ""), "revert-annotations-exportable.txt") + strings.Join(m.AllOutputs(), ""), "revert-annotations-exportable.txt") // revert-annotations.txt passed to exportable stubs generation metalava command - exportableManifest := fooModule.Output("metalava_exportable.sbox.textproto") - exportableCmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, exportableManifest).Commands[0].Command) - android.AssertStringDoesContain(t, "flagged api hide command not included", exportableCmdline, "revert-annotations-exportable.txt") + manifest := m.Output("metalava_exportable.sbox.textproto") + cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command) + android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "revert-annotations-exportable.txt") android.AssertStringDoesContain(t, "foo generates exportable stubs jar", - strings.Join(fooModule.AllOutputs(), ""), "exportable/foo-stubs.srcjar") - - // revert-annotations.txt passed to runtime stubs generation metalava command - runtimeManifest := fooModule.Output("metalava_runtime.sbox.textproto") - runtimeCmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, runtimeManifest).Commands[0].Command) - android.AssertStringDoesContain(t, "flagged api hide command not included", runtimeCmdline, "revert-annotations-runtime.txt") - - android.AssertStringDoesContain(t, "foo generates runtime stubs jar", - strings.Join(fooModule.AllOutputs(), ""), "runtime/foo-stubs.srcjar") - - // If aconfig_declarations property is not defined, the runtime stubs is a copy of the exportable stubs - bazModule := result.ModuleForTests("baz", "android_common") - bazRuntimeCmdline := bazModule.Rule("metalava_runtime").RuleParams.Command - android.AssertStringDoesContain(t, "copy command should include the input stub", bazRuntimeCmdline, "exportable/baz-stubs.srcjar") + strings.Join(m.AllOutputs(), ""), "exportable/foo-stubs.srcjar") } func TestReleaseExportRuntimeApis(t *testing.T) { From 104faabd88d5798fca7dc2548500f5eda14a5d8b Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Tue, 5 Mar 2024 16:12:20 +0000 Subject: [PATCH 13/67] Revert "Additional cleanup prior to adding the runtime stubs" Revert submission 2929615 Reason for revert: b/328225000 Reverted changes: /q/submissionid:2929615 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:de57c7a324b405fbbfe887b2512afa1845083f2d) Merged-In: I29c605adb9401c9cb8b58646f2ae7b53b9a758e9 Change-Id: I29c605adb9401c9cb8b58646f2ae7b53b9a758e9 24D1-dev is based on 24Q2-release. Therefore, we merged this CL to 24D1-dev. --- java/droidstubs.go | 106 +++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 57 deletions(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index e506ee6d1..76c8d8890 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -242,18 +242,16 @@ type stubsCommandParams struct { stubConfig stubsCommandConfigParams } type stubsCommandConfigParams struct { - stubsType StubsType - javaVersion javaVersion - deps deps - checkApi bool - generateStubs bool - doApiLint bool - doCheckReleased bool - writeSdkValues bool - migratingNullability bool - validatingNullability bool - annotationsEnabled bool - apiLevelsAnnotationsEnabled bool + stubsType StubsType + javaVersion javaVersion + deps deps + checkApi bool + generateStubs bool + doApiLint bool + doCheckReleased bool + writeSdkValues bool + migratingNullability bool + validatingNullability bool } // droidstubs passes sources files through Metalava to generate stub .java files that only contain the API to be @@ -523,28 +521,30 @@ func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuil } func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, params annotationFlagsParams) { - cmd.Flag(config.MetalavaAnnotationsFlags) + if Bool(d.properties.Annotations_enabled) { + cmd.Flag(config.MetalavaAnnotationsFlags) - if params.migratingNullability { - previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api)) - cmd.FlagWithInput("--migrate-nullness ", previousApi) + if params.migratingNullability { + previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api)) + cmd.FlagWithInput("--migrate-nullness ", previousApi) + } + + if s := String(d.properties.Validate_nullability_from_list); s != "" { + cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s)) + } + + if params.validatingNullability { + cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile) + } + + cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip) + + if len(d.properties.Merge_annotations_dirs) != 0 { + d.mergeAnnoDirFlags(ctx, cmd) + } + + cmd.Flag(config.MetalavaAnnotationsWarningsFlags) } - - if s := String(d.properties.Validate_nullability_from_list); s != "" { - cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s)) - } - - if params.validatingNullability { - cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile) - } - - cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip) - - if len(d.properties.Merge_annotations_dirs) != 0 { - d.mergeAnnoDirFlags(ctx, cmd) - } - - cmd.Flag(config.MetalavaAnnotationsWarningsFlags) } func (d *Droidstubs) mergeAnnoDirFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) { @@ -569,11 +569,9 @@ func (d *Droidstubs) inclusionAnnotationsFlags(ctx android.ModuleContext, cmd *a }) } -func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, params stubsCommandParams) { +func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) { var apiVersions android.Path - stubsType := params.stubConfig.stubsType - apiVersionsXml := params.apiVersionsXml - if params.stubConfig.apiLevelsAnnotationsEnabled { + if proptools.Bool(d.properties.Api_levels_annotations_enabled) { d.apiLevelsGenerationFlags(ctx, cmd, stubsType, apiVersionsXml) apiVersions = apiVersionsXml } else { @@ -822,11 +820,9 @@ func (d *Droidstubs) commonMetalavaStubCmd(ctx android.ModuleContext, rule *andr annotationsZip: params.annotationsZip, } - if params.stubConfig.annotationsEnabled { - d.annotationsFlags(ctx, cmd, annotationParams) - } + d.annotationsFlags(ctx, cmd, annotationParams) d.inclusionAnnotationsFlags(ctx, cmd) - d.apiLevelsAnnotationsFlags(ctx, cmd, params) + d.apiLevelsAnnotationsFlags(ctx, cmd, params.stubConfig.stubsType, params.apiVersionsXml) d.expandArgs(ctx, cmd) @@ -856,13 +852,13 @@ func (d *Droidstubs) everythingStubCmd(ctx android.ModuleContext, params stubsCo d.everythingArtifacts.metadataZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"-metadata.zip") } - if params.annotationsEnabled { + if Bool(d.properties.Annotations_enabled) { if params.validatingNullability { d.everythingArtifacts.nullabilityWarningsFile = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_nullability_warnings.txt") } d.everythingArtifacts.annotationsZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_annotations.zip") } - if params.apiLevelsAnnotationsEnabled { + if Bool(d.properties.Api_levels_annotations_enabled) { d.everythingArtifacts.apiVersionsXml = android.PathForModuleOut(ctx, Everything.String(), "api-versions.xml") } @@ -1040,7 +1036,7 @@ func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCo optionalCmdParams.metadataDir = d.exportableArtifacts.metadataDir } - if params.annotationsEnabled { + if Bool(d.properties.Annotations_enabled) { if params.validatingNullability { d.exportableArtifacts.nullabilityWarningsFile = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_nullability_warnings.txt") optionalCmdParams.nullabilityWarningsFile = d.exportableArtifacts.nullabilityWarningsFile @@ -1048,7 +1044,7 @@ func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCo d.exportableArtifacts.annotationsZip = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_annotations.zip") optionalCmdParams.annotationsZip = d.exportableArtifacts.annotationsZip } - if params.apiLevelsAnnotationsEnabled { + if Bool(d.properties.Api_levels_annotations_enabled) { d.exportableArtifacts.apiVersionsXml = android.PathForModuleOut(ctx, params.stubsType.String(), "api-versions.xml") optionalCmdParams.apiVersionsXml = d.exportableArtifacts.apiVersionsXml } @@ -1144,20 +1140,16 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) { checkApi := apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") || apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") - apiLevelsAnnotationsEnabled := proptools.Bool(d.properties.Api_levels_annotations_enabled) - stubCmdParams := stubsCommandConfigParams{ - javaVersion: javaVersion, - deps: deps, - checkApi: checkApi, - generateStubs: generateStubs, - doApiLint: doApiLint, - doCheckReleased: doCheckReleased, - writeSdkValues: writeSdkValues, - migratingNullability: migratingNullability, - validatingNullability: validatingNullability, - annotationsEnabled: annotationsEnabled, - apiLevelsAnnotationsEnabled: apiLevelsAnnotationsEnabled, + javaVersion: javaVersion, + deps: deps, + checkApi: checkApi, + generateStubs: generateStubs, + doApiLint: doApiLint, + doCheckReleased: doCheckReleased, + writeSdkValues: writeSdkValues, + migratingNullability: migratingNullability, + validatingNullability: validatingNullability, } stubCmdParams.stubsType = Everything // Create default (i.e. "everything" stubs) rule for metalava From f6e0cfcaad726d8757a2d50ad4b48cbf53498ba7 Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Thu, 14 Mar 2024 17:28:44 +0000 Subject: [PATCH 14/67] Create rule to generate the exportable api files when checkapi is disabled WITHOUT_CHECK_API environment variable enables the checkapi to be removed from the critical path. The variable is rarely used within AOSP, but the downstream vendors may depend on it, in order to improve the build performance given that the api signature file through metalava is a resource costly task. Currently, the exportable api files / removed api files are not generated when checkapi is disabled, but a module may depend on the exportable api files when a checkapi is disabled. In order to prevent the missing build rules error in this case, generate the rule to copy the checked in api file / removed api file to the exportable api file / removed api file to prevent build errors. This change also fixes the error message when the OutputFiles(string) api file is null, to correctly inform the user the error. Test: m BUILD_FROM_SOURCE_STUB=true WITHOUT_CHECK_API=true && inspect ninja path and verify that "non-updatable-exportable-current.txt" depends on the generated exportable api file. Bug: 329374072 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2d4074a022c0d836c712a6606b5c6e2cb376e07a) Merged-In: I24f88d450fb46b6ea9d5920d83617d8228edd34b Change-Id: I24f88d450fb46b6ea9d5920d83617d8228edd34b 24D1-dev is based on 24Q2-release. Therefore, we merged this CL to 24D1-dev. --- java/droidstubs.go | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index f4bcaca15..3c79c92b8 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -372,7 +372,7 @@ func (d *Droidstubs) ApiFilePath(stubsType StubsType) (ret android.Path, err err ret, err = nil, fmt.Errorf("api file path not supported for the stub type %s", stubsType.String()) } if ret == nil && err == nil { - err = fmt.Errorf("stubs srcjar is null for the stub type %s", stubsType.String()) + err = fmt.Errorf("api file is null for the stub type %s", stubsType.String()) } return ret, err } @@ -482,34 +482,41 @@ func (d *Droidstubs) sdkValuesFlags(ctx android.ModuleContext, cmd *android.Rule } func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.OptionalPath, stubsType StubsType, checkApi bool) { - if checkApi || String(d.properties.Api_filename) != "" { - filename := proptools.StringDefault(d.properties.Api_filename, ctx.ModuleName()+"_api.txt") - uncheckedApiFile := android.PathForModuleOut(ctx, stubsType.String(), filename) - cmd.FlagWithOutput("--api ", uncheckedApiFile) + apiFileName := proptools.StringDefault(d.properties.Api_filename, ctx.ModuleName()+"_api.txt") + uncheckedApiFile := android.PathForModuleOut(ctx, stubsType.String(), apiFileName) + cmd.FlagWithOutput("--api ", uncheckedApiFile) + if checkApi || String(d.properties.Api_filename) != "" { if stubsType == Everything { d.apiFile = uncheckedApiFile } else if stubsType == Exportable { d.exportableApiFile = uncheckedApiFile } } else if sourceApiFile := proptools.String(d.properties.Check_api.Current.Api_file); sourceApiFile != "" { - // If check api is disabled then make the source file available for export. - d.apiFile = android.PathForModuleSrc(ctx, sourceApiFile) + if stubsType == Everything { + // If check api is disabled then make the source file available for export. + d.apiFile = android.PathForModuleSrc(ctx, sourceApiFile) + } else if stubsType == Exportable { + d.exportableApiFile = uncheckedApiFile + } } + removedApiFileName := proptools.StringDefault(d.properties.Removed_api_filename, ctx.ModuleName()+"_removed.txt") + uncheckedRemovedFile := android.PathForModuleOut(ctx, stubsType.String(), removedApiFileName) + cmd.FlagWithOutput("--removed-api ", uncheckedRemovedFile) if checkApi || String(d.properties.Removed_api_filename) != "" { - filename := proptools.StringDefault(d.properties.Removed_api_filename, ctx.ModuleName()+"_removed.txt") - uncheckedRemovedFile := android.PathForModuleOut(ctx, stubsType.String(), filename) - cmd.FlagWithOutput("--removed-api ", uncheckedRemovedFile) - if stubsType == Everything { d.removedApiFile = uncheckedRemovedFile } else if stubsType == Exportable { d.exportableRemovedApiFile = uncheckedRemovedFile } } else if sourceRemovedApiFile := proptools.String(d.properties.Check_api.Current.Removed_api_file); sourceRemovedApiFile != "" { - // If check api is disabled then make the source removed api file available for export. - d.removedApiFile = android.PathForModuleSrc(ctx, sourceRemovedApiFile) + if stubsType == Everything { + // If check api is disabled then make the source removed api file available for export. + d.removedApiFile = android.PathForModuleSrc(ctx, sourceRemovedApiFile) + } else if stubsType == Exportable { + d.exportableRemovedApiFile = uncheckedRemovedFile + } } if stubsDir.Valid() { From 4017d70d3be3530a517df4863c8a3949ac56f889 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 8 Mar 2024 04:20:15 +0000 Subject: [PATCH 15/67] Convert BuildIgnoreApexContritbutions variable to a boolean The ignore list is burdensome to maintain once we start adding the module sdk contents to apex_contributions. Convert the variable to a boolean. When set to true, all contents in `apex_contributions` will be ignored Bug: 308187268 Test: m nothing on aosp,google and google_fullmte devices Ignore-AOSP-first: CL topic does a cleanup of an internal only denylist Change-Id: Ibdd1e0d0d4f08f4f5251b9c4baa1aaf42e7df34f --- android/apex_contributions.go | 24 +++++++++++++----------- android/config.go | 2 +- android/variable.go | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/android/apex_contributions.go b/android/apex_contributions.go index c76d9c235..dd09fbf44 100644 --- a/android/apex_contributions.go +++ b/android/apex_contributions.go @@ -115,10 +115,6 @@ func (a *allApexContributions) DepsMutator(ctx BottomUpMutatorContext) { func (a *allApexContributions) SetPrebuiltSelectionInfoProvider(ctx BaseModuleContext) { addContentsToProvider := func(p *PrebuiltSelectionInfoMap, m *apexContributions) { for _, content := range m.Contents() { - // Skip any apexes that have been added to the product specific ignore list - if InList(content, ctx.Config().BuildIgnoreApexContributionContents()) { - continue - } // Coverage builds for TARGET_RELEASE=foo should always build from source, // even if TARGET_RELEASE=foo uses prebuilt mainline modules. // This is necessary because the checked-in prebuilts were generated with @@ -141,13 +137,19 @@ func (a *allApexContributions) SetPrebuiltSelectionInfoProvider(ctx BaseModuleCo } p := PrebuiltSelectionInfoMap{} - ctx.VisitDirectDepsWithTag(acDepTag, func(child Module) { - if m, ok := child.(*apexContributions); ok { - addContentsToProvider(&p, m) - } else { - ctx.ModuleErrorf("%s is not an apex_contributions module\n", child.Name()) - } - }) + // Skip apex_contributions if BuildApexContributionContents is true + // This product config var allows some products in the same family to use mainline modules from source + // (e.g. shiba and shiba_fullmte) + // Eventually these product variants will have their own release config maps. + if !proptools.Bool(ctx.Config().BuildIgnoreApexContributionContents()) { + ctx.VisitDirectDepsWithTag(acDepTag, func(child Module) { + if m, ok := child.(*apexContributions); ok { + addContentsToProvider(&p, m) + } else { + ctx.ModuleErrorf("%s is not an apex_contributions module\n", child.Name()) + } + }) + } SetProvider(ctx, PrebuiltSelectionInfoProvider, p) } diff --git a/android/config.go b/android/config.go index 567ebd83f..dcefdf354 100644 --- a/android/config.go +++ b/android/config.go @@ -2076,6 +2076,6 @@ func (c *config) AllApexContributions() []string { return ret } -func (c *config) BuildIgnoreApexContributionContents() []string { +func (c *config) BuildIgnoreApexContributionContents() *bool { return c.productVariables.BuildIgnoreApexContributionContents } diff --git a/android/variable.go b/android/variable.go index 4cb11da3a..6553f1aee 100644 --- a/android/variable.go +++ b/android/variable.go @@ -496,7 +496,7 @@ type ProductVariables struct { BuildFromSourceStub *bool `json:",omitempty"` - BuildIgnoreApexContributionContents []string `json:",omitempty"` + BuildIgnoreApexContributionContents *bool `json:",omitempty"` HiddenapiExportableStubs *bool `json:",omitempty"` From 78ffdd47a658dec4bf79e63d11a5f0f3b94876a4 Mon Sep 17 00:00:00 2001 From: Zi Wang Date: Tue, 12 Mar 2024 14:11:50 -0700 Subject: [PATCH 16/67] Move jarjar repackage action before combine action With this change, the jarjar repackage actions are only on the local classes of each module instead of the combined jar that contains the static libs. The static libs don't need jarjar repackage action on this module level because it has been repackaged when building itself. This change also removes the skip_jarjar_repackage property since it's incompatible with this change. Actually skipping jarjar repackage on a dep may result in incomplete repackage on the module output. Test: CI and observing the build time of SystemUIGoogle Bug: 328067025 Ignore-AOSP-First: Will cp to aosp Change-Id: I476d959af025c46d2ba6d3f48ea378a086666a33 --- java/base.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/java/base.go b/java/base.go index 69f88be1e..17074a671 100644 --- a/java/base.go +++ b/java/base.go @@ -94,9 +94,6 @@ type CommonProperties struct { // if not blank, used as prefix to generate repackage rule Jarjar_prefix *string - // if set to true, skip the jarjar repackaging - Skip_jarjar_repackage *bool - // If not blank, set the java version passed to javac as -source and -target Java_version *string @@ -1103,13 +1100,11 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath jarjarProviderData := j.collectJarJarRules(ctx) if jarjarProviderData != nil { android.SetProvider(ctx, JarJarProvider, *jarjarProviderData) - if !proptools.Bool(j.properties.Skip_jarjar_repackage) { - text := getJarJarRuleText(jarjarProviderData) - if text != "" { - ruleTextFile := android.PathForModuleOut(ctx, "repackaged-jarjar", "repackaging.txt") - android.WriteFileRule(ctx, ruleTextFile, text) - j.repackageJarjarRules = ruleTextFile - } + text := getJarJarRuleText(jarjarProviderData) + if text != "" { + ruleTextFile := android.PathForModuleOut(ctx, "repackaged-jarjar", "repackaging.txt") + android.WriteFileRule(ctx, ruleTextFile, text) + j.repackageJarjarRules = ruleTextFile } } @@ -1293,10 +1288,12 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath return } + kotlinJarPath := j.repackageFlagsIfNecessary(ctx, kotlinJar.OutputPath, jarName, "kotlinc") + // Make javac rule depend on the kotlinc rule flags.classpath = append(classpath{kotlinHeaderJar}, flags.classpath...) - kotlinJars = append(kotlinJars, kotlinJar) + kotlinJars = append(kotlinJars, kotlinJarPath) kotlinHeaderJars = append(kotlinHeaderJars, kotlinHeaderJar) // Jar kotlin classes into the final jar after javac @@ -1376,6 +1373,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath for idx, shardSrc := range shardSrcs { classes := j.compileJavaClasses(ctx, jarName, idx, shardSrc, nil, flags, extraJarDeps) + classes = j.repackageFlagsIfNecessary(ctx, classes, jarName, "javac-"+strconv.Itoa(idx)) jars = append(jars, classes) } } @@ -1388,11 +1386,13 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath for idx, shardSrcJars := range shardSrcJarsList { classes := j.compileJavaClasses(ctx, jarName, startIdx+idx, nil, shardSrcJars, flags, extraJarDeps) + classes = j.repackageFlagsIfNecessary(ctx, classes, jarName, "javac-"+strconv.Itoa(startIdx+idx)) jars = append(jars, classes) } } } else { classes := j.compileJavaClasses(ctx, jarName, -1, uniqueJavaFiles, srcJars, flags, extraJarDeps) + classes = j.repackageFlagsIfNecessary(ctx, classes, jarName, "javac") jars = append(jars, classes) } if ctx.Failed() { @@ -1551,16 +1551,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath } } - // Automatic jarjar rules propagation - if j.repackageJarjarRules != nil { - repackagedJarjarFile := android.PathForModuleOut(ctx, "repackaged-jarjar", jarName).OutputPath - TransformJarJar(ctx, repackagedJarjarFile, outputFile, j.repackageJarjarRules) - outputFile = repackagedJarjarFile - if ctx.Failed() { - return - } - } - // Check package restrictions if necessary. if len(j.properties.Permitted_packages) > 0 { // Time stamp file created by the package check rule. @@ -2678,6 +2668,16 @@ func getJarJarRuleText(provider *JarJarProviderData) string { return result } +// Repackage the flags if the jarjar rule txt for the flags is generated +func (j *Module) repackageFlagsIfNecessary(ctx android.ModuleContext, infile android.WritablePath, jarName, info string) android.WritablePath { + if j.repackageJarjarRules == nil { + return infile + } + repackagedJarjarFile := android.PathForModuleOut(ctx, "repackaged-jarjar", info+jarName) + TransformJarJar(ctx, repackagedJarjarFile, infile, j.repackageJarjarRules) + return repackagedJarjarFile +} + func addPlugins(deps *deps, pluginJars android.Paths, pluginClasses ...string) { deps.processorPath = append(deps.processorPath, pluginJars...) deps.processorClasses = append(deps.processorClasses, pluginClasses...) From b763553ed318429b4002bd0e6982f9b3329b3b7c Mon Sep 17 00:00:00 2001 From: Luis Useche Date: Mon, 1 Apr 2024 19:33:18 -0700 Subject: [PATCH 17/67] Add global C flags to compile_commands This solves linter warnings in editor by adding flags to ignore errors we don't care about. This also means that compile_commands.json is closer to the flags we actually use for compilation. Test: Checked generated compile_commands for new flags. Merged-In: Id583da6eb5151a9baa9a47771f5f937c88bc43f7 Change-Id: Id583da6eb5151a9baa9a47771f5f937c88bc43f7 --- cc/builder.go | 47 ++++++++++++++++------------------------------- cc/cc.go | 3 ++- cc/compdb.go | 1 + cc/compiler.go | 11 ++++++++++- cc/util.go | 25 +++++++++++++------------ 5 files changed, 42 insertions(+), 45 deletions(-) diff --git a/cc/builder.go b/cc/builder.go index e4d5be2c7..f28f47fa2 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -375,13 +375,14 @@ type builderFlags struct { localCppFlags string localLdFlags string - libFlags string // Flags to add to the linker directly after specifying libraries to link. - extraLibFlags string // Flags to add to the linker last. - tidyFlags string // Flags that apply to clang-tidy - sAbiFlags string // Flags that apply to header-abi-dumps - aidlFlags string // Flags that apply to aidl source files - rsFlags string // Flags that apply to renderscript source files - toolchain config.Toolchain + noOverrideFlags string // Flags appended at the end so they are not overridden. + libFlags string // Flags to add to the linker directly after specifying libraries to link. + extraLibFlags string // Flags to add to the linker last. + tidyFlags string // Flags that apply to clang-tidy + sAbiFlags string // Flags that apply to header-abi-dumps + aidlFlags string // Flags that apply to aidl source files + rsFlags string // Flags that apply to renderscript source files + toolchain config.Toolchain // True if these extra features are enabled. tidy bool @@ -485,7 +486,8 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs flags.localCommonFlags + " " + flags.localToolingCFlags + " " + flags.localConlyFlags + " " + - flags.systemIncludeFlags + flags.systemIncludeFlags + " " + + flags.noOverrideFlags cflags := flags.globalCommonFlags + " " + flags.globalCFlags + " " + @@ -493,7 +495,8 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs flags.localCommonFlags + " " + flags.localCFlags + " " + flags.localConlyFlags + " " + - flags.systemIncludeFlags + flags.systemIncludeFlags + " " + + flags.noOverrideFlags toolingCppflags := flags.globalCommonFlags + " " + flags.globalToolingCFlags + " " + @@ -501,7 +504,8 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs flags.localCommonFlags + " " + flags.localToolingCFlags + " " + flags.localToolingCppFlags + " " + - flags.systemIncludeFlags + flags.systemIncludeFlags + " " + + flags.noOverrideFlags cppflags := flags.globalCommonFlags + " " + flags.globalCFlags + " " + @@ -509,7 +513,8 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs flags.localCommonFlags + " " + flags.localCFlags + " " + flags.localCppFlags + " " + - flags.systemIncludeFlags + flags.systemIncludeFlags + " " + + flags.noOverrideFlags asflags := flags.globalCommonFlags + " " + flags.globalAsFlags + " " + @@ -522,26 +527,6 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs sAbiDumpFiles = make(android.Paths, 0, len(srcFiles)) } - cflags += " ${config.NoOverrideGlobalCflags}" - toolingCflags += " ${config.NoOverrideGlobalCflags}" - cppflags += " ${config.NoOverrideGlobalCflags}" - toolingCppflags += " ${config.NoOverrideGlobalCflags}" - - if flags.toolchain.Is64Bit() { - cflags += " ${config.NoOverride64GlobalCflags}" - toolingCflags += " ${config.NoOverride64GlobalCflags}" - cppflags += " ${config.NoOverride64GlobalCflags}" - toolingCppflags += " ${config.NoOverride64GlobalCflags}" - } - - modulePath := ctx.ModuleDir() - if android.IsThirdPartyPath(modulePath) { - cflags += " ${config.NoOverrideExternalGlobalCflags}" - toolingCflags += " ${config.NoOverrideExternalGlobalCflags}" - cppflags += " ${config.NoOverrideExternalGlobalCflags}" - toolingCppflags += " ${config.NoOverrideExternalGlobalCflags}" - } - // Multiple source files have build rules usually share the same cFlags or tidyFlags. // Define only one version in this module and share it in multiple build rules. // To simplify the code, the shared variables are all named as $flags. diff --git a/cc/cc.go b/cc/cc.go index 2770fb23b..1f0b21e4f 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -215,7 +215,8 @@ type Flags struct { // Local flags (which individual modules are responsible for). These may override global flags. Local LocalOrGlobalFlags // Global flags (which build system or toolchain is responsible for). - Global LocalOrGlobalFlags + Global LocalOrGlobalFlags + NoOverrideFlags []string // Flags applied to the end of list of flags so they are not overridden aidlFlags []string // Flags that apply to aidl source files rsFlags []string // Flags that apply to renderscript source files diff --git a/cc/compdb.go b/cc/compdb.go index 617be1a19..da2818324 100644 --- a/cc/compdb.go +++ b/cc/compdb.go @@ -164,6 +164,7 @@ func getArguments(src android.Path, ctx android.SingletonContext, ccModule *Modu args = append(args, expandAllVars(ctx, ccModule.flags.Local.ConlyFlags)...) } args = append(args, expandAllVars(ctx, ccModule.flags.SystemIncludeFlags)...) + args = append(args, expandAllVars(ctx, ccModule.flags.NoOverrideFlags)...) args = append(args, src.String()) return args } diff --git a/cc/compiler.go b/cc/compiler.go index de1ae719a..9a961cfb9 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -539,7 +539,6 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps flags.Global.CommonFlags = append(flags.Global.CommonFlags, tc.ToolchainCflags()) } - cStd := parseCStd(compiler.Properties.C_std) cppStd := parseCppStd(compiler.Properties.Cpp_std) @@ -671,6 +670,16 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps flags.Local.CFlags = append(flags.Local.CFlags, "-DDO_NOT_CHECK_MANUAL_BINDER_INTERFACES") } + flags.NoOverrideFlags = append(flags.NoOverrideFlags, "${config.NoOverrideGlobalCflags}") + + if flags.Toolchain.Is64Bit() { + flags.NoOverrideFlags = append(flags.NoOverrideFlags, "${config.NoOverride64GlobalCflags}") + } + + if android.IsThirdPartyPath(ctx.ModuleDir()) { + flags.NoOverrideFlags = append(flags.NoOverrideFlags, "${config.NoOverrideExternalGlobalCflags}") + } + return flags } diff --git a/cc/util.go b/cc/util.go index c93646b98..d6089aba8 100644 --- a/cc/util.go +++ b/cc/util.go @@ -56,18 +56,19 @@ func flagsToBuilderFlags(in Flags) builderFlags { localCppFlags: strings.Join(in.Local.CppFlags, " "), localLdFlags: strings.Join(in.Local.LdFlags, " "), - aidlFlags: strings.Join(in.aidlFlags, " "), - rsFlags: strings.Join(in.rsFlags, " "), - libFlags: strings.Join(in.libFlags, " "), - extraLibFlags: strings.Join(in.extraLibFlags, " "), - tidyFlags: strings.Join(in.TidyFlags, " "), - sAbiFlags: strings.Join(in.SAbiFlags, " "), - toolchain: in.Toolchain, - gcovCoverage: in.GcovCoverage, - tidy: in.Tidy, - needTidyFiles: in.NeedTidyFiles, - sAbiDump: in.SAbiDump, - emitXrefs: in.EmitXrefs, + noOverrideFlags: strings.Join(in.NoOverrideFlags, " "), + aidlFlags: strings.Join(in.aidlFlags, " "), + rsFlags: strings.Join(in.rsFlags, " "), + libFlags: strings.Join(in.libFlags, " "), + extraLibFlags: strings.Join(in.extraLibFlags, " "), + tidyFlags: strings.Join(in.TidyFlags, " "), + sAbiFlags: strings.Join(in.SAbiFlags, " "), + toolchain: in.Toolchain, + gcovCoverage: in.GcovCoverage, + tidy: in.Tidy, + needTidyFiles: in.NeedTidyFiles, + sAbiDump: in.SAbiDump, + emitXrefs: in.EmitXrefs, systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "), From 58378c9dbcadc0008e9d1e719ad744c91dd53d02 Mon Sep 17 00:00:00 2001 From: Dennis Shen Date: Wed, 3 Apr 2024 19:26:36 +0000 Subject: [PATCH 18/67] use build system flag RELEASE_READ_FROM_NEW_STORAGE to drive codegen When RELEASE_READ_FROM_NEW_STORAGE is true, enable reading from new storage. So that we can ensure nextfood is not impacted. Ignore-AOSP-First: code only needed for git_main, and will be removed once test mission 1 is finished. Bug: b/332737012 Test: m Change-Id: Ide3f432321ebd3dce9427e7cb8f2086e24d3cc31 --- aconfig/codegen/init.go | 3 ++- aconfig/codegen/rust_aconfig_library.go | 2 ++ android/config.go | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/aconfig/codegen/init.go b/aconfig/codegen/init.go index 73a89514d..6784797eb 100644 --- a/aconfig/codegen/init.go +++ b/aconfig/codegen/init.go @@ -63,11 +63,12 @@ var ( ` && ${aconfig} create-rust-lib` + ` --mode ${mode}` + ` --cache ${in}` + + ` --allow-instrumentation ${debug}` + ` --out ${gendir}`, CommandDeps: []string{ "$aconfig", }, - }, "gendir", "mode") + }, "gendir", "mode", "debug") ) func init() { diff --git a/aconfig/codegen/rust_aconfig_library.go b/aconfig/codegen/rust_aconfig_library.go index ad8d632a9..4b896c32d 100644 --- a/aconfig/codegen/rust_aconfig_library.go +++ b/aconfig/codegen/rust_aconfig_library.go @@ -2,6 +2,7 @@ package codegen import ( "fmt" + "strconv" "android/soong/android" "android/soong/rust" @@ -82,6 +83,7 @@ func (a *aconfigDecorator) GenerateSource(ctx rust.ModuleContext, deps rust.Path Args: map[string]string{ "gendir": generatedDir.String(), "mode": mode, + "debug": strconv.FormatBool(ctx.Config().ReleaseReadFromNewStorage()), }, }) a.BaseSourceProvider.OutputFiles = android.Paths{generatedSource} diff --git a/android/config.go b/android/config.go index f2f7d7de9..74fba6b3e 100644 --- a/android/config.go +++ b/android/config.go @@ -234,6 +234,11 @@ func (c Config) ReleaseHiddenApiExportableStubs() bool { Bool(c.config.productVariables.HiddenapiExportableStubs) } +// Enable read flag from new storage +func (c Config) ReleaseReadFromNewStorage() bool { + return c.config.productVariables.GetBuildFlagBool("RELEASE_READ_FROM_NEW_STORAGE") +} + // A DeviceConfig object represents the configuration for a particular device // being built. For now there will only be one of these, but in the future there // may be multiple devices being built. From 3ef72837357edfb32b7f0056624cd71673a3cd86 Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Thu, 28 Mar 2024 11:52:08 +0000 Subject: [PATCH 19/67] Refactor the contruction of the manifest check inputs. This is a no-op change for a majority of cases. Before this change, the contruction of the manifest check inputs is confusing. It mutates uses_libs properties in place just for the manifest check, by replacing module names with library names for direct dependencies and merging library names from CLC for both direct denpendencies and transitive denpendencies, and then constructs manifest check inputs from those mutated uses_libs properties. This is error-prone and leads to insistency: the goal is to check that the CLC matches the manifest, but the inputs to the check don't reflect the CLC. After this change, we no longer mutate uses_libs properties in place. Instead, we maintain a separate list of missing denpendencies, and then construct manifest check inputs directly from the CLC for all existing libraries, no matter they are direct or transtive, and from the separate list of missing libraries. This change makes the logic more consistent and straightforward, and it also allows us to easily do the next change, which is to propagate transtive missing denpendencies. In fact, this change revealed several bugs around library optionality and order in CLC construction, and fixed them. Bug: 331528424 Test: m --no-skip-soong-tests Ignore-AOSP-First: Depends on internal changes. Will cherry-pick once merged. Change-Id: I0de82e76c47995b54aba9efd41538d950256a95f --- dexpreopt/class_loader_context.go | 1 + java/aar.go | 8 +++- java/app.go | 77 ++++++++++++------------------- java/app_import.go | 8 +++- java/app_test.go | 14 +++--- java/base.go | 16 ++++++- java/java.go | 10 +++- scripts/manifest_check.py | 35 ++++++++++---- scripts/manifest_check_test.py | 17 +++++-- 9 files changed, 113 insertions(+), 73 deletions(-) diff --git a/dexpreopt/class_loader_context.go b/dexpreopt/class_loader_context.go index 57c7ae851..af1d33da6 100644 --- a/dexpreopt/class_loader_context.go +++ b/dexpreopt/class_loader_context.go @@ -323,6 +323,7 @@ func (clcMap ClassLoaderContextMap) addContext(ctx android.ModuleInstallPathCont } else if clc.Host == hostPath && clc.Device == devicePath { // Ok, the same library with the same paths. Don't re-add it, but don't raise an error // either, as the same library may be reachable via different transitional dependencies. + clc.Optional = clc.Optional && optional return nil } else { // Fail, as someone is trying to add the same library with different paths. This likely diff --git a/java/aar.go b/java/aar.go index 1734da945..07b2755cb 100644 --- a/java/aar.go +++ b/java/aar.go @@ -803,12 +803,12 @@ func (a *AndroidLibrary) OutputFiles(tag string) (android.Paths, error) { var _ AndroidLibraryDependency = (*AndroidLibrary)(nil) func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { + a.usesLibrary.deps(ctx, false) a.Module.deps(ctx) sdkDep := decodeSdkDep(ctx, android.SdkContext(a)) if sdkDep.hasFrameworkLibs() { a.aapt.deps(ctx, sdkDep) } - a.usesLibrary.deps(ctx, false) for _, aconfig_declaration := range a.aaptProperties.Flags_packages { ctx.AddDependency(ctx.Module(), aconfigDeclarationTag, aconfig_declaration) @@ -1366,6 +1366,12 @@ func (a *AARImport) ShouldSupportSdkVersion(ctx android.BaseModuleContext, var _ android.PrebuiltInterface = (*AARImport)(nil) +func (a *AARImport) UsesLibrary() *usesLibrary { + return &a.usesLibrary +} + +var _ ModuleWithUsesLibrary = (*AARImport)(nil) + // android_library_import imports an `.aar` file into the build graph as if it was built with android_library. // // This module is not suitable for installing on a device, but can be used as a `static_libs` dependency of diff --git a/java/app.go b/java/app.go index 2abc45107..a02ada12c 100755 --- a/java/app.go +++ b/java/app.go @@ -249,13 +249,13 @@ func (c Certificate) AndroidMkString() string { } func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) { - a.Module.deps(ctx) - if String(a.appProperties.Stl) == "c++_shared" && !a.SdkVersion(ctx).Specified() { ctx.PropertyErrorf("stl", "sdk_version must be set in order to use c++_shared") } sdkDep := decodeSdkDep(ctx, android.SdkContext(a)) + a.usesLibrary.deps(ctx, sdkDep.hasFrameworkLibs()) + a.Module.deps(ctx) if sdkDep.hasFrameworkLibs() { a.aapt.deps(ctx, sdkDep) } @@ -285,9 +285,6 @@ func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) { } ctx.AddFarVariationDependencies(variation, jniLibTag, a.appProperties.Jni_libs...) } - - a.usesLibrary.deps(ctx, sdkDep.hasFrameworkLibs()) - for _, aconfig_declaration := range a.aaptProperties.Flags_packages { ctx.AddDependency(ctx.Module(), aconfigDeclarationTag, aconfig_declaration) } @@ -811,18 +808,10 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { // The decision to enforce checks is made before adding implicit SDK libraries. a.usesLibrary.freezeEnforceUsesLibraries() - // Add implicit SDK libraries to list. - requiredUsesLibs, optionalUsesLibs := a.classLoaderContexts.UsesLibs() - for _, usesLib := range requiredUsesLibs { - a.usesLibrary.addLib(usesLib, false) - } - for _, usesLib := range optionalUsesLibs { - a.usesLibrary.addLib(usesLib, true) - } - // Check that the list is coherent with the manifest. if a.usesLibrary.enforceUsesLibraries() { - manifestCheckFile := a.usesLibrary.verifyUsesLibrariesManifest(ctx, a.mergedManifestFile) + manifestCheckFile := a.usesLibrary.verifyUsesLibrariesManifest( + ctx, a.mergedManifestFile, &a.classLoaderContexts) apkDeps = append(apkDeps, manifestCheckFile) } @@ -1580,6 +1569,9 @@ type UsesLibraryProperties struct { // provide the android.test.base statically and use jarjar to rename them so they do not collide // with the classes provided by the android.test.base library. Exclude_uses_libs []string + + // The module names of optional uses-library libraries that are missing from the source tree. + Missing_optional_uses_libs []string `blueprint:"mutated"` } // usesLibrary provides properties and helper functions for AndroidApp and AndroidAppImport to verify that the @@ -1596,20 +1588,11 @@ type usesLibrary struct { shouldDisableDexpreopt bool } -func (u *usesLibrary) addLib(lib string, optional bool) { - if !android.InList(lib, u.usesLibraryProperties.Uses_libs) && !android.InList(lib, u.usesLibraryProperties.Optional_uses_libs) { - if optional { - u.usesLibraryProperties.Optional_uses_libs = append(u.usesLibraryProperties.Optional_uses_libs, lib) - } else { - u.usesLibraryProperties.Uses_libs = append(u.usesLibraryProperties.Uses_libs, lib) - } - } -} - func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, addCompatDeps bool) { if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() { ctx.AddVariationDependencies(nil, usesLibReqTag, u.usesLibraryProperties.Uses_libs...) - ctx.AddVariationDependencies(nil, usesLibOptTag, u.presentOptionalUsesLibs(ctx)...) + presentOptionalUsesLibs := u.presentOptionalUsesLibs(ctx) + ctx.AddVariationDependencies(nil, usesLibOptTag, presentOptionalUsesLibs...) // Only add these extra dependencies if the module is an app that depends on framework // libs. This avoids creating a cyclic dependency: // e.g. framework-res -> org.apache.http.legacy -> ... -> framework-res. @@ -1620,6 +1603,8 @@ func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, addCompatDeps boo ctx.AddVariationDependencies(nil, usesLibCompat28OptTag, dexpreopt.OptionalCompatUsesLibs28...) ctx.AddVariationDependencies(nil, usesLibCompat30OptTag, dexpreopt.OptionalCompatUsesLibs30...) } + _, diff, _ := android.ListSetDifference(u.usesLibraryProperties.Optional_uses_libs, presentOptionalUsesLibs) + u.usesLibraryProperties.Missing_optional_uses_libs = diff } else { ctx.AddVariationDependencies(nil, r8LibraryJarTag, u.usesLibraryProperties.Uses_libs...) ctx.AddVariationDependencies(nil, r8LibraryJarTag, u.presentOptionalUsesLibs(ctx)...) @@ -1638,15 +1623,6 @@ func (u *usesLibrary) presentOptionalUsesLibs(ctx android.BaseModuleContext) []s return optionalUsesLibs } -// Helper function to replace string in a list. -func replaceInList(list []string, oldstr, newstr string) { - for i, str := range list { - if str == oldstr { - list[i] = newstr - } - } -} - // Returns a map of module names of shared library dependencies to the paths to their dex jars on // host and on device. func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext) dexpreopt.ClassLoaderContextMap { @@ -1688,11 +1664,6 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext libName := dep if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil { libName = *ulib.ProvidesUsesLib() - // Replace module name with library name in `uses_libs`/`optional_uses_libs` in - // order to pass verify_uses_libraries check (which compares these properties - // against library names written in the manifest). - replaceInList(u.usesLibraryProperties.Uses_libs, dep, libName) - replaceInList(u.usesLibraryProperties.Optional_uses_libs, dep, libName) } clcMap.AddContext(ctx, tag.sdkVersion, libName, tag.optional, lib.DexJarBuildPath(ctx).PathOrNil(), lib.DexJarInstallPath(), @@ -1726,7 +1697,7 @@ func (u *usesLibrary) freezeEnforceUsesLibraries() { // an APK with the manifest embedded in it (manifest_check will know which one it is by the file // extension: APKs are supposed to end with '.apk'). func (u *usesLibrary) verifyUsesLibraries(ctx android.ModuleContext, inputFile android.Path, - outputFile android.WritablePath) android.Path { + outputFile android.WritablePath, classLoaderContexts *dexpreopt.ClassLoaderContextMap) android.Path { statusFile := dexpreopt.UsesLibrariesStatusFile(ctx) @@ -1754,27 +1725,37 @@ func (u *usesLibrary) verifyUsesLibraries(ctx android.ModuleContext, inputFile a cmd.Flag("--enforce-uses-libraries-relax") } - for _, lib := range u.usesLibraryProperties.Uses_libs { + requiredUsesLibs, optionalUsesLibs := classLoaderContexts.UsesLibs() + for _, lib := range requiredUsesLibs { cmd.FlagWithArg("--uses-library ", lib) } - - for _, lib := range u.usesLibraryProperties.Optional_uses_libs { + for _, lib := range optionalUsesLibs { cmd.FlagWithArg("--optional-uses-library ", lib) } + // Also add missing optional uses libs, as the manifest check expects them. + // Note that what we add here are the module names of those missing libs, not library names, while + // the manifest check actually expects library names. However, the case where a library is missing + // and the module name != the library name is too rare for us to handle. + for _, lib := range u.usesLibraryProperties.Missing_optional_uses_libs { + cmd.FlagWithArg("--missing-optional-uses-library ", lib) + } + rule.Build("verify_uses_libraries", "verify ") return outputFile } // verifyUsesLibrariesManifest checks the tags in an AndroidManifest.xml against // the build system and returns the path to a copy of the manifest. -func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, manifest android.Path) android.Path { +func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, manifest android.Path, + classLoaderContexts *dexpreopt.ClassLoaderContextMap) android.Path { outputFile := android.PathForModuleOut(ctx, "manifest_check", "AndroidManifest.xml") - return u.verifyUsesLibraries(ctx, manifest, outputFile) + return u.verifyUsesLibraries(ctx, manifest, outputFile, classLoaderContexts) } // verifyUsesLibrariesAPK checks the tags in the manifest of an APK against the build // system and returns the path to a copy of the APK. -func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk android.Path) { - u.verifyUsesLibraries(ctx, apk, nil) // for APKs manifest_check does not write output file +func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk android.Path, + classLoaderContexts *dexpreopt.ClassLoaderContextMap) { + u.verifyUsesLibraries(ctx, apk, nil, classLoaderContexts) // for APKs manifest_check does not write output file } diff --git a/java/app_import.go b/java/app_import.go index 7387e168c..bb07c423a 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -355,7 +355,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext } if a.usesLibrary.enforceUsesLibraries() { - a.usesLibrary.verifyUsesLibrariesAPK(ctx, srcApk) + a.usesLibrary.verifyUsesLibrariesAPK(ctx, srcApk, &a.dexpreopter.classLoaderContexts) } a.dexpreopter.dexpreopt(ctx, android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName()), jnisUncompressed) @@ -611,6 +611,12 @@ func createArchDpiVariantGroupType(archNames []string, dpiNames []string) reflec return return_struct } +func (a *AndroidAppImport) UsesLibrary() *usesLibrary { + return &a.usesLibrary +} + +var _ ModuleWithUsesLibrary = (*AndroidAppImport)(nil) + // android_app_import imports a prebuilt apk with additional processing specified in the module. // DPI-specific apk source files can be specified using dpi_variants. Example: // diff --git a/java/app_test.go b/java/app_test.go index ca9d31704..972424c11 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -3280,7 +3280,7 @@ func TestUsesLibraries(t *testing.T) { sdk_version: "current", optional_uses_libs: [ "bar", - "baz", + "missing-lib-b", ], } @@ -3295,7 +3295,7 @@ func TestUsesLibraries(t *testing.T) { ], optional_uses_libs: [ "bar", - "baz", + "missing-lib-b", ], } ` @@ -3317,10 +3317,10 @@ func TestUsesLibraries(t *testing.T) { // propagated from dependencies. actualManifestFixerArgs := app.Output("manifest_fixer/AndroidManifest.xml").Args["args"] expectManifestFixerArgs := `--extract-native-libs=true ` + - `--uses-library qux ` + - `--uses-library quuz ` + `--uses-library foo ` + `--uses-library com.non.sdk.lib ` + + `--uses-library qux ` + + `--uses-library quuz ` + `--uses-library runtime-library ` + `--uses-library runtime-required-x ` + `--uses-library runtime-required-y ` + @@ -3339,9 +3339,9 @@ func TestUsesLibraries(t *testing.T) { `--uses-library runtime-required-x ` + `--uses-library runtime-required-y ` + `--optional-uses-library bar ` + - `--optional-uses-library baz ` + `--optional-uses-library runtime-optional-x ` + - `--optional-uses-library runtime-optional-y ` + `--optional-uses-library runtime-optional-y ` + + `--missing-optional-uses-library missing-lib-b ` android.AssertStringDoesContain(t, "verify cmd args", verifyCmd, verifyArgs) // Test that all libraries are verified for an APK (library order matters). @@ -3350,7 +3350,7 @@ func TestUsesLibraries(t *testing.T) { `--uses-library com.non.sdk.lib ` + `--uses-library android.test.runner ` + `--optional-uses-library bar ` + - `--optional-uses-library baz ` + `--missing-optional-uses-library missing-lib-b ` android.AssertStringDoesContain(t, "verify apk cmd args", verifyApkCmd, verifyApkArgs) // Test that necessary args are passed for constructing CLC in Ninja phase. diff --git a/java/base.go b/java/base.go index be286fe33..afc1b8965 100644 --- a/java/base.go +++ b/java/base.go @@ -837,9 +837,11 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { if dep != nil { if component, ok := dep.(SdkLibraryComponentDependency); ok { if lib := component.OptionalSdkLibraryImplementation(); lib != nil { - // Add library as optional if it's one of the optional compatibility libs. + // Add library as optional if it's one of the optional compatibility libs or it's + // explicitly listed in the optional_uses_libs property. tag := usesLibReqTag - if android.InList(*lib, dexpreopt.OptionalCompatUsesLibs) { + if android.InList(*lib, dexpreopt.OptionalCompatUsesLibs) || + android.InList(*lib, j.usesLibrary.usesLibraryProperties.Optional_uses_libs) { tag = usesLibOptTag } ctx.AddVariationDependencies(nil, tag, *lib) @@ -2703,3 +2705,13 @@ type ModuleWithStem interface { } var _ ModuleWithStem = (*Module)(nil) + +type ModuleWithUsesLibrary interface { + UsesLibrary() *usesLibrary +} + +func (j *Module) UsesLibrary() *usesLibrary { + return &j.usesLibrary +} + +var _ ModuleWithUsesLibrary = (*Module)(nil) diff --git a/java/java.go b/java/java.go index 72536cd6d..f5238476a 100644 --- a/java/java.go +++ b/java/java.go @@ -960,8 +960,8 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { } func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) { - j.deps(ctx) j.usesLibrary.deps(ctx, false) + j.deps(ctx) } const ( @@ -3138,7 +3138,13 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module, // and should not be added to CLC, but the transitive dependencies // from its CLC should be added to the current CLC. if sdkLib != nil { - clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib, false, + optional := false + if module, ok := ctx.Module().(ModuleWithUsesLibrary); ok { + if android.InList(*sdkLib, module.UsesLibrary().usesLibraryProperties.Optional_uses_libs) { + optional = true + } + } + clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib, optional, dep.DexJarBuildPath(ctx).PathOrNil(), dep.DexJarInstallPath(), dep.ClassLoaderContexts()) } else { clcMap.AddContextMap(dep.ClassLoaderContexts(), depName) diff --git a/scripts/manifest_check.py b/scripts/manifest_check.py index c33b104bd..b10125994 100755 --- a/scripts/manifest_check.py +++ b/scripts/manifest_check.py @@ -51,6 +51,14 @@ def parse_args(): help='specify uses-library entries known to the build system with ' 'required:false' ) + parser.add_argument( + '--missing-optional-uses-library', + dest='missing_optional_uses_libraries', + action='append', + help='specify uses-library entries missing from the build system with ' + 'required:false', + default=[] + ) parser.add_argument( '--enforce-uses-libraries', dest='enforce_uses_libraries', @@ -91,7 +99,7 @@ C_OFF = "\033[0m" C_BOLD = "\033[1m" -def enforce_uses_libraries(manifest, required, optional, relax, is_apk, path): +def enforce_uses_libraries(manifest, required, optional, missing_optional, relax, is_apk, path): """Verify that the tags in the manifest match those provided by the build system. @@ -119,7 +127,12 @@ def enforce_uses_libraries(manifest, required, optional, relax, is_apk, path): required = trim_namespace_parts(required) optional = trim_namespace_parts(optional) - if manifest_required == required and manifest_optional == optional: + existing_manifest_optional = [ + lib for lib in manifest_optional if lib not in missing_optional] + + # The order of the existing libraries matter, while the order of the missing + # ones doesn't. + if manifest_required == required and existing_manifest_optional == optional: return None #pylint: disable=line-too-long @@ -129,6 +142,7 @@ def enforce_uses_libraries(manifest, required, optional, relax, is_apk, path): '\t- required libraries in build system: %s[%s]%s\n' % (C_RED, ', '.join(required), C_OFF), '\t vs. in the manifest: %s[%s]%s\n' % (C_RED, ', '.join(manifest_required), C_OFF), '\t- optional libraries in build system: %s[%s]%s\n' % (C_RED, ', '.join(optional), C_OFF), + '\t and missing ones in build system: %s[%s]%s\n' % (C_RED, ', '.join(missing_optional), C_OFF), '\t vs. in the manifest: %s[%s]%s\n' % (C_RED, ', '.join(manifest_optional), C_OFF), '\t- tags in the manifest (%s):\n' % path, '\t\t%s\n' % '\t\t'.join(tags), @@ -340,11 +354,14 @@ def main(): if args.enforce_uses_libraries: # Load dexpreopt.config files and build a mapping from module - # names to library names. This is necessary because build system - # addresses libraries by their module name (`uses_libs`, - # `optional_uses_libs`, `LOCAL_USES_LIBRARIES`, - # `LOCAL_OPTIONAL_LIBRARY_NAMES` all contain module names), while - # the manifest addresses libraries by their name. + # names to library names. This is for Make only and it's necessary + # because Make passes module names from `LOCAL_USES_LIBRARIES`, + # `LOCAL_OPTIONAL_LIBRARY_NAMES`, while the manifest addresses + # libraries by their name. Soong doesn't use it and doesn't need it + # because it converts the module names to the library names and + # passes the library names. There is no need to translate missing + # optional libs because they are missing and therefore there is no + # mapping for them. mod_to_lib = load_dexpreopt_configs(args.dexpreopt_configs) required = translate_libnames(args.uses_libraries, mod_to_lib) optional = translate_libnames(args.optional_uses_libraries, @@ -354,8 +371,8 @@ def main(): # those in the manifest. Raise an exception on mismatch, unless the # script was passed a special parameter to suppress exceptions. errmsg = enforce_uses_libraries(manifest, required, optional, - args.enforce_uses_libraries_relax, - is_apk, args.input) + args.missing_optional_uses_libraries, + args.enforce_uses_libraries_relax, is_apk, args.input) # Create a status file that is empty on success, or contains an # error message on failure. When exceptions are suppressed, diff --git a/scripts/manifest_check_test.py b/scripts/manifest_check_test.py index 3be7a30bf..8003b3e19 100755 --- a/scripts/manifest_check_test.py +++ b/scripts/manifest_check_test.py @@ -44,15 +44,17 @@ def required_apk(value): class EnforceUsesLibrariesTest(unittest.TestCase): """Unit tests for add_extract_native_libs function.""" - def run_test(self, xml, apk, uses_libraries=[], optional_uses_libraries=[]): #pylint: disable=dangerous-default-value + def run_test(self, xml, apk, uses_libraries=[], optional_uses_libraries=[], + missing_optional_uses_libraries=[]): #pylint: disable=dangerous-default-value doc = minidom.parseString(xml) try: relax = False manifest_check.enforce_uses_libraries( - doc, uses_libraries, optional_uses_libraries, relax, False, - 'path/to/X/AndroidManifest.xml') + doc, uses_libraries, optional_uses_libraries, missing_optional_uses_libraries, + relax, False, 'path/to/X/AndroidManifest.xml') manifest_check.enforce_uses_libraries(apk, uses_libraries, optional_uses_libraries, + missing_optional_uses_libraries, relax, True, 'path/to/X/X.apk') return True @@ -102,6 +104,15 @@ class EnforceUsesLibrariesTest(unittest.TestCase): matches = self.run_test(xml, apk, optional_uses_libraries=['foo']) self.assertFalse(matches) + def test_expected_missing_optional_uses_library(self): + xml = self.xml_tmpl % ( + uses_library_xml('foo') + uses_library_xml('missing') + uses_library_xml('bar')) + apk = self.apk_tmpl % ( + uses_library_apk('foo') + uses_library_apk('missing') + uses_library_apk('bar')) + matches = self.run_test(xml, apk, optional_uses_libraries=['foo', 'bar'], + missing_optional_uses_libraries=['missing']) + self.assertFalse(matches) + def test_missing_uses_library(self): xml = self.xml_tmpl % ('') apk = self.apk_tmpl % ('') From 22154d8c3e82225c2d295f137ec37eebbef70235 Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Thu, 28 Mar 2024 13:50:43 +0000 Subject: [PATCH 20/67] Propagate transitive missing optional_uses_libs. Bug: 331528424 Test: m --no-skip-soong-tests Ignore-AOSP-First: Depends on internal changes. Will cherry-pick once merged. Change-Id: Ied2821f11b6a5056ecf577e1e25765bc6dd212c0 --- java/aar.go | 13 ++++++++++--- java/app.go | 1 + java/app_test.go | 8 ++++++-- java/base.go | 1 + java/java.go | 16 ++++++++++++++++ 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/java/aar.go b/java/aar.go index 07b2755cb..ee5ebcd82 100644 --- a/java/aar.go +++ b/java/aar.go @@ -354,12 +354,13 @@ type aaptBuildActionOptions struct { forceNonFinalResourceIDs bool extraLinkFlags []string aconfigTextFiles android.Paths + usesLibrary *usesLibrary } func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptions) { staticResourcesNodesDepSet, sharedResourcesNodesDepSet, staticRRODirsDepSet, staticManifestsDepSet, sharedExportPackages, libFlags := - aaptLibs(ctx, opts.sdkContext, opts.classLoaderContexts) + aaptLibs(ctx, opts.sdkContext, opts.classLoaderContexts, opts.usesLibrary) // Exclude any libraries from the supplied list. opts.classLoaderContexts = opts.classLoaderContexts.ExcludeLibs(opts.excludedLibs) @@ -701,7 +702,8 @@ func (t transitiveAarDeps) assets() android.Paths { } // aaptLibs collects libraries from dependencies and sdk_version and converts them into paths -func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoaderContexts dexpreopt.ClassLoaderContextMap) ( +func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, + classLoaderContexts dexpreopt.ClassLoaderContextMap, usesLibrary *usesLibrary) ( staticResourcesNodes, sharedResourcesNodes *android.DepSet[*resourcesNode], staticRRODirs *android.DepSet[rroDir], staticManifests *android.DepSet[android.Path], sharedLibs android.Paths, flags []string) { @@ -751,6 +753,9 @@ func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoa } addCLCFromDep(ctx, module, classLoaderContexts) + if usesLibrary != nil { + addMissingOptionalUsesLibsFromDep(ctx, module, usesLibrary) + } }) // AAPT2 overlays are in lowest to highest priority order, the topological order will be reversed later. @@ -827,6 +832,7 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) classLoaderContexts: a.classLoaderContexts, enforceDefaultTargetSdkVersion: false, aconfigTextFiles: getAconfigFilePaths(ctx), + usesLibrary: &a.usesLibrary, }, ) @@ -1204,7 +1210,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { linkDeps = append(linkDeps, a.manifest) staticResourcesNodesDepSet, sharedResourcesNodesDepSet, staticRRODirsDepSet, staticManifestsDepSet, sharedLibs, libFlags := - aaptLibs(ctx, android.SdkContext(a), nil) + aaptLibs(ctx, android.SdkContext(a), nil, nil) _ = sharedResourcesNodesDepSet _ = staticRRODirsDepSet @@ -1274,6 +1280,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { } } addCLCFromDep(ctx, module, a.classLoaderContexts) + addMissingOptionalUsesLibsFromDep(ctx, module, &a.usesLibrary) }) if len(staticJars) > 0 { diff --git a/java/app.go b/java/app.go index a02ada12c..61e3235bc 100755 --- a/java/app.go +++ b/java/app.go @@ -527,6 +527,7 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) { forceNonFinalResourceIDs: nonFinalIds, extraLinkFlags: aaptLinkFlags, aconfigTextFiles: getAconfigFilePaths(ctx), + usesLibrary: &a.usesLibrary, }, ) diff --git a/java/app_test.go b/java/app_test.go index 972424c11..d9fd884cc 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -3244,7 +3244,10 @@ func TestUsesLibraries(t *testing.T) { name: "static-y", srcs: ["a.java"], uses_libs: ["runtime-required-y"], - optional_uses_libs: ["runtime-optional-y"], + optional_uses_libs: [ + "runtime-optional-y", + "missing-lib-a", + ], sdk_version: "current", } @@ -3341,7 +3344,8 @@ func TestUsesLibraries(t *testing.T) { `--optional-uses-library bar ` + `--optional-uses-library runtime-optional-x ` + `--optional-uses-library runtime-optional-y ` + - `--missing-optional-uses-library missing-lib-b ` + `--missing-optional-uses-library missing-lib-b ` + + `--missing-optional-uses-library missing-lib-a` android.AssertStringDoesContain(t, "verify cmd args", verifyCmd, verifyArgs) // Test that all libraries are verified for an APK (library order matters). diff --git a/java/base.go b/java/base.go index afc1b8965..6e9680952 100644 --- a/java/base.go +++ b/java/base.go @@ -2382,6 +2382,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { } addCLCFromDep(ctx, module, j.classLoaderContexts) + addMissingOptionalUsesLibsFromDep(ctx, module, &j.usesLibrary) }) return deps diff --git a/java/java.go b/java/java.go index f5238476a..963651a21 100644 --- a/java/java.go +++ b/java/java.go @@ -3151,6 +3151,22 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module, } } +func addMissingOptionalUsesLibsFromDep(ctx android.ModuleContext, depModule android.Module, + usesLibrary *usesLibrary) { + + dep, ok := depModule.(ModuleWithUsesLibrary) + if !ok { + return + } + + for _, lib := range dep.UsesLibrary().usesLibraryProperties.Missing_optional_uses_libs { + if !android.InList(lib, usesLibrary.usesLibraryProperties.Missing_optional_uses_libs) { + usesLibrary.usesLibraryProperties.Missing_optional_uses_libs = + append(usesLibrary.usesLibraryProperties.Missing_optional_uses_libs, lib) + } + } +} + type JavaApiContributionImport struct { JavaApiContribution From 68e4da146c9b485831c28a6d3cc5f3863480b501 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 23 Apr 2024 14:18:39 +0100 Subject: [PATCH 21/67] Use new --api-lint-previous-api Bug: 327019023 Test: ./gradlew Merged-In: Ief4d7380e7242dff4e82df96778af17d56c4fe82 Change-Id: I4c032bad2cff6d0bacb2b93fcf657f2a1d1bbd08 --- java/droidstubs.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index ea9305f51..7460843ea 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -610,11 +610,10 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) { if BoolDefault(d.properties.Check_api.Api_lint.Enabled, false) { doApiLint = true + cmd.Flag("--api-lint") newSince := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.New_since) if newSince.Valid() { - cmd.FlagWithInput("--api-lint ", newSince.Path()) - } else { - cmd.Flag("--api-lint") + cmd.FlagWithInput("--api-lint-previous-api ", newSince.Path()) } d.apiLintReport = android.PathForModuleOut(ctx, "metalava", "api_lint_report.txt") cmd.FlagWithOutput("--report-even-if-suppressed ", d.apiLintReport) // TODO: Change to ":api-lint" From be77e450dfb8057d6df5c513ca6911979da850d7 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 23 Apr 2024 12:39:54 -0700 Subject: [PATCH 22/67] Allow overriding android_library_import manifests Some of the androidx libraries have a transformed manifest alongside that needs to be used to avoid introducing extra androidx.startup provider entries. Add a manifest property that allows overriding the manifest provided by the aar file. Bug: 336549758 Test: examine PermissionController.apk Ignore-AOSP-First: submitting in topic with internal CL Change-Id: I5c8daf810d2fde9a150cbfe48b4f4216f5d1ba0d --- java/aar.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/java/aar.go b/java/aar.go index f8955ce90..2e95c682f 100644 --- a/java/aar.go +++ b/java/aar.go @@ -968,6 +968,9 @@ type AARImportProperties struct { // will be passed transitively through android_libraries to an android_app. //TODO(b/241138093) evaluate whether we can have this flag default to true for Bazel conversion Extract_jni *bool + + // If set, overrides the manifest extracted from the AAR with the provided path. + Manifest *string `android:"path"` } type AARImport struct { @@ -990,7 +993,7 @@ type AARImport struct { exportPackage android.WritablePath transitiveAaptResourcePackagesFile android.Path extraAaptPackagesFile android.WritablePath - manifest android.WritablePath + manifest android.Path assetsPackage android.WritablePath rTxt android.WritablePath rJar android.WritablePath @@ -1166,7 +1169,15 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { jarName := ctx.ModuleName() + ".jar" extractedAARDir := android.PathForModuleOut(ctx, "aar") classpathFile := extractedAARDir.Join(ctx, jarName) - a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml") + + extractedManifest := extractedAARDir.Join(ctx, "AndroidManifest.xml") + providedManifest := android.OptionalPathForModuleSrc(ctx, a.properties.Manifest) + if providedManifest.Valid() { + a.manifest = providedManifest.Path() + } else { + a.manifest = extractedManifest + } + a.rTxt = extractedAARDir.Join(ctx, "R.txt") a.assetsPackage = android.PathForModuleOut(ctx, "assets.zip") a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt") @@ -1187,7 +1198,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.Build(pctx, android.BuildParams{ Rule: unzipAAR, Input: a.aarPath, - Outputs: android.WritablePaths{classpathFile, a.proguardFlags, a.manifest, a.assetsPackage, a.rTxt}, + Outputs: android.WritablePaths{classpathFile, a.proguardFlags, extractedManifest, a.assetsPackage, a.rTxt}, Description: "unzip AAR", Args: map[string]string{ "outDir": extractedAARDir.String(), From e916a2c758d2a95037d1d366e7cd0e10d241d510 Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Wed, 20 Mar 2024 19:47:28 +0000 Subject: [PATCH 23/67] Make container mandatory in aconfig_declarations. Bug: 330354107 Test: Unit test and CI. Ignore-AOSP-First: It is easier to detect all the missing ones in internal master. Change-Id: I4ab4271c67a35d0fdcc0b57c27260e29fb7dea56 --- aconfig/aconfig_declarations.go | 5 +- aconfig/aconfig_declarations_test.go | 60 ++++++++++++++----- .../aconfig_declarations_group_test.go | 5 +- aconfig/codegen/cc_aconfig_library_test.go | 4 ++ aconfig/codegen/java_aconfig_library_test.go | 55 ++++++++++++++++- aconfig/codegen/rust_aconfig_library_test.go | 3 + apex/apex_test.go | 1 + java/aar_test.go | 5 +- java/app_test.go | 2 + java/droidstubs_test.go | 2 + java/java_test.go | 1 + java/rro_test.go | 2 + java/sdk_library_test.go | 1 + 13 files changed, 126 insertions(+), 20 deletions(-) diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go index d29e3122d..71a64dddc 100644 --- a/aconfig/aconfig_declarations.go +++ b/aconfig/aconfig_declarations.go @@ -73,8 +73,9 @@ func (module *DeclarationsModule) DepsMutator(ctx android.BottomUpMutatorContext if len(module.properties.Package) == 0 { ctx.PropertyErrorf("package", "missing package property") } - // TODO(b/311155208): Add mandatory check for container after all pre-existing - // ones are changed. + if len(module.properties.Container) == 0 { + ctx.PropertyErrorf("container", "missing container property") + } // Add a dependency on the aconfig_value_sets defined in // RELEASE_ACONFIG_VALUE_SETS, and add any aconfig_values that diff --git a/aconfig/aconfig_declarations_test.go b/aconfig/aconfig_declarations_test.go index 5201fedb1..c37274c71 100644 --- a/aconfig/aconfig_declarations_test.go +++ b/aconfig/aconfig_declarations_test.go @@ -88,19 +88,49 @@ func TestAconfigDeclarationsWithContainer(t *testing.T) { android.AssertStringEquals(t, "rule must contain container", rule.Args["container"], "--container com.android.foo") } -func TestAconfigDeclarationsWithoutContainer(t *testing.T) { - bp := ` - aconfig_declarations { - name: "module_name", - package: "com.example.package", - srcs: [ - "foo.aconfig", - ], - } - ` - result := runTest(t, android.FixtureExpectsNoErrors, bp) - - module := result.ModuleForTests("module_name", "") - rule := module.Rule("aconfig") - android.AssertIntEquals(t, "rule must not contain container", len(rule.Args["container"]), 0) +func TestMandatoryProperties(t *testing.T) { + testCases := []struct { + name string + expectedError string + bp string + }{ + { + name: "Srcs missing from aconfig_declarations", + bp: ` + aconfig_declarations { + name: "my_aconfig_declarations_foo", + package: "com.example.package", + container: "otherapex", + }`, + expectedError: `missing source files`, + }, + { + name: "Package missing from aconfig_declarations", + bp: ` + aconfig_declarations { + name: "my_aconfig_declarations_foo", + container: "otherapex", + srcs: ["foo.aconfig"], + }`, + expectedError: `missing package property`, + }, + { + name: "Container missing from aconfig_declarations", + bp: ` + aconfig_declarations { + name: "my_aconfig_declarations_foo", + package: "com.example.package", + srcs: ["foo.aconfig"], + }`, + expectedError: `missing container property`, + }, + } + for _, test := range testCases { + t.Run(test.name, func(t *testing.T) { + errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(test.expectedError) + android.GroupFixturePreparers(PrepareForTestWithAconfigBuildComponents). + ExtendWithErrorHandler(errorHandler). + RunTestWithBp(t, test.bp) + }) + } } diff --git a/aconfig/codegen/aconfig_declarations_group_test.go b/aconfig/codegen/aconfig_declarations_group_test.go index ec7cea383..c69d21ffd 100644 --- a/aconfig/codegen/aconfig_declarations_group_test.go +++ b/aconfig/codegen/aconfig_declarations_group_test.go @@ -15,9 +15,10 @@ package codegen import ( + "testing" + "android/soong/android" "android/soong/java" - "testing" ) func TestAconfigDeclarationsGroup(t *testing.T) { @@ -28,6 +29,7 @@ func TestAconfigDeclarationsGroup(t *testing.T) { aconfig_declarations { name: "foo-aconfig", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } @@ -39,6 +41,7 @@ func TestAconfigDeclarationsGroup(t *testing.T) { aconfig_declarations { name: "bar-aconfig", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } diff --git a/aconfig/codegen/cc_aconfig_library_test.go b/aconfig/codegen/cc_aconfig_library_test.go index 05449bc6c..860f9487e 100644 --- a/aconfig/codegen/cc_aconfig_library_test.go +++ b/aconfig/codegen/cc_aconfig_library_test.go @@ -50,6 +50,7 @@ func testCCCodegenModeHelper(t *testing.T, bpMode string, ruleMode string) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } @@ -92,6 +93,7 @@ func testIncorrectCCCodegenModeHelper(t *testing.T, bpMode string, err string) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } @@ -126,6 +128,7 @@ func TestAndroidMkCcLibrary(t *testing.T) { aconfig_declarations { name: "my_aconfig_declarations_bar", package: "com.example.package", + container: "com.android.foo", srcs: ["bar.aconfig"], } @@ -176,6 +179,7 @@ func TestForceReadOnly(t *testing.T) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } diff --git a/aconfig/codegen/java_aconfig_library_test.go b/aconfig/codegen/java_aconfig_library_test.go index de45b5cc3..87b54a47f 100644 --- a/aconfig/codegen/java_aconfig_library_test.go +++ b/aconfig/codegen/java_aconfig_library_test.go @@ -35,6 +35,7 @@ func runJavaAndroidMkTest(t *testing.T, bp string) { aconfig_declarations { name: "my_aconfig_declarations_foo", package: "com.example.package.foo", + container: "system", srcs: ["foo.aconfig"], } @@ -46,6 +47,7 @@ func runJavaAndroidMkTest(t *testing.T, bp string) { aconfig_declarations { name: "my_aconfig_declarations_bar", package: "com.example.package.bar", + container: "system", srcs: ["bar.aconfig"], } @@ -60,7 +62,7 @@ func runJavaAndroidMkTest(t *testing.T, bp string) { entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0] makeVar := entry.EntryMap["LOCAL_ACONFIG_FILES"] - android.EnsureListContainsSuffix(t, makeVar, "android_common/aconfig_merged.pb") + android.EnsureListContainsSuffix(t, makeVar, "android_common/system/aconfig_merged.pb") } func TestAndroidMkJavaLibrary(t *testing.T) { @@ -175,6 +177,7 @@ func testCodegenMode(t *testing.T, bpMode string, ruleMode string) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], exportable: true, } @@ -200,6 +203,7 @@ func testCodegenModeWithError(t *testing.T, bpMode string, err string) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } @@ -234,3 +238,52 @@ func TestForceReadOnlyMode(t *testing.T) { func TestUnsupportedMode(t *testing.T) { testCodegenModeWithError(t, "mode: `unsupported`,", "mode: \"unsupported\" is not a supported mode") } + +func TestMkEntriesMatchedContainer(t *testing.T) { + result := android.GroupFixturePreparers( + PrepareForTestWithAconfigBuildComponents, + java.PrepareForTestWithJavaDefaultModules). + ExtendWithErrorHandler(android.FixtureExpectsNoErrors). + RunTestWithBp(t, ` + aconfig_declarations { + name: "my_aconfig_declarations_foo", + package: "com.example.package.foo", + container: "system", + srcs: ["foo.aconfig"], + } + + java_aconfig_library { + name: "my_java_aconfig_library_foo", + aconfig_declarations: "my_aconfig_declarations_foo", + } + + aconfig_declarations { + name: "my_aconfig_declarations_bar", + package: "com.example.package.bar", + container: "system_ext", + srcs: ["bar.aconfig"], + } + + java_aconfig_library { + name: "my_java_aconfig_library_bar", + aconfig_declarations: "my_aconfig_declarations_bar", + } + + java_library { + name: "my_module", + srcs: [ + "src/foo.java", + ], + static_libs: [ + "my_java_aconfig_library_foo", + "my_java_aconfig_library_bar", + ], + platform_apis: true, + } + `) + + module := result.ModuleForTests("my_module", "android_common").Module() + entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0] + makeVar := entry.EntryMap["LOCAL_ACONFIG_FILES"] + android.EnsureListContainsSuffix(t, makeVar, "my_aconfig_declarations_foo/intermediate.pb") +} diff --git a/aconfig/codegen/rust_aconfig_library_test.go b/aconfig/codegen/rust_aconfig_library_test.go index fe28f9441..523b464c0 100644 --- a/aconfig/codegen/rust_aconfig_library_test.go +++ b/aconfig/codegen/rust_aconfig_library_test.go @@ -46,6 +46,7 @@ func TestRustAconfigLibrary(t *testing.T) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } @@ -131,6 +132,7 @@ func testRustCodegenModeHelper(t *testing.T, bpMode string, ruleMode string) { aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } rust_aconfig_library { @@ -193,6 +195,7 @@ func testIncorrectRustCodegenModeHelper(t *testing.T, bpMode string, err string) aconfig_declarations { name: "my_aconfig_declarations", package: "com.example.package", + container: "com.android.foo", srcs: ["foo.aconfig"], } rust_aconfig_library { diff --git a/apex/apex_test.go b/apex/apex_test.go index a59c0c326..89c29af2e 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -11421,6 +11421,7 @@ func TestAconfifDeclarationsValidation(t *testing.T) { aconfig_declarations { name: "%[1]s", package: "com.example.package", + container: "system", srcs: [ "%[1]s.aconfig", ], diff --git a/java/aar_test.go b/java/aar_test.go index d6dbe3c25..18efd2067 100644 --- a/java/aar_test.go +++ b/java/aar_test.go @@ -15,8 +15,9 @@ package java import ( - "android/soong/android" "testing" + + "android/soong/android" ) func TestAarImportProducesJniPackages(t *testing.T) { @@ -98,6 +99,7 @@ func TestLibraryFlagsPackages(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package.bar", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -105,6 +107,7 @@ func TestLibraryFlagsPackages(t *testing.T) { aconfig_declarations { name: "baz", package: "com.example.package.baz", + container: "com.android.foo", srcs: [ "baz.aconfig", ], diff --git a/java/app_test.go b/java/app_test.go index eab40e7da..a7c48a1ed 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -4382,6 +4382,7 @@ func TestAppFlagsPackages(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package.bar", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -4389,6 +4390,7 @@ func TestAppFlagsPackages(t *testing.T) { aconfig_declarations { name: "baz", package: "com.example.package.baz", + container: "com.android.foo", srcs: [ "baz.aconfig", ], diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go index 8da695f08..6a14f3645 100644 --- a/java/droidstubs_test.go +++ b/java/droidstubs_test.go @@ -379,6 +379,7 @@ func TestAconfigDeclarations(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -434,6 +435,7 @@ func TestReleaseExportRuntimeApis(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], diff --git a/java/java_test.go b/java/java_test.go index a1192bb5f..2f2793202 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2801,6 +2801,7 @@ func TestApiLibraryAconfigDeclarations(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], diff --git a/java/rro_test.go b/java/rro_test.go index d697ec627..742c83982 100644 --- a/java/rro_test.go +++ b/java/rro_test.go @@ -421,6 +421,7 @@ func TestRuntimeResourceOverlayFlagsPackages(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package.bar", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -428,6 +429,7 @@ func TestRuntimeResourceOverlayFlagsPackages(t *testing.T) { aconfig_declarations { name: "baz", package: "com.example.package.baz", + container: "com.android.foo", srcs: [ "baz.aconfig", ], diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 0f163e6e0..34c63ac61 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -1715,6 +1715,7 @@ func TestSdkLibraryExportableStubsLibrary(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], From c91d0cdc0fb70bdcb34ad858e95e3ef1462bd677 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Tue, 23 Apr 2024 22:50:41 +0000 Subject: [PATCH 24/67] V is 35. It's not bromine, it's not a gauge of film: it's the next Android release. Ignore-AOSP-First: VanillaIceCream Finalization Bug: 335304236 Test: presubmit Change-Id: Ie4e17236c85944e828edaf01dcdc782984dc0ad4 --- android/api_levels.go | 41 +++++++++++++++++++++-------------------- java/droidstubs.go | 3 ++- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/android/api_levels.go b/android/api_levels.go index fab5fc7bf..8f2ff1790 100644 --- a/android/api_levels.go +++ b/android/api_levels.go @@ -442,26 +442,27 @@ func GetApiLevelsJson(ctx PathContext) WritablePath { func getApiLevelsMapReleasedVersions() (map[string]int, error) { return map[string]int{ - "G": 9, - "I": 14, - "J": 16, - "J-MR1": 17, - "J-MR2": 18, - "K": 19, - "L": 21, - "L-MR1": 22, - "M": 23, - "N": 24, - "N-MR1": 25, - "O": 26, - "O-MR1": 27, - "P": 28, - "Q": 29, - "R": 30, - "S": 31, - "S-V2": 32, - "Tiramisu": 33, - "UpsideDownCake": 34, + "G": 9, + "I": 14, + "J": 16, + "J-MR1": 17, + "J-MR2": 18, + "K": 19, + "L": 21, + "L-MR1": 22, + "M": 23, + "N": 24, + "N-MR1": 25, + "O": 26, + "O-MR1": 27, + "P": 28, + "Q": 29, + "R": 30, + "S": 31, + "S-V2": 32, + "Tiramisu": 33, + "UpsideDownCake": 34, + "VanillaIceCream": 35, }, nil } diff --git a/java/droidstubs.go b/java/droidstubs.go index ffd3caf99..60af299a3 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -599,7 +599,8 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a } if apiVersions != nil { cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion().String()) - cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) + // STOPSHIP: RESTORE THIS LOGIC WHEN DECLARING "REL" BUILD + // cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) cmd.FlagWithInput("--apply-api-levels ", apiVersions) } } From 27eee7045a5e7d6dc7202d9655041937c0250abf Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Tue, 30 Apr 2024 19:11:26 +0000 Subject: [PATCH 25/67] Read from original flag Test: m Change-Id: I72f0a3fc765a00fc57a293f39cefa1f6c3aac519 Bug: 328444881 Ignore-AOSP-First: reconciling with aosp/3067403 --- aconfig/codegen/cc_aconfig_library.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aconfig/codegen/cc_aconfig_library.go b/aconfig/codegen/cc_aconfig_library.go index ec0a6b6cd..b5cf68798 100644 --- a/aconfig/codegen/cc_aconfig_library.go +++ b/aconfig/codegen/cc_aconfig_library.go @@ -156,7 +156,7 @@ func (this *CcAconfigLibraryCallbacks) GeneratorBuildActions(ctx cc.ModuleContex Args: map[string]string{ "gendir": this.generatedDir.String(), "mode": mode, - "debug": strconv.FormatBool(ctx.Config().ReleaseReadFromNewStorageCc()), + "debug": strconv.FormatBool(ctx.Config().ReleaseReadFromNewStorage()), }, }) From 13af44136839aa28a1e883fdfb6e1c68d2b92e79 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 3 May 2024 21:36:48 +0000 Subject: [PATCH 26/67] Align boot jar exclusion with apex_contributions During trunk stable development, it is possible that a new boot jar is added to the source apex, but not available in prebuilt apex yet. Thefore we need to conditionally check the `contents` of the respective bootclasspath_fragment modules. https://r.android.com/2822393 did this using isActiveModule. This function relies on soong config namespaces to "hide" the source bootclasspath_fragment module when .source_build is false. Soong config namespaces for mainline source vs prebuilt selection is no longer in use, so this CL replaces `isActiveModule`. The CL cleaves the implementation 1. For source builds, the check will run in the context of the bootclasspath_fragment module. `disableSourceApexVariant` will be used to skip the check if prebuilts are selected. 2. For prebuilt builds, the prebuilt bootclasspath_fragment module sets a provider, and the top-level apex will do the check. (2) is necessary to handle the edge case of multiple versioned mainline prebuilts and possible skew in apex boot jars across them. In case of prebuilt builds, the unselected mainline prebuilts will have HideFromMake called on them, so the check will only run on the apex that is actually used during the build. Bug: 328578801 Test: go test ./apex Ignore-AOSP-First: required to fix merge conflict Change-Id: I6eec603397eea926f3a481b79ca938245064d809 --- apex/platform_bootclasspath_test.go | 124 ++++++++++++++++++++++++++++ apex/prebuilt.go | 17 ++++ java/bootclasspath_fragment.go | 27 +++++- 3 files changed, 166 insertions(+), 2 deletions(-) diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go index 2be9c10e1..9f1e1e16f 100644 --- a/apex/platform_bootclasspath_test.go +++ b/apex/platform_bootclasspath_test.go @@ -795,3 +795,127 @@ func TestNonBootJarInFragment(t *testing.T) { } `) } + +// Source and prebuilt apex provide different set of boot jars +func TestNonBootJarMissingInPrebuiltFragment(t *testing.T) { + bp := ` + apex { + name: "myapex", + key: "myapex.key", + bootclasspath_fragments: ["apex-fragment"], + updatable: false, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + java_library { + name: "foo", + srcs: ["b.java"], + installable: true, + apex_available: ["myapex"], + permitted_packages: ["foo"], + } + + java_library { + name: "bar", + srcs: ["b.java"], + installable: true, + apex_available: ["myapex"], + permitted_packages: ["bar"], + } + + bootclasspath_fragment { + name: "apex-fragment", + contents: ["foo", "bar"], + apex_available:[ "myapex" ], + hidden_api: { + split_packages: ["*"], + }, + } + + prebuilt_apex { + name: "com.google.android.myapex", // mainline prebuilt selection logic in soong relies on the naming convention com.google.android + apex_name: "myapex", + source_apex_name: "myapex", + src: "myapex.apex", + exported_bootclasspath_fragments: ["apex-fragment"], + } + + java_import { + name: "foo", + jars: ["foo.jar"], + apex_available: ["myapex"], + permitted_packages: ["foo"], + } + + prebuilt_bootclasspath_fragment { + name: "apex-fragment", + contents: ["foo"], // Unlike the source fragment, this is missing bar + apex_available:[ "myapex" ], + hidden_api: { + annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv", + metadata: "my-bootclasspath-fragment/metadata.csv", + index: "my-bootclasspath-fragment/index.csv", + stub_flags: "my-bootclasspath-fragment/stub-flags.csv", + all_flags: "my-bootclasspath-fragment/all-flags.csv", + }, + } + + apex_contributions { + name: "my_apex_contributions", + api_domain: "myapex", + contents: [%v], + } + ` + testCases := []struct { + desc string + configuredBootJars []string + apexContributionContents string + errorExpected bool + }{ + { + desc: "Source apex is selected, and APEX_BOOT_JARS is correctly configured for source apex builds", + configuredBootJars: []string{"myapex:foo", "myapex:bar"}, + }, + { + desc: "Source apex is selected, and APEX_BOOT_JARS is missing bar", + configuredBootJars: []string{"myapex:foo"}, + errorExpected: true, + }, + { + desc: "Prebuilt apex is selected, and APEX_BOOT_JARS is correctly configured for prebuilt apex build", + configuredBootJars: []string{"myapex:foo"}, + apexContributionContents: `"prebuilt_com.google.android.myapex"`, + }, + { + desc: "Prebuilt apex is selected, and APEX_BOOT_JARS is missing foo", + configuredBootJars: []string{"myapex:bar"}, + apexContributionContents: `"prebuilt_com.google.android.myapex"`, + errorExpected: true, + }, + } + + for _, tc := range testCases { + fixture := android.GroupFixturePreparers( + prepareForTestWithPlatformBootclasspath, + PrepareForTestWithApexBuildComponents, + prepareForTestWithMyapex, + java.FixtureConfigureApexBootJars(tc.configuredBootJars...), + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.BuildFlags = map[string]string{ + "RELEASE_APEX_CONTRIBUTIONS_ART": "my_apex_contributions", + } + }), + ) + if tc.errorExpected { + fixture = fixture.ExtendWithErrorHandler( + android.FixtureExpectsAtLeastOneErrorMatchingPattern(`in contents.*must also be declared in PRODUCT_APEX_BOOT_JARS`), + ) + } + fixture.RunTestWithBp(t, fmt.Sprintf(bp, tc.apexContributionContents)) + } +} diff --git a/apex/prebuilt.go b/apex/prebuilt.go index ea847e15c..12c3e9db8 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -838,7 +838,21 @@ func (p *prebuiltCommon) providePrebuiltInfo(ctx android.ModuleContext) { android.SetProvider(ctx, android.PrebuiltInfoProvider, info) } +// Uses an object provided by its deps to validate that the contents of bcpf have been added to the global +// PRODUCT_APEX_BOOT_JARS +// This validation will only run on the apex which is active for this product/release_config +func validateApexClasspathFragments(ctx android.ModuleContext) { + ctx.VisitDirectDeps(func(m android.Module) { + if info, exists := android.OtherModuleProvider(ctx, m, java.ClasspathFragmentValidationInfoProvider); exists { + ctx.ModuleErrorf("%s in contents of %s must also be declared in PRODUCT_APEX_BOOT_JARS", info.UnknownJars, info.ClasspathFragmentModuleName) + } + }) +} + func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { + // Validate contents of classpath fragments + validateApexClasspathFragments(ctx) + p.apexKeysPath = writeApexKeys(ctx, p) // TODO(jungjw): Check the key validity. p.inputApex = android.OptionalPathForModuleSrc(ctx, p.prebuiltCommonProperties.Selected_apex).Path() @@ -1064,6 +1078,9 @@ func (a *ApexSet) ApexInfoMutator(mctx android.TopDownMutatorContext) { } func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) { + // Validate contents of classpath fragments + validateApexClasspathFragments(ctx) + a.apexKeysPath = writeApexKeys(ctx, a) a.installFilename = a.InstallFilename() if !strings.HasSuffix(a.installFilename, imageApexSuffix) && !strings.HasSuffix(a.installFilename, imageCapexSuffix) { diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 82a34ca9d..4d3d794d8 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -590,13 +590,36 @@ func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext) // So ignore it even if it is not in PRODUCT_APEX_BOOT_JARS. // TODO(b/202896428): Add better way to handle this. _, unknown = android.RemoveFromList("android.car-module", unknown) - if isActiveModule(ctx, ctx.Module()) && len(unknown) > 0 { - ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_BOOT_JARS", unknown) + if isApexVariant(ctx) && len(unknown) > 0 { + if android.IsModulePrebuilt(ctx.Module()) { + // prebuilt bcpf. the validation of this will be done at the top-level apex + providerClasspathFragmentValidationInfoProvider(ctx, unknown) + } else if !disableSourceApexVariant(ctx) { + // source bcpf, and prebuilt apex are not selected. + ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_BOOT_JARS", unknown) + } } } return jars } +var ClasspathFragmentValidationInfoProvider = blueprint.NewProvider[ClasspathFragmentValidationInfo]() + +type ClasspathFragmentValidationInfo struct { + ClasspathFragmentModuleName string + UnknownJars []string +} + +// Set a provider with the list of jars that have not been added to PRODUCT_APEX_BOOT_JARS +// The validation will be done in the ctx of the top-level _selected_ apex +func providerClasspathFragmentValidationInfoProvider(ctx android.ModuleContext, unknown []string) { + info := ClasspathFragmentValidationInfo{ + ClasspathFragmentModuleName: ctx.ModuleName(), + UnknownJars: unknown, + } + android.SetProvider(ctx, ClasspathFragmentValidationInfoProvider, info) +} + // generateHiddenAPIBuildActions generates all the hidden API related build rules. func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, contents []android.Module, fragments []android.Module) *HiddenAPIOutput { From 8308852d738bc543796a2986ea35dcc983f12a2b Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Mon, 8 Apr 2024 09:09:35 -0700 Subject: [PATCH 27/67] release_config: Initial implementation Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I25a2a197f0227bfa7c63e0dfb7cab09e7d756d90 Change-Id: I25a2a197f0227bfa7c63e0dfb7cab09e7d756d90 --- cmd/release_config/Android.bp | 30 + cmd/release_config/main.go | 691 ++++++++++++++ .../release_config_proto/Android.bp | 30 + .../build_flags_out.pb.go | 486 ++++++++++ .../build_flags_out.proto | 86 ++ .../build_flags_src.pb.go | 855 ++++++++++++++++++ .../build_flags_src.proto | 154 ++++ .../release_config_proto/regen.sh | 3 + 8 files changed, 2335 insertions(+) create mode 100644 cmd/release_config/Android.bp create mode 100644 cmd/release_config/main.go create mode 100644 cmd/release_config/release_config_proto/Android.bp create mode 100644 cmd/release_config/release_config_proto/build_flags_out.pb.go create mode 100644 cmd/release_config/release_config_proto/build_flags_out.proto create mode 100644 cmd/release_config/release_config_proto/build_flags_src.pb.go create mode 100644 cmd/release_config/release_config_proto/build_flags_src.proto create mode 100644 cmd/release_config/release_config_proto/regen.sh diff --git a/cmd/release_config/Android.bp b/cmd/release_config/Android.bp new file mode 100644 index 000000000..7f627ffb7 --- /dev/null +++ b/cmd/release_config/Android.bp @@ -0,0 +1,30 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +bootstrap_go_package { + name: "release-config", + pkgPath: "android/soong/cmd/release_config", + deps: [ + "golang-protobuf-encoding-prototext", + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + "soong-cmd-release-config-proto", + ], + srcs: [ + "main.go", + ], +} + +bootstrap_go_package { + name: "soong-cmd-release-config-proto", + pkgPath: "android/soong/cmd/release_config/release_config_proto", + deps: [ + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + ], + srcs: [ + "release_config_proto/build_flags_out.pb.go", + "release_config_proto/build_flags_src.pb.go", + ], +} diff --git a/cmd/release_config/main.go b/cmd/release_config/main.go new file mode 100644 index 000000000..3bb6b3dfe --- /dev/null +++ b/cmd/release_config/main.go @@ -0,0 +1,691 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// 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 main + +import ( + "cmp" + "encoding/json" + "flag" + "fmt" + "io/fs" + "os" + "path/filepath" + "slices" + "strings" + + "android/soong/cmd/release_config/release_config_proto" + + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" +) + +var verboseFlag bool + +type StringList []string + +func (l *StringList) Set(v string) error { + *l = append(*l, v) + return nil +} + +func (l *StringList) String() string { + return fmt.Sprintf("%v", *l) +} + +var releaseConfigMapPaths StringList + +func DumpProtos(outDir string, message proto.Message) error { + basePath := filepath.Join(outDir, "all_release_configs") + writer := func(suffix string, marshal func() ([]byte, error)) error { + data, err := marshal() + if err != nil { + return err + } + return os.WriteFile(fmt.Sprintf("%s.%s", basePath, suffix), data, 0644) + } + err := writer("textproto", func() ([]byte, error) { return prototext.MarshalOptions{Multiline: true}.Marshal(message) }) + if err != nil { + return err + } + + err = writer("pb", func() ([]byte, error) { return proto.Marshal(message) }) + if err != nil { + return err + } + + return writer("json", func() ([]byte, error) { return json.MarshalIndent(message, "", " ") }) +} + +func LoadTextproto(path string, message proto.Message) error { + data, err := os.ReadFile(path) + if err != nil { + return err + } + ret := prototext.Unmarshal(data, message) + if verboseFlag { + debug, _ := prototext.Marshal(message) + fmt.Printf("%s: %s\n", path, debug) + } + return ret +} + +func WalkTextprotoFiles(root string, subdir string, Func fs.WalkDirFunc) error { + path := filepath.Join(root, subdir) + if _, err := os.Stat(path); err != nil { + // Missing subdirs are not an error. + return nil + } + return filepath.WalkDir(path, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if strings.HasSuffix(d.Name(), ".textproto") && d.Type().IsRegular() { + return Func(path, d, err) + } + return nil + }) +} + +type FlagValue struct { + // The path providing this value. + path string + + // Protobuf + proto release_config_proto.FlagValue +} + +func FlagValueFactory(protoPath string) (fv *FlagValue) { + fv = &FlagValue{path: protoPath} + if protoPath != "" { + LoadTextproto(protoPath, &fv.proto) + } + return fv +} + +// One directory's contribution to the a release config. +type ReleaseConfigContribution struct { + // Paths to files providing this config. + path string + + // The index of the config directory where this release config + // contribution was declared. + // Flag values cannot be set in a location with a lower index. + DeclarationIndex int + + // Protobufs relevant to the config. + proto release_config_proto.ReleaseConfig + + FlagValues []*FlagValue +} + +// A single release_config_map.textproto and its associated data. +// Used primarily for debugging. +type ReleaseConfigMap struct { + // The path to this release_config_map file. + path string + + // Data received + proto release_config_proto.ReleaseConfigMap + + ReleaseConfigContributions map[string]*ReleaseConfigContribution + FlagDeclarations []release_config_proto.FlagDeclaration +} + +// A generated release config. +type ReleaseConfig struct { + // the Name of the release config + Name string + + // The index of the config directory where this release config was + // first declared. + // Flag values cannot be set in a location with a lower index. + DeclarationIndex int + + // What contributes to this config. + Contributions []*ReleaseConfigContribution + + // Aliases for this release + OtherNames []string + + // The names of release configs that we inherit + InheritNames []string + + // Unmarshalled flag artifacts + FlagArtifacts FlagArtifacts + + // Generated release config + ReleaseConfigArtifact *release_config_proto.ReleaseConfigArtifact + + // We have begun compiling this release config. + compileInProgress bool +} + +type FlagArtifact struct { + FlagDeclaration *release_config_proto.FlagDeclaration + + // The index of the config directory where this flag was declared. + // Flag values cannot be set in a location with a lower index. + DeclarationIndex int + + Traces []*release_config_proto.Tracepoint + + // Assigned value + Value *release_config_proto.Value +} + +// Key is flag name. +type FlagArtifacts map[string]*FlagArtifact + +type ReleaseConfigDirMap map[string]int + +// The generated release configs. +type ReleaseConfigs struct { + // Ordered list of release config maps processed. + ReleaseConfigMaps []*ReleaseConfigMap + + // Aliases + Aliases map[string]*string + + // Dictionary of flag_name:FlagDeclaration, with no overrides applied. + FlagArtifacts FlagArtifacts + + // Dictionary of name:ReleaseConfig + ReleaseConfigs map[string]*ReleaseConfig + + // Generated release configs + Artifact release_config_proto.ReleaseConfigsArtifact + + // The list of config directories used. + ConfigDirs []string + + // A map from the config directory to its order in the list of config + // directories. + ConfigDirIndexes ReleaseConfigDirMap +} + +func (src *FlagArtifact) Clone() *FlagArtifact { + value := &release_config_proto.Value{} + proto.Merge(value, src.Value) + return &FlagArtifact{ + FlagDeclaration: src.FlagDeclaration, + Traces: src.Traces, + Value: value, + } +} + +func (src FlagArtifacts) Clone() (dst FlagArtifacts) { + if dst == nil { + dst = make(FlagArtifacts) + } + for k, v := range src { + dst[k] = v.Clone() + } + return +} + +func ReleaseConfigFactory(name string, index int) (c *ReleaseConfig) { + return &ReleaseConfig{Name: name, DeclarationIndex: index} +} + +func ReleaseConfigsFactory() (c *ReleaseConfigs) { + return &ReleaseConfigs{ + Aliases: make(map[string]*string), + FlagArtifacts: make(map[string]*FlagArtifact), + ReleaseConfigs: make(map[string]*ReleaseConfig), + ConfigDirs: []string{}, + ConfigDirIndexes: make(ReleaseConfigDirMap), + } +} + +func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { + m = &ReleaseConfigMap{ + path: protoPath, + ReleaseConfigContributions: make(map[string]*ReleaseConfigContribution), + } + if protoPath != "" { + LoadTextproto(protoPath, &m.proto) + } + return m +} + +func FlagDeclarationFactory(protoPath string) (fd *release_config_proto.FlagDeclaration) { + fd = &release_config_proto.FlagDeclaration{} + if protoPath != "" { + LoadTextproto(protoPath, fd) + } + return fd +} + +func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex int) error { + m := ReleaseConfigMapFactory(path) + if m.proto.Origin == nil || *m.proto.Origin == "" { + return fmt.Errorf("Release config map %s lacks origin", path) + } + if m.proto.DefaultContainer == nil { + return fmt.Errorf("Release config map %s lacks default_container", path) + } + dir := filepath.Dir(path) + // Record any aliases, checking for duplicates. + for _, alias := range m.proto.Aliases { + name := *alias.Name + oldTarget, ok := configs.Aliases[name] + if ok { + if *oldTarget != *alias.Target { + return fmt.Errorf("Conflicting alias declarations: %s vs %s", + *oldTarget, *alias.Target) + } + } + configs.Aliases[name] = alias.Target + } + var err error + err = WalkTextprotoFiles(dir, "flag_declarations", func(path string, d fs.DirEntry, err error) error { + flagDeclaration := FlagDeclarationFactory(path) + // Container must be specified. + if flagDeclaration.Container == nil { + flagDeclaration.Container = m.proto.DefaultContainer + } + // TODO: drop flag_declaration.origin from the proto. + if flagDeclaration.Origin == nil { + flagDeclaration.Origin = m.proto.Origin + } + // There is always a default value. + if flagDeclaration.Value == nil { + flagDeclaration.Value = &release_config_proto.Value{Val: &release_config_proto.Value_UnspecifiedValue{true}} + } + m.FlagDeclarations = append(m.FlagDeclarations, *flagDeclaration) + name := *flagDeclaration.Name + if def, ok := configs.FlagArtifacts[name]; !ok { + configs.FlagArtifacts[name] = &FlagArtifact{FlagDeclaration: flagDeclaration, DeclarationIndex: ConfigDirIndex} + } else if !proto.Equal(def.FlagDeclaration, flagDeclaration) { + return fmt.Errorf("Duplicate definition of %s", *flagDeclaration.Name) + } + // Set the initial value in the flag artifact. + configs.FlagArtifacts[name].UpdateValue( + FlagValue{path: path, proto: release_config_proto.FlagValue{ + Name: proto.String(name), Value: flagDeclaration.Value}}) + return nil + }) + if err != nil { + return err + } + + err = WalkTextprotoFiles(dir, "release_configs", func(path string, d fs.DirEntry, err error) error { + releaseConfigContribution := &ReleaseConfigContribution{path: path, DeclarationIndex: ConfigDirIndex} + LoadTextproto(path, &releaseConfigContribution.proto) + name := *releaseConfigContribution.proto.Name + if fmt.Sprintf("%s.textproto", name) != filepath.Base(path) { + return fmt.Errorf("%s incorrectly declares release config %s", path, name) + } + if _, ok := configs.ReleaseConfigs[name]; !ok { + configs.ReleaseConfigs[name] = ReleaseConfigFactory(name, ConfigDirIndex) + } + config := configs.ReleaseConfigs[name] + config.InheritNames = append(config.InheritNames, releaseConfigContribution.proto.Inherits...) + + // Only walk flag_values/{RELEASE} for defined releases. + err2 := WalkTextprotoFiles(dir, filepath.Join("flag_values", name), func(path string, d fs.DirEntry, err error) error { + flagValue := FlagValueFactory(path) + if fmt.Sprintf("%s.textproto", *flagValue.proto.Name) != filepath.Base(path) { + return fmt.Errorf("%s incorrectly sets value for flag %s", path, *flagValue.proto.Name) + } + releaseConfigContribution.FlagValues = append(releaseConfigContribution.FlagValues, flagValue) + return nil + }) + if err2 != nil { + return err2 + } + m.ReleaseConfigContributions[name] = releaseConfigContribution + config.Contributions = append(config.Contributions, releaseConfigContribution) + return nil + }) + if err != nil { + return err + } + configs.ReleaseConfigMaps = append(configs.ReleaseConfigMaps, m) + return nil +} + +func (configs *ReleaseConfigs) GetReleaseConfig(name string) (*ReleaseConfig, error) { + trace := []string{name} + for target, ok := configs.Aliases[name]; ok; target, ok = configs.Aliases[name] { + name = *target + trace = append(trace, name) + } + if config, ok := configs.ReleaseConfigs[name]; ok { + return config, nil + } + return nil, fmt.Errorf("Missing config %s. Trace=%v", name, trace) +} + +func (configs *ReleaseConfigs) DumpMakefile(outDir, targetRelease string) error { + outFile := filepath.Join(outDir, "release_config.mk") + makeVars := make(map[string]string) + config, err := configs.GetReleaseConfig(targetRelease) + if err != nil { + return err + } + // Sort the flags by name first. + names := []string{} + for k, _ := range config.FlagArtifacts { + names = append(names, k) + } + slices.SortFunc(names, func(a, b string) int { + return cmp.Compare(a, b) + }) + partitions := make(map[string][]string) + + vNames := []string{} + addVar := func(name, suffix, value string) { + fullName := fmt.Sprintf("_ALL_RELEASE_FLAGS.%s.%s", name, suffix) + vNames = append(vNames, fullName) + makeVars[fullName] = value + } + + for _, name := range names { + flag := config.FlagArtifacts[name] + decl := flag.FlagDeclaration + + // cName := strings.ToLower(release_config_proto.Container_name[decl.GetContainer()]) + cName := strings.ToLower(decl.Container.String()) + if cName == strings.ToLower(release_config_proto.Container_ALL.String()) { + partitions["product"] = append(partitions["product"], name) + partitions["system"] = append(partitions["system"], name) + partitions["system_ext"] = append(partitions["system_ext"], name) + partitions["vendor"] = append(partitions["vendor"], name) + } else { + partitions[cName] = append(partitions[cName], name) + } + value := MarshalValue(flag.Value) + makeVars[name] = value + addVar(name, "PARTITIONS", cName) + addVar(name, "DEFAULT", MarshalValue(decl.Value)) + addVar(name, "VALUE", value) + addVar(name, "DECLARED_IN", *flag.Traces[0].Source) + addVar(name, "SET_IN", *flag.Traces[len(flag.Traces)-1].Source) + addVar(name, "ORIGIN", *decl.Origin) + } + pNames := []string{} + for k, _ := range partitions { + pNames = append(pNames, k) + } + slices.SortFunc(pNames, func(a, b string) int { + return cmp.Compare(a, b) + }) + + // Now sort the make variables, and output them. + slices.SortFunc(vNames, func(a, b string) int { + return cmp.Compare(a, b) + }) + + // Write the flags as: + // _ALL_RELELASE_FLAGS + // _ALL_RELEASE_FLAGS.PARTITIONS.* + // all _ALL_RELEASE_FLAGS.*, sorted by name + // Final flag values, sorted by name. + data := fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " ")) + for _, pName := range pNames { + data += fmt.Sprintf("_ALL_RELEASE_FLAGS.PARTITIONS.%s :=$= %s\n", pName, strings.Join(partitions[pName], " ")) + } + for _, vName := range vNames { + data += fmt.Sprintf("%s :=$= %s\n", vName, makeVars[vName]) + } + data += "\n\n# Values for all build flags\n" + data += fmt.Sprintf("RELEASE_ACONFIG_VALUE_SETS :=$= %s\n", + strings.Join(config.ReleaseConfigArtifact.AconfigValueSets, " ")) + for _, name := range names { + data += fmt.Sprintf("%s :=$= %s\n", name, makeVars[name]) + } + return os.WriteFile(outFile, []byte(data), 0644) +} + +func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) error { + otherNames := make(map[string][]string) + for aliasName, aliasTarget := range configs.Aliases { + if _, ok := configs.ReleaseConfigs[aliasName]; ok { + return fmt.Errorf("Alias %s is a declared release config", aliasName) + } + if _, ok := configs.ReleaseConfigs[*aliasTarget]; !ok { + if _, ok2 := configs.Aliases[*aliasTarget]; !ok2 { + return fmt.Errorf("Alias %s points to non-existing config %s", aliasName, *aliasTarget) + } + } + otherNames[*aliasTarget] = append(otherNames[*aliasTarget], aliasName) + } + for name, aliases := range otherNames { + configs.ReleaseConfigs[name].OtherNames = aliases + } + + for _, config := range configs.ReleaseConfigs { + err := config.GenerateReleaseConfig(configs) + if err != nil { + return err + } + } + + releaseConfig, err := configs.GetReleaseConfig(targetRelease) + if err != nil { + return err + } + configs.Artifact = release_config_proto.ReleaseConfigsArtifact{ + ReleaseConfig: releaseConfig.ReleaseConfigArtifact, + OtherReleaseConfigs: func() []*release_config_proto.ReleaseConfigArtifact { + orc := []*release_config_proto.ReleaseConfigArtifact{} + for name, config := range configs.ReleaseConfigs { + if name != releaseConfig.Name { + orc = append(orc, config.ReleaseConfigArtifact) + } + } + return orc + }(), + } + return nil +} + +func MarshalValue(value *release_config_proto.Value) string { + switch val := value.Val.(type) { + case *release_config_proto.Value_UnspecifiedValue: + // Value was never set. + return "" + case *release_config_proto.Value_StringValue: + return val.StringValue + case *release_config_proto.Value_BoolValue: + if val.BoolValue { + return "true" + } + // False ==> empty string + return "" + case *release_config_proto.Value_Obsolete: + return " #OBSOLETE" + default: + // Flagged as error elsewhere, so return empty string here. + return "" + } +} + +func (fa *FlagArtifact) UpdateValue(flagValue FlagValue) error { + name := *flagValue.proto.Name + fa.Traces = append(fa.Traces, &release_config_proto.Tracepoint{Source: proto.String(flagValue.path), Value: flagValue.proto.Value}) + if fa.Value.GetObsolete() { + return fmt.Errorf("Attempting to set obsolete flag %s. Trace=%v", name, fa.Traces) + } + switch val := flagValue.proto.Value.Val.(type) { + case *release_config_proto.Value_StringValue: + fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_StringValue{val.StringValue}} + case *release_config_proto.Value_BoolValue: + fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_BoolValue{val.BoolValue}} + case *release_config_proto.Value_Obsolete: + if !val.Obsolete { + return fmt.Errorf("%s: Cannot set obsolete=false. Trace=%v", name, fa.Traces) + } + fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_Obsolete{true}} + default: + return fmt.Errorf("Invalid type for flag_value: %T. Trace=%v", val, fa.Traces) + } + return nil +} + +func (fa *FlagArtifact) Marshal() (*release_config_proto.FlagArtifact, error) { + return &release_config_proto.FlagArtifact{ + FlagDeclaration: fa.FlagDeclaration, + Value: fa.Value, + Traces: fa.Traces, + }, nil +} + +func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) error { + if config.ReleaseConfigArtifact != nil { + return nil + } + if config.compileInProgress { + return fmt.Errorf("Loop detected for release config %s", config.Name) + } + config.compileInProgress = true + + // Generate any configs we need to inherit. This will detect loops in + // the config. + contributionsToApply := []*ReleaseConfigContribution{} + myInherits := []string{} + myInheritsSet := make(map[string]bool) + for _, inherit := range config.InheritNames { + if _, ok := myInheritsSet[inherit]; ok { + continue + } + myInherits = append(myInherits, inherit) + myInheritsSet[inherit] = true + iConfig, err := configs.GetReleaseConfig(inherit) + if err != nil { + return err + } + iConfig.GenerateReleaseConfig(configs) + contributionsToApply = append(contributionsToApply, iConfig.Contributions...) + } + contributionsToApply = append(contributionsToApply, config.Contributions...) + + myAconfigValueSets := []string{} + myFlags := configs.FlagArtifacts.Clone() + myDirsMap := make(map[int]bool) + for _, contrib := range contributionsToApply { + myAconfigValueSets = append(myAconfigValueSets, contrib.proto.AconfigValueSets...) + myDirsMap[contrib.DeclarationIndex] = true + for _, value := range contrib.FlagValues { + fa, ok := myFlags[*value.proto.Name] + if !ok { + return fmt.Errorf("Setting value for undefined flag %s in %s\n", *value.proto.Name, value.path) + } + myDirsMap[fa.DeclarationIndex] = true + if fa.DeclarationIndex > contrib.DeclarationIndex { + // Setting location is to the left of declaration. + return fmt.Errorf("Setting value for flag %s not allowed in %s\n", *value.proto.Name, value.path) + } + if err := fa.UpdateValue(*value); err != nil { + return err + } + } + } + + directories := []string{} + for idx, confDir := range configs.ConfigDirs { + if _, ok := myDirsMap[idx]; ok { + directories = append(directories, confDir) + } + } + + config.FlagArtifacts = myFlags + config.ReleaseConfigArtifact = &release_config_proto.ReleaseConfigArtifact{ + Name: proto.String(config.Name), + OtherNames: config.OtherNames, + FlagArtifacts: func() []*release_config_proto.FlagArtifact { + ret := []*release_config_proto.FlagArtifact{} + for _, flag := range myFlags { + ret = append(ret, &release_config_proto.FlagArtifact{ + FlagDeclaration: flag.FlagDeclaration, + Traces: flag.Traces, + Value: flag.Value, + }) + } + return ret + }(), + AconfigValueSets: myAconfigValueSets, + Inherits: myInherits, + Directories: directories, + } + + config.compileInProgress = false + return nil +} + +func main() { + var targetRelease string + var outputDir string + + outEnv := os.Getenv("OUT_DIR") + if outEnv == "" { + outEnv = "out" + } + defaultOutputDir := filepath.Join(outEnv, "soong", "release-config") + var defaultMapPaths StringList + defaultLocations := StringList{ + "build/release/release_config_map.textproto", + "vendor/google_shared/build/release/release_config_map.textproto", + "vendor/google/release/release_config_map.textproto", + } + for _, path := range defaultLocations { + if _, err := os.Stat(path); err == nil { + defaultMapPaths = append(defaultMapPaths, path) + } + } + prodMaps := os.Getenv("PRODUCT_RELEASE_CONFIG_MAPS") + if prodMaps != "" { + defaultMapPaths = append(defaultMapPaths, strings.Split(prodMaps, " ")...) + } + + flag.BoolVar(&verboseFlag, "debug", false, "print debugging information") + flag.Var(&releaseConfigMapPaths, "map", "path to a release_config_map.textproto. may be repeated") + flag.StringVar(&targetRelease, "release", "trunk_staging", "TARGET_RELEASE for this build") + flag.StringVar(&outputDir, "out_dir", defaultOutputDir, "basepath for the output. Multiple formats are created") + flag.Parse() + + if len(releaseConfigMapPaths) == 0 { + releaseConfigMapPaths = defaultMapPaths + fmt.Printf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) + } + + configs := ReleaseConfigsFactory() + for idx, releaseConfigMapPath := range releaseConfigMapPaths { + // Maintain an ordered list of release config directories. + configDir := filepath.Dir(releaseConfigMapPath) + configs.ConfigDirIndexes[configDir] = idx + configs.ConfigDirs = append(configs.ConfigDirs, configDir) + err := configs.LoadReleaseConfigMap(releaseConfigMapPath, idx) + if err != nil { + panic(err) + } + } + + // Now that we have all of the release config maps, can meld them and generate the artifacts. + err := configs.GenerateReleaseConfigs(targetRelease) + if err != nil { + panic(err) + } + err = os.MkdirAll(outputDir, 0775) + if err != nil { + panic(err) + } + err = configs.DumpMakefile(outputDir, targetRelease) + if err != nil { + panic(err) + } + DumpProtos(outputDir, &configs.Artifact) +} diff --git a/cmd/release_config/release_config_proto/Android.bp b/cmd/release_config/release_config_proto/Android.bp new file mode 100644 index 000000000..a8660c753 --- /dev/null +++ b/cmd/release_config/release_config_proto/Android.bp @@ -0,0 +1,30 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// 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 { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +bootstrap_go_package { + name: "soong-release_config_proto", + pkgPath: "android/soong/release_config/release_config_proto", + deps: [ + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + ], + srcs: [ + "build_flags_src.pb.go", + "build_flags_out.pb.go", + ], +} diff --git a/cmd/release_config/release_config_proto/build_flags_out.pb.go b/cmd/release_config/release_config_proto/build_flags_out.pb.go new file mode 100644 index 000000000..adc1ea4bd --- /dev/null +++ b/cmd/release_config/release_config_proto/build_flags_out.pb.go @@ -0,0 +1,486 @@ +// 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. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.33.0 +// protoc v3.21.12 +// source: build_flags_out.proto + +package release_config_proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Tracepoint struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Path to declaration or value file relative to $TOP + Source *string `protobuf:"bytes,1,opt,name=source" json:"source,omitempty"` + Value *Value `protobuf:"bytes,201,opt,name=value" json:"value,omitempty"` +} + +func (x *Tracepoint) Reset() { + *x = Tracepoint{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_out_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Tracepoint) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Tracepoint) ProtoMessage() {} + +func (x *Tracepoint) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_out_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Tracepoint.ProtoReflect.Descriptor instead. +func (*Tracepoint) Descriptor() ([]byte, []int) { + return file_build_flags_out_proto_rawDescGZIP(), []int{0} +} + +func (x *Tracepoint) GetSource() string { + if x != nil && x.Source != nil { + return *x.Source + } + return "" +} + +func (x *Tracepoint) GetValue() *Value { + if x != nil { + return x.Value + } + return nil +} + +type FlagArtifact struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The original declaration + FlagDeclaration *FlagDeclaration `protobuf:"bytes,1,opt,name=flag_declaration,json=flagDeclaration" json:"flag_declaration,omitempty"` + // Value for the flag + Value *Value `protobuf:"bytes,201,opt,name=value" json:"value,omitempty"` + // Trace of where the flag value was assigned. + Traces []*Tracepoint `protobuf:"bytes,8,rep,name=traces" json:"traces,omitempty"` +} + +func (x *FlagArtifact) Reset() { + *x = FlagArtifact{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_out_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FlagArtifact) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FlagArtifact) ProtoMessage() {} + +func (x *FlagArtifact) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_out_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FlagArtifact.ProtoReflect.Descriptor instead. +func (*FlagArtifact) Descriptor() ([]byte, []int) { + return file_build_flags_out_proto_rawDescGZIP(), []int{1} +} + +func (x *FlagArtifact) GetFlagDeclaration() *FlagDeclaration { + if x != nil { + return x.FlagDeclaration + } + return nil +} + +func (x *FlagArtifact) GetValue() *Value { + if x != nil { + return x.Value + } + return nil +} + +func (x *FlagArtifact) GetTraces() []*Tracepoint { + if x != nil { + return x.Traces + } + return nil +} + +type ReleaseConfigArtifact struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The name of the release config. + // See # name for format detail + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // Other names by which this release is known (for example, `next`) + OtherNames []string `protobuf:"bytes,2,rep,name=other_names,json=otherNames" json:"other_names,omitempty"` + // The complete set of build flags in this release config, after all + // inheritance and other processing is complete. + FlagArtifacts []*FlagArtifact `protobuf:"bytes,3,rep,name=flag_artifacts,json=flagArtifacts" json:"flag_artifacts,omitempty"` + // The (complete) list of aconfig_value_sets Soong modules to use. + AconfigValueSets []string `protobuf:"bytes,4,rep,name=aconfig_value_sets,json=aconfigValueSets" json:"aconfig_value_sets,omitempty"` + // The names of the release_config_artifacts from which we inherited. + // Included for reference only. + Inherits []string `protobuf:"bytes,5,rep,name=inherits" json:"inherits,omitempty"` + // The release config directories used for this config. + // For example, "build/release". + Directories []string `protobuf:"bytes,6,rep,name=directories" json:"directories,omitempty"` +} + +func (x *ReleaseConfigArtifact) Reset() { + *x = ReleaseConfigArtifact{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_out_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReleaseConfigArtifact) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReleaseConfigArtifact) ProtoMessage() {} + +func (x *ReleaseConfigArtifact) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_out_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReleaseConfigArtifact.ProtoReflect.Descriptor instead. +func (*ReleaseConfigArtifact) Descriptor() ([]byte, []int) { + return file_build_flags_out_proto_rawDescGZIP(), []int{2} +} + +func (x *ReleaseConfigArtifact) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *ReleaseConfigArtifact) GetOtherNames() []string { + if x != nil { + return x.OtherNames + } + return nil +} + +func (x *ReleaseConfigArtifact) GetFlagArtifacts() []*FlagArtifact { + if x != nil { + return x.FlagArtifacts + } + return nil +} + +func (x *ReleaseConfigArtifact) GetAconfigValueSets() []string { + if x != nil { + return x.AconfigValueSets + } + return nil +} + +func (x *ReleaseConfigArtifact) GetInherits() []string { + if x != nil { + return x.Inherits + } + return nil +} + +func (x *ReleaseConfigArtifact) GetDirectories() []string { + if x != nil { + return x.Directories + } + return nil +} + +type ReleaseConfigsArtifact struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The active release config for this build. + ReleaseConfig *ReleaseConfigArtifact `protobuf:"bytes,1,opt,name=release_config,json=releaseConfig" json:"release_config,omitempty"` + // All other release configs defined for this TARGET_PRODUCT. + OtherReleaseConfigs []*ReleaseConfigArtifact `protobuf:"bytes,2,rep,name=other_release_configs,json=otherReleaseConfigs" json:"other_release_configs,omitempty"` +} + +func (x *ReleaseConfigsArtifact) Reset() { + *x = ReleaseConfigsArtifact{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_out_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReleaseConfigsArtifact) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReleaseConfigsArtifact) ProtoMessage() {} + +func (x *ReleaseConfigsArtifact) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_out_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReleaseConfigsArtifact.ProtoReflect.Descriptor instead. +func (*ReleaseConfigsArtifact) Descriptor() ([]byte, []int) { + return file_build_flags_out_proto_rawDescGZIP(), []int{3} +} + +func (x *ReleaseConfigsArtifact) GetReleaseConfig() *ReleaseConfigArtifact { + if x != nil { + return x.ReleaseConfig + } + return nil +} + +func (x *ReleaseConfigsArtifact) GetOtherReleaseConfigs() []*ReleaseConfigArtifact { + if x != nil { + return x.OtherReleaseConfigs + } + return nil +} + +var File_build_flags_out_proto protoreflect.FileDescriptor + +var file_build_flags_out_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x5f, 0x6f, 0x75, + 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, + 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x66, 0x6c, 0x61, + 0x67, 0x73, 0x5f, 0x73, 0x72, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x60, 0x0a, 0x0a, + 0x74, 0x72, 0x61, 0x63, 0x65, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xe8, + 0x01, 0x0a, 0x0d, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, + 0x12, 0x59, 0x0a, 0x10, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x61, 0x6e, 0x64, + 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x64, + 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x66, 0x6c, 0x61, 0x67, + 0x44, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3a, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, + 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x40, 0x0a, 0x06, 0x74, 0x72, 0x61, 0x63, 0x65, + 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, + 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x52, 0x06, 0x74, 0x72, 0x61, 0x63, 0x65, 0x73, 0x22, 0x8e, 0x02, 0x0a, 0x17, 0x72, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, + 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x74, 0x68, + 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, + 0x6f, 0x74, 0x68, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x52, 0x0a, 0x0e, 0x66, 0x6c, + 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, + 0x0d, 0x66, 0x6c, 0x61, 0x67, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x12, 0x2c, + 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, + 0x73, 0x65, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74, 0x73, 0x12, 0x1a, 0x0a, 0x08, + 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, + 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x69, 0x72, 0x65, + 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x64, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x22, 0xe3, 0x01, 0x0a, 0x18, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x5f, 0x61, + 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x5c, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x35, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, + 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x69, 0x0a, 0x15, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x13, 0x6f, 0x74, 0x68, + 0x65, 0x72, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, + 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, + 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, +} + +var ( + file_build_flags_out_proto_rawDescOnce sync.Once + file_build_flags_out_proto_rawDescData = file_build_flags_out_proto_rawDesc +) + +func file_build_flags_out_proto_rawDescGZIP() []byte { + file_build_flags_out_proto_rawDescOnce.Do(func() { + file_build_flags_out_proto_rawDescData = protoimpl.X.CompressGZIP(file_build_flags_out_proto_rawDescData) + }) + return file_build_flags_out_proto_rawDescData +} + +var file_build_flags_out_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_build_flags_out_proto_goTypes = []interface{}{ + (*Tracepoint)(nil), // 0: android.release_config_proto.tracepoint + (*FlagArtifact)(nil), // 1: android.release_config_proto.flag_artifact + (*ReleaseConfigArtifact)(nil), // 2: android.release_config_proto.release_config_artifact + (*ReleaseConfigsArtifact)(nil), // 3: android.release_config_proto.release_configs_artifact + (*Value)(nil), // 4: android.release_config_proto.value + (*FlagDeclaration)(nil), // 5: android.release_config_proto.flag_declaration +} +var file_build_flags_out_proto_depIdxs = []int32{ + 4, // 0: android.release_config_proto.tracepoint.value:type_name -> android.release_config_proto.value + 5, // 1: android.release_config_proto.flag_artifact.flag_declaration:type_name -> android.release_config_proto.flag_declaration + 4, // 2: android.release_config_proto.flag_artifact.value:type_name -> android.release_config_proto.value + 0, // 3: android.release_config_proto.flag_artifact.traces:type_name -> android.release_config_proto.tracepoint + 1, // 4: android.release_config_proto.release_config_artifact.flag_artifacts:type_name -> android.release_config_proto.flag_artifact + 2, // 5: android.release_config_proto.release_configs_artifact.release_config:type_name -> android.release_config_proto.release_config_artifact + 2, // 6: android.release_config_proto.release_configs_artifact.other_release_configs:type_name -> android.release_config_proto.release_config_artifact + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_build_flags_out_proto_init() } +func file_build_flags_out_proto_init() { + if File_build_flags_out_proto != nil { + return + } + file_build_flags_src_proto_init() + if !protoimpl.UnsafeEnabled { + file_build_flags_out_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Tracepoint); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_build_flags_out_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FlagArtifact); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_build_flags_out_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReleaseConfigArtifact); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_build_flags_out_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReleaseConfigsArtifact); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_build_flags_out_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_build_flags_out_proto_goTypes, + DependencyIndexes: file_build_flags_out_proto_depIdxs, + MessageInfos: file_build_flags_out_proto_msgTypes, + }.Build() + File_build_flags_out_proto = out.File + file_build_flags_out_proto_rawDesc = nil + file_build_flags_out_proto_goTypes = nil + file_build_flags_out_proto_depIdxs = nil +} diff --git a/cmd/release_config/release_config_proto/build_flags_out.proto b/cmd/release_config/release_config_proto/build_flags_out.proto new file mode 100644 index 000000000..fd8487bd4 --- /dev/null +++ b/cmd/release_config/release_config_proto/build_flags_out.proto @@ -0,0 +1,86 @@ +// 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. + +syntax = "proto2"; +package android.release_config_proto; +option go_package = "android/soong/release_config/release_config_proto"; + +import "build_flags_src.proto"; + +// This protobuf file defines messages used to represent the release config for +// the android build system, delivered as a build artifact for use by tools such +// as Gantry. +// +// The following format requirements apply across various message fields: +// +// # name: name of the flag +// +// format: an uppercase string in SNAKE_CASE format starting with RELEASE_, +// no consecutive underscores, and no leading digit. For example +// RELEASE_MY_PACKAGE_FLAG is a valid name, while MY_PACKAGE_FLAG, and +// RELEASE_MY_PACKAGE__FLAG are invalid. +// +// # package: package to which the flag belongs +// +// format: lowercase strings in snake_case format, delimited by dots, no +// consecutive underscores and no leading digit in each string. For example +// com.android.mypackage is a valid name while com.android.myPackage, +// com.android.1mypackage are invalid + +message tracepoint { + // Path to declaration or value file relative to $TOP + optional string source = 1; + optional value value = 201; +} + +message flag_artifact { + // The original declaration + optional flag_declaration flag_declaration = 1; + + // Value for the flag + optional value value = 201; + + // Trace of where the flag value was assigned. + repeated tracepoint traces = 8; +} + +message release_config_artifact { + // The name of the release config. + // See # name for format detail + optional string name = 1; + + // Other names by which this release is known (for example, `next`) + repeated string other_names = 2; + + // The complete set of build flags in this release config, after all + // inheritance and other processing is complete. + repeated flag_artifact flag_artifacts = 3; + + // The (complete) list of aconfig_value_sets Soong modules to use. + repeated string aconfig_value_sets = 4; + + // The names of the release_config_artifacts from which we inherited. + // Included for reference only. + repeated string inherits = 5; + + // The release config directories used for this config. + // For example, "build/release". + repeated string directories = 6; +} + +message release_configs_artifact { + // The active release config for this build. + optional release_config_artifact release_config = 1; + + // All other release configs defined for this TARGET_PRODUCT. + repeated release_config_artifact other_release_configs = 2; +} + diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go new file mode 100644 index 000000000..0f2c30b76 --- /dev/null +++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go @@ -0,0 +1,855 @@ +// 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. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.33.0 +// protoc v3.21.12 +// source: build_flags_src.proto + +package release_config_proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Workflow int32 + +const ( + Workflow_UNSPECIFIED_workflow Workflow = 0 + // Boolean value flags that progress from false to true. + Workflow_LAUNCH Workflow = 1 + // String value flags that get updated with new version strings to control + // prebuilt inclusion. + Workflow_PREBUILT Workflow = 2 + // Manually managed outside flags. These are likely to be found in a + // different directory than flags with other workflows. + Workflow_MANUAL Workflow = 3 +) + +// Enum value maps for Workflow. +var ( + Workflow_name = map[int32]string{ + 0: "UNSPECIFIED_workflow", + 1: "LAUNCH", + 2: "PREBUILT", + 3: "MANUAL", + } + Workflow_value = map[string]int32{ + "UNSPECIFIED_workflow": 0, + "LAUNCH": 1, + "PREBUILT": 2, + "MANUAL": 3, + } +) + +func (x Workflow) Enum() *Workflow { + p := new(Workflow) + *p = x + return p +} + +func (x Workflow) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Workflow) Descriptor() protoreflect.EnumDescriptor { + return file_build_flags_src_proto_enumTypes[0].Descriptor() +} + +func (Workflow) Type() protoreflect.EnumType { + return &file_build_flags_src_proto_enumTypes[0] +} + +func (x Workflow) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Workflow) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) + if err != nil { + return err + } + *x = Workflow(num) + return nil +} + +// Deprecated: Use Workflow.Descriptor instead. +func (Workflow) EnumDescriptor() ([]byte, []int) { + return file_build_flags_src_proto_rawDescGZIP(), []int{0} +} + +type Container int32 + +const ( + Container_UNSPECIFIED_container Container = 0 + // All containers + Container_ALL Container = 1 + // Specific containers + Container_PRODUCT Container = 2 + Container_SYSTEM Container = 3 + Container_SYSTEM_EXT Container = 4 + Container_VENDOR Container = 5 +) + +// Enum value maps for Container. +var ( + Container_name = map[int32]string{ + 0: "UNSPECIFIED_container", + 1: "ALL", + 2: "PRODUCT", + 3: "SYSTEM", + 4: "SYSTEM_EXT", + 5: "VENDOR", + } + Container_value = map[string]int32{ + "UNSPECIFIED_container": 0, + "ALL": 1, + "PRODUCT": 2, + "SYSTEM": 3, + "SYSTEM_EXT": 4, + "VENDOR": 5, + } +) + +func (x Container) Enum() *Container { + p := new(Container) + *p = x + return p +} + +func (x Container) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Container) Descriptor() protoreflect.EnumDescriptor { + return file_build_flags_src_proto_enumTypes[1].Descriptor() +} + +func (Container) Type() protoreflect.EnumType { + return &file_build_flags_src_proto_enumTypes[1] +} + +func (x Container) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Container) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) + if err != nil { + return err + } + *x = Container(num) + return nil +} + +// Deprecated: Use Container.Descriptor instead. +func (Container) EnumDescriptor() ([]byte, []int) { + return file_build_flags_src_proto_rawDescGZIP(), []int{1} +} + +type Value struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Val: + // + // *Value_UnspecifiedValue + // *Value_StringValue + // *Value_BoolValue + // *Value_Obsolete + Val isValue_Val `protobuf_oneof:"val"` +} + +func (x *Value) Reset() { + *x = Value{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_src_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Value) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Value) ProtoMessage() {} + +func (x *Value) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_src_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Value.ProtoReflect.Descriptor instead. +func (*Value) Descriptor() ([]byte, []int) { + return file_build_flags_src_proto_rawDescGZIP(), []int{0} +} + +func (m *Value) GetVal() isValue_Val { + if m != nil { + return m.Val + } + return nil +} + +func (x *Value) GetUnspecifiedValue() bool { + if x, ok := x.GetVal().(*Value_UnspecifiedValue); ok { + return x.UnspecifiedValue + } + return false +} + +func (x *Value) GetStringValue() string { + if x, ok := x.GetVal().(*Value_StringValue); ok { + return x.StringValue + } + return "" +} + +func (x *Value) GetBoolValue() bool { + if x, ok := x.GetVal().(*Value_BoolValue); ok { + return x.BoolValue + } + return false +} + +func (x *Value) GetObsolete() bool { + if x, ok := x.GetVal().(*Value_Obsolete); ok { + return x.Obsolete + } + return false +} + +type isValue_Val interface { + isValue_Val() +} + +type Value_UnspecifiedValue struct { + UnspecifiedValue bool `protobuf:"varint,200,opt,name=unspecified_value,json=unspecifiedValue,oneof"` +} + +type Value_StringValue struct { + StringValue string `protobuf:"bytes,201,opt,name=string_value,json=stringValue,oneof"` +} + +type Value_BoolValue struct { + BoolValue bool `protobuf:"varint,202,opt,name=bool_value,json=boolValue,oneof"` +} + +type Value_Obsolete struct { + // If true, the flag is obsolete. Assigning it further will be flagged. + Obsolete bool `protobuf:"varint,203,opt,name=obsolete,oneof"` +} + +func (*Value_UnspecifiedValue) isValue_Val() {} + +func (*Value_StringValue) isValue_Val() {} + +func (*Value_BoolValue) isValue_Val() {} + +func (*Value_Obsolete) isValue_Val() {} + +// The proto used in the source tree. +type FlagDeclaration struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The name of the flag. + // See # name for format detail + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // Text description of the flag's purpose. + Description *string `protobuf:"bytes,3,opt,name=description" json:"description,omitempty"` + // Value for the flag + Value *Value `protobuf:"bytes,201,opt,name=value" json:"value,omitempty"` + // Workflow for this flag. + Workflow *Workflow `protobuf:"varint,205,opt,name=workflow,enum=android.release_config_proto.Workflow" json:"workflow,omitempty"` + // The container for this flag. This overrides any default container given + // in the release_config_map message. + Container *Container `protobuf:"varint,206,opt,name=container,enum=android.release_config_proto.Container" json:"container,omitempty"` + // Temporarily allow origin at the flag declaration level while we + // move flags to their own locations. + Origin *string `protobuf:"bytes,208,opt,name=origin" json:"origin,omitempty"` +} + +func (x *FlagDeclaration) Reset() { + *x = FlagDeclaration{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_src_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FlagDeclaration) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FlagDeclaration) ProtoMessage() {} + +func (x *FlagDeclaration) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_src_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FlagDeclaration.ProtoReflect.Descriptor instead. +func (*FlagDeclaration) Descriptor() ([]byte, []int) { + return file_build_flags_src_proto_rawDescGZIP(), []int{1} +} + +func (x *FlagDeclaration) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *FlagDeclaration) GetDescription() string { + if x != nil && x.Description != nil { + return *x.Description + } + return "" +} + +func (x *FlagDeclaration) GetValue() *Value { + if x != nil { + return x.Value + } + return nil +} + +func (x *FlagDeclaration) GetWorkflow() Workflow { + if x != nil && x.Workflow != nil { + return *x.Workflow + } + return Workflow_UNSPECIFIED_workflow +} + +func (x *FlagDeclaration) GetContainer() Container { + if x != nil && x.Container != nil { + return *x.Container + } + return Container_UNSPECIFIED_container +} + +func (x *FlagDeclaration) GetOrigin() string { + if x != nil && x.Origin != nil { + return *x.Origin + } + return "" +} + +type FlagValue struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Name of the flag. + // See # name for format detail + Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` + // Value for the flag + Value *Value `protobuf:"bytes,201,opt,name=value" json:"value,omitempty"` +} + +func (x *FlagValue) Reset() { + *x = FlagValue{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_src_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FlagValue) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FlagValue) ProtoMessage() {} + +func (x *FlagValue) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_src_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FlagValue.ProtoReflect.Descriptor instead. +func (*FlagValue) Descriptor() ([]byte, []int) { + return file_build_flags_src_proto_rawDescGZIP(), []int{2} +} + +func (x *FlagValue) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *FlagValue) GetValue() *Value { + if x != nil { + return x.Value + } + return nil +} + +// This replaces $(call declare-release-config). +type ReleaseConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The name of the release config. + // See # name for format detail + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // From which other release configs does this one inherit? + Inherits []string `protobuf:"bytes,2,rep,name=inherits" json:"inherits,omitempty"` + // List of names of the aconfig_value_set soong module(s) for this + // contribution. + AconfigValueSets []string `protobuf:"bytes,3,rep,name=aconfig_value_sets,json=aconfigValueSets" json:"aconfig_value_sets,omitempty"` +} + +func (x *ReleaseConfig) Reset() { + *x = ReleaseConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_src_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReleaseConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReleaseConfig) ProtoMessage() {} + +func (x *ReleaseConfig) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_src_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReleaseConfig.ProtoReflect.Descriptor instead. +func (*ReleaseConfig) Descriptor() ([]byte, []int) { + return file_build_flags_src_proto_rawDescGZIP(), []int{3} +} + +func (x *ReleaseConfig) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *ReleaseConfig) GetInherits() []string { + if x != nil { + return x.Inherits + } + return nil +} + +func (x *ReleaseConfig) GetAconfigValueSets() []string { + if x != nil { + return x.AconfigValueSets + } + return nil +} + +// Any aliases. These are used for continuous integration builder config. +type ReleaseAlias struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The name of the alias. + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // The release that `name` is an alias for. + Target *string `protobuf:"bytes,2,opt,name=target" json:"target,omitempty"` +} + +func (x *ReleaseAlias) Reset() { + *x = ReleaseAlias{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_src_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReleaseAlias) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReleaseAlias) ProtoMessage() {} + +func (x *ReleaseAlias) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_src_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReleaseAlias.ProtoReflect.Descriptor instead. +func (*ReleaseAlias) Descriptor() ([]byte, []int) { + return file_build_flags_src_proto_rawDescGZIP(), []int{4} +} + +func (x *ReleaseAlias) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *ReleaseAlias) GetTarget() string { + if x != nil && x.Target != nil { + return *x.Target + } + return "" +} + +// This provides the data from release_config_map.mk +type ReleaseConfigMap struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Any aliases. + Aliases []*ReleaseAlias `protobuf:"bytes,1,rep,name=aliases" json:"aliases,omitempty"` + // The origin for flags declared here. + Origin *string `protobuf:"bytes,2,opt,name=origin" json:"origin,omitempty"` + // The default container for flags declared here. + DefaultContainer *Container `protobuf:"varint,3,opt,name=default_container,json=defaultContainer,enum=android.release_config_proto.Container" json:"default_container,omitempty"` +} + +func (x *ReleaseConfigMap) Reset() { + *x = ReleaseConfigMap{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_src_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReleaseConfigMap) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReleaseConfigMap) ProtoMessage() {} + +func (x *ReleaseConfigMap) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_src_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReleaseConfigMap.ProtoReflect.Descriptor instead. +func (*ReleaseConfigMap) Descriptor() ([]byte, []int) { + return file_build_flags_src_proto_rawDescGZIP(), []int{5} +} + +func (x *ReleaseConfigMap) GetAliases() []*ReleaseAlias { + if x != nil { + return x.Aliases + } + return nil +} + +func (x *ReleaseConfigMap) GetOrigin() string { + if x != nil && x.Origin != nil { + return *x.Origin + } + return "" +} + +func (x *ReleaseConfigMap) GetDefaultContainer() Container { + if x != nil && x.DefaultContainer != nil { + return *x.DefaultContainer + } + return Container_UNSPECIFIED_container +} + +var File_build_flags_src_proto protoreflect.FileDescriptor + +var file_build_flags_src_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x5f, 0x73, 0x72, + 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, + 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa5, 0x01, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, + 0x2e, 0x0a, 0x11, 0x75, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x10, 0x75, + 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, + 0x24, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0xc9, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x20, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, + 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x6f, 0x6c, + 0x65, 0x74, 0x65, 0x18, 0xcb, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x08, 0x6f, 0x62, + 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x22, 0xb8, 0x02, + 0x0a, 0x10, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, + 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x12, 0x43, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, + 0x18, 0xcd, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, + 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x52, + 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x46, 0x0a, 0x09, 0x63, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0xce, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, + 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x12, 0x17, 0x0a, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x18, 0xd0, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, + 0x4a, 0x06, 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x5c, 0x0a, 0x0a, 0x66, 0x6c, 0x61, 0x67, + 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, + 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x6e, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, + 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, + 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x53, 0x65, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x22, 0xc9, 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x6c, + 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, + 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, + 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x12, 0x54, 0x0a, 0x11, 0x64, 0x65, 0x66, + 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x10, 0x64, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2a, + 0x4a, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, + 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, + 0x6c, 0x6f, 0x77, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, + 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, + 0x0a, 0x0a, 0x06, 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x2a, 0x64, 0x0a, 0x09, 0x63, + 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, + 0x50, 0x52, 0x4f, 0x44, 0x55, 0x43, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x59, 0x53, + 0x54, 0x45, 0x4d, 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, + 0x45, 0x58, 0x54, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x10, + 0x05, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, + 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, +} + +var ( + file_build_flags_src_proto_rawDescOnce sync.Once + file_build_flags_src_proto_rawDescData = file_build_flags_src_proto_rawDesc +) + +func file_build_flags_src_proto_rawDescGZIP() []byte { + file_build_flags_src_proto_rawDescOnce.Do(func() { + file_build_flags_src_proto_rawDescData = protoimpl.X.CompressGZIP(file_build_flags_src_proto_rawDescData) + }) + return file_build_flags_src_proto_rawDescData +} + +var file_build_flags_src_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_build_flags_src_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_build_flags_src_proto_goTypes = []interface{}{ + (Workflow)(0), // 0: android.release_config_proto.workflow + (Container)(0), // 1: android.release_config_proto.container + (*Value)(nil), // 2: android.release_config_proto.value + (*FlagDeclaration)(nil), // 3: android.release_config_proto.flag_declaration + (*FlagValue)(nil), // 4: android.release_config_proto.flag_value + (*ReleaseConfig)(nil), // 5: android.release_config_proto.release_config + (*ReleaseAlias)(nil), // 6: android.release_config_proto.release_alias + (*ReleaseConfigMap)(nil), // 7: android.release_config_proto.release_config_map +} +var file_build_flags_src_proto_depIdxs = []int32{ + 2, // 0: android.release_config_proto.flag_declaration.value:type_name -> android.release_config_proto.value + 0, // 1: android.release_config_proto.flag_declaration.workflow:type_name -> android.release_config_proto.workflow + 1, // 2: android.release_config_proto.flag_declaration.container:type_name -> android.release_config_proto.container + 2, // 3: android.release_config_proto.flag_value.value:type_name -> android.release_config_proto.value + 6, // 4: android.release_config_proto.release_config_map.aliases:type_name -> android.release_config_proto.release_alias + 1, // 5: android.release_config_proto.release_config_map.default_container:type_name -> android.release_config_proto.container + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name +} + +func init() { file_build_flags_src_proto_init() } +func file_build_flags_src_proto_init() { + if File_build_flags_src_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_build_flags_src_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Value); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_build_flags_src_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FlagDeclaration); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_build_flags_src_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FlagValue); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_build_flags_src_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReleaseConfig); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_build_flags_src_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReleaseAlias); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_build_flags_src_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReleaseConfigMap); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_build_flags_src_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Value_UnspecifiedValue)(nil), + (*Value_StringValue)(nil), + (*Value_BoolValue)(nil), + (*Value_Obsolete)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_build_flags_src_proto_rawDesc, + NumEnums: 2, + NumMessages: 6, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_build_flags_src_proto_goTypes, + DependencyIndexes: file_build_flags_src_proto_depIdxs, + EnumInfos: file_build_flags_src_proto_enumTypes, + MessageInfos: file_build_flags_src_proto_msgTypes, + }.Build() + File_build_flags_src_proto = out.File + file_build_flags_src_proto_rawDesc = nil + file_build_flags_src_proto_goTypes = nil + file_build_flags_src_proto_depIdxs = nil +} diff --git a/cmd/release_config/release_config_proto/build_flags_src.proto b/cmd/release_config/release_config_proto/build_flags_src.proto new file mode 100644 index 000000000..0662716d5 --- /dev/null +++ b/cmd/release_config/release_config_proto/build_flags_src.proto @@ -0,0 +1,154 @@ +// 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. + +syntax = "proto2"; +package android.release_config_proto; +option go_package = "android/soong/release_config/release_config_proto"; + +// This protobuf file defines messages used to represent the build flags used by +// a release in a more human-editable form. It is used for on-disk files in the +// source tree. +// +// The following format requirements apply across various message fields: +// +// # name: name of the flag +// +// format: an uppercase string in SNAKE_CASE format starting with RELEASE_, +// no consecutive underscores, and no leading digit. For example +// RELEASE_MY_PACKAGE_FLAG is a valid name, while MY_PACKAGE_FLAG, and +// RELEASE_MY_PACKAGE__FLAG are invalid. +// +// # package: package to which the flag belongs +// +// format: lowercase strings in snake_case format, delimited by dots, no +// consecutive underscores and no leading digit in each string. For example +// com.android.mypackage is a valid name while com.android.myPackage, +// com.android.1mypackage are invalid + +enum workflow { + UNSPECIFIED_workflow = 0; + + // Boolean value flags that progress from false to true. + LAUNCH = 1; + + // String value flags that get updated with new version strings to control + // prebuilt inclusion. + PREBUILT = 2; + + // Manually managed outside flags. These are likely to be found in a + // different directory than flags with other workflows. + MANUAL = 3; +} + +enum container { + UNSPECIFIED_container = 0; + + // All containers + ALL = 1; + + // Specific containers + PRODUCT = 2; + SYSTEM = 3; + SYSTEM_EXT = 4; + VENDOR = 5; +} + +message value { + oneof val { + bool unspecified_value = 200; + string string_value = 201; + bool bool_value = 202; + // If true, the flag is obsolete. Assigning it further will be flagged. + bool obsolete = 203; + } +} + +// The proto used in the source tree. +message flag_declaration { + // The name of the flag. + // See # name for format detail + optional string name = 1; + + // Text description of the flag's purpose. + optional string description = 3; + + // reserve this for bug, if needed. + reserved 4; + + // Value for the flag + optional value value = 201; + + // Workflow for this flag. + optional workflow workflow = 205; + + // The container for this flag. This overrides any default container given + // in the release_config_map message. + optional container container = 206; + + // The package associated with this flag. + // (when Gantry is ready for it) optional string package = 207; + reserved 207; + + // Temporarily allow origin at the flag declaration level while we + // move flags to their own locations. + optional string origin = 208; + + // TODO: do we want to include "first used in" (= ap2a)? +} + +message flag_value { + // Name of the flag. + // See # name for format detail + optional string name = 2; + + // Value for the flag + optional value value = 201; +} + +// This replaces $(call declare-release-config). +message release_config { + // The name of the release config. + // See # name for format detail + optional string name = 1; + + // From which other release configs does this one inherit? + repeated string inherits = 2; + + // List of names of the aconfig_value_set soong module(s) for this + // contribution. + repeated string aconfig_value_sets = 3; +} + +// Any aliases. These are used for continuous integration builder config. +message release_alias { + // The name of the alias. + optional string name = 1; + + // The release that `name` is an alias for. + optional string target = 2; +} + +// This provides the data from release_config_map.mk +message release_config_map { + // Any aliases. + repeated release_alias aliases = 1; + + // The origin for flags declared here. + optional string origin = 2; + + // The default container for flags declared here. + optional container default_container = 3; + + // If needed, we can add these fields instead of hardcoding the location. + // Flag declarations: `flag_declarations/*.textproto` + // Release config contributions: `release_configs/*.textproto` + // Flag values: `flag_values/{RELEASE_NAME}/*.textproto` +} diff --git a/cmd/release_config/release_config_proto/regen.sh b/cmd/release_config/release_config_proto/regen.sh new file mode 100644 index 000000000..1846c4d87 --- /dev/null +++ b/cmd/release_config/release_config_proto/regen.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +aprotoc --go_out=paths=source_relative:. build_flags_src.proto build_flags_out.proto From f7c45daf07ac3c4f49de0258f8382cead6b72921 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 10 Apr 2024 16:15:58 -0700 Subject: [PATCH 28/67] release_config: add namespace to proto flag_declaration needs to include the namespace, and origin is not needed. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: Icbadbe6d9888323874c07d84ccd6f50c284e1a1c Change-Id: Icbadbe6d9888323874c07d84ccd6f50c284e1a1c --- cmd/release_config/main.go | 67 ++++---- .../build_flags_src.pb.go | 150 ++++++++---------- .../build_flags_src.proto | 18 +-- 3 files changed, 118 insertions(+), 117 deletions(-) diff --git a/cmd/release_config/main.go b/cmd/release_config/main.go index 3bb6b3dfe..b7f7fab8d 100644 --- a/cmd/release_config/main.go +++ b/cmd/release_config/main.go @@ -270,9 +270,6 @@ func FlagDeclarationFactory(protoPath string) (fd *release_config_proto.FlagDecl func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex int) error { m := ReleaseConfigMapFactory(path) - if m.proto.Origin == nil || *m.proto.Origin == "" { - return fmt.Errorf("Release config map %s lacks origin", path) - } if m.proto.DefaultContainer == nil { return fmt.Errorf("Release config map %s lacks default_container", path) } @@ -296,13 +293,13 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex if flagDeclaration.Container == nil { flagDeclaration.Container = m.proto.DefaultContainer } - // TODO: drop flag_declaration.origin from the proto. - if flagDeclaration.Origin == nil { - flagDeclaration.Origin = m.proto.Origin + // TODO: once we have namespaces initialized, we can throw an error here. + if flagDeclaration.Namespace == nil { + flagDeclaration.Namespace = proto.String("android_UNKNOWN") } - // There is always a default value. + // If the input didn't specify a value, create one (== UnspecifiedValue). if flagDeclaration.Value == nil { - flagDeclaration.Value = &release_config_proto.Value{Val: &release_config_proto.Value_UnspecifiedValue{true}} + flagDeclaration.Value = &release_config_proto.Value{Val: &release_config_proto.Value_UnspecifiedValue{false}} } m.FlagDeclarations = append(m.FlagDeclarations, *flagDeclaration) name := *flagDeclaration.Name @@ -414,7 +411,7 @@ func (configs *ReleaseConfigs) DumpMakefile(outDir, targetRelease string) error addVar(name, "VALUE", value) addVar(name, "DECLARED_IN", *flag.Traces[0].Source) addVar(name, "SET_IN", *flag.Traces[len(flag.Traces)-1].Source) - addVar(name, "ORIGIN", *decl.Origin) + addVar(name, "NAMESPACE", *decl.Namespace) } pNames := []string{} for k, _ := range partitions { @@ -626,15 +623,14 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro return nil } -func main() { - var targetRelease string - var outputDir string - +func GetDefaultOutDir() string { outEnv := os.Getenv("OUT_DIR") if outEnv == "" { outEnv = "out" } - defaultOutputDir := filepath.Join(outEnv, "soong", "release-config") + return filepath.Join(outEnv, "soong", "release-config") +} +func GetDefaultMapPaths() StringList { var defaultMapPaths StringList defaultLocations := StringList{ "build/release/release_config_map.textproto", @@ -650,32 +646,47 @@ func main() { if prodMaps != "" { defaultMapPaths = append(defaultMapPaths, strings.Split(prodMaps, " ")...) } + return defaultMapPaths +} - flag.BoolVar(&verboseFlag, "debug", false, "print debugging information") - flag.Var(&releaseConfigMapPaths, "map", "path to a release_config_map.textproto. may be repeated") - flag.StringVar(&targetRelease, "release", "trunk_staging", "TARGET_RELEASE for this build") - flag.StringVar(&outputDir, "out_dir", defaultOutputDir, "basepath for the output. Multiple formats are created") - flag.Parse() - - if len(releaseConfigMapPaths) == 0 { - releaseConfigMapPaths = defaultMapPaths - fmt.Printf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) - } - +func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease string) (*ReleaseConfigs, error) { + var err error configs := ReleaseConfigsFactory() for idx, releaseConfigMapPath := range releaseConfigMapPaths { // Maintain an ordered list of release config directories. configDir := filepath.Dir(releaseConfigMapPath) configs.ConfigDirIndexes[configDir] = idx configs.ConfigDirs = append(configs.ConfigDirs, configDir) - err := configs.LoadReleaseConfigMap(releaseConfigMapPath, idx) + err = configs.LoadReleaseConfigMap(releaseConfigMapPath, idx) if err != nil { - panic(err) + return nil, err } } // Now that we have all of the release config maps, can meld them and generate the artifacts. - err := configs.GenerateReleaseConfigs(targetRelease) + err = configs.GenerateReleaseConfigs(targetRelease) + return configs, err +} + +func main() { + var targetRelease string + var outputDir string + + flag.BoolVar(&verboseFlag, "debug", false, "print debugging information") + flag.Var(&releaseConfigMapPaths, "map", "path to a release_config_map.textproto. may be repeated") + flag.StringVar(&targetRelease, "release", "trunk_staging", "TARGET_RELEASE for this build") + flag.StringVar(&outputDir, "out_dir", GetDefaultOutDir(), "basepath for the output. Multiple formats are created") + flag.Parse() + + if len(releaseConfigMapPaths) == 0 { + releaseConfigMapPaths = GetDefaultMapPaths() + if len(releaseConfigMapPaths) == 0 { + panic(fmt.Errorf("No maps found")) + } + fmt.Printf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) + } + + configs, err := ReadReleaseConfigMaps(releaseConfigMapPaths, targetRelease) if err != nil { panic(err) } diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go index 0f2c30b76..ccf3b3f14 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go @@ -287,6 +287,9 @@ type FlagDeclaration struct { // The name of the flag. // See # name for format detail Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // Namespace the flag belongs to (required) + // See # namespace for format detail + Namespace *string `protobuf:"bytes,2,opt,name=namespace" json:"namespace,omitempty"` // Text description of the flag's purpose. Description *string `protobuf:"bytes,3,opt,name=description" json:"description,omitempty"` // Value for the flag @@ -296,9 +299,6 @@ type FlagDeclaration struct { // The container for this flag. This overrides any default container given // in the release_config_map message. Container *Container `protobuf:"varint,206,opt,name=container,enum=android.release_config_proto.Container" json:"container,omitempty"` - // Temporarily allow origin at the flag declaration level while we - // move flags to their own locations. - Origin *string `protobuf:"bytes,208,opt,name=origin" json:"origin,omitempty"` } func (x *FlagDeclaration) Reset() { @@ -340,6 +340,13 @@ func (x *FlagDeclaration) GetName() string { return "" } +func (x *FlagDeclaration) GetNamespace() string { + if x != nil && x.Namespace != nil { + return *x.Namespace + } + return "" +} + func (x *FlagDeclaration) GetDescription() string { if x != nil && x.Description != nil { return *x.Description @@ -368,13 +375,6 @@ func (x *FlagDeclaration) GetContainer() Container { return Container_UNSPECIFIED_container } -func (x *FlagDeclaration) GetOrigin() string { - if x != nil && x.Origin != nil { - return *x.Origin - } - return "" -} - type FlagValue struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -568,8 +568,6 @@ type ReleaseConfigMap struct { // Any aliases. Aliases []*ReleaseAlias `protobuf:"bytes,1,rep,name=aliases" json:"aliases,omitempty"` - // The origin for flags declared here. - Origin *string `protobuf:"bytes,2,opt,name=origin" json:"origin,omitempty"` // The default container for flags declared here. DefaultContainer *Container `protobuf:"varint,3,opt,name=default_container,json=defaultContainer,enum=android.release_config_proto.Container" json:"default_container,omitempty"` } @@ -613,13 +611,6 @@ func (x *ReleaseConfigMap) GetAliases() []*ReleaseAlias { return nil } -func (x *ReleaseConfigMap) GetOrigin() string { - if x != nil && x.Origin != nil { - return *x.Origin - } - return "" -} - func (x *ReleaseConfigMap) GetDefaultContainer() Container { if x != nil && x.DefaultContainer != nil { return *x.DefaultContainer @@ -643,71 +634,70 @@ var file_build_flags_src_proto_rawDesc = []byte{ 0x6c, 0x75, 0x65, 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x18, 0xcb, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x08, 0x6f, 0x62, - 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x22, 0xb8, 0x02, + 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x22, 0xbd, 0x02, 0x0a, 0x10, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, - 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x12, 0x43, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, - 0x18, 0xcd, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, - 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x52, - 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x46, 0x0a, 0x09, 0x63, 0x6f, 0x6e, - 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0xce, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, - 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6e, - 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, - 0x72, 0x12, 0x17, 0x0a, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x18, 0xd0, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, - 0x4a, 0x06, 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x5c, 0x0a, 0x0a, 0x66, 0x6c, 0x61, 0x67, - 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, - 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x6e, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, - 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, - 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x53, 0x65, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, - 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x22, 0xc9, 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x6c, - 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, + 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x12, 0x43, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x18, 0xcd, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x52, 0x08, 0x77, + 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x46, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x18, 0xce, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, - 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x12, 0x54, 0x0a, 0x11, 0x64, 0x65, 0x66, - 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, + 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x4a, + 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x06, 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x5c, 0x0a, + 0x0a, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x6e, 0x0a, 0x0e, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, + 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, + 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xb1, 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, + 0x45, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x52, 0x07, 0x61, + 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x54, 0x0a, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, + 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x27, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x10, 0x64, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2a, 0x4a, 0x0a, 0x08, + 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, + 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, 0x0c, + 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, + 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x2a, 0x64, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x74, + 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, + 0x46, 0x49, 0x45, 0x44, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x10, 0x00, + 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x4f, + 0x44, 0x55, 0x43, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, + 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x58, 0x54, + 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x10, 0x05, 0x42, 0x33, + 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x10, 0x64, - 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2a, - 0x4a, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, - 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, - 0x6c, 0x6f, 0x77, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, - 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, - 0x0a, 0x0a, 0x06, 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x2a, 0x64, 0x0a, 0x09, 0x63, - 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, - 0x72, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, - 0x50, 0x52, 0x4f, 0x44, 0x55, 0x43, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x59, 0x53, - 0x54, 0x45, 0x4d, 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, - 0x45, 0x58, 0x54, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x10, - 0x05, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, - 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x6f, 0x74, 0x6f, } var ( diff --git a/cmd/release_config/release_config_proto/build_flags_src.proto b/cmd/release_config/release_config_proto/build_flags_src.proto index 0662716d5..85015248e 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.proto +++ b/cmd/release_config/release_config_proto/build_flags_src.proto @@ -26,6 +26,11 @@ option go_package = "android/soong/release_config/release_config_proto"; // RELEASE_MY_PACKAGE_FLAG is a valid name, while MY_PACKAGE_FLAG, and // RELEASE_MY_PACKAGE__FLAG are invalid. // +// # namespace: namespace the flag belongs to +// +// format: a lowercase string in snake_case format, no consecutive underscores, and no leading +// digit. For example android_bar_system +// // # package: package to which the flag belongs // // format: lowercase strings in snake_case format, delimited by dots, no @@ -77,6 +82,10 @@ message flag_declaration { // See # name for format detail optional string name = 1; + // Namespace the flag belongs to (required) + // See # namespace for format detail + optional string namespace = 2; + // Text description of the flag's purpose. optional string description = 3; @@ -96,12 +105,6 @@ message flag_declaration { // The package associated with this flag. // (when Gantry is ready for it) optional string package = 207; reserved 207; - - // Temporarily allow origin at the flag declaration level while we - // move flags to their own locations. - optional string origin = 208; - - // TODO: do we want to include "first used in" (= ap2a)? } message flag_value { @@ -141,9 +144,6 @@ message release_config_map { // Any aliases. repeated release_alias aliases = 1; - // The origin for flags declared here. - optional string origin = 2; - // The default container for flags declared here. optional container default_container = 3; From 81ad0b898bc0b7586594a8b7f7f0a87790b073e5 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 11 Apr 2024 11:01:18 -0700 Subject: [PATCH 29/67] release_config: make the code more sharable This will allow the `build-flag` command to use release_config_lib code. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: If068597b1d68c52c941788931997b7f77c73d2b3 Change-Id: If068597b1d68c52c941788931997b7f77c73d2b3 --- cmd/release_config/Android.bp | 30 -- cmd/release_config/release_config/Android.bp | 18 + cmd/release_config/release_config/main.go | 57 +++ .../release_config_lib/Android.bp | 36 ++ .../release_config_lib/flag_artifact.go | 89 ++++ .../release_config_lib/flag_declaration.go | 27 ++ .../release_config_lib/flag_value.go | 56 +++ .../release_config_lib/flag_value_test.go | 67 +++ .../release_config_lib/release_config.go | 154 +++++++ .../release_configs.go} | 391 ++---------------- cmd/release_config/release_config_lib/util.go | 90 ++++ .../release_config_proto/Android.bp | 2 +- 12 files changed, 622 insertions(+), 395 deletions(-) delete mode 100644 cmd/release_config/Android.bp create mode 100644 cmd/release_config/release_config/Android.bp create mode 100644 cmd/release_config/release_config/main.go create mode 100644 cmd/release_config/release_config_lib/Android.bp create mode 100644 cmd/release_config/release_config_lib/flag_artifact.go create mode 100644 cmd/release_config/release_config_lib/flag_declaration.go create mode 100644 cmd/release_config/release_config_lib/flag_value.go create mode 100644 cmd/release_config/release_config_lib/flag_value_test.go create mode 100644 cmd/release_config/release_config_lib/release_config.go rename cmd/release_config/{main.go => release_config_lib/release_configs.go} (55%) create mode 100644 cmd/release_config/release_config_lib/util.go diff --git a/cmd/release_config/Android.bp b/cmd/release_config/Android.bp deleted file mode 100644 index 7f627ffb7..000000000 --- a/cmd/release_config/Android.bp +++ /dev/null @@ -1,30 +0,0 @@ -package { - default_applicable_licenses: ["Android-Apache-2.0"], -} - -bootstrap_go_package { - name: "release-config", - pkgPath: "android/soong/cmd/release_config", - deps: [ - "golang-protobuf-encoding-prototext", - "golang-protobuf-reflect-protoreflect", - "golang-protobuf-runtime-protoimpl", - "soong-cmd-release-config-proto", - ], - srcs: [ - "main.go", - ], -} - -bootstrap_go_package { - name: "soong-cmd-release-config-proto", - pkgPath: "android/soong/cmd/release_config/release_config_proto", - deps: [ - "golang-protobuf-reflect-protoreflect", - "golang-protobuf-runtime-protoimpl", - ], - srcs: [ - "release_config_proto/build_flags_out.pb.go", - "release_config_proto/build_flags_src.pb.go", - ], -} diff --git a/cmd/release_config/release_config/Android.bp b/cmd/release_config/release_config/Android.bp new file mode 100644 index 000000000..3c7382637 --- /dev/null +++ b/cmd/release_config/release_config/Android.bp @@ -0,0 +1,18 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +bootstrap_go_package { + name: "soong-cmd-release_config-release_config", + pkgPath: "android/soong/cmd/release_config/release_config", + deps: [ + "golang-protobuf-encoding-prototext", + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + "soong-cmd-release_config-proto", + "soong-cmd-release_config-lib", + ], + srcs: [ + "main.go", + ], +} diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go new file mode 100644 index 000000000..076abfaaf --- /dev/null +++ b/cmd/release_config/release_config/main.go @@ -0,0 +1,57 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// 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 main + +import ( + "flag" + "os" + + rc_lib "android/soong/cmd/release_config/release_config_lib" +) + +func main() { + var top string + var releaseConfigMapPaths rc_lib.StringList + var targetRelease string + var outputDir string + var err error + var configs *rc_lib.ReleaseConfigs + + flag.StringVar(&top, "top", ".", "path to top of workspace") + flag.Var(&releaseConfigMapPaths, "map", "path to a release_config_map.textproto. may be repeated") + flag.StringVar(&targetRelease, "release", "trunk_staging", "TARGET_RELEASE for this build") + flag.StringVar(&outputDir, "out_dir", rc_lib.GetDefaultOutDir(), "basepath for the output. Multiple formats are created") + flag.Parse() + + if err = os.Chdir(top); err != nil { + panic(err) + } + configs, err = rc_lib.ReadReleaseConfigMaps(releaseConfigMapPaths, targetRelease) + if err != nil { + panic(err) + } + err = os.MkdirAll(outputDir, 0775) + if err != nil { + panic(err) + } + err = configs.DumpMakefile(outputDir, targetRelease) + if err != nil { + panic(err) + } + err = configs.DumpArtifact(outputDir) + if err != nil { + panic(err) + } +} diff --git a/cmd/release_config/release_config_lib/Android.bp b/cmd/release_config/release_config_lib/Android.bp new file mode 100644 index 000000000..601194c93 --- /dev/null +++ b/cmd/release_config/release_config_lib/Android.bp @@ -0,0 +1,36 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// 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 { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +bootstrap_go_package { + name: "soong-cmd-release_config-lib", + pkgPath: "android/soong/release_config/release_config_lib", + deps: [ + "golang-protobuf-encoding-prototext", + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + "soong-cmd-release_config-proto", + ], + srcs: [ + "flag_artifact.go", + "flag_declaration.go", + "flag_value.go", + "release_config.go", + "release_configs.go", + "util.go", + ], +} diff --git a/cmd/release_config/release_config_lib/flag_artifact.go b/cmd/release_config/release_config_lib/flag_artifact.go new file mode 100644 index 000000000..51673a5ec --- /dev/null +++ b/cmd/release_config/release_config_lib/flag_artifact.go @@ -0,0 +1,89 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// 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 release_config_lib + +import ( + "fmt" + + "android/soong/cmd/release_config/release_config_proto" + + "google.golang.org/protobuf/proto" +) + +type FlagArtifact struct { + FlagDeclaration *release_config_proto.FlagDeclaration + + // The index of the config directory where this flag was declared. + // Flag values cannot be set in a location with a lower index. + DeclarationIndex int + + Traces []*release_config_proto.Tracepoint + + // Assigned value + Value *release_config_proto.Value +} + +// Key is flag name. +type FlagArtifacts map[string]*FlagArtifact + +func (src *FlagArtifact) Clone() *FlagArtifact { + value := &release_config_proto.Value{} + proto.Merge(value, src.Value) + return &FlagArtifact{ + FlagDeclaration: src.FlagDeclaration, + Traces: src.Traces, + Value: value, + } +} + +func (src FlagArtifacts) Clone() (dst FlagArtifacts) { + if dst == nil { + dst = make(FlagArtifacts) + } + for k, v := range src { + dst[k] = v.Clone() + } + return +} + +func (fa *FlagArtifact) UpdateValue(flagValue FlagValue) error { + name := *flagValue.proto.Name + fa.Traces = append(fa.Traces, &release_config_proto.Tracepoint{Source: proto.String(flagValue.path), Value: flagValue.proto.Value}) + if fa.Value.GetObsolete() { + return fmt.Errorf("Attempting to set obsolete flag %s. Trace=%v", name, fa.Traces) + } + switch val := flagValue.proto.Value.Val.(type) { + case *release_config_proto.Value_StringValue: + fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_StringValue{val.StringValue}} + case *release_config_proto.Value_BoolValue: + fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_BoolValue{val.BoolValue}} + case *release_config_proto.Value_Obsolete: + if !val.Obsolete { + return fmt.Errorf("%s: Cannot set obsolete=false. Trace=%v", name, fa.Traces) + } + fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_Obsolete{true}} + default: + return fmt.Errorf("Invalid type for flag_value: %T. Trace=%v", val, fa.Traces) + } + return nil +} + +func (fa *FlagArtifact) Marshal() (*release_config_proto.FlagArtifact, error) { + return &release_config_proto.FlagArtifact{ + FlagDeclaration: fa.FlagDeclaration, + Value: fa.Value, + Traces: fa.Traces, + }, nil +} diff --git a/cmd/release_config/release_config_lib/flag_declaration.go b/cmd/release_config/release_config_lib/flag_declaration.go new file mode 100644 index 000000000..d5cc41845 --- /dev/null +++ b/cmd/release_config/release_config_lib/flag_declaration.go @@ -0,0 +1,27 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// 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 release_config_lib + +import ( + "android/soong/cmd/release_config/release_config_proto" +) + +func FlagDeclarationFactory(protoPath string) (fd *release_config_proto.FlagDeclaration) { + fd = &release_config_proto.FlagDeclaration{} + if protoPath != "" { + LoadTextproto(protoPath, fd) + } + return fd +} diff --git a/cmd/release_config/release_config_lib/flag_value.go b/cmd/release_config/release_config_lib/flag_value.go new file mode 100644 index 000000000..138e8f8d3 --- /dev/null +++ b/cmd/release_config/release_config_lib/flag_value.go @@ -0,0 +1,56 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// 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 release_config_lib + +import ( + "android/soong/cmd/release_config/release_config_proto" +) + +type FlagValue struct { + // The path providing this value. + path string + + // Protobuf + proto release_config_proto.FlagValue +} + +func FlagValueFactory(protoPath string) (fv *FlagValue) { + fv = &FlagValue{path: protoPath} + if protoPath != "" { + LoadTextproto(protoPath, &fv.proto) + } + return fv +} + +func MarshalValue(value *release_config_proto.Value) string { + switch val := value.Val.(type) { + case *release_config_proto.Value_UnspecifiedValue: + // Value was never set. + return "" + case *release_config_proto.Value_StringValue: + return val.StringValue + case *release_config_proto.Value_BoolValue: + if val.BoolValue { + return "true" + } + // False ==> empty string + return "" + case *release_config_proto.Value_Obsolete: + return " #OBSOLETE" + default: + // Flagged as error elsewhere, so return empty string here. + return "" + } +} diff --git a/cmd/release_config/release_config_lib/flag_value_test.go b/cmd/release_config/release_config_lib/flag_value_test.go new file mode 100644 index 000000000..aaa4cafeb --- /dev/null +++ b/cmd/release_config/release_config_lib/flag_value_test.go @@ -0,0 +1,67 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// 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 release_config_lib + +import ( + "os" + "path/filepath" + "testing" + + rc_proto "android/soong/cmd/release_config/release_config_proto" + + "google.golang.org/protobuf/proto" +) + +type testCaseFlagValue struct { + protoPath string + name string + data []byte + expected rc_proto.FlagValue + err error +} + +func (tc testCaseFlagValue) assertProtoEqual(t *testing.T, expected, actual proto.Message) { + if !proto.Equal(expected, actual) { + t.Errorf("Expected %q found %q", expected, actual) + } +} + +func TestFlagValue(t *testing.T) { + testCases := []testCaseFlagValue{ + { + name: "stringVal", + protoPath: "build/release/flag_values/test/RELEASE_FOO.textproto", + data: []byte(`name: "RELEASE_FOO" value {string_value: "BAR"}`), + expected: rc_proto.FlagValue{ + Name: proto.String("RELEASE_FOO"), + Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{"BAR"}}, + }, + err: nil, + }, + } + for _, tc := range testCases { + var err error + tempdir := t.TempDir() + path := filepath.Join(tempdir, tc.protoPath) + if err = os.MkdirAll(filepath.Dir(path), 0755); err != nil { + t.Fatal(err) + } + if err = os.WriteFile(path, tc.data, 0644); err != nil { + t.Fatal(err) + } + actual := FlagValueFactory(path) + tc.assertProtoEqual(t, &tc.expected, &actual.proto) + } +} diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go new file mode 100644 index 000000000..3110dae81 --- /dev/null +++ b/cmd/release_config/release_config_lib/release_config.go @@ -0,0 +1,154 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// 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 release_config_lib + +import ( + "fmt" + + "android/soong/cmd/release_config/release_config_proto" + + "google.golang.org/protobuf/proto" +) + +// One directory's contribution to the a release config. +type ReleaseConfigContribution struct { + // Paths to files providing this config. + path string + + // The index of the config directory where this release config + // contribution was declared. + // Flag values cannot be set in a location with a lower index. + DeclarationIndex int + + // Protobufs relevant to the config. + proto release_config_proto.ReleaseConfig + + FlagValues []*FlagValue +} + +// A generated release config. +type ReleaseConfig struct { + // the Name of the release config + Name string + + // The index of the config directory where this release config was + // first declared. + // Flag values cannot be set in a location with a lower index. + DeclarationIndex int + + // What contributes to this config. + Contributions []*ReleaseConfigContribution + + // Aliases for this release + OtherNames []string + + // The names of release configs that we inherit + InheritNames []string + + // Unmarshalled flag artifacts + FlagArtifacts FlagArtifacts + + // Generated release config + ReleaseConfigArtifact *release_config_proto.ReleaseConfigArtifact + + // We have begun compiling this release config. + compileInProgress bool +} + +func ReleaseConfigFactory(name string, index int) (c *ReleaseConfig) { + return &ReleaseConfig{Name: name, DeclarationIndex: index} +} + +func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) error { + if config.ReleaseConfigArtifact != nil { + return nil + } + if config.compileInProgress { + return fmt.Errorf("Loop detected for release config %s", config.Name) + } + config.compileInProgress = true + + // Generate any configs we need to inherit. This will detect loops in + // the config. + contributionsToApply := []*ReleaseConfigContribution{} + myInherits := []string{} + myInheritsSet := make(map[string]bool) + for _, inherit := range config.InheritNames { + if _, ok := myInheritsSet[inherit]; ok { + continue + } + myInherits = append(myInherits, inherit) + myInheritsSet[inherit] = true + iConfig, err := configs.GetReleaseConfig(inherit) + if err != nil { + return err + } + iConfig.GenerateReleaseConfig(configs) + contributionsToApply = append(contributionsToApply, iConfig.Contributions...) + } + contributionsToApply = append(contributionsToApply, config.Contributions...) + + myAconfigValueSets := []string{} + myFlags := configs.FlagArtifacts.Clone() + myDirsMap := make(map[int]bool) + for _, contrib := range contributionsToApply { + myAconfigValueSets = append(myAconfigValueSets, contrib.proto.AconfigValueSets...) + myDirsMap[contrib.DeclarationIndex] = true + for _, value := range contrib.FlagValues { + fa, ok := myFlags[*value.proto.Name] + if !ok { + return fmt.Errorf("Setting value for undefined flag %s in %s\n", *value.proto.Name, value.path) + } + myDirsMap[fa.DeclarationIndex] = true + if fa.DeclarationIndex > contrib.DeclarationIndex { + // Setting location is to the left of declaration. + return fmt.Errorf("Setting value for flag %s not allowed in %s\n", *value.proto.Name, value.path) + } + if err := fa.UpdateValue(*value); err != nil { + return err + } + } + } + + directories := []string{} + for idx, confDir := range configs.ConfigDirs { + if _, ok := myDirsMap[idx]; ok { + directories = append(directories, confDir) + } + } + + config.FlagArtifacts = myFlags + config.ReleaseConfigArtifact = &release_config_proto.ReleaseConfigArtifact{ + Name: proto.String(config.Name), + OtherNames: config.OtherNames, + FlagArtifacts: func() []*release_config_proto.FlagArtifact { + ret := []*release_config_proto.FlagArtifact{} + for _, flag := range myFlags { + ret = append(ret, &release_config_proto.FlagArtifact{ + FlagDeclaration: flag.FlagDeclaration, + Traces: flag.Traces, + Value: flag.Value, + }) + } + return ret + }(), + AconfigValueSets: myAconfigValueSets, + Inherits: myInherits, + Directories: directories, + } + + config.compileInProgress = false + return nil +} diff --git a/cmd/release_config/main.go b/cmd/release_config/release_config_lib/release_configs.go similarity index 55% rename from cmd/release_config/main.go rename to cmd/release_config/release_config_lib/release_configs.go index b7f7fab8d..74fdc005f 100644 --- a/cmd/release_config/main.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -12,12 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package release_config_lib import ( "cmp" "encoding/json" - "flag" "fmt" "io/fs" "os" @@ -31,105 +30,6 @@ import ( "google.golang.org/protobuf/proto" ) -var verboseFlag bool - -type StringList []string - -func (l *StringList) Set(v string) error { - *l = append(*l, v) - return nil -} - -func (l *StringList) String() string { - return fmt.Sprintf("%v", *l) -} - -var releaseConfigMapPaths StringList - -func DumpProtos(outDir string, message proto.Message) error { - basePath := filepath.Join(outDir, "all_release_configs") - writer := func(suffix string, marshal func() ([]byte, error)) error { - data, err := marshal() - if err != nil { - return err - } - return os.WriteFile(fmt.Sprintf("%s.%s", basePath, suffix), data, 0644) - } - err := writer("textproto", func() ([]byte, error) { return prototext.MarshalOptions{Multiline: true}.Marshal(message) }) - if err != nil { - return err - } - - err = writer("pb", func() ([]byte, error) { return proto.Marshal(message) }) - if err != nil { - return err - } - - return writer("json", func() ([]byte, error) { return json.MarshalIndent(message, "", " ") }) -} - -func LoadTextproto(path string, message proto.Message) error { - data, err := os.ReadFile(path) - if err != nil { - return err - } - ret := prototext.Unmarshal(data, message) - if verboseFlag { - debug, _ := prototext.Marshal(message) - fmt.Printf("%s: %s\n", path, debug) - } - return ret -} - -func WalkTextprotoFiles(root string, subdir string, Func fs.WalkDirFunc) error { - path := filepath.Join(root, subdir) - if _, err := os.Stat(path); err != nil { - // Missing subdirs are not an error. - return nil - } - return filepath.WalkDir(path, func(path string, d fs.DirEntry, err error) error { - if err != nil { - return err - } - if strings.HasSuffix(d.Name(), ".textproto") && d.Type().IsRegular() { - return Func(path, d, err) - } - return nil - }) -} - -type FlagValue struct { - // The path providing this value. - path string - - // Protobuf - proto release_config_proto.FlagValue -} - -func FlagValueFactory(protoPath string) (fv *FlagValue) { - fv = &FlagValue{path: protoPath} - if protoPath != "" { - LoadTextproto(protoPath, &fv.proto) - } - return fv -} - -// One directory's contribution to the a release config. -type ReleaseConfigContribution struct { - // Paths to files providing this config. - path string - - // The index of the config directory where this release config - // contribution was declared. - // Flag values cannot be set in a location with a lower index. - DeclarationIndex int - - // Protobufs relevant to the config. - proto release_config_proto.ReleaseConfig - - FlagValues []*FlagValue -} - // A single release_config_map.textproto and its associated data. // Used primarily for debugging. type ReleaseConfigMap struct { @@ -143,51 +43,6 @@ type ReleaseConfigMap struct { FlagDeclarations []release_config_proto.FlagDeclaration } -// A generated release config. -type ReleaseConfig struct { - // the Name of the release config - Name string - - // The index of the config directory where this release config was - // first declared. - // Flag values cannot be set in a location with a lower index. - DeclarationIndex int - - // What contributes to this config. - Contributions []*ReleaseConfigContribution - - // Aliases for this release - OtherNames []string - - // The names of release configs that we inherit - InheritNames []string - - // Unmarshalled flag artifacts - FlagArtifacts FlagArtifacts - - // Generated release config - ReleaseConfigArtifact *release_config_proto.ReleaseConfigArtifact - - // We have begun compiling this release config. - compileInProgress bool -} - -type FlagArtifact struct { - FlagDeclaration *release_config_proto.FlagDeclaration - - // The index of the config directory where this flag was declared. - // Flag values cannot be set in a location with a lower index. - DeclarationIndex int - - Traces []*release_config_proto.Tracepoint - - // Assigned value - Value *release_config_proto.Value -} - -// Key is flag name. -type FlagArtifacts map[string]*FlagArtifact - type ReleaseConfigDirMap map[string]int // The generated release configs. @@ -215,28 +70,27 @@ type ReleaseConfigs struct { ConfigDirIndexes ReleaseConfigDirMap } -func (src *FlagArtifact) Clone() *FlagArtifact { - value := &release_config_proto.Value{} - proto.Merge(value, src.Value) - return &FlagArtifact{ - FlagDeclaration: src.FlagDeclaration, - Traces: src.Traces, - Value: value, +func (configs *ReleaseConfigs) DumpArtifact(outDir string) error { + message := &configs.Artifact + basePath := filepath.Join(outDir, "all_release_configs") + writer := func(suffix string, marshal func() ([]byte, error)) error { + data, err := marshal() + if err != nil { + return err + } + return os.WriteFile(fmt.Sprintf("%s.%s", basePath, suffix), data, 0644) + } + err := writer("textproto", func() ([]byte, error) { return prototext.MarshalOptions{Multiline: true}.Marshal(message) }) + if err != nil { + return err } -} -func (src FlagArtifacts) Clone() (dst FlagArtifacts) { - if dst == nil { - dst = make(FlagArtifacts) + err = writer("pb", func() ([]byte, error) { return proto.Marshal(message) }) + if err != nil { + return err } - for k, v := range src { - dst[k] = v.Clone() - } - return -} -func ReleaseConfigFactory(name string, index int) (c *ReleaseConfig) { - return &ReleaseConfig{Name: name, DeclarationIndex: index} + return writer("json", func() ([]byte, error) { return json.MarshalIndent(message, "", " ") }) } func ReleaseConfigsFactory() (c *ReleaseConfigs) { @@ -260,14 +114,6 @@ func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { return m } -func FlagDeclarationFactory(protoPath string) (fd *release_config_proto.FlagDeclaration) { - fd = &release_config_proto.FlagDeclaration{} - if protoPath != "" { - LoadTextproto(protoPath, fd) - } - return fd -} - func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex int) error { m := ReleaseConfigMapFactory(path) if m.proto.DefaultContainer == nil { @@ -490,167 +336,17 @@ func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) erro return nil } -func MarshalValue(value *release_config_proto.Value) string { - switch val := value.Val.(type) { - case *release_config_proto.Value_UnspecifiedValue: - // Value was never set. - return "" - case *release_config_proto.Value_StringValue: - return val.StringValue - case *release_config_proto.Value_BoolValue: - if val.BoolValue { - return "true" - } - // False ==> empty string - return "" - case *release_config_proto.Value_Obsolete: - return " #OBSOLETE" - default: - // Flagged as error elsewhere, so return empty string here. - return "" - } -} - -func (fa *FlagArtifact) UpdateValue(flagValue FlagValue) error { - name := *flagValue.proto.Name - fa.Traces = append(fa.Traces, &release_config_proto.Tracepoint{Source: proto.String(flagValue.path), Value: flagValue.proto.Value}) - if fa.Value.GetObsolete() { - return fmt.Errorf("Attempting to set obsolete flag %s. Trace=%v", name, fa.Traces) - } - switch val := flagValue.proto.Value.Val.(type) { - case *release_config_proto.Value_StringValue: - fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_StringValue{val.StringValue}} - case *release_config_proto.Value_BoolValue: - fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_BoolValue{val.BoolValue}} - case *release_config_proto.Value_Obsolete: - if !val.Obsolete { - return fmt.Errorf("%s: Cannot set obsolete=false. Trace=%v", name, fa.Traces) - } - fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_Obsolete{true}} - default: - return fmt.Errorf("Invalid type for flag_value: %T. Trace=%v", val, fa.Traces) - } - return nil -} - -func (fa *FlagArtifact) Marshal() (*release_config_proto.FlagArtifact, error) { - return &release_config_proto.FlagArtifact{ - FlagDeclaration: fa.FlagDeclaration, - Value: fa.Value, - Traces: fa.Traces, - }, nil -} - -func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) error { - if config.ReleaseConfigArtifact != nil { - return nil - } - if config.compileInProgress { - return fmt.Errorf("Loop detected for release config %s", config.Name) - } - config.compileInProgress = true - - // Generate any configs we need to inherit. This will detect loops in - // the config. - contributionsToApply := []*ReleaseConfigContribution{} - myInherits := []string{} - myInheritsSet := make(map[string]bool) - for _, inherit := range config.InheritNames { - if _, ok := myInheritsSet[inherit]; ok { - continue - } - myInherits = append(myInherits, inherit) - myInheritsSet[inherit] = true - iConfig, err := configs.GetReleaseConfig(inherit) - if err != nil { - return err - } - iConfig.GenerateReleaseConfig(configs) - contributionsToApply = append(contributionsToApply, iConfig.Contributions...) - } - contributionsToApply = append(contributionsToApply, config.Contributions...) - - myAconfigValueSets := []string{} - myFlags := configs.FlagArtifacts.Clone() - myDirsMap := make(map[int]bool) - for _, contrib := range contributionsToApply { - myAconfigValueSets = append(myAconfigValueSets, contrib.proto.AconfigValueSets...) - myDirsMap[contrib.DeclarationIndex] = true - for _, value := range contrib.FlagValues { - fa, ok := myFlags[*value.proto.Name] - if !ok { - return fmt.Errorf("Setting value for undefined flag %s in %s\n", *value.proto.Name, value.path) - } - myDirsMap[fa.DeclarationIndex] = true - if fa.DeclarationIndex > contrib.DeclarationIndex { - // Setting location is to the left of declaration. - return fmt.Errorf("Setting value for flag %s not allowed in %s\n", *value.proto.Name, value.path) - } - if err := fa.UpdateValue(*value); err != nil { - return err - } - } - } - - directories := []string{} - for idx, confDir := range configs.ConfigDirs { - if _, ok := myDirsMap[idx]; ok { - directories = append(directories, confDir) - } - } - - config.FlagArtifacts = myFlags - config.ReleaseConfigArtifact = &release_config_proto.ReleaseConfigArtifact{ - Name: proto.String(config.Name), - OtherNames: config.OtherNames, - FlagArtifacts: func() []*release_config_proto.FlagArtifact { - ret := []*release_config_proto.FlagArtifact{} - for _, flag := range myFlags { - ret = append(ret, &release_config_proto.FlagArtifact{ - FlagDeclaration: flag.FlagDeclaration, - Traces: flag.Traces, - Value: flag.Value, - }) - } - return ret - }(), - AconfigValueSets: myAconfigValueSets, - Inherits: myInherits, - Directories: directories, - } - - config.compileInProgress = false - return nil -} - -func GetDefaultOutDir() string { - outEnv := os.Getenv("OUT_DIR") - if outEnv == "" { - outEnv = "out" - } - return filepath.Join(outEnv, "soong", "release-config") -} -func GetDefaultMapPaths() StringList { - var defaultMapPaths StringList - defaultLocations := StringList{ - "build/release/release_config_map.textproto", - "vendor/google_shared/build/release/release_config_map.textproto", - "vendor/google/release/release_config_map.textproto", - } - for _, path := range defaultLocations { - if _, err := os.Stat(path); err == nil { - defaultMapPaths = append(defaultMapPaths, path) - } - } - prodMaps := os.Getenv("PRODUCT_RELEASE_CONFIG_MAPS") - if prodMaps != "" { - defaultMapPaths = append(defaultMapPaths, strings.Split(prodMaps, " ")...) - } - return defaultMapPaths -} - func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease string) (*ReleaseConfigs, error) { var err error + + if len(releaseConfigMapPaths) == 0 { + releaseConfigMapPaths = GetDefaultMapPaths() + if len(releaseConfigMapPaths) == 0 { + return nil, fmt.Errorf("No maps found") + } + fmt.Printf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) + } + configs := ReleaseConfigsFactory() for idx, releaseConfigMapPath := range releaseConfigMapPaths { // Maintain an ordered list of release config directories. @@ -667,36 +363,3 @@ func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease strin err = configs.GenerateReleaseConfigs(targetRelease) return configs, err } - -func main() { - var targetRelease string - var outputDir string - - flag.BoolVar(&verboseFlag, "debug", false, "print debugging information") - flag.Var(&releaseConfigMapPaths, "map", "path to a release_config_map.textproto. may be repeated") - flag.StringVar(&targetRelease, "release", "trunk_staging", "TARGET_RELEASE for this build") - flag.StringVar(&outputDir, "out_dir", GetDefaultOutDir(), "basepath for the output. Multiple formats are created") - flag.Parse() - - if len(releaseConfigMapPaths) == 0 { - releaseConfigMapPaths = GetDefaultMapPaths() - if len(releaseConfigMapPaths) == 0 { - panic(fmt.Errorf("No maps found")) - } - fmt.Printf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) - } - - configs, err := ReadReleaseConfigMaps(releaseConfigMapPaths, targetRelease) - if err != nil { - panic(err) - } - err = os.MkdirAll(outputDir, 0775) - if err != nil { - panic(err) - } - err = configs.DumpMakefile(outputDir, targetRelease) - if err != nil { - panic(err) - } - DumpProtos(outputDir, &configs.Artifact) -} diff --git a/cmd/release_config/release_config_lib/util.go b/cmd/release_config/release_config_lib/util.go new file mode 100644 index 000000000..c59deb337 --- /dev/null +++ b/cmd/release_config/release_config_lib/util.go @@ -0,0 +1,90 @@ +// Copyright 2024 Google Inc. All rights reserved. +// +// 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 release_config_lib + +import ( + "fmt" + "io/fs" + "os" + "path/filepath" + "strings" + + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" +) + +type StringList []string + +func (l *StringList) Set(v string) error { + *l = append(*l, v) + return nil +} + +func (l *StringList) String() string { + return fmt.Sprintf("%v", *l) +} + +func LoadTextproto(path string, message proto.Message) error { + data, err := os.ReadFile(path) + if err != nil { + return err + } + ret := prototext.Unmarshal(data, message) + return ret +} + +func WalkTextprotoFiles(root string, subdir string, Func fs.WalkDirFunc) error { + path := filepath.Join(root, subdir) + if _, err := os.Stat(path); err != nil { + // Missing subdirs are not an error. + return nil + } + return filepath.WalkDir(path, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if strings.HasSuffix(d.Name(), ".textproto") && d.Type().IsRegular() { + return Func(path, d, err) + } + return nil + }) +} + +func GetDefaultOutDir() string { + outEnv := os.Getenv("OUT_DIR") + if outEnv == "" { + outEnv = "out" + } + return filepath.Join(outEnv, "soong", "release-config") +} + +func GetDefaultMapPaths() StringList { + var defaultMapPaths StringList + defaultLocations := StringList{ + "build/release/release_config_map.textproto", + "vendor/google_shared/build/release/release_config_map.textproto", + "vendor/google/release/release_config_map.textproto", + } + for _, path := range defaultLocations { + if _, err := os.Stat(path); err == nil { + defaultMapPaths = append(defaultMapPaths, path) + } + } + prodMaps := os.Getenv("PRODUCT_RELEASE_CONFIG_MAPS") + if prodMaps != "" { + defaultMapPaths = append(defaultMapPaths, strings.Split(prodMaps, " ")...) + } + return defaultMapPaths +} diff --git a/cmd/release_config/release_config_proto/Android.bp b/cmd/release_config/release_config_proto/Android.bp index a8660c753..5a6aeab54 100644 --- a/cmd/release_config/release_config_proto/Android.bp +++ b/cmd/release_config/release_config_proto/Android.bp @@ -17,7 +17,7 @@ package { } bootstrap_go_package { - name: "soong-release_config_proto", + name: "soong-cmd-release_config-proto", pkgPath: "android/soong/release_config/release_config_proto", deps: [ "golang-protobuf-reflect-protoreflect", From a3b89b8fdfd10c64794a340569f8e0efc05fa591 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 16 Apr 2024 13:41:25 -0700 Subject: [PATCH 30/67] Add description to release_config_map message Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: Ifff2dc9a2f33595bde9ef57e407bbb4b529f6e08 Change-Id: Ifff2dc9a2f33595bde9ef57e407bbb4b529f6e08 --- .../release_config_lib/release_configs.go | 22 +++++-- .../build_flags_out.pb.go | 63 ++++++++++++++----- .../build_flags_out.proto | 3 + .../build_flags_src.pb.go | 55 +++++++++------- .../build_flags_src.proto | 3 + 5 files changed, 102 insertions(+), 44 deletions(-) diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 74fdc005f..a609b4d33 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -50,6 +50,9 @@ type ReleaseConfigs struct { // Ordered list of release config maps processed. ReleaseConfigMaps []*ReleaseConfigMap + // Map of directory to *ReleaseConfigMap + ReleaseConfigMapsMap map[string]*ReleaseConfigMap + // Aliases Aliases map[string]*string @@ -95,11 +98,12 @@ func (configs *ReleaseConfigs) DumpArtifact(outDir string) error { func ReleaseConfigsFactory() (c *ReleaseConfigs) { return &ReleaseConfigs{ - Aliases: make(map[string]*string), - FlagArtifacts: make(map[string]*FlagArtifact), - ReleaseConfigs: make(map[string]*ReleaseConfig), - ConfigDirs: []string{}, - ConfigDirIndexes: make(ReleaseConfigDirMap), + Aliases: make(map[string]*string), + FlagArtifacts: make(map[string]*FlagArtifact), + ReleaseConfigs: make(map[string]*ReleaseConfig), + ReleaseConfigMapsMap: make(map[string]*ReleaseConfigMap), + ConfigDirs: []string{}, + ConfigDirIndexes: make(ReleaseConfigDirMap), } } @@ -197,6 +201,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex return err } configs.ReleaseConfigMaps = append(configs.ReleaseConfigMaps, m) + configs.ReleaseConfigMapsMap[dir] = m return nil } @@ -332,6 +337,13 @@ func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) erro } return orc }(), + ReleaseConfigMapsMap: func() map[string]*release_config_proto.ReleaseConfigMap { + ret := make(map[string]*release_config_proto.ReleaseConfigMap) + for k, v := range configs.ReleaseConfigMapsMap { + ret[k] = &v.proto + } + return ret + }(), } return nil } diff --git a/cmd/release_config/release_config_proto/build_flags_out.pb.go b/cmd/release_config/release_config_proto/build_flags_out.pb.go index adc1ea4bd..0372d633b 100644 --- a/cmd/release_config/release_config_proto/build_flags_out.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_out.pb.go @@ -259,6 +259,8 @@ type ReleaseConfigsArtifact struct { ReleaseConfig *ReleaseConfigArtifact `protobuf:"bytes,1,opt,name=release_config,json=releaseConfig" json:"release_config,omitempty"` // All other release configs defined for this TARGET_PRODUCT. OtherReleaseConfigs []*ReleaseConfigArtifact `protobuf:"bytes,2,rep,name=other_release_configs,json=otherReleaseConfigs" json:"other_release_configs,omitempty"` + // Map of release_config_artifact.directories to release_config_map message. + ReleaseConfigMapsMap map[string]*ReleaseConfigMap `protobuf:"bytes,3,rep,name=release_config_maps_map,json=releaseConfigMapsMap" json:"release_config_maps_map,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` } func (x *ReleaseConfigsArtifact) Reset() { @@ -307,6 +309,13 @@ func (x *ReleaseConfigsArtifact) GetOtherReleaseConfigs() []*ReleaseConfigArtifa return nil } +func (x *ReleaseConfigsArtifact) GetReleaseConfigMapsMap() map[string]*ReleaseConfigMap { + if x != nil { + return x.ReleaseConfigMapsMap + } + return nil +} + var File_build_flags_out_proto protoreflect.FileDescriptor var file_build_flags_out_proto_rawDesc = []byte{ @@ -352,7 +361,7 @@ var file_build_flags_out_proto_rawDesc = []byte{ 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x22, 0xe3, 0x01, 0x0a, 0x18, 0x72, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x22, 0xe8, 0x03, 0x0a, 0x18, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x5c, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, @@ -367,10 +376,26 @@ var file_build_flags_out_proto_rawDesc = []byte{ 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x13, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, - 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, - 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x87, 0x01, 0x0a, 0x17, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x73, 0x5f, 0x6d, 0x61, 0x70, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x50, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x73, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, 0x61, 0x70, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x52, 0x14, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, 0x61, 0x70, 0x1a, 0x79, 0x0a, 0x19, 0x52, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, + 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x46, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, + 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, + 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, } var ( @@ -385,28 +410,32 @@ func file_build_flags_out_proto_rawDescGZIP() []byte { return file_build_flags_out_proto_rawDescData } -var file_build_flags_out_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_build_flags_out_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_build_flags_out_proto_goTypes = []interface{}{ (*Tracepoint)(nil), // 0: android.release_config_proto.tracepoint (*FlagArtifact)(nil), // 1: android.release_config_proto.flag_artifact (*ReleaseConfigArtifact)(nil), // 2: android.release_config_proto.release_config_artifact (*ReleaseConfigsArtifact)(nil), // 3: android.release_config_proto.release_configs_artifact - (*Value)(nil), // 4: android.release_config_proto.value - (*FlagDeclaration)(nil), // 5: android.release_config_proto.flag_declaration + nil, // 4: android.release_config_proto.release_configs_artifact.ReleaseConfigMapsMapEntry + (*Value)(nil), // 5: android.release_config_proto.value + (*FlagDeclaration)(nil), // 6: android.release_config_proto.flag_declaration + (*ReleaseConfigMap)(nil), // 7: android.release_config_proto.release_config_map } var file_build_flags_out_proto_depIdxs = []int32{ - 4, // 0: android.release_config_proto.tracepoint.value:type_name -> android.release_config_proto.value - 5, // 1: android.release_config_proto.flag_artifact.flag_declaration:type_name -> android.release_config_proto.flag_declaration - 4, // 2: android.release_config_proto.flag_artifact.value:type_name -> android.release_config_proto.value + 5, // 0: android.release_config_proto.tracepoint.value:type_name -> android.release_config_proto.value + 6, // 1: android.release_config_proto.flag_artifact.flag_declaration:type_name -> android.release_config_proto.flag_declaration + 5, // 2: android.release_config_proto.flag_artifact.value:type_name -> android.release_config_proto.value 0, // 3: android.release_config_proto.flag_artifact.traces:type_name -> android.release_config_proto.tracepoint 1, // 4: android.release_config_proto.release_config_artifact.flag_artifacts:type_name -> android.release_config_proto.flag_artifact 2, // 5: android.release_config_proto.release_configs_artifact.release_config:type_name -> android.release_config_proto.release_config_artifact 2, // 6: android.release_config_proto.release_configs_artifact.other_release_configs:type_name -> android.release_config_proto.release_config_artifact - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 4, // 7: android.release_config_proto.release_configs_artifact.release_config_maps_map:type_name -> android.release_config_proto.release_configs_artifact.ReleaseConfigMapsMapEntry + 7, // 8: android.release_config_proto.release_configs_artifact.ReleaseConfigMapsMapEntry.value:type_name -> android.release_config_proto.release_config_map + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_build_flags_out_proto_init() } @@ -471,7 +500,7 @@ func file_build_flags_out_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_build_flags_out_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/cmd/release_config/release_config_proto/build_flags_out.proto b/cmd/release_config/release_config_proto/build_flags_out.proto index fd8487bd4..05e770f3e 100644 --- a/cmd/release_config/release_config_proto/build_flags_out.proto +++ b/cmd/release_config/release_config_proto/build_flags_out.proto @@ -82,5 +82,8 @@ message release_configs_artifact { // All other release configs defined for this TARGET_PRODUCT. repeated release_config_artifact other_release_configs = 2; + + // Map of release_config_artifact.directories to release_config_map message. + map release_config_maps_map = 3; } diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go index ccf3b3f14..d0c924dae 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go @@ -568,6 +568,8 @@ type ReleaseConfigMap struct { // Any aliases. Aliases []*ReleaseAlias `protobuf:"bytes,1,rep,name=aliases" json:"aliases,omitempty"` + // Description of this map and its intended use. + Description *string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` // The default container for flags declared here. DefaultContainer *Container `protobuf:"varint,3,opt,name=default_container,json=defaultContainer,enum=android.release_config_proto.Container" json:"default_container,omitempty"` } @@ -611,6 +613,13 @@ func (x *ReleaseConfigMap) GetAliases() []*ReleaseAlias { return nil } +func (x *ReleaseConfigMap) GetDescription() string { + if x != nil && x.Description != nil { + return *x.Description + } + return "" +} + func (x *ReleaseConfigMap) GetDefaultContainer() Container { if x != nil && x.DefaultContainer != nil { return *x.DefaultContainer @@ -671,33 +680,35 @@ var file_build_flags_src_proto_rawDesc = []byte{ 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xb1, 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, + 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xd3, 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x52, 0x07, 0x61, - 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x54, 0x0a, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, - 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x27, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x10, 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2a, 0x4a, 0x0a, 0x08, - 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, - 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, 0x0c, - 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, - 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x2a, 0x64, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x74, - 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, - 0x46, 0x49, 0x45, 0x44, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x10, 0x00, - 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x4f, - 0x44, 0x55, 0x43, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, - 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x58, 0x54, - 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x10, 0x05, 0x42, 0x33, - 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, - 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, + 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x54, 0x0a, 0x11, 0x64, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x10, 0x64, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2a, 0x4a, + 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, + 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, + 0x6f, 0x77, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, + 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, + 0x0a, 0x06, 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x2a, 0x64, 0x0a, 0x09, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x4e, 0x53, 0x50, 0x45, + 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, + 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, + 0x52, 0x4f, 0x44, 0x55, 0x43, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x59, 0x53, 0x54, + 0x45, 0x4d, 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, + 0x58, 0x54, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x10, 0x05, + 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, + 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, } var ( diff --git a/cmd/release_config/release_config_proto/build_flags_src.proto b/cmd/release_config/release_config_proto/build_flags_src.proto index 85015248e..c077f5cd8 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.proto +++ b/cmd/release_config/release_config_proto/build_flags_src.proto @@ -144,6 +144,9 @@ message release_config_map { // Any aliases. repeated release_alias aliases = 1; + // Description of this map and its intended use. + optional string description = 2; + // The default container for flags declared here. optional container default_container = 3; From f63c31b3046a2cd4cb7faf36072dfc1b2c1caf38 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 11 Apr 2024 11:50:06 -0700 Subject: [PATCH 31/67] Print a warning on redundant overrides Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I35bff9d6751e9aa304e4c2d7e24b9a44a3994264 Change-Id: I35bff9d6751e9aa304e4c2d7e24b9a44a3994264 --- cmd/release_config/release_config/main.go | 6 ++++++ .../release_config_lib/flag_artifact.go | 11 ++++++++--- cmd/release_config/release_config_lib/util.go | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index 076abfaaf..4870f259f 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -23,6 +23,7 @@ import ( func main() { var top string + var quiet bool var releaseConfigMapPaths rc_lib.StringList var targetRelease string var outputDir string @@ -30,11 +31,16 @@ func main() { var configs *rc_lib.ReleaseConfigs flag.StringVar(&top, "top", ".", "path to top of workspace") + flag.BoolVar(&quiet, "quiet", false, "disable warning messages") flag.Var(&releaseConfigMapPaths, "map", "path to a release_config_map.textproto. may be repeated") flag.StringVar(&targetRelease, "release", "trunk_staging", "TARGET_RELEASE for this build") flag.StringVar(&outputDir, "out_dir", rc_lib.GetDefaultOutDir(), "basepath for the output. Multiple formats are created") flag.Parse() + if quiet { + rc_lib.DisableWarnings() + } + if err = os.Chdir(top); err != nil { panic(err) } diff --git a/cmd/release_config/release_config_lib/flag_artifact.go b/cmd/release_config/release_config_lib/flag_artifact.go index 51673a5ec..6d8085dd4 100644 --- a/cmd/release_config/release_config_lib/flag_artifact.go +++ b/cmd/release_config/release_config_lib/flag_artifact.go @@ -64,19 +64,24 @@ func (fa *FlagArtifact) UpdateValue(flagValue FlagValue) error { if fa.Value.GetObsolete() { return fmt.Errorf("Attempting to set obsolete flag %s. Trace=%v", name, fa.Traces) } + var newValue *release_config_proto.Value switch val := flagValue.proto.Value.Val.(type) { case *release_config_proto.Value_StringValue: - fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_StringValue{val.StringValue}} + newValue = &release_config_proto.Value{Val: &release_config_proto.Value_StringValue{val.StringValue}} case *release_config_proto.Value_BoolValue: - fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_BoolValue{val.BoolValue}} + newValue = &release_config_proto.Value{Val: &release_config_proto.Value_BoolValue{val.BoolValue}} case *release_config_proto.Value_Obsolete: if !val.Obsolete { return fmt.Errorf("%s: Cannot set obsolete=false. Trace=%v", name, fa.Traces) } - fa.Value = &release_config_proto.Value{Val: &release_config_proto.Value_Obsolete{true}} + newValue = &release_config_proto.Value{Val: &release_config_proto.Value_Obsolete{true}} default: return fmt.Errorf("Invalid type for flag_value: %T. Trace=%v", val, fa.Traces) } + if proto.Equal(newValue, fa.Value) { + warnf("%s: redundant override (set in %s)\n", flagValue.path, *fa.Traces[len(fa.Traces)-2].Source) + } + fa.Value = newValue return nil } diff --git a/cmd/release_config/release_config_lib/util.go b/cmd/release_config/release_config_lib/util.go index c59deb337..b04f344af 100644 --- a/cmd/release_config/release_config_lib/util.go +++ b/cmd/release_config/release_config_lib/util.go @@ -25,6 +25,8 @@ import ( "google.golang.org/protobuf/proto" ) +var disableWarnings bool + type StringList []string func (l *StringList) Set(v string) error { @@ -62,6 +64,18 @@ func WalkTextprotoFiles(root string, subdir string, Func fs.WalkDirFunc) error { }) } +// Turn off all warning output +func DisableWarnings() { + disableWarnings = true +} + +func warnf(format string, args ...any) (n int, err error) { + if !disableWarnings { + return fmt.Printf(format, args...) + } + return 0, nil +} + func GetDefaultOutDir() string { outEnv := os.Getenv("OUT_DIR") if outEnv == "" { From f1af88b06ae3cbfe2c0f6aba1883c8482e025e34 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 17 Apr 2024 11:21:37 -0700 Subject: [PATCH 32/67] release_config: cleanup how we emit results - Allow each of the formats (json, pb, textproto) to be individually controlled. - Include product and release in the name of the aritfact. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: Ia08e7224200a48994bea882a61b8199d53576d38 Change-Id: Ia08e7224200a48994bea882a61b8199d53576d38 --- cmd/release_config/release_config/main.go | 43 +++++- .../release_config_lib/Android.bp | 2 +- .../release_config_lib/flag_artifact.go | 57 +++++--- .../release_config_lib/flag_declaration.go | 8 +- .../release_config_lib/flag_value.go | 33 +++-- .../release_config_lib/release_config.go | 66 +++++++-- .../release_config_lib/release_configs.go | 125 ++++++++++-------- cmd/release_config/release_config_lib/util.go | 60 ++++++++- .../release_config_proto/Android.bp | 2 +- 9 files changed, 291 insertions(+), 105 deletions(-) diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index 4870f259f..a43fdccbe 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -16,7 +16,9 @@ package main import ( "flag" + "fmt" "os" + "path/filepath" rc_lib "android/soong/cmd/release_config/release_config_lib" ) @@ -29,12 +31,23 @@ func main() { var outputDir string var err error var configs *rc_lib.ReleaseConfigs + var json, pb, textproto bool + var product string + + defaultRelease := os.Getenv("TARGET_RELEASE") + if defaultRelease == "" { + defaultRelease = "trunk_staging" + } flag.StringVar(&top, "top", ".", "path to top of workspace") + flag.StringVar(&product, "product", os.Getenv("TARGET_PRODUCT"), "TARGET_PRODUCT for the build") flag.BoolVar(&quiet, "quiet", false, "disable warning messages") flag.Var(&releaseConfigMapPaths, "map", "path to a release_config_map.textproto. may be repeated") - flag.StringVar(&targetRelease, "release", "trunk_staging", "TARGET_RELEASE for this build") + flag.StringVar(&targetRelease, "release", defaultRelease, "TARGET_RELEASE for this build") flag.StringVar(&outputDir, "out_dir", rc_lib.GetDefaultOutDir(), "basepath for the output. Multiple formats are created") + flag.BoolVar(&textproto, "textproto", true, "write artifacts as text protobuf") + flag.BoolVar(&json, "json", true, "write artifacts as json") + flag.BoolVar(&pb, "pb", true, "write artifacts as binary protobuf") flag.Parse() if quiet { @@ -48,16 +61,36 @@ func main() { if err != nil { panic(err) } + config, err := configs.GetReleaseConfig(targetRelease) + if err != nil { + panic(err) + } + releaseName := config.Name err = os.MkdirAll(outputDir, 0775) if err != nil { panic(err) } - err = configs.DumpMakefile(outputDir, targetRelease) + makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, releaseName)) + err = configs.WriteMakefile(makefilePath, targetRelease) if err != nil { panic(err) } - err = configs.DumpArtifact(outputDir) - if err != nil { - panic(err) + if json { + err = configs.WriteArtifact(outputDir, product, "json") + if err != nil { + panic(err) + } + } + if pb { + err = configs.WriteArtifact(outputDir, product, "pb") + if err != nil { + panic(err) + } + } + if textproto { + err = configs.WriteArtifact(outputDir, product, "textproto") + if err != nil { + panic(err) + } } } diff --git a/cmd/release_config/release_config_lib/Android.bp b/cmd/release_config/release_config_lib/Android.bp index 601194c93..0c67e1106 100644 --- a/cmd/release_config/release_config_lib/Android.bp +++ b/cmd/release_config/release_config_lib/Android.bp @@ -18,7 +18,7 @@ package { bootstrap_go_package { name: "soong-cmd-release_config-lib", - pkgPath: "android/soong/release_config/release_config_lib", + pkgPath: "android/soong/cmd/release_config/release_config_lib", deps: [ "golang-protobuf-encoding-prototext", "golang-protobuf-reflect-protoreflect", diff --git a/cmd/release_config/release_config_lib/flag_artifact.go b/cmd/release_config/release_config_lib/flag_artifact.go index 6d8085dd4..4446655f7 100644 --- a/cmd/release_config/release_config_lib/flag_artifact.go +++ b/cmd/release_config/release_config_lib/flag_artifact.go @@ -17,29 +17,37 @@ package release_config_lib import ( "fmt" - "android/soong/cmd/release_config/release_config_proto" + rc_proto "android/soong/cmd/release_config/release_config_proto" "google.golang.org/protobuf/proto" ) +// A flag artifact, with its final value and declaration/override history. type FlagArtifact struct { - FlagDeclaration *release_config_proto.FlagDeclaration + // The flag_declaration message. + FlagDeclaration *rc_proto.FlagDeclaration // The index of the config directory where this flag was declared. // Flag values cannot be set in a location with a lower index. DeclarationIndex int - Traces []*release_config_proto.Tracepoint + // A history of value assignments and overrides. + Traces []*rc_proto.Tracepoint - // Assigned value - Value *release_config_proto.Value + // The value of the flag. + Value *rc_proto.Value } // Key is flag name. type FlagArtifacts map[string]*FlagArtifact +// Create a clone of the flag artifact. +// +// Returns: +// +// *FlagArtifact: the copy of the artifact. func (src *FlagArtifact) Clone() *FlagArtifact { - value := &release_config_proto.Value{} + value := &rc_proto.Value{} proto.Merge(value, src.Value) return &FlagArtifact{ FlagDeclaration: src.FlagDeclaration, @@ -48,6 +56,11 @@ func (src *FlagArtifact) Clone() *FlagArtifact { } } +// Clone FlagArtifacts. +// +// Returns: +// +// FlagArtifacts: a copy of the source FlagArtifacts. func (src FlagArtifacts) Clone() (dst FlagArtifacts) { if dst == nil { dst = make(FlagArtifacts) @@ -58,23 +71,34 @@ func (src FlagArtifacts) Clone() (dst FlagArtifacts) { return } +// Update the value of a flag. +// +// This appends to flagArtifact.Traces, and updates flagArtifact.Value. +// +// Args: +// +// flagValue FlagValue: the value to assign +// +// Returns: +// +// error: any error encountered func (fa *FlagArtifact) UpdateValue(flagValue FlagValue) error { name := *flagValue.proto.Name - fa.Traces = append(fa.Traces, &release_config_proto.Tracepoint{Source: proto.String(flagValue.path), Value: flagValue.proto.Value}) + fa.Traces = append(fa.Traces, &rc_proto.Tracepoint{Source: proto.String(flagValue.path), Value: flagValue.proto.Value}) if fa.Value.GetObsolete() { return fmt.Errorf("Attempting to set obsolete flag %s. Trace=%v", name, fa.Traces) } - var newValue *release_config_proto.Value + var newValue *rc_proto.Value switch val := flagValue.proto.Value.Val.(type) { - case *release_config_proto.Value_StringValue: - newValue = &release_config_proto.Value{Val: &release_config_proto.Value_StringValue{val.StringValue}} - case *release_config_proto.Value_BoolValue: - newValue = &release_config_proto.Value{Val: &release_config_proto.Value_BoolValue{val.BoolValue}} - case *release_config_proto.Value_Obsolete: + case *rc_proto.Value_StringValue: + newValue = &rc_proto.Value{Val: &rc_proto.Value_StringValue{val.StringValue}} + case *rc_proto.Value_BoolValue: + newValue = &rc_proto.Value{Val: &rc_proto.Value_BoolValue{val.BoolValue}} + case *rc_proto.Value_Obsolete: if !val.Obsolete { return fmt.Errorf("%s: Cannot set obsolete=false. Trace=%v", name, fa.Traces) } - newValue = &release_config_proto.Value{Val: &release_config_proto.Value_Obsolete{true}} + newValue = &rc_proto.Value{Val: &rc_proto.Value_Obsolete{true}} default: return fmt.Errorf("Invalid type for flag_value: %T. Trace=%v", val, fa.Traces) } @@ -85,8 +109,9 @@ func (fa *FlagArtifact) UpdateValue(flagValue FlagValue) error { return nil } -func (fa *FlagArtifact) Marshal() (*release_config_proto.FlagArtifact, error) { - return &release_config_proto.FlagArtifact{ +// Marshal the FlagArtifact into a flag_artifact message. +func (fa *FlagArtifact) Marshal() (*rc_proto.FlagArtifact, error) { + return &rc_proto.FlagArtifact{ FlagDeclaration: fa.FlagDeclaration, Value: fa.Value, Traces: fa.Traces, diff --git a/cmd/release_config/release_config_lib/flag_declaration.go b/cmd/release_config/release_config_lib/flag_declaration.go index d5cc41845..97d4d4c76 100644 --- a/cmd/release_config/release_config_lib/flag_declaration.go +++ b/cmd/release_config/release_config_lib/flag_declaration.go @@ -15,13 +15,13 @@ package release_config_lib import ( - "android/soong/cmd/release_config/release_config_proto" + rc_proto "android/soong/cmd/release_config/release_config_proto" ) -func FlagDeclarationFactory(protoPath string) (fd *release_config_proto.FlagDeclaration) { - fd = &release_config_proto.FlagDeclaration{} +func FlagDeclarationFactory(protoPath string) (fd *rc_proto.FlagDeclaration) { + fd = &rc_proto.FlagDeclaration{} if protoPath != "" { - LoadTextproto(protoPath, fd) + LoadMessage(protoPath, fd) } return fd } diff --git a/cmd/release_config/release_config_lib/flag_value.go b/cmd/release_config/release_config_lib/flag_value.go index 138e8f8d3..e155e7782 100644 --- a/cmd/release_config/release_config_lib/flag_value.go +++ b/cmd/release_config/release_config_lib/flag_value.go @@ -15,7 +15,9 @@ package release_config_lib import ( - "android/soong/cmd/release_config/release_config_proto" + "strings" + + rc_proto "android/soong/cmd/release_config/release_config_proto" ) type FlagValue struct { @@ -23,31 +25,46 @@ type FlagValue struct { path string // Protobuf - proto release_config_proto.FlagValue + proto rc_proto.FlagValue } func FlagValueFactory(protoPath string) (fv *FlagValue) { fv = &FlagValue{path: protoPath} if protoPath != "" { - LoadTextproto(protoPath, &fv.proto) + LoadMessage(protoPath, &fv.proto) } return fv } -func MarshalValue(value *release_config_proto.Value) string { +func UnmarshalValue(str string) *rc_proto.Value { + ret := &rc_proto.Value{} + switch v := strings.ToLower(str); v { + case "true": + ret = &rc_proto.Value{Val: &rc_proto.Value_BoolValue{true}} + case "false": + ret = &rc_proto.Value{Val: &rc_proto.Value_BoolValue{false}} + case "##obsolete": + ret = &rc_proto.Value{Val: &rc_proto.Value_Obsolete{true}} + default: + ret = &rc_proto.Value{Val: &rc_proto.Value_StringValue{str}} + } + return ret +} + +func MarshalValue(value *rc_proto.Value) string { switch val := value.Val.(type) { - case *release_config_proto.Value_UnspecifiedValue: + case *rc_proto.Value_UnspecifiedValue: // Value was never set. return "" - case *release_config_proto.Value_StringValue: + case *rc_proto.Value_StringValue: return val.StringValue - case *release_config_proto.Value_BoolValue: + case *rc_proto.Value_BoolValue: if val.BoolValue { return "true" } // False ==> empty string return "" - case *release_config_proto.Value_Obsolete: + case *rc_proto.Value_Obsolete: return " #OBSOLETE" default: // Flagged as error elsewhere, so return empty string here. diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index 3110dae81..c67cee54a 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -16,8 +16,9 @@ package release_config_lib import ( "fmt" + "strings" - "android/soong/cmd/release_config/release_config_proto" + rc_proto "android/soong/cmd/release_config/release_config_proto" "google.golang.org/protobuf/proto" ) @@ -33,7 +34,7 @@ type ReleaseConfigContribution struct { DeclarationIndex int // Protobufs relevant to the config. - proto release_config_proto.ReleaseConfig + proto rc_proto.ReleaseConfig FlagValues []*FlagValue } @@ -61,7 +62,7 @@ type ReleaseConfig struct { FlagArtifacts FlagArtifacts // Generated release config - ReleaseConfigArtifact *release_config_proto.ReleaseConfigArtifact + ReleaseConfigArtifact *rc_proto.ReleaseConfigArtifact // We have begun compiling this release config. compileInProgress bool @@ -79,12 +80,18 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro return fmt.Errorf("Loop detected for release config %s", config.Name) } config.compileInProgress = true + isRoot := config.Name == "root" // Generate any configs we need to inherit. This will detect loops in // the config. contributionsToApply := []*ReleaseConfigContribution{} myInherits := []string{} myInheritsSet := make(map[string]bool) + // If there is a "root" release config, it is the start of every inheritance chain. + _, err := configs.GetReleaseConfig("root") + if err == nil && !isRoot { + config.InheritNames = append([]string{"root"}, config.InheritNames...) + } for _, inherit := range config.InheritNames { if _, ok := myInheritsSet[inherit]; ok { continue @@ -101,10 +108,46 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro contributionsToApply = append(contributionsToApply, config.Contributions...) myAconfigValueSets := []string{} + myAconfigValueSetsMap := map[string]bool{} myFlags := configs.FlagArtifacts.Clone() + workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) + container := rc_proto.Container(rc_proto.Container_ALL) + releaseAconfigValueSets := FlagArtifact{ + FlagDeclaration: &rc_proto.FlagDeclaration{ + Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), + Namespace: proto.String("android_UNKNOWN"), + Description: proto.String("Aconfig value sets assembled by release-config"), + Workflow: &workflowManual, + Container: &container, + Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{""}}, + }, + DeclarationIndex: -1, + Traces: []*rc_proto.Tracepoint{ + &rc_proto.Tracepoint{ + Source: proto.String("$release-config"), + Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{""}}, + }, + }, + } + myFlags["RELEASE_ACONFIG_VALUE_SETS"] = &releaseAconfigValueSets myDirsMap := make(map[int]bool) for _, contrib := range contributionsToApply { - myAconfigValueSets = append(myAconfigValueSets, contrib.proto.AconfigValueSets...) + if len(contrib.proto.AconfigValueSets) > 0 { + contribAconfigValueSets := []string{} + for _, v := range contrib.proto.AconfigValueSets { + if _, ok := myAconfigValueSetsMap[v]; !ok { + contribAconfigValueSets = append(contribAconfigValueSets, v) + myAconfigValueSetsMap[v] = true + } + } + myAconfigValueSets = append(myAconfigValueSets, contribAconfigValueSets...) + releaseAconfigValueSets.Traces = append( + releaseAconfigValueSets.Traces, + &rc_proto.Tracepoint{ + Source: proto.String(contrib.path), + Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.Join(contribAconfigValueSets, " ")}}, + }) + } myDirsMap[contrib.DeclarationIndex] = true for _, value := range contrib.FlagValues { fa, ok := myFlags[*value.proto.Name] @@ -116,27 +159,32 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro // Setting location is to the left of declaration. return fmt.Errorf("Setting value for flag %s not allowed in %s\n", *value.proto.Name, value.path) } + if isRoot && *fa.FlagDeclaration.Workflow != workflowManual { + // The "root" release config can only contain workflow: MANUAL flags. + return fmt.Errorf("Setting value for non-MANUAL flag %s is not allowed in %s", *value.proto.Name, value.path) + } if err := fa.UpdateValue(*value); err != nil { return err } } } + releaseAconfigValueSets.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.Join(myAconfigValueSets, " ")}} directories := []string{} - for idx, confDir := range configs.ConfigDirs { + for idx, confDir := range configs.configDirs { if _, ok := myDirsMap[idx]; ok { directories = append(directories, confDir) } } config.FlagArtifacts = myFlags - config.ReleaseConfigArtifact = &release_config_proto.ReleaseConfigArtifact{ + config.ReleaseConfigArtifact = &rc_proto.ReleaseConfigArtifact{ Name: proto.String(config.Name), OtherNames: config.OtherNames, - FlagArtifacts: func() []*release_config_proto.FlagArtifact { - ret := []*release_config_proto.FlagArtifact{} + FlagArtifacts: func() []*rc_proto.FlagArtifact { + ret := []*rc_proto.FlagArtifact{} for _, flag := range myFlags { - ret = append(ret, &release_config_proto.FlagArtifact{ + ret = append(ret, &rc_proto.FlagArtifact{ FlagDeclaration: flag.FlagDeclaration, Traces: flag.Traces, Value: flag.Value, diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index a609b4d33..6efdb2f08 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -16,7 +16,6 @@ package release_config_lib import ( "cmp" - "encoding/json" "fmt" "io/fs" "os" @@ -24,9 +23,8 @@ import ( "slices" "strings" - "android/soong/cmd/release_config/release_config_proto" + rc_proto "android/soong/cmd/release_config/release_config_proto" - "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" ) @@ -37,10 +35,13 @@ type ReleaseConfigMap struct { path string // Data received - proto release_config_proto.ReleaseConfigMap + proto rc_proto.ReleaseConfigMap + // Map of name:contribution for release config contributions. ReleaseConfigContributions map[string]*ReleaseConfigContribution - FlagDeclarations []release_config_proto.FlagDeclaration + + // Flags declared this directory's flag_declarations/*.textproto + FlagDeclarations []rc_proto.FlagDeclaration } type ReleaseConfigDirMap map[string]int @@ -50,50 +51,47 @@ type ReleaseConfigs struct { // Ordered list of release config maps processed. ReleaseConfigMaps []*ReleaseConfigMap - // Map of directory to *ReleaseConfigMap - ReleaseConfigMapsMap map[string]*ReleaseConfigMap - // Aliases Aliases map[string]*string // Dictionary of flag_name:FlagDeclaration, with no overrides applied. FlagArtifacts FlagArtifacts + // Generated release configs artifact + Artifact rc_proto.ReleaseConfigsArtifact + // Dictionary of name:ReleaseConfig + // Use `GetReleaseConfigs(name)` to get a release config. ReleaseConfigs map[string]*ReleaseConfig - // Generated release configs - Artifact release_config_proto.ReleaseConfigsArtifact + // Map of directory to *ReleaseConfigMap + releaseConfigMapsMap map[string]*ReleaseConfigMap // The list of config directories used. - ConfigDirs []string + configDirs []string // A map from the config directory to its order in the list of config // directories. - ConfigDirIndexes ReleaseConfigDirMap + configDirIndexes ReleaseConfigDirMap } -func (configs *ReleaseConfigs) DumpArtifact(outDir string) error { - message := &configs.Artifact - basePath := filepath.Join(outDir, "all_release_configs") - writer := func(suffix string, marshal func() ([]byte, error)) error { - data, err := marshal() - if err != nil { - return err - } - return os.WriteFile(fmt.Sprintf("%s.%s", basePath, suffix), data, 0644) - } - err := writer("textproto", func() ([]byte, error) { return prototext.MarshalOptions{Multiline: true}.Marshal(message) }) - if err != nil { - return err - } - - err = writer("pb", func() ([]byte, error) { return proto.Marshal(message) }) - if err != nil { - return err - } - - return writer("json", func() ([]byte, error) { return json.MarshalIndent(message, "", " ") }) +// Write the "all_release_configs" artifact. +// +// The file will be in "{outDir}/all_release_configs-{product}.{format}" +// +// Args: +// +// outDir string: directory path. Will be created if not present. +// product string: TARGET_PRODUCT for the release_configs. +// format string: one of "json", "pb", or "textproto" +// +// Returns: +// +// error: Any error encountered. +func (configs *ReleaseConfigs) WriteArtifact(outDir, product, format string) error { + return WriteMessage( + filepath.Join(outDir, fmt.Sprintf("all_release_configs-%s.%s", product, format)), + &configs.Artifact) } func ReleaseConfigsFactory() (c *ReleaseConfigs) { @@ -101,9 +99,9 @@ func ReleaseConfigsFactory() (c *ReleaseConfigs) { Aliases: make(map[string]*string), FlagArtifacts: make(map[string]*FlagArtifact), ReleaseConfigs: make(map[string]*ReleaseConfig), - ReleaseConfigMapsMap: make(map[string]*ReleaseConfigMap), - ConfigDirs: []string{}, - ConfigDirIndexes: make(ReleaseConfigDirMap), + releaseConfigMapsMap: make(map[string]*ReleaseConfigMap), + configDirs: []string{}, + configDirIndexes: make(ReleaseConfigDirMap), } } @@ -113,7 +111,7 @@ func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { ReleaseConfigContributions: make(map[string]*ReleaseConfigContribution), } if protoPath != "" { - LoadTextproto(protoPath, &m.proto) + LoadMessage(protoPath, &m.proto) } return m } @@ -149,7 +147,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex } // If the input didn't specify a value, create one (== UnspecifiedValue). if flagDeclaration.Value == nil { - flagDeclaration.Value = &release_config_proto.Value{Val: &release_config_proto.Value_UnspecifiedValue{false}} + flagDeclaration.Value = &rc_proto.Value{Val: &rc_proto.Value_UnspecifiedValue{false}} } m.FlagDeclarations = append(m.FlagDeclarations, *flagDeclaration) name := *flagDeclaration.Name @@ -160,7 +158,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex } // Set the initial value in the flag artifact. configs.FlagArtifacts[name].UpdateValue( - FlagValue{path: path, proto: release_config_proto.FlagValue{ + FlagValue{path: path, proto: rc_proto.FlagValue{ Name: proto.String(name), Value: flagDeclaration.Value}}) return nil }) @@ -170,7 +168,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex err = WalkTextprotoFiles(dir, "release_configs", func(path string, d fs.DirEntry, err error) error { releaseConfigContribution := &ReleaseConfigContribution{path: path, DeclarationIndex: ConfigDirIndex} - LoadTextproto(path, &releaseConfigContribution.proto) + LoadMessage(path, &releaseConfigContribution.proto) name := *releaseConfigContribution.proto.Name if fmt.Sprintf("%s.textproto", name) != filepath.Base(path) { return fmt.Errorf("%s incorrectly declares release config %s", path, name) @@ -201,7 +199,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex return err } configs.ReleaseConfigMaps = append(configs.ReleaseConfigMaps, m) - configs.ReleaseConfigMapsMap[dir] = m + configs.releaseConfigMapsMap[dir] = m return nil } @@ -217,16 +215,23 @@ func (configs *ReleaseConfigs) GetReleaseConfig(name string) (*ReleaseConfig, er return nil, fmt.Errorf("Missing config %s. Trace=%v", name, trace) } -func (configs *ReleaseConfigs) DumpMakefile(outDir, targetRelease string) error { - outFile := filepath.Join(outDir, "release_config.mk") +// Write the makefile for this targetRelease. +func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) error { makeVars := make(map[string]string) + var allReleaseNames []string + for _, v := range configs.ReleaseConfigs { + allReleaseNames = append(allReleaseNames, v.Name) + allReleaseNames = append(allReleaseNames, v.OtherNames...) + } config, err := configs.GetReleaseConfig(targetRelease) if err != nil { return err } + + myFlagArtifacts := config.FlagArtifacts.Clone() // Sort the flags by name first. names := []string{} - for k, _ := range config.FlagArtifacts { + for k, _ := range myFlagArtifacts { names = append(names, k) } slices.SortFunc(names, func(a, b string) int { @@ -242,12 +247,12 @@ func (configs *ReleaseConfigs) DumpMakefile(outDir, targetRelease string) error } for _, name := range names { - flag := config.FlagArtifacts[name] + flag := myFlagArtifacts[name] decl := flag.FlagDeclaration - // cName := strings.ToLower(release_config_proto.Container_name[decl.GetContainer()]) + // cName := strings.ToLower(rc_proto.Container_name[decl.GetContainer()]) cName := strings.ToLower(decl.Container.String()) - if cName == strings.ToLower(release_config_proto.Container_ALL.String()) { + if cName == strings.ToLower(rc_proto.Container_ALL.String()) { partitions["product"] = append(partitions["product"], name) partitions["system"] = append(partitions["system"], name) partitions["system_ext"] = append(partitions["system_ext"], name) @@ -282,7 +287,13 @@ func (configs *ReleaseConfigs) DumpMakefile(outDir, targetRelease string) error // _ALL_RELEASE_FLAGS.PARTITIONS.* // all _ALL_RELEASE_FLAGS.*, sorted by name // Final flag values, sorted by name. - data := fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " ")) + data := fmt.Sprintf("# TARGET_RELEASE=%s\n", config.Name) + if targetRelease != config.Name { + data += fmt.Sprintf("# User specified TARGET_RELEASE=%s\n", targetRelease) + } + // The variable _all_release_configs will get deleted during processing, so do not mark it read-only. + data += fmt.Sprintf("_all_release_configs := %s\n", strings.Join(allReleaseNames, " ")) + data += fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " ")) for _, pName := range pNames { data += fmt.Sprintf("_ALL_RELEASE_FLAGS.PARTITIONS.%s :=$= %s\n", pName, strings.Join(partitions[pName], " ")) } @@ -290,8 +301,6 @@ func (configs *ReleaseConfigs) DumpMakefile(outDir, targetRelease string) error data += fmt.Sprintf("%s :=$= %s\n", vName, makeVars[vName]) } data += "\n\n# Values for all build flags\n" - data += fmt.Sprintf("RELEASE_ACONFIG_VALUE_SETS :=$= %s\n", - strings.Join(config.ReleaseConfigArtifact.AconfigValueSets, " ")) for _, name := range names { data += fmt.Sprintf("%s :=$= %s\n", name, makeVars[name]) } @@ -326,10 +335,10 @@ func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) erro if err != nil { return err } - configs.Artifact = release_config_proto.ReleaseConfigsArtifact{ + configs.Artifact = rc_proto.ReleaseConfigsArtifact{ ReleaseConfig: releaseConfig.ReleaseConfigArtifact, - OtherReleaseConfigs: func() []*release_config_proto.ReleaseConfigArtifact { - orc := []*release_config_proto.ReleaseConfigArtifact{} + OtherReleaseConfigs: func() []*rc_proto.ReleaseConfigArtifact { + orc := []*rc_proto.ReleaseConfigArtifact{} for name, config := range configs.ReleaseConfigs { if name != releaseConfig.Name { orc = append(orc, config.ReleaseConfigArtifact) @@ -337,9 +346,9 @@ func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) erro } return orc }(), - ReleaseConfigMapsMap: func() map[string]*release_config_proto.ReleaseConfigMap { - ret := make(map[string]*release_config_proto.ReleaseConfigMap) - for k, v := range configs.ReleaseConfigMapsMap { + ReleaseConfigMapsMap: func() map[string]*rc_proto.ReleaseConfigMap { + ret := make(map[string]*rc_proto.ReleaseConfigMap) + for k, v := range configs.releaseConfigMapsMap { ret[k] = &v.proto } return ret @@ -363,8 +372,8 @@ func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease strin for idx, releaseConfigMapPath := range releaseConfigMapPaths { // Maintain an ordered list of release config directories. configDir := filepath.Dir(releaseConfigMapPath) - configs.ConfigDirIndexes[configDir] = idx - configs.ConfigDirs = append(configs.ConfigDirs, configDir) + configs.configDirIndexes[configDir] = idx + configs.configDirs = append(configs.configDirs, configDir) err = configs.LoadReleaseConfigMap(releaseConfigMapPath, idx) if err != nil { return nil, err diff --git a/cmd/release_config/release_config_lib/util.go b/cmd/release_config/release_config_lib/util.go index b04f344af..86940da68 100644 --- a/cmd/release_config/release_config_lib/util.go +++ b/cmd/release_config/release_config_lib/util.go @@ -15,6 +15,7 @@ package release_config_lib import ( + "encoding/json" "fmt" "io/fs" "os" @@ -38,15 +39,66 @@ func (l *StringList) String() string { return fmt.Sprintf("%v", *l) } -func LoadTextproto(path string, message proto.Message) error { +// Write a marshalled message to a file. +// +// Marshal the message based on the extension of the path we are writing it to. +// +// Args: +// +// path string: the path of the file to write to. Directories are not created. +// Supported extensions are: ".json", ".pb", and ".textproto". +// message proto.Message: the message to write. +// +// Returns: +// +// error: any error encountered. +func WriteMessage(path string, message proto.Message) (err error) { + var data []byte + switch filepath.Ext(path) { + case ".json": + data, err = json.MarshalIndent(message, "", " ") + case ".pb": + data, err = proto.Marshal(message) + case ".textproto": + data, err = prototext.MarshalOptions{Multiline: true}.Marshal(message) + default: + return fmt.Errorf("Unknown message format for %s", path) + } + if err != nil { + return err + } + return os.WriteFile(path, data, 0644) +} + +// Read a message from a file. +// +// The message is unmarshalled based on the extension of the file read. +// +// Args: +// +// path string: the path of the file to read. +// message proto.Message: the message to unmarshal the message into. +// +// Returns: +// +// error: any error encountered. +func LoadMessage(path string, message proto.Message) error { data, err := os.ReadFile(path) if err != nil { return err } - ret := prototext.Unmarshal(data, message) - return ret + switch filepath.Ext(path) { + case ".json": + return json.Unmarshal(data, message) + case ".pb": + return proto.Unmarshal(data, message) + case ".textproto": + return prototext.Unmarshal(data, message) + } + return fmt.Errorf("Unknown message format for %s", path) } +// Call Func for any textproto files found in {root}/{subdir}. func WalkTextprotoFiles(root string, subdir string, Func fs.WalkDirFunc) error { path := filepath.Join(root, subdir) if _, err := os.Stat(path); err != nil { @@ -76,6 +128,7 @@ func warnf(format string, args ...any) (n int, err error) { return 0, nil } +// Returns the default value for release config artifacts. func GetDefaultOutDir() string { outEnv := os.Getenv("OUT_DIR") if outEnv == "" { @@ -84,6 +137,7 @@ func GetDefaultOutDir() string { return filepath.Join(outEnv, "soong", "release-config") } +// Return the default list of map files to use. func GetDefaultMapPaths() StringList { var defaultMapPaths StringList defaultLocations := StringList{ diff --git a/cmd/release_config/release_config_proto/Android.bp b/cmd/release_config/release_config_proto/Android.bp index 5a6aeab54..8c47f2ac0 100644 --- a/cmd/release_config/release_config_proto/Android.bp +++ b/cmd/release_config/release_config_proto/Android.bp @@ -18,7 +18,7 @@ package { bootstrap_go_package { name: "soong-cmd-release_config-proto", - pkgPath: "android/soong/release_config/release_config_proto", + pkgPath: "android/soong/cmd/release_config/release_config_proto", deps: [ "golang-protobuf-reflect-protoreflect", "golang-protobuf-runtime-protoimpl", From 9fe184b1c458a0793de3ec79e06faa50b0005e9c Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 11 Apr 2024 17:41:15 -0700 Subject: [PATCH 33/67] Add crunch-flags and build-flag binaries - crunch-flags automates converting build flags from starlark to protobuf. - build-flag is used to set, get and trace flag values. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I941a4420a8bdfa2df73d94e52b3f34a6d1ea3278 Change-Id: I941a4420a8bdfa2df73d94e52b3f34a6d1ea3278 --- cmd/release_config/build_flag/Android.bp | 32 ++ cmd/release_config/build_flag/main.go | 229 +++++++++++++ cmd/release_config/crunch_flags/Android.bp | 32 ++ cmd/release_config/crunch_flags/main.go | 359 +++++++++++++++++++++ 4 files changed, 652 insertions(+) create mode 100644 cmd/release_config/build_flag/Android.bp create mode 100644 cmd/release_config/build_flag/main.go create mode 100644 cmd/release_config/crunch_flags/Android.bp create mode 100644 cmd/release_config/crunch_flags/main.go diff --git a/cmd/release_config/build_flag/Android.bp b/cmd/release_config/build_flag/Android.bp new file mode 100644 index 000000000..0f10c91cb --- /dev/null +++ b/cmd/release_config/build_flag/Android.bp @@ -0,0 +1,32 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +blueprint_go_binary { + name: "build-flag", + deps: [ + "golang-protobuf-encoding-prototext", + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + "soong-cmd-release_config-proto", + "soong-cmd-release_config-lib", + ], + srcs: [ + "main.go", + ], +} + +bootstrap_go_package { + name: "soong-cmd-release_config-build_flag", + pkgPath: "android/soong/cmd/release_config/build_flag", + deps: [ + "golang-protobuf-encoding-prototext", + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + "soong-cmd-release_config-proto", + "soong-cmd-release_config-lib", + ], + srcs: [ + "main.go", + ], +} diff --git a/cmd/release_config/build_flag/main.go b/cmd/release_config/build_flag/main.go new file mode 100644 index 000000000..6f909af86 --- /dev/null +++ b/cmd/release_config/build_flag/main.go @@ -0,0 +1,229 @@ +package main + +import ( + "flag" + "fmt" + "os" + "path/filepath" + "strings" + + rc_lib "android/soong/cmd/release_config/release_config_lib" + rc_proto "android/soong/cmd/release_config/release_config_proto" + + "google.golang.org/protobuf/proto" +) + +type Flags struct { + // The path to the top of the workspace. Default: ".". + top string + + // Pathlist of release config map textproto files. + // If not specified, then the value is (if present): + // - build/release/release_config_map.textproto + // - vendor/google_shared/build/release/release_config_map.textproto + // - vendor/google/release/release_config_map.textproto + // + // Additionally, any maps specified in the environment variable + // `PRODUCT_RELEASE_CONFIG_MAPS` are used. + maps rc_lib.StringList + + // Output directory (relative to `top`). + outDir string + + // Which $TARGET_RELEASE(s) should we use. Some commands will only + // accept one value, others also accept `--release --all`. + targetReleases rc_lib.StringList + + // Disable warning messages + quiet bool +} + +type CommandFunc func(*rc_lib.ReleaseConfigs, Flags, string, []string) error + +var commandMap map[string]CommandFunc = map[string]CommandFunc{ + "get": GetCommand, + "set": SetCommand, + "trace": GetCommand, // Also handled by GetCommand +} + +// Find the top of the release config contribution directory. +// Returns the parent of the flag_declarations and flag_values directories. +func GetMapDir(path string) (string, error) { + for p := path; p != "."; p = filepath.Dir(p) { + switch filepath.Base(p) { + case "flag_declarations": + return filepath.Dir(p), nil + case "flag_values": + return filepath.Dir(p), nil + } + } + return "", fmt.Errorf("Could not determine directory from %s", path) +} + +func MarshalFlagValue(config *rc_lib.ReleaseConfig, name string) (ret string, err error) { + fa, ok := config.FlagArtifacts[name] + if !ok { + return "", fmt.Errorf("%s not found in %s", name, config.Name) + } + return rc_lib.MarshalValue(fa.Value), nil +} + +func GetReleaseArgs(configs *rc_lib.ReleaseConfigs, commonFlags Flags) ([]*rc_lib.ReleaseConfig, error) { + var all bool + relFlags := flag.NewFlagSet("set", flag.ExitOnError) + relFlags.BoolVar(&all, "all", false, "Display all flags") + relFlags.Parse(commonFlags.targetReleases) + var ret []*rc_lib.ReleaseConfig + if all { + for _, config := range configs.ReleaseConfigs { + ret = append(ret, config) + } + return ret, nil + } + for _, arg := range relFlags.Args() { + config, err := configs.GetReleaseConfig(arg) + if err != nil { + return nil, err + } + ret = append(ret, config) + } + return ret, nil +} + +func GetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, args []string) error { + isTrace := cmd == "trace" + var all bool + getFlags := flag.NewFlagSet("set", flag.ExitOnError) + getFlags.BoolVar(&all, "all", false, "Display all flags") + getFlags.Parse(args) + args = getFlags.Args() + + releaseConfigList, err := GetReleaseArgs(configs, commonFlags) + if err != nil { + return err + } + if isTrace && len(releaseConfigList) > 1 { + return fmt.Errorf("trace command only allows one --release argument. Got: %s", strings.Join(commonFlags.targetReleases, " ")) + } + + if all { + args = []string{} + for _, fa := range configs.FlagArtifacts { + args = append(args, *fa.FlagDeclaration.Name) + } + } + + showName := len(releaseConfigList) > 1 || len(args) > 1 + for _, config := range releaseConfigList { + var configName string + if len(releaseConfigList) > 1 { + configName = fmt.Sprintf("%s.", config.Name) + } + for _, arg := range args { + val, err := MarshalFlagValue(config, arg) + if err != nil { + return err + } + if showName { + fmt.Printf("%s%s=%s\n", configName, arg, val) + } else { + fmt.Printf("%s\n", val) + } + if isTrace { + for _, trace := range config.FlagArtifacts[arg].Traces { + fmt.Printf(" => \"%s\" in %s\n", rc_lib.MarshalValue(trace.Value), *trace.Source) + } + } + } + } + return nil +} + +func SetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, args []string) error { + var valueDir string + if len(commonFlags.targetReleases) > 1 { + return fmt.Errorf("set command only allows one --release argument. Got: %s", strings.Join(commonFlags.targetReleases, " ")) + } + targetRelease := commonFlags.targetReleases[0] + + setFlags := flag.NewFlagSet("set", flag.ExitOnError) + setFlags.StringVar(&valueDir, "dir", "", "Directory in which to place the value") + setFlags.Parse(args) + setArgs := setFlags.Args() + if len(setArgs) != 2 { + return fmt.Errorf("set command expected flag and value, got: %s", strings.Join(setArgs, " ")) + } + name := setArgs[0] + value := setArgs[1] + release, err := configs.GetReleaseConfig(targetRelease) + targetRelease = release.Name + if err != nil { + return err + } + flagArtifact, ok := release.FlagArtifacts[name] + if !ok { + return fmt.Errorf("Unknown build flag %s", name) + } + if valueDir == "" { + mapDir, err := GetMapDir(*flagArtifact.Traces[len(flagArtifact.Traces)-1].Source) + if err != nil { + return err + } + valueDir = mapDir + } + + flagValue := &rc_proto.FlagValue{ + Name: proto.String(name), + Value: rc_lib.UnmarshalValue(value), + } + flagPath := filepath.Join(valueDir, "flag_values", targetRelease, fmt.Sprintf("%s.textproto", name)) + return rc_lib.WriteMessage(flagPath, flagValue) +} + +func main() { + var err error + var commonFlags Flags + var configs *rc_lib.ReleaseConfigs + + outEnv := os.Getenv("OUT_DIR") + if outEnv == "" { + outEnv = "out" + } + // Handle the common arguments + flag.StringVar(&commonFlags.top, "top", ".", "path to top of workspace") + flag.BoolVar(&commonFlags.quiet, "quiet", false, "disable warning messages") + flag.Var(&commonFlags.maps, "map", "path to a release_config_map.textproto. may be repeated") + flag.StringVar(&commonFlags.outDir, "out_dir", rc_lib.GetDefaultOutDir(), "basepath for the output. Multiple formats are created") + flag.Var(&commonFlags.targetReleases, "release", "TARGET_RELEASE for this build") + flag.Parse() + + if commonFlags.quiet { + rc_lib.DisableWarnings() + } + + if len(commonFlags.targetReleases) == 0 { + commonFlags.targetReleases = rc_lib.StringList{"trunk_staging"} + } + + if err = os.Chdir(commonFlags.top); err != nil { + panic(err) + } + + // Get the current state of flagging. + relName := commonFlags.targetReleases[0] + if relName == "--all" || relName == "-all" { + // If the users said `--release --all`, grab trunk staging for simplicity. + relName = "trunk_staging" + } + configs, err = rc_lib.ReadReleaseConfigMaps(commonFlags.maps, relName) + if err != nil { + panic(err) + } + + if cmd, ok := commandMap[flag.Arg(0)]; ok { + args := flag.Args() + if err = cmd(configs, commonFlags, args[0], args[1:]); err != nil { + panic(err) + } + } +} diff --git a/cmd/release_config/crunch_flags/Android.bp b/cmd/release_config/crunch_flags/Android.bp new file mode 100644 index 000000000..89c95913d --- /dev/null +++ b/cmd/release_config/crunch_flags/Android.bp @@ -0,0 +1,32 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +blueprint_go_binary { + name: "crunch-flags", + deps: [ + "golang-protobuf-encoding-prototext", + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + "soong-cmd-release_config-lib", + "soong-cmd-release_config-proto", + ], + srcs: [ + "main.go", + ], +} + +bootstrap_go_package { + name: "soong-cmd-release_config-crunch_flags", + pkgPath: "android/soong/cmd/release_config/crunch_flags", + deps: [ + "golang-protobuf-encoding-prototext", + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + "soong-cmd-release_config-lib", + "soong-cmd-release_config-proto", + ], + srcs: [ + "main.go", + ], +} diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go new file mode 100644 index 000000000..616674bc5 --- /dev/null +++ b/cmd/release_config/crunch_flags/main.go @@ -0,0 +1,359 @@ +package main + +import ( + "flag" + "fmt" + "io/fs" + "os" + "path/filepath" + "regexp" + "strings" + + rc_lib "android/soong/cmd/release_config/release_config_lib" + rc_proto "android/soong/cmd/release_config/release_config_proto" + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" +) + +// When a flag declaration has an initial value that is a string, the default workflow is PREBUILT. +// If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is MANUAL. +var manualFlagNamePrefixes []string = []string{ + "RELEASE_ACONFIG_", + "RELEASE_PLATFORM_", +} + +var defaultFlagNamespace string = "android_UNKNOWN" + +func RenameNext(name string) string { + if name == "next" { + return "ap3a" + } + return name +} + +func WriteFile(path string, message proto.Message) error { + data, err := prototext.MarshalOptions{Multiline: true}.Marshal(message) + if err != nil { + return err + } + + err = os.MkdirAll(filepath.Dir(path), 0775) + if err != nil { + return err + } + return os.WriteFile(path, data, 0644) +} + +func WalkValueFiles(dir string, Func fs.WalkDirFunc) error { + valPath := filepath.Join(dir, "build_config") + if _, err := os.Stat(valPath); err != nil { + fmt.Printf("%s not found, ignoring.\n", valPath) + return nil + } + + return filepath.WalkDir(valPath, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if strings.HasSuffix(d.Name(), ".scl") && d.Type().IsRegular() { + return Func(path, d, err) + } + return nil + }) +} + +func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { + var rootAconfigModule string + + path := filepath.Join(dir, "build_flags.scl") + if _, err := os.Stat(path); err != nil { + fmt.Printf("%s not found, ignoring.\n", path) + return nil + } else { + fmt.Printf("Processing %s\n", path) + } + commentRegexp, err := regexp.Compile("^[[:space:]]*#(?.+)") + if err != nil { + return err + } + declRegexp, err := regexp.Compile("^[[:space:]]*flag.\"(?[A-Z_0-9]+)\",[[:space:]]*(?[_A-Z]*),[[:space:]]*(?(\"[^\"]*\"|[^\",)]*))") + if err != nil { + return err + } + declIn, err := os.ReadFile(path) + if err != nil { + return err + } + lines := strings.Split(string(declIn), "\n") + var description string + for _, line := range lines { + if comment := commentRegexp.FindStringSubmatch(commentRegexp.FindString(line)); comment != nil { + // Description is the text from any contiguous series of lines before a `flag()` call. + description += fmt.Sprintf(" %s", strings.TrimSpace(comment[commentRegexp.SubexpIndex("comment")])) + continue + } + matches := declRegexp.FindStringSubmatch(declRegexp.FindString(line)) + if matches == nil { + // The line is neither a comment nor a `flag()` call. + // Discard any description we have gathered and process the next line. + description = "" + continue + } + declValue := matches[declRegexp.SubexpIndex("value")] + declName := matches[declRegexp.SubexpIndex("name")] + container := rc_proto.Container(rc_proto.Container_value[matches[declRegexp.SubexpIndex("container")]]) + description = strings.TrimSpace(description) + var namespace string + var ok bool + if namespace, ok = namespaceMap[declName]; !ok { + namespace = defaultFlagNamespace + } + flagDeclaration := &rc_proto.FlagDeclaration{ + Name: proto.String(declName), + Namespace: proto.String(namespace), + Description: proto.String(description), + Container: &container, + } + description = "" + // Most build flags are `workflow: PREBUILT`. + workflow := rc_proto.Workflow(rc_proto.Workflow_PREBUILT) + switch { + case declName == "RELEASE_ACONFIG_VALUE_SETS": + rootAconfigModule = declValue[1 : len(declValue)-1] + continue + case strings.HasPrefix(declValue, "\""): + // String values mean that the flag workflow is (most likely) either MANUAL or PREBUILT. + declValue = declValue[1 : len(declValue)-1] + flagDeclaration.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{declValue}} + for _, prefix := range manualFlagNamePrefixes { + if strings.HasPrefix(declName, prefix) { + workflow = rc_proto.Workflow(rc_proto.Workflow_MANUAL) + break + } + } + case declValue == "False" || declValue == "True": + // Boolean values are LAUNCH flags. + flagDeclaration.Value = &rc_proto.Value{Val: &rc_proto.Value_BoolValue{declValue == "True"}} + workflow = rc_proto.Workflow(rc_proto.Workflow_LAUNCH) + case declValue == "None": + // Use PREBUILT workflow with no initial value. + default: + fmt.Printf("%s: Unexpected value %s=%s\n", path, declName, declValue) + } + flagDeclaration.Workflow = &workflow + if flagDeclaration != nil { + declPath := filepath.Join(dir, "flag_declarations", fmt.Sprintf("%s.textproto", declName)) + err := WriteFile(declPath, flagDeclaration) + if err != nil { + return err + } + } + } + if rootAconfigModule != "" { + rootProto := &rc_proto.ReleaseConfig{ + Name: proto.String("root"), + AconfigValueSets: []string{rootAconfigModule}, + } + return WriteFile(filepath.Join(dir, "release_configs", "root.textproto"), rootProto) + } + return nil +} + +func ProcessBuildConfigs(dir, name string, paths []string, releaseProto *rc_proto.ReleaseConfig) error { + valRegexp, err := regexp.Compile("[[:space:]]+value.\"(?[A-Z_0-9]+)\",[[:space:]]*(?[^,)]*)") + if err != nil { + return err + } + for _, path := range paths { + fmt.Printf("Processing %s\n", path) + valIn, err := os.ReadFile(path) + if err != nil { + fmt.Printf("%s: error: %v\n", path, err) + return err + } + vals := valRegexp.FindAllString(string(valIn), -1) + for _, val := range vals { + matches := valRegexp.FindStringSubmatch(val) + valValue := matches[valRegexp.SubexpIndex("value")] + valName := matches[valRegexp.SubexpIndex("name")] + flagValue := &rc_proto.FlagValue{ + Name: proto.String(valName), + } + switch { + case valName == "RELEASE_ACONFIG_VALUE_SETS": + flagValue = nil + if releaseProto.AconfigValueSets == nil { + releaseProto.AconfigValueSets = []string{} + } + releaseProto.AconfigValueSets = append(releaseProto.AconfigValueSets, valValue[1:len(valValue)-1]) + case strings.HasPrefix(valValue, "\""): + valValue = valValue[1 : len(valValue)-1] + flagValue.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{valValue}} + case valValue == "None": + // nothing to do here. + case valValue == "True": + flagValue.Value = &rc_proto.Value{Val: &rc_proto.Value_BoolValue{true}} + case valValue == "False": + flagValue.Value = &rc_proto.Value{Val: &rc_proto.Value_BoolValue{false}} + default: + fmt.Printf("%s: Unexpected value %s=%s\n", path, valName, valValue) + } + if flagValue != nil { + valPath := filepath.Join(dir, "flag_values", RenameNext(name), fmt.Sprintf("%s.textproto", valName)) + err := WriteFile(valPath, flagValue) + if err != nil { + return err + } + } + } + } + return err +} + +func ProcessReleaseConfigMap(dir string, descriptionMap map[string]string) error { + path := filepath.Join(dir, "release_config_map.mk") + if _, err := os.Stat(path); err != nil { + fmt.Printf("%s not found, ignoring.\n", path) + return nil + } else { + fmt.Printf("Processing %s\n", path) + } + configRegexp, err := regexp.Compile("^..call[[:space:]]+declare-release-config,[[:space:]]+(?[_a-z0-0A-Z]+),[[:space:]]+(?[^,]*)(,[[:space:]]*(?.*)|[[:space:]]*)[)]$") + if err != nil { + return err + } + aliasRegexp, err := regexp.Compile("^..call[[:space:]]+alias-release-config,[[:space:]]+(?[_a-z0-9A-Z]+),[[:space:]]+(?[_a-z0-9A-Z]+)") + if err != nil { + return err + } + + mapIn, err := os.ReadFile(path) + if err != nil { + return err + } + cleanDir := strings.TrimLeft(dir, "../") + var defaultContainer rc_proto.Container + switch { + case strings.HasPrefix(cleanDir, "build/") || cleanDir == "vendor/google_shared/build": + defaultContainer = rc_proto.Container(rc_proto.Container_ALL) + case cleanDir == "vendor/google/release": + defaultContainer = rc_proto.Container(rc_proto.Container_ALL) + default: + defaultContainer = rc_proto.Container(rc_proto.Container_VENDOR) + } + releaseConfigMap := &rc_proto.ReleaseConfigMap{DefaultContainer: &defaultContainer} + // If we find a description for the directory, include it. + if description, ok := descriptionMap[cleanDir]; ok { + releaseConfigMap.Description = proto.String(description) + } + lines := strings.Split(string(mapIn), "\n") + for _, line := range lines { + alias := aliasRegexp.FindStringSubmatch(aliasRegexp.FindString(line)) + if alias != nil { + fmt.Printf("processing alias %s\n", line) + name := alias[aliasRegexp.SubexpIndex("name")] + target := alias[aliasRegexp.SubexpIndex("target")] + if target == "next" { + if RenameNext(target) != name { + return fmt.Errorf("Unexpected name for next (%s)", RenameNext(target)) + } + target, name = name, target + } + releaseConfigMap.Aliases = append(releaseConfigMap.Aliases, + &rc_proto.ReleaseAlias{ + Name: proto.String(name), + Target: proto.String(target), + }) + } + config := configRegexp.FindStringSubmatch(configRegexp.FindString(line)) + if config == nil { + continue + } + name := config[configRegexp.SubexpIndex("name")] + releaseConfig := &rc_proto.ReleaseConfig{ + Name: proto.String(RenameNext(name)), + } + configFiles := config[configRegexp.SubexpIndex("files")] + files := strings.Split(strings.ReplaceAll(configFiles, "$(local_dir)", dir+"/"), " ") + configInherits := config[configRegexp.SubexpIndex("inherits")] + if len(configInherits) > 0 { + releaseConfig.Inherits = strings.Split(configInherits, " ") + } + err := ProcessBuildConfigs(dir, name, files, releaseConfig) + if err != nil { + return err + } + + releasePath := filepath.Join(dir, "release_configs", fmt.Sprintf("%s.textproto", RenameNext(name))) + err = WriteFile(releasePath, releaseConfig) + if err != nil { + return err + } + } + return WriteFile(filepath.Join(dir, "release_config_map.textproto"), releaseConfigMap) +} + +func main() { + var err error + var top string + var dirs rc_lib.StringList + var namespacesFile string + var descriptionsFile string + + flag.StringVar(&top, "top", ".", "path to top of workspace") + flag.Var(&dirs, "dir", "directory to process, relative to the top of the workspace") + flag.StringVar(&namespacesFile, "namespaces", "", "location of file with 'flag_name namespace' information") + flag.StringVar(&descriptionsFile, "descriptions", "", "location of file with 'directory description' information") + flag.Parse() + + if err = os.Chdir(top); err != nil { + panic(err) + } + if len(dirs) == 0 { + dirs = rc_lib.StringList{"build/release", "vendor/google_shared/build/release", "vendor/google/release"} + } + + namespaceMap := make(map[string]string) + if namespacesFile != "" { + data, err := os.ReadFile(namespacesFile) + if err != nil { + panic(err) + } + for idx, line := range strings.Split(string(data), "\n") { + fields := strings.Split(line, " ") + if len(fields) > 2 { + panic(fmt.Errorf("line %d: too many fields: %s", idx, line)) + } + namespaceMap[fields[0]] = fields[1] + } + + } + + descriptionMap := make(map[string]string) + descriptionMap["build/release"] = "Published open-source flags and declarations" + if descriptionsFile != "" { + data, err := os.ReadFile(descriptionsFile) + if err != nil { + panic(err) + } + for _, line := range strings.Split(string(data), "\n") { + if strings.TrimSpace(line) != "" { + fields := strings.SplitN(line, " ", 2) + descriptionMap[fields[0]] = fields[1] + } + } + + } + + for _, dir := range dirs { + err = ProcessBuildFlags(dir, namespaceMap) + if err != nil { + panic(err) + } + + err = ProcessReleaseConfigMap(dir, descriptionMap) + if err != nil { + panic(err) + } + } +} From 5e200c043dc7d0340a85753c8264b876a0658e20 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 9 Apr 2024 18:03:07 -0700 Subject: [PATCH 34/67] Bootstrap out/release-config early Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I4e9d6eba21da128adc7d8eab097ade2e69b4cbcc Change-Id: I4e9d6eba21da128adc7d8eab097ade2e69b4cbcc --- soong_ui.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/soong_ui.bash b/soong_ui.bash index 8e7cd195d..77378807f 100755 --- a/soong_ui.bash +++ b/soong_ui.bash @@ -35,6 +35,7 @@ source ${TOP}/build/soong/scripts/microfactory.bash soong_build_go soong_ui android/soong/cmd/soong_ui soong_build_go mk2rbc android/soong/mk2rbc/mk2rbc soong_build_go rbcrun rbcrun/rbcrun +soong_build_go release-config android/soong/cmd/release_config/release_config cd ${TOP} exec "$(getoutdir)/soong_ui" "$@" From 6121f13d6f30bb1f1b7622c398749448da6ae0f7 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Fri, 19 Apr 2024 17:26:27 -0700 Subject: [PATCH 35/67] crunch_flags: keep-sorted lines are not descriptions Also fix a typo in parsing declare-release-config. Bug: 328495189 Test: manual, TH Ignore-AOSP-First: cherry-pick Merged-In: Ibfed4a217275df0dd6bd9c2fb124e0d1f791be08 Change-Id: Ibfed4a217275df0dd6bd9c2fb124e0d1f791be08 --- cmd/release_config/crunch_flags/main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index 616674bc5..69abba2a5 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -89,7 +89,10 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { for _, line := range lines { if comment := commentRegexp.FindStringSubmatch(commentRegexp.FindString(line)); comment != nil { // Description is the text from any contiguous series of lines before a `flag()` call. - description += fmt.Sprintf(" %s", strings.TrimSpace(comment[commentRegexp.SubexpIndex("comment")])) + descLine := strings.TrimSpace(comment[commentRegexp.SubexpIndex("comment")]) + if !strings.HasPrefix(descLine, "keep-sorted") { + description += fmt.Sprintf(" %s", descLine) + } continue } matches := declRegexp.FindStringSubmatch(declRegexp.FindString(line)) @@ -218,7 +221,7 @@ func ProcessReleaseConfigMap(dir string, descriptionMap map[string]string) error } else { fmt.Printf("Processing %s\n", path) } - configRegexp, err := regexp.Compile("^..call[[:space:]]+declare-release-config,[[:space:]]+(?[_a-z0-0A-Z]+),[[:space:]]+(?[^,]*)(,[[:space:]]*(?.*)|[[:space:]]*)[)]$") + configRegexp, err := regexp.Compile("^..call[[:space:]]+declare-release-config,[[:space:]]+(?[_a-z0-9A-Z]+),[[:space:]]+(?[^,]*)(,[[:space:]]*(?.*)|[[:space:]]*)[)]$") if err != nil { return err } From 4f3ce4919fe463e6a96bd87f618425eb4fe25c28 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 24 Apr 2024 10:08:17 -0700 Subject: [PATCH 36/67] add flag_value.redacted When set, this removes all traces of the flag from the release config. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: Iab39d06e134bfc020ba4875c1b8e89c5cdf18924 Change-Id: Iab39d06e134bfc020ba4875c1b8e89c5cdf18924 --- .../release_config_lib/flag_artifact.go | 12 +++ .../release_config_lib/release_config.go | 12 ++- .../release_config_lib/release_configs.go | 3 + .../build_flags_out.pb.go | 2 +- .../build_flags_src.pb.go | 92 +++++++++++-------- .../build_flags_src.proto | 4 + 6 files changed, 80 insertions(+), 45 deletions(-) diff --git a/cmd/release_config/release_config_lib/flag_artifact.go b/cmd/release_config/release_config_lib/flag_artifact.go index 4446655f7..d6a629b10 100644 --- a/cmd/release_config/release_config_lib/flag_artifact.go +++ b/cmd/release_config/release_config_lib/flag_artifact.go @@ -36,6 +36,10 @@ type FlagArtifact struct { // The value of the flag. Value *rc_proto.Value + + // This flag is redacted. Set by UpdateValue when the FlagValue proto + // says to redact it. + Redacted bool } // Key is flag name. @@ -85,6 +89,11 @@ func (src FlagArtifacts) Clone() (dst FlagArtifacts) { func (fa *FlagArtifact) UpdateValue(flagValue FlagValue) error { name := *flagValue.proto.Name fa.Traces = append(fa.Traces, &rc_proto.Tracepoint{Source: proto.String(flagValue.path), Value: flagValue.proto.Value}) + if flagValue.proto.GetRedacted() { + fa.Redacted = true + fmt.Printf("Redacting flag %s in %s\n", name, flagValue.path) + return nil + } if fa.Value.GetObsolete() { return fmt.Errorf("Attempting to set obsolete flag %s. Trace=%v", name, fa.Traces) } @@ -111,6 +120,9 @@ func (fa *FlagArtifact) UpdateValue(flagValue FlagValue) error { // Marshal the FlagArtifact into a flag_artifact message. func (fa *FlagArtifact) Marshal() (*rc_proto.FlagArtifact, error) { + if fa.Redacted { + return nil, nil + } return &rc_proto.FlagArtifact{ FlagDeclaration: fa.FlagDeclaration, Value: fa.Value, diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index c67cee54a..b08b6a339 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -150,22 +150,26 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro } myDirsMap[contrib.DeclarationIndex] = true for _, value := range contrib.FlagValues { - fa, ok := myFlags[*value.proto.Name] + name := *value.proto.Name + fa, ok := myFlags[name] if !ok { - return fmt.Errorf("Setting value for undefined flag %s in %s\n", *value.proto.Name, value.path) + return fmt.Errorf("Setting value for undefined flag %s in %s\n", name, value.path) } myDirsMap[fa.DeclarationIndex] = true if fa.DeclarationIndex > contrib.DeclarationIndex { // Setting location is to the left of declaration. - return fmt.Errorf("Setting value for flag %s not allowed in %s\n", *value.proto.Name, value.path) + return fmt.Errorf("Setting value for flag %s not allowed in %s\n", name, value.path) } if isRoot && *fa.FlagDeclaration.Workflow != workflowManual { // The "root" release config can only contain workflow: MANUAL flags. - return fmt.Errorf("Setting value for non-MANUAL flag %s is not allowed in %s", *value.proto.Name, value.path) + return fmt.Errorf("Setting value for non-MANUAL flag %s is not allowed in %s", name, value.path) } if err := fa.UpdateValue(*value); err != nil { return err } + if fa.Redacted { + delete(myFlags, name) + } } } releaseAconfigValueSets.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.Join(myAconfigValueSets, " ")}} diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 6efdb2f08..aba8cd2c2 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -160,6 +160,9 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex configs.FlagArtifacts[name].UpdateValue( FlagValue{path: path, proto: rc_proto.FlagValue{ Name: proto.String(name), Value: flagDeclaration.Value}}) + if configs.FlagArtifacts[name].Redacted { + return fmt.Errorf("%s may not be redacted by default.", *flagDeclaration.Name) + } return nil }) if err != nil { diff --git a/cmd/release_config/release_config_proto/build_flags_out.pb.go b/cmd/release_config/release_config_proto/build_flags_out.pb.go index 0372d633b..77e20698e 100644 --- a/cmd/release_config/release_config_proto/build_flags_out.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_out.pb.go @@ -11,7 +11,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.30.0 // protoc v3.21.12 // source: build_flags_out.proto diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go index d0c924dae..ca2005c4b 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go @@ -11,7 +11,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.30.0 // protoc v3.21.12 // source: build_flags_src.proto @@ -385,6 +385,9 @@ type FlagValue struct { Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` // Value for the flag Value *Value `protobuf:"bytes,201,opt,name=value" json:"value,omitempty"` + // If true, the flag is completely removed from the release config as if + // never declared. + Redacted *bool `protobuf:"varint,202,opt,name=redacted" json:"redacted,omitempty"` } func (x *FlagValue) Reset() { @@ -433,6 +436,13 @@ func (x *FlagValue) GetValue() *Value { return nil } +func (x *FlagValue) GetRedacted() bool { + if x != nil && x.Redacted != nil { + return *x.Redacted + } + return false +} + // This replaces $(call declare-release-config). type ReleaseConfig struct { state protoimpl.MessageState @@ -663,52 +673,54 @@ var file_build_flags_src_proto_rawDesc = []byte{ 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x4a, - 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x06, 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x5c, 0x0a, + 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x06, 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x79, 0x0a, 0x0a, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x6e, 0x0a, 0x0e, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, - 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, - 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xd3, 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, - 0x45, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x0a, 0x08, 0x72, + 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, 0x64, 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, + 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, 0x64, 0x22, 0x6e, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, + 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xd3, 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, + 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, + 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, + 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x54, 0x0a, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x27, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x52, 0x07, 0x61, - 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x54, 0x0a, 0x11, 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, + 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x10, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2a, 0x4a, 0x0a, 0x08, 0x77, + 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x53, 0x50, 0x45, + 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x10, + 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, 0x0c, 0x0a, + 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x4d, + 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x2a, 0x64, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, + 0x49, 0x45, 0x44, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x10, 0x00, 0x12, + 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x4f, 0x44, + 0x55, 0x43, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x10, + 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x58, 0x54, 0x10, + 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x10, 0x05, 0x42, 0x33, 0x5a, + 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x10, 0x64, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2a, 0x4a, - 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, - 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, - 0x6f, 0x77, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, - 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, - 0x0a, 0x06, 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x2a, 0x64, 0x0a, 0x09, 0x63, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x4e, 0x53, 0x50, 0x45, - 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, - 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, - 0x52, 0x4f, 0x44, 0x55, 0x43, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x59, 0x53, 0x54, - 0x45, 0x4d, 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, - 0x58, 0x54, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x10, 0x05, - 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, - 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x74, 0x6f, } var ( diff --git a/cmd/release_config/release_config_proto/build_flags_src.proto b/cmd/release_config/release_config_proto/build_flags_src.proto index c077f5cd8..92edc2a66 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.proto +++ b/cmd/release_config/release_config_proto/build_flags_src.proto @@ -114,6 +114,10 @@ message flag_value { // Value for the flag optional value value = 201; + + // If true, the flag is completely removed from the release config as if + // never declared. + optional bool redacted = 202; } // This replaces $(call declare-release-config). From 1662c73d96fc4db20489f321227d607f4ba75c77 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 24 Apr 2024 16:01:44 -0700 Subject: [PATCH 37/67] release_config: various cleanup - Parse release_config_map.textproto files only once - Fix inheritance - Sort flag artifacts by flag name - Add --all_make option for testing - Fix value() parsing in crunch_flags Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I577e7fb07171bea9a53d61eaf77ec728b60d7a26 Change-Id: I577e7fb07171bea9a53d61eaf77ec728b60d7a26 --- cmd/release_config/crunch_flags/main.go | 2 +- cmd/release_config/release_config/main.go | 20 ++++- .../release_config_lib/release_config.go | 84 +++++++++++++------ .../release_config_lib/release_configs.go | 5 ++ 4 files changed, 79 insertions(+), 32 deletions(-) diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index 69abba2a5..29290a414 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -163,7 +163,7 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { } func ProcessBuildConfigs(dir, name string, paths []string, releaseProto *rc_proto.ReleaseConfig) error { - valRegexp, err := regexp.Compile("[[:space:]]+value.\"(?[A-Z_0-9]+)\",[[:space:]]*(?[^,)]*)") + valRegexp, err := regexp.Compile("[[:space:]]+value.\"(?[A-Z_0-9]+)\",[[:space:]]*(?(\"[^\"]*\"|[^\",)]*))") if err != nil { return err } diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index a43fdccbe..4c8cefc2f 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -33,6 +33,7 @@ func main() { var configs *rc_lib.ReleaseConfigs var json, pb, textproto bool var product string + var allMake bool defaultRelease := os.Getenv("TARGET_RELEASE") if defaultRelease == "" { @@ -48,6 +49,7 @@ func main() { flag.BoolVar(&textproto, "textproto", true, "write artifacts as text protobuf") flag.BoolVar(&json, "json", true, "write artifacts as json") flag.BoolVar(&pb, "pb", true, "write artifacts as binary protobuf") + flag.BoolVar(&allMake, "all_make", true, "write makefiles for all release configs") flag.Parse() if quiet { @@ -70,10 +72,20 @@ func main() { if err != nil { panic(err) } - makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, releaseName)) - err = configs.WriteMakefile(makefilePath, targetRelease) - if err != nil { - panic(err) + if allMake { + for k, _ := range configs.ReleaseConfigs { + makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k)) + err = configs.WriteMakefile(makefilePath, k) + if err != nil { + panic(err) + } + } + } else { + makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, releaseName)) + err = configs.WriteMakefile(makefilePath, targetRelease) + if err != nil { + panic(err) + } } if json { err = configs.WriteArtifact(outputDir, product, "json") diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index b08b6a339..079f6b592 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -16,6 +16,7 @@ package release_config_lib import ( "fmt" + "sort" "strings" rc_proto "android/soong/cmd/release_config/release_config_proto" @@ -72,6 +73,22 @@ func ReleaseConfigFactory(name string, index int) (c *ReleaseConfig) { return &ReleaseConfig{Name: name, DeclarationIndex: index} } +func (config *ReleaseConfig) InheritConfig(iConfig *ReleaseConfig) error { + for _, fa := range iConfig.FlagArtifacts { + name := *fa.FlagDeclaration.Name + myFa, ok := config.FlagArtifacts[name] + if !ok { + return fmt.Errorf("Could not inherit flag %s from %s", name, iConfig.Name) + } + if len(fa.Traces) > 1 { + // A value was assigned. Set our value. + myFa.Traces = append(myFa.Traces, fa.Traces[1:]...) + myFa.Value = fa.Value + } + } + return nil +} + func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) error { if config.ReleaseConfigArtifact != nil { return nil @@ -82,6 +99,30 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro config.compileInProgress = true isRoot := config.Name == "root" + // Start with only the flag declarations. + config.FlagArtifacts = configs.FlagArtifacts.Clone() + // Add RELEASE_ACONFIG_VALUE_SETS + workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) + container := rc_proto.Container(rc_proto.Container_ALL) + releaseAconfigValueSets := FlagArtifact{ + FlagDeclaration: &rc_proto.FlagDeclaration{ + Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), + Namespace: proto.String("android_UNKNOWN"), + Description: proto.String("Aconfig value sets assembled by release-config"), + Workflow: &workflowManual, + Container: &container, + Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{""}}, + }, + DeclarationIndex: -1, + Traces: []*rc_proto.Tracepoint{ + &rc_proto.Tracepoint{ + Source: proto.String("$release-config"), + Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{""}}, + }, + }, + } + config.FlagArtifacts["RELEASE_ACONFIG_VALUE_SETS"] = &releaseAconfigValueSets + // Generate any configs we need to inherit. This will detect loops in // the config. contributionsToApply := []*ReleaseConfigContribution{} @@ -103,33 +144,17 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro return err } iConfig.GenerateReleaseConfig(configs) - contributionsToApply = append(contributionsToApply, iConfig.Contributions...) + if err := config.InheritConfig(iConfig); err != nil { + return err + } } contributionsToApply = append(contributionsToApply, config.Contributions...) - myAconfigValueSets := []string{} + myAconfigValueSets := strings.Split(releaseAconfigValueSets.Value.GetStringValue(), " ") myAconfigValueSetsMap := map[string]bool{} - myFlags := configs.FlagArtifacts.Clone() - workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) - container := rc_proto.Container(rc_proto.Container_ALL) - releaseAconfigValueSets := FlagArtifact{ - FlagDeclaration: &rc_proto.FlagDeclaration{ - Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), - Namespace: proto.String("android_UNKNOWN"), - Description: proto.String("Aconfig value sets assembled by release-config"), - Workflow: &workflowManual, - Container: &container, - Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{""}}, - }, - DeclarationIndex: -1, - Traces: []*rc_proto.Tracepoint{ - &rc_proto.Tracepoint{ - Source: proto.String("$release-config"), - Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{""}}, - }, - }, + for _, v := range myAconfigValueSets { + myAconfigValueSetsMap[v] = true } - myFlags["RELEASE_ACONFIG_VALUE_SETS"] = &releaseAconfigValueSets myDirsMap := make(map[int]bool) for _, contrib := range contributionsToApply { if len(contrib.proto.AconfigValueSets) > 0 { @@ -151,7 +176,7 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro myDirsMap[contrib.DeclarationIndex] = true for _, value := range contrib.FlagValues { name := *value.proto.Name - fa, ok := myFlags[name] + fa, ok := config.FlagArtifacts[name] if !ok { return fmt.Errorf("Setting value for undefined flag %s in %s\n", name, value.path) } @@ -168,11 +193,11 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro return err } if fa.Redacted { - delete(myFlags, name) + delete(config.FlagArtifacts, name) } } } - releaseAconfigValueSets.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.Join(myAconfigValueSets, " ")}} + releaseAconfigValueSets.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.TrimSpace(strings.Join(myAconfigValueSets, " "))}} directories := []string{} for idx, confDir := range configs.configDirs { @@ -181,13 +206,18 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro } } - config.FlagArtifacts = myFlags config.ReleaseConfigArtifact = &rc_proto.ReleaseConfigArtifact{ Name: proto.String(config.Name), OtherNames: config.OtherNames, FlagArtifacts: func() []*rc_proto.FlagArtifact { ret := []*rc_proto.FlagArtifact{} - for _, flag := range myFlags { + flagNames := []string{} + for k := range config.FlagArtifacts { + flagNames = append(flagNames, k) + } + sort.Strings(flagNames) + for _, flagName := range flagNames { + flag := config.FlagArtifacts[flagName] ret = append(ret, &rc_proto.FlagArtifact{ FlagDeclaration: flag.FlagDeclaration, Traces: flag.Traces, diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index aba8cd2c2..3204b1873 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -372,9 +372,14 @@ func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease strin } configs := ReleaseConfigsFactory() + mapsRead := make(map[string]bool) for idx, releaseConfigMapPath := range releaseConfigMapPaths { // Maintain an ordered list of release config directories. configDir := filepath.Dir(releaseConfigMapPath) + if mapsRead[configDir] { + continue + } + mapsRead[configDir] = true configs.configDirIndexes[configDir] = idx configs.configDirs = append(configs.configDirs, configDir) err = configs.LoadReleaseConfigMap(releaseConfigMapPath, idx) From 73bb4e1e4f713edc7f762f90d410235799c697a6 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Fri, 26 Apr 2024 09:14:30 -0700 Subject: [PATCH 38/67] Write per-partition build_flags.json Create build_flags_{partition}-{TARGET_PRODUCT}-{TARGET_RELEASE}.json in {OUT_DIR}/soong/release-config. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I708c37f9b1216b4283886c98cacaf66bfcd28143 Change-Id: I708c37f9b1216b4283886c98cacaf66bfcd28143 --- cmd/release_config/release_config/main.go | 5 + .../release_config_lib/flag_artifact.go | 11 + .../release_config_lib/release_config.go | 47 ++++ .../build_flags_out.pb.go | 226 ++++++++++++------ .../build_flags_out.proto | 5 + 5 files changed, 215 insertions(+), 79 deletions(-) diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index 4c8cefc2f..22e72a560 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -72,6 +72,11 @@ func main() { if err != nil { panic(err) } + + if err = config.WritePartitionBuildFlags(outputDir, product, targetRelease); err != nil { + panic(err) + } + if allMake { for k, _ := range configs.ReleaseConfigs { makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k)) diff --git a/cmd/release_config/release_config_lib/flag_artifact.go b/cmd/release_config/release_config_lib/flag_artifact.go index d6a629b10..cba1b5cd8 100644 --- a/cmd/release_config/release_config_lib/flag_artifact.go +++ b/cmd/release_config/release_config_lib/flag_artifact.go @@ -129,3 +129,14 @@ func (fa *FlagArtifact) Marshal() (*rc_proto.FlagArtifact, error) { Traces: fa.Traces, }, nil } + +// Marshal the FlagArtifact without Traces. +func (fa *FlagArtifact) MarshalWithoutTraces() (*rc_proto.FlagArtifact, error) { + if fa.Redacted { + return nil, nil + } + return &rc_proto.FlagArtifact{ + FlagDeclaration: fa.FlagDeclaration, + Value: fa.Value, + }, nil +} diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index 079f6b592..a7a05ae6a 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -15,7 +15,10 @@ package release_config_lib import ( + "cmp" "fmt" + "path/filepath" + "slices" "sort" "strings" @@ -67,6 +70,9 @@ type ReleaseConfig struct { // We have begun compiling this release config. compileInProgress bool + + // Partitioned artifacts for {partition}/etc/build_flags.json + PartitionBuildFlags map[string]*rc_proto.FlagArtifacts } func ReleaseConfigFactory(name string, index int) (c *ReleaseConfig) { @@ -206,6 +212,34 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro } } + // Now build the per-partition artifacts + config.PartitionBuildFlags = make(map[string]*rc_proto.FlagArtifacts) + addPartitionArtifact := func(container string, artifact *rc_proto.FlagArtifact) { + if _, ok := config.PartitionBuildFlags[container]; !ok { + config.PartitionBuildFlags[container] = &rc_proto.FlagArtifacts{} + } + config.PartitionBuildFlags[container].FlagArtifacts = append(config.PartitionBuildFlags[container].FlagArtifacts, artifact) + } + for _, v := range config.FlagArtifacts { + container := strings.ToLower(rc_proto.Container_name[int32(v.FlagDeclaration.GetContainer())]) + artifact, err := v.MarshalWithoutTraces() + if err != nil { + return err + } + switch container { + case "all": + for cVal, cName := range rc_proto.Container_name { + // Skip unspecified, and "ALL", but place the flag in the rest. + if cVal == 0 || cName == "ALL" { + continue + } + cName = strings.ToLower(cName) + addPartitionArtifact(cName, artifact) + } + default: + addPartitionArtifact(container, artifact) + } + } config.ReleaseConfigArtifact = &rc_proto.ReleaseConfigArtifact{ Name: proto.String(config.Name), OtherNames: config.OtherNames, @@ -234,3 +268,16 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro config.compileInProgress = false return nil } + +func (config *ReleaseConfig) WritePartitionBuildFlags(outDir, product, targetRelease string) error { + var err error + for partition, flags := range config.PartitionBuildFlags { + slices.SortFunc(flags.FlagArtifacts, func(a, b *rc_proto.FlagArtifact) int { + return cmp.Compare(*a.FlagDeclaration.Name, *b.FlagDeclaration.Name) + }) + if err = WriteMessage(filepath.Join(outDir, fmt.Sprintf("build_flags_%s-%s-%s.json", partition, config.Name, product)), flags); err != nil { + return err + } + } + return nil +} diff --git a/cmd/release_config/release_config_proto/build_flags_out.pb.go b/cmd/release_config/release_config_proto/build_flags_out.pb.go index 77e20698e..483cffac1 100644 --- a/cmd/release_config/release_config_proto/build_flags_out.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_out.pb.go @@ -153,6 +153,54 @@ func (x *FlagArtifact) GetTraces() []*Tracepoint { return nil } +type FlagArtifacts struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The artifacts + FlagArtifacts []*FlagArtifact `protobuf:"bytes,1,rep,name=flag_artifacts,json=flagArtifacts" json:"flag_artifacts,omitempty"` +} + +func (x *FlagArtifacts) Reset() { + *x = FlagArtifacts{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_out_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FlagArtifacts) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FlagArtifacts) ProtoMessage() {} + +func (x *FlagArtifacts) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_out_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FlagArtifacts.ProtoReflect.Descriptor instead. +func (*FlagArtifacts) Descriptor() ([]byte, []int) { + return file_build_flags_out_proto_rawDescGZIP(), []int{2} +} + +func (x *FlagArtifacts) GetFlagArtifacts() []*FlagArtifact { + if x != nil { + return x.FlagArtifacts + } + return nil +} + type ReleaseConfigArtifact struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -179,7 +227,7 @@ type ReleaseConfigArtifact struct { func (x *ReleaseConfigArtifact) Reset() { *x = ReleaseConfigArtifact{} if protoimpl.UnsafeEnabled { - mi := &file_build_flags_out_proto_msgTypes[2] + mi := &file_build_flags_out_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -192,7 +240,7 @@ func (x *ReleaseConfigArtifact) String() string { func (*ReleaseConfigArtifact) ProtoMessage() {} func (x *ReleaseConfigArtifact) ProtoReflect() protoreflect.Message { - mi := &file_build_flags_out_proto_msgTypes[2] + mi := &file_build_flags_out_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -205,7 +253,7 @@ func (x *ReleaseConfigArtifact) ProtoReflect() protoreflect.Message { // Deprecated: Use ReleaseConfigArtifact.ProtoReflect.Descriptor instead. func (*ReleaseConfigArtifact) Descriptor() ([]byte, []int) { - return file_build_flags_out_proto_rawDescGZIP(), []int{2} + return file_build_flags_out_proto_rawDescGZIP(), []int{3} } func (x *ReleaseConfigArtifact) GetName() string { @@ -266,7 +314,7 @@ type ReleaseConfigsArtifact struct { func (x *ReleaseConfigsArtifact) Reset() { *x = ReleaseConfigsArtifact{} if protoimpl.UnsafeEnabled { - mi := &file_build_flags_out_proto_msgTypes[3] + mi := &file_build_flags_out_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -279,7 +327,7 @@ func (x *ReleaseConfigsArtifact) String() string { func (*ReleaseConfigsArtifact) ProtoMessage() {} func (x *ReleaseConfigsArtifact) ProtoReflect() protoreflect.Message { - mi := &file_build_flags_out_proto_msgTypes[3] + mi := &file_build_flags_out_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -292,7 +340,7 @@ func (x *ReleaseConfigsArtifact) ProtoReflect() protoreflect.Message { // Deprecated: Use ReleaseConfigsArtifact.ProtoReflect.Descriptor instead. func (*ReleaseConfigsArtifact) Descriptor() ([]byte, []int) { - return file_build_flags_out_proto_rawDescGZIP(), []int{3} + return file_build_flags_out_proto_rawDescGZIP(), []int{4} } func (x *ReleaseConfigsArtifact) GetReleaseConfig() *ReleaseConfigArtifact { @@ -344,58 +392,64 @@ var file_build_flags_out_proto_rawDesc = []byte{ 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x70, 0x6f, 0x69, 0x6e, - 0x74, 0x52, 0x06, 0x74, 0x72, 0x61, 0x63, 0x65, 0x73, 0x22, 0x8e, 0x02, 0x0a, 0x17, 0x72, 0x65, - 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, - 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x74, 0x68, - 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, - 0x6f, 0x74, 0x68, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x52, 0x0a, 0x0e, 0x66, 0x6c, - 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, - 0x0d, 0x66, 0x6c, 0x61, 0x67, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x12, 0x2c, - 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, - 0x73, 0x65, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74, 0x73, 0x12, 0x1a, 0x0a, 0x08, - 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, - 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x69, 0x72, 0x65, - 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x22, 0xe8, 0x03, 0x0a, 0x18, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x5f, 0x61, - 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x5c, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x35, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, - 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x69, 0x0a, 0x15, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x13, 0x6f, 0x74, 0x68, - 0x65, 0x72, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, - 0x12, 0x87, 0x01, 0x0a, 0x17, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x73, 0x5f, 0x6d, 0x61, 0x70, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x50, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x73, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, 0x61, 0x70, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x52, 0x14, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, 0x61, 0x70, 0x1a, 0x79, 0x0a, 0x19, 0x52, 0x65, - 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, - 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x46, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, + 0x74, 0x52, 0x06, 0x74, 0x72, 0x61, 0x63, 0x65, 0x73, 0x22, 0x64, 0x0a, 0x0e, 0x66, 0x6c, 0x61, + 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x12, 0x52, 0x0a, 0x0e, 0x66, + 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, + 0x52, 0x0d, 0x66, 0x6c, 0x61, 0x67, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x22, + 0x8e, 0x02, 0x0a, 0x17, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x1f, 0x0a, 0x0b, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, + 0x12, 0x52, 0x0a, 0x0e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, + 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, + 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x61, 0x72, 0x74, + 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x0d, 0x66, 0x6c, 0x61, 0x67, 0x41, 0x72, 0x74, 0x69, 0x66, + 0x61, 0x63, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, + 0x74, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x05, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x06, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, + 0x22, 0xe8, 0x03, 0x0a, 0x18, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x73, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x5c, 0x0a, + 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x0d, 0x72, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x69, 0x0a, 0x15, 0x6f, + 0x74, 0x68, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x61, 0x6e, 0x64, + 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, + 0x74, 0x52, 0x13, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x12, 0x87, 0x01, 0x0a, 0x17, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x73, 0x5f, 0x6d, + 0x61, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x50, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, - 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, + 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x61, + 0x70, 0x73, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x14, 0x72, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, 0x61, 0x70, + 0x1a, 0x79, 0x0a, 0x19, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x4d, 0x61, 0x70, 0x73, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x46, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, + 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x33, 0x5a, 0x31, 0x61, + 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, } var ( @@ -410,32 +464,34 @@ func file_build_flags_out_proto_rawDescGZIP() []byte { return file_build_flags_out_proto_rawDescData } -var file_build_flags_out_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_build_flags_out_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_build_flags_out_proto_goTypes = []interface{}{ (*Tracepoint)(nil), // 0: android.release_config_proto.tracepoint (*FlagArtifact)(nil), // 1: android.release_config_proto.flag_artifact - (*ReleaseConfigArtifact)(nil), // 2: android.release_config_proto.release_config_artifact - (*ReleaseConfigsArtifact)(nil), // 3: android.release_config_proto.release_configs_artifact - nil, // 4: android.release_config_proto.release_configs_artifact.ReleaseConfigMapsMapEntry - (*Value)(nil), // 5: android.release_config_proto.value - (*FlagDeclaration)(nil), // 6: android.release_config_proto.flag_declaration - (*ReleaseConfigMap)(nil), // 7: android.release_config_proto.release_config_map + (*FlagArtifacts)(nil), // 2: android.release_config_proto.flag_artifacts + (*ReleaseConfigArtifact)(nil), // 3: android.release_config_proto.release_config_artifact + (*ReleaseConfigsArtifact)(nil), // 4: android.release_config_proto.release_configs_artifact + nil, // 5: android.release_config_proto.release_configs_artifact.ReleaseConfigMapsMapEntry + (*Value)(nil), // 6: android.release_config_proto.value + (*FlagDeclaration)(nil), // 7: android.release_config_proto.flag_declaration + (*ReleaseConfigMap)(nil), // 8: android.release_config_proto.release_config_map } var file_build_flags_out_proto_depIdxs = []int32{ - 5, // 0: android.release_config_proto.tracepoint.value:type_name -> android.release_config_proto.value - 6, // 1: android.release_config_proto.flag_artifact.flag_declaration:type_name -> android.release_config_proto.flag_declaration - 5, // 2: android.release_config_proto.flag_artifact.value:type_name -> android.release_config_proto.value - 0, // 3: android.release_config_proto.flag_artifact.traces:type_name -> android.release_config_proto.tracepoint - 1, // 4: android.release_config_proto.release_config_artifact.flag_artifacts:type_name -> android.release_config_proto.flag_artifact - 2, // 5: android.release_config_proto.release_configs_artifact.release_config:type_name -> android.release_config_proto.release_config_artifact - 2, // 6: android.release_config_proto.release_configs_artifact.other_release_configs:type_name -> android.release_config_proto.release_config_artifact - 4, // 7: android.release_config_proto.release_configs_artifact.release_config_maps_map:type_name -> android.release_config_proto.release_configs_artifact.ReleaseConfigMapsMapEntry - 7, // 8: android.release_config_proto.release_configs_artifact.ReleaseConfigMapsMapEntry.value:type_name -> android.release_config_proto.release_config_map - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 6, // 0: android.release_config_proto.tracepoint.value:type_name -> android.release_config_proto.value + 7, // 1: android.release_config_proto.flag_artifact.flag_declaration:type_name -> android.release_config_proto.flag_declaration + 6, // 2: android.release_config_proto.flag_artifact.value:type_name -> android.release_config_proto.value + 0, // 3: android.release_config_proto.flag_artifact.traces:type_name -> android.release_config_proto.tracepoint + 1, // 4: android.release_config_proto.flag_artifacts.flag_artifacts:type_name -> android.release_config_proto.flag_artifact + 1, // 5: android.release_config_proto.release_config_artifact.flag_artifacts:type_name -> android.release_config_proto.flag_artifact + 3, // 6: android.release_config_proto.release_configs_artifact.release_config:type_name -> android.release_config_proto.release_config_artifact + 3, // 7: android.release_config_proto.release_configs_artifact.other_release_configs:type_name -> android.release_config_proto.release_config_artifact + 5, // 8: android.release_config_proto.release_configs_artifact.release_config_maps_map:type_name -> android.release_config_proto.release_configs_artifact.ReleaseConfigMapsMapEntry + 8, // 9: android.release_config_proto.release_configs_artifact.ReleaseConfigMapsMapEntry.value:type_name -> android.release_config_proto.release_config_map + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_build_flags_out_proto_init() } @@ -470,7 +526,7 @@ func file_build_flags_out_proto_init() { } } file_build_flags_out_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReleaseConfigArtifact); i { + switch v := v.(*FlagArtifacts); i { case 0: return &v.state case 1: @@ -482,6 +538,18 @@ func file_build_flags_out_proto_init() { } } file_build_flags_out_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReleaseConfigArtifact); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_build_flags_out_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ReleaseConfigsArtifact); i { case 0: return &v.state @@ -500,7 +568,7 @@ func file_build_flags_out_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_build_flags_out_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/cmd/release_config/release_config_proto/build_flags_out.proto b/cmd/release_config/release_config_proto/build_flags_out.proto index 05e770f3e..6f34d6f67 100644 --- a/cmd/release_config/release_config_proto/build_flags_out.proto +++ b/cmd/release_config/release_config_proto/build_flags_out.proto @@ -52,6 +52,11 @@ message flag_artifact { repeated tracepoint traces = 8; } +message flag_artifacts { + // The artifacts + repeated flag_artifact flag_artifacts = 1; +} + message release_config_artifact { // The name of the release config. // See # name for format detail From dcd4684a4ae0f9e52d369520c2fc29c719fc0109 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Fri, 26 Apr 2024 14:19:19 -0700 Subject: [PATCH 39/67] release_config: container is a repeated string field Container is a string, and a flag can be in more than one container. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I5a2a9855532027584d2b67f63f1b9584fce3d8d9 Change-Id: I5a2a9855532027584d2b67f63f1b9584fce3d8d9 --- cmd/release_config/crunch_flags/main.go | 25 +- .../release_config_lib/release_config.go | 62 ++--- .../release_config_lib/release_configs.go | 31 +-- cmd/release_config/release_config_lib/util.go | 10 +- .../build_flags_src.pb.go | 221 ++++++------------ .../build_flags_src.proto | 17 +- 6 files changed, 135 insertions(+), 231 deletions(-) diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index 29290a414..5b640622b 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -102,10 +102,13 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { description = "" continue } - declValue := matches[declRegexp.SubexpIndex("value")] declName := matches[declRegexp.SubexpIndex("name")] - container := rc_proto.Container(rc_proto.Container_value[matches[declRegexp.SubexpIndex("container")]]) + declValue := matches[declRegexp.SubexpIndex("value")] description = strings.TrimSpace(description) + containers := []string{strings.ToLower(matches[declRegexp.SubexpIndex("container")])} + if containers[0] == "all" { + containers = []string{"product", "system", "system_ext", "vendor"} + } var namespace string var ok bool if namespace, ok = namespaceMap[declName]; !ok { @@ -115,7 +118,7 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { Name: proto.String(declName), Namespace: proto.String(namespace), Description: proto.String(description), - Container: &container, + Containers: containers, } description = "" // Most build flags are `workflow: PREBUILT`. @@ -213,6 +216,12 @@ func ProcessBuildConfigs(dir, name string, paths []string, releaseProto *rc_prot return err } +var ( + allContainers = func() []string { + return []string{"product", "system", "system_ext", "vendor"} + }() +) + func ProcessReleaseConfigMap(dir string, descriptionMap map[string]string) error { path := filepath.Join(dir, "release_config_map.mk") if _, err := os.Stat(path); err != nil { @@ -235,16 +244,16 @@ func ProcessReleaseConfigMap(dir string, descriptionMap map[string]string) error return err } cleanDir := strings.TrimLeft(dir, "../") - var defaultContainer rc_proto.Container + var defaultContainers []string switch { case strings.HasPrefix(cleanDir, "build/") || cleanDir == "vendor/google_shared/build": - defaultContainer = rc_proto.Container(rc_proto.Container_ALL) + defaultContainers = allContainers case cleanDir == "vendor/google/release": - defaultContainer = rc_proto.Container(rc_proto.Container_ALL) + defaultContainers = allContainers default: - defaultContainer = rc_proto.Container(rc_proto.Container_VENDOR) + defaultContainers = []string{"vendor"} } - releaseConfigMap := &rc_proto.ReleaseConfigMap{DefaultContainer: &defaultContainer} + releaseConfigMap := &rc_proto.ReleaseConfigMap{DefaultContainers: defaultContainers} // If we find a description for the directory, include it. if description, ok := descriptionMap[cleanDir]; ok { releaseConfigMap.Description = proto.String(description) diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index a7a05ae6a..5996c469c 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -109,23 +109,17 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro config.FlagArtifacts = configs.FlagArtifacts.Clone() // Add RELEASE_ACONFIG_VALUE_SETS workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) - container := rc_proto.Container(rc_proto.Container_ALL) releaseAconfigValueSets := FlagArtifact{ FlagDeclaration: &rc_proto.FlagDeclaration{ Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), Namespace: proto.String("android_UNKNOWN"), Description: proto.String("Aconfig value sets assembled by release-config"), Workflow: &workflowManual, - Container: &container, - Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{""}}, + Containers: []string{"system", "system_ext", "product", "vendor"}, + Value: &rc_proto.Value{Val: &rc_proto.Value_UnspecifiedValue{false}}, }, DeclarationIndex: -1, - Traces: []*rc_proto.Tracepoint{ - &rc_proto.Tracepoint{ - Source: proto.String("$release-config"), - Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{""}}, - }, - }, + Traces: []*rc_proto.Tracepoint{}, } config.FlagArtifacts["RELEASE_ACONFIG_VALUE_SETS"] = &releaseAconfigValueSets @@ -163,22 +157,22 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro } myDirsMap := make(map[int]bool) for _, contrib := range contributionsToApply { - if len(contrib.proto.AconfigValueSets) > 0 { - contribAconfigValueSets := []string{} - for _, v := range contrib.proto.AconfigValueSets { - if _, ok := myAconfigValueSetsMap[v]; !ok { - contribAconfigValueSets = append(contribAconfigValueSets, v) - myAconfigValueSetsMap[v] = true - } + contribAconfigValueSets := []string{} + // Gather the aconfig_value_sets from this contribution that are not already in the list. + for _, v := range contrib.proto.AconfigValueSets { + if _, ok := myAconfigValueSetsMap[v]; !ok { + contribAconfigValueSets = append(contribAconfigValueSets, v) + myAconfigValueSetsMap[v] = true } - myAconfigValueSets = append(myAconfigValueSets, contribAconfigValueSets...) - releaseAconfigValueSets.Traces = append( - releaseAconfigValueSets.Traces, - &rc_proto.Tracepoint{ - Source: proto.String(contrib.path), - Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.Join(contribAconfigValueSets, " ")}}, - }) } + myAconfigValueSets = append(myAconfigValueSets, contribAconfigValueSets...) + releaseAconfigValueSets.Traces = append( + releaseAconfigValueSets.Traces, + &rc_proto.Tracepoint{ + Source: proto.String(contrib.path), + Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.Join(contribAconfigValueSets, " ")}}, + }) + myDirsMap[contrib.DeclarationIndex] = true for _, value := range contrib.FlagValues { name := *value.proto.Name @@ -214,30 +208,16 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro // Now build the per-partition artifacts config.PartitionBuildFlags = make(map[string]*rc_proto.FlagArtifacts) - addPartitionArtifact := func(container string, artifact *rc_proto.FlagArtifact) { - if _, ok := config.PartitionBuildFlags[container]; !ok { - config.PartitionBuildFlags[container] = &rc_proto.FlagArtifacts{} - } - config.PartitionBuildFlags[container].FlagArtifacts = append(config.PartitionBuildFlags[container].FlagArtifacts, artifact) - } for _, v := range config.FlagArtifacts { - container := strings.ToLower(rc_proto.Container_name[int32(v.FlagDeclaration.GetContainer())]) artifact, err := v.MarshalWithoutTraces() if err != nil { return err } - switch container { - case "all": - for cVal, cName := range rc_proto.Container_name { - // Skip unspecified, and "ALL", but place the flag in the rest. - if cVal == 0 || cName == "ALL" { - continue - } - cName = strings.ToLower(cName) - addPartitionArtifact(cName, artifact) + for _, container := range v.FlagDeclaration.Containers { + if _, ok := config.PartitionBuildFlags[container]; !ok { + config.PartitionBuildFlags[container] = &rc_proto.FlagArtifacts{} } - default: - addPartitionArtifact(container, artifact) + config.PartitionBuildFlags[container].FlagArtifacts = append(config.PartitionBuildFlags[container].FlagArtifacts, artifact) } } config.ReleaseConfigArtifact = &rc_proto.ReleaseConfigArtifact{ diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 3204b1873..d7d4a8c9c 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -118,9 +118,14 @@ func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex int) error { m := ReleaseConfigMapFactory(path) - if m.proto.DefaultContainer == nil { + if m.proto.DefaultContainers == nil { return fmt.Errorf("Release config map %s lacks default_container", path) } + for _, container := range m.proto.DefaultContainers { + if !validContainer(container) { + return fmt.Errorf("Release config map %s has invalid container %s", path, container) + } + } dir := filepath.Dir(path) // Record any aliases, checking for duplicates. for _, alias := range m.proto.Aliases { @@ -138,9 +143,16 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex err = WalkTextprotoFiles(dir, "flag_declarations", func(path string, d fs.DirEntry, err error) error { flagDeclaration := FlagDeclarationFactory(path) // Container must be specified. - if flagDeclaration.Container == nil { - flagDeclaration.Container = m.proto.DefaultContainer + if flagDeclaration.Containers == nil { + flagDeclaration.Containers = m.proto.DefaultContainers + } else { + for _, container := range flagDeclaration.Containers { + if !validContainer(container) { + return fmt.Errorf("Flag declaration %s has invalid container %s", path, container) + } + } } + // TODO: once we have namespaces initialized, we can throw an error here. if flagDeclaration.Namespace == nil { flagDeclaration.Namespace = proto.String("android_UNKNOWN") @@ -253,19 +265,12 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro flag := myFlagArtifacts[name] decl := flag.FlagDeclaration - // cName := strings.ToLower(rc_proto.Container_name[decl.GetContainer()]) - cName := strings.ToLower(decl.Container.String()) - if cName == strings.ToLower(rc_proto.Container_ALL.String()) { - partitions["product"] = append(partitions["product"], name) - partitions["system"] = append(partitions["system"], name) - partitions["system_ext"] = append(partitions["system_ext"], name) - partitions["vendor"] = append(partitions["vendor"], name) - } else { - partitions[cName] = append(partitions[cName], name) + for _, container := range decl.Containers { + partitions[container] = append(partitions[container], name) } value := MarshalValue(flag.Value) makeVars[name] = value - addVar(name, "PARTITIONS", cName) + addVar(name, "PARTITIONS", strings.Join(decl.Containers, " ")) addVar(name, "DEFAULT", MarshalValue(decl.Value)) addVar(name, "VALUE", value) addVar(name, "DECLARED_IN", *flag.Traces[0].Source) diff --git a/cmd/release_config/release_config_lib/util.go b/cmd/release_config/release_config_lib/util.go index 86940da68..d55cf291e 100644 --- a/cmd/release_config/release_config_lib/util.go +++ b/cmd/release_config/release_config_lib/util.go @@ -20,13 +20,17 @@ import ( "io/fs" "os" "path/filepath" + "regexp" "strings" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" ) -var disableWarnings bool +var ( + disableWarnings bool + containerRegexp, _ = regexp.Compile("^[a-z][a-z0-9]*([._][a-z][a-z0-9]*)*$") +) type StringList []string @@ -128,6 +132,10 @@ func warnf(format string, args ...any) (n int, err error) { return 0, nil } +func validContainer(container string) bool { + return containerRegexp.MatchString(container) +} + // Returns the default value for release config artifacts. func GetDefaultOutDir() string { outEnv := os.Getenv("OUT_DIR") diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go index ca2005c4b..8054bd9ea 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go @@ -98,76 +98,6 @@ func (Workflow) EnumDescriptor() ([]byte, []int) { return file_build_flags_src_proto_rawDescGZIP(), []int{0} } -type Container int32 - -const ( - Container_UNSPECIFIED_container Container = 0 - // All containers - Container_ALL Container = 1 - // Specific containers - Container_PRODUCT Container = 2 - Container_SYSTEM Container = 3 - Container_SYSTEM_EXT Container = 4 - Container_VENDOR Container = 5 -) - -// Enum value maps for Container. -var ( - Container_name = map[int32]string{ - 0: "UNSPECIFIED_container", - 1: "ALL", - 2: "PRODUCT", - 3: "SYSTEM", - 4: "SYSTEM_EXT", - 5: "VENDOR", - } - Container_value = map[string]int32{ - "UNSPECIFIED_container": 0, - "ALL": 1, - "PRODUCT": 2, - "SYSTEM": 3, - "SYSTEM_EXT": 4, - "VENDOR": 5, - } -) - -func (x Container) Enum() *Container { - p := new(Container) - *p = x - return p -} - -func (x Container) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Container) Descriptor() protoreflect.EnumDescriptor { - return file_build_flags_src_proto_enumTypes[1].Descriptor() -} - -func (Container) Type() protoreflect.EnumType { - return &file_build_flags_src_proto_enumTypes[1] -} - -func (x Container) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Do not use. -func (x *Container) UnmarshalJSON(b []byte) error { - num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) - if err != nil { - return err - } - *x = Container(num) - return nil -} - -// Deprecated: Use Container.Descriptor instead. -func (Container) EnumDescriptor() ([]byte, []int) { - return file_build_flags_src_proto_rawDescGZIP(), []int{1} -} - type Value struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -298,7 +228,7 @@ type FlagDeclaration struct { Workflow *Workflow `protobuf:"varint,205,opt,name=workflow,enum=android.release_config_proto.Workflow" json:"workflow,omitempty"` // The container for this flag. This overrides any default container given // in the release_config_map message. - Container *Container `protobuf:"varint,206,opt,name=container,enum=android.release_config_proto.Container" json:"container,omitempty"` + Containers []string `protobuf:"bytes,206,rep,name=containers" json:"containers,omitempty"` } func (x *FlagDeclaration) Reset() { @@ -368,11 +298,11 @@ func (x *FlagDeclaration) GetWorkflow() Workflow { return Workflow_UNSPECIFIED_workflow } -func (x *FlagDeclaration) GetContainer() Container { - if x != nil && x.Container != nil { - return *x.Container +func (x *FlagDeclaration) GetContainers() []string { + if x != nil { + return x.Containers } - return Container_UNSPECIFIED_container + return nil } type FlagValue struct { @@ -581,7 +511,7 @@ type ReleaseConfigMap struct { // Description of this map and its intended use. Description *string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` // The default container for flags declared here. - DefaultContainer *Container `protobuf:"varint,3,opt,name=default_container,json=defaultContainer,enum=android.release_config_proto.Container" json:"default_container,omitempty"` + DefaultContainers []string `protobuf:"bytes,3,rep,name=default_containers,json=defaultContainers" json:"default_containers,omitempty"` } func (x *ReleaseConfigMap) Reset() { @@ -630,11 +560,11 @@ func (x *ReleaseConfigMap) GetDescription() string { return "" } -func (x *ReleaseConfigMap) GetDefaultContainer() Container { - if x != nil && x.DefaultContainer != nil { - return *x.DefaultContainer +func (x *ReleaseConfigMap) GetDefaultContainers() []string { + if x != nil { + return x.DefaultContainers } - return Container_UNSPECIFIED_container + return nil } var File_build_flags_src_proto protoreflect.FileDescriptor @@ -653,7 +583,7 @@ var file_build_flags_src_proto_rawDesc = []byte{ 0x6c, 0x75, 0x65, 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x18, 0xcb, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x08, 0x6f, 0x62, - 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x22, 0xbd, 0x02, + 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x96, 0x02, 0x0a, 0x10, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, @@ -668,59 +598,47 @@ var file_build_flags_src_proto_rawDesc = []byte{ 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x52, 0x08, 0x77, - 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x46, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x18, 0xce, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x61, 0x6e, - 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x4a, - 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x06, 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x79, 0x0a, - 0x0a, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x0a, 0x08, 0x72, - 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, 0x64, 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, - 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, 0x64, 0x22, 0x6e, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, - 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, - 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, - 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xd3, 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, - 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, - 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, - 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x54, 0x0a, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, - 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x27, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x10, 0x64, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2a, 0x4a, 0x0a, 0x08, 0x77, - 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x53, 0x50, 0x45, - 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x10, - 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, 0x0c, 0x0a, - 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x4d, - 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x2a, 0x64, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x10, 0x00, 0x12, - 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x4f, 0x44, - 0x55, 0x43, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x10, - 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x58, 0x54, 0x10, - 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x10, 0x05, 0x42, 0x33, 0x5a, - 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, - 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, + 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x1f, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0xce, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x06, + 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x79, 0x0a, 0x0a, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, + 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x0a, 0x08, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, 0x64, + 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, + 0x64, 0x22, 0x6e, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, + 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, + 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74, + 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, + 0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xac, + 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, + 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, + 0x69, 0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, + 0x0a, 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, + 0x6e, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x4a, 0x0a, + 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x53, + 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, + 0x77, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, + 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, + 0x06, 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, + 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, } var ( @@ -735,30 +653,27 @@ func file_build_flags_src_proto_rawDescGZIP() []byte { return file_build_flags_src_proto_rawDescData } -var file_build_flags_src_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_build_flags_src_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_build_flags_src_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_build_flags_src_proto_goTypes = []interface{}{ (Workflow)(0), // 0: android.release_config_proto.workflow - (Container)(0), // 1: android.release_config_proto.container - (*Value)(nil), // 2: android.release_config_proto.value - (*FlagDeclaration)(nil), // 3: android.release_config_proto.flag_declaration - (*FlagValue)(nil), // 4: android.release_config_proto.flag_value - (*ReleaseConfig)(nil), // 5: android.release_config_proto.release_config - (*ReleaseAlias)(nil), // 6: android.release_config_proto.release_alias - (*ReleaseConfigMap)(nil), // 7: android.release_config_proto.release_config_map + (*Value)(nil), // 1: android.release_config_proto.value + (*FlagDeclaration)(nil), // 2: android.release_config_proto.flag_declaration + (*FlagValue)(nil), // 3: android.release_config_proto.flag_value + (*ReleaseConfig)(nil), // 4: android.release_config_proto.release_config + (*ReleaseAlias)(nil), // 5: android.release_config_proto.release_alias + (*ReleaseConfigMap)(nil), // 6: android.release_config_proto.release_config_map } var file_build_flags_src_proto_depIdxs = []int32{ - 2, // 0: android.release_config_proto.flag_declaration.value:type_name -> android.release_config_proto.value + 1, // 0: android.release_config_proto.flag_declaration.value:type_name -> android.release_config_proto.value 0, // 1: android.release_config_proto.flag_declaration.workflow:type_name -> android.release_config_proto.workflow - 1, // 2: android.release_config_proto.flag_declaration.container:type_name -> android.release_config_proto.container - 2, // 3: android.release_config_proto.flag_value.value:type_name -> android.release_config_proto.value - 6, // 4: android.release_config_proto.release_config_map.aliases:type_name -> android.release_config_proto.release_alias - 1, // 5: android.release_config_proto.release_config_map.default_container:type_name -> android.release_config_proto.container - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 1, // 2: android.release_config_proto.flag_value.value:type_name -> android.release_config_proto.value + 5, // 3: android.release_config_proto.release_config_map.aliases:type_name -> android.release_config_proto.release_alias + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_build_flags_src_proto_init() } @@ -851,7 +766,7 @@ func file_build_flags_src_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_build_flags_src_proto_rawDesc, - NumEnums: 2, + NumEnums: 1, NumMessages: 6, NumExtensions: 0, NumServices: 0, diff --git a/cmd/release_config/release_config_proto/build_flags_src.proto b/cmd/release_config/release_config_proto/build_flags_src.proto index 92edc2a66..017e5d400 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.proto +++ b/cmd/release_config/release_config_proto/build_flags_src.proto @@ -53,19 +53,6 @@ enum workflow { MANUAL = 3; } -enum container { - UNSPECIFIED_container = 0; - - // All containers - ALL = 1; - - // Specific containers - PRODUCT = 2; - SYSTEM = 3; - SYSTEM_EXT = 4; - VENDOR = 5; -} - message value { oneof val { bool unspecified_value = 200; @@ -100,7 +87,7 @@ message flag_declaration { // The container for this flag. This overrides any default container given // in the release_config_map message. - optional container container = 206; + repeated string containers = 206; // The package associated with this flag. // (when Gantry is ready for it) optional string package = 207; @@ -152,7 +139,7 @@ message release_config_map { optional string description = 2; // The default container for flags declared here. - optional container default_container = 3; + repeated string default_containers = 3; // If needed, we can add these fields instead of hardcoding the location. // Flag declarations: `flag_declarations/*.textproto` From 89185daf2cbf0cc3aea0e96574d89de56c109167 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Mon, 29 Apr 2024 14:16:19 -0700 Subject: [PATCH 40/67] release_config: better default map paths - Automatically determine the top of the workspace. - build-flag defaults to using `get_build_var` to get product specific release config maps. - release-config defaults to using PRODUCT_RELEASE_CONFIG_MAPS but does not use `get_build_var` unless the argument is given. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I4ba3c5dfab43c4ebc3eeda13318f42e886dada4e Change-Id: I4ba3c5dfab43c4ebc3eeda13318f42e886dada4e --- cmd/release_config/build_flag/main.go | 4 +- cmd/release_config/crunch_flags/main.go | 3 +- cmd/release_config/release_config/main.go | 5 +- .../release_config_lib/release_configs.go | 7 ++- cmd/release_config/release_config_lib/util.go | 55 +++++++++++++++++-- 5 files changed, 63 insertions(+), 11 deletions(-) diff --git a/cmd/release_config/build_flag/main.go b/cmd/release_config/build_flag/main.go index 6f909af86..a8e632658 100644 --- a/cmd/release_config/build_flag/main.go +++ b/cmd/release_config/build_flag/main.go @@ -184,6 +184,7 @@ func main() { var err error var commonFlags Flags var configs *rc_lib.ReleaseConfigs + var useBuildVar bool outEnv := os.Getenv("OUT_DIR") if outEnv == "" { @@ -195,6 +196,7 @@ func main() { flag.Var(&commonFlags.maps, "map", "path to a release_config_map.textproto. may be repeated") flag.StringVar(&commonFlags.outDir, "out_dir", rc_lib.GetDefaultOutDir(), "basepath for the output. Multiple formats are created") flag.Var(&commonFlags.targetReleases, "release", "TARGET_RELEASE for this build") + flag.BoolVar(&useBuildVar, "use_get_build_var", true, "use get_build_var PRODUCT_RELEASE_CONFIG_MAPS") flag.Parse() if commonFlags.quiet { @@ -215,7 +217,7 @@ func main() { // If the users said `--release --all`, grab trunk staging for simplicity. relName = "trunk_staging" } - configs, err = rc_lib.ReadReleaseConfigMaps(commonFlags.maps, relName) + configs, err = rc_lib.ReadReleaseConfigMaps(commonFlags.maps, relName, true) if err != nil { panic(err) } diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index 5b640622b..b67374abf 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -311,8 +311,9 @@ func main() { var dirs rc_lib.StringList var namespacesFile string var descriptionsFile string + defaultTopDir, err := rc_lib.GetTopDir() - flag.StringVar(&top, "top", ".", "path to top of workspace") + flag.StringVar(&top, "top", defaultTopDir, "path to top of workspace") flag.Var(&dirs, "dir", "directory to process, relative to the top of the workspace") flag.StringVar(&namespacesFile, "namespaces", "", "location of file with 'flag_name namespace' information") flag.StringVar(&descriptionsFile, "descriptions", "", "location of file with 'directory description' information") diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index 22e72a560..c443257c6 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -34,6 +34,7 @@ func main() { var json, pb, textproto bool var product string var allMake bool + var useBuildVar bool defaultRelease := os.Getenv("TARGET_RELEASE") if defaultRelease == "" { @@ -50,6 +51,8 @@ func main() { flag.BoolVar(&json, "json", true, "write artifacts as json") flag.BoolVar(&pb, "pb", true, "write artifacts as binary protobuf") flag.BoolVar(&allMake, "all_make", true, "write makefiles for all release configs") + flag.BoolVar(&useBuildVar, "use_get_build_var", false, "use get_build_var PRODUCT_RELEASE_CONFIG_MAPS") + flag.Parse() if quiet { @@ -59,7 +62,7 @@ func main() { if err = os.Chdir(top); err != nil { panic(err) } - configs, err = rc_lib.ReadReleaseConfigMaps(releaseConfigMapPaths, targetRelease) + configs, err = rc_lib.ReadReleaseConfigMaps(releaseConfigMapPaths, targetRelease, useBuildVar) if err != nil { panic(err) } diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index d7d4a8c9c..6b4709107 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -365,11 +365,14 @@ func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) erro return nil } -func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease string) (*ReleaseConfigs, error) { +func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease string, useBuildVar bool) (*ReleaseConfigs, error) { var err error if len(releaseConfigMapPaths) == 0 { - releaseConfigMapPaths = GetDefaultMapPaths() + releaseConfigMapPaths, err = GetDefaultMapPaths(useBuildVar) + if err != nil { + return nil, err + } if len(releaseConfigMapPaths) == 0 { return nil, fmt.Errorf("No maps found") } diff --git a/cmd/release_config/release_config_lib/util.go b/cmd/release_config/release_config_lib/util.go index d55cf291e..52a1f85de 100644 --- a/cmd/release_config/release_config_lib/util.go +++ b/cmd/release_config/release_config_lib/util.go @@ -19,6 +19,7 @@ import ( "fmt" "io/fs" "os" + "os/exec" "path/filepath" "regexp" "strings" @@ -145,22 +146,64 @@ func GetDefaultOutDir() string { return filepath.Join(outEnv, "soong", "release-config") } +// Find the top of the workspace. +// +// This mirrors the logic in build/envsetup.sh's gettop(). +func GetTopDir() (topDir string, err error) { + workingDir, err := os.Getwd() + if err != nil { + return + } + topFile := "build/make/core/envsetup.mk" + for topDir = workingDir; topDir != "/"; topDir = filepath.Dir(topDir) { + if _, err = os.Stat(filepath.Join(topDir, topFile)); err == nil { + return filepath.Rel(workingDir, topDir) + } + } + return "", fmt.Errorf("Unable to locate top of workspace") +} + // Return the default list of map files to use. -func GetDefaultMapPaths() StringList { +func GetDefaultMapPaths(queryMaps bool) (defaultLocations StringList, err error) { var defaultMapPaths StringList - defaultLocations := StringList{ + workingDir, err := os.Getwd() + if err != nil { + return + } + defer func() { + os.Chdir(workingDir) + }() + topDir, err := GetTopDir() + os.Chdir(topDir) + + defaultLocations = StringList{ "build/release/release_config_map.textproto", "vendor/google_shared/build/release/release_config_map.textproto", "vendor/google/release/release_config_map.textproto", } for _, path := range defaultLocations { - if _, err := os.Stat(path); err == nil { + if _, err = os.Stat(path); err == nil { defaultMapPaths = append(defaultMapPaths, path) } } - prodMaps := os.Getenv("PRODUCT_RELEASE_CONFIG_MAPS") - if prodMaps != "" { + + var prodMaps string + if queryMaps { + getBuildVar := exec.Command("build/soong/soong_ui.bash", "--dumpvar-mode", "PRODUCT_RELEASE_CONFIG_MAPS") + var stdout strings.Builder + getBuildVar.Stdin = strings.NewReader("") + getBuildVar.Stdout = &stdout + err = getBuildVar.Run() + if err != nil { + return + } + prodMaps = stdout.String() + } else { + prodMaps = os.Getenv("PRODUCT_RELEASE_CONFIG_MAPS") + } + prodMaps = strings.TrimSpace(prodMaps) + if len(prodMaps) > 0 { defaultMapPaths = append(defaultMapPaths, strings.Split(prodMaps, " ")...) } - return defaultMapPaths + return } From 1cf2be9414f1f7eafc0b3048229e1150c451f3d0 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 30 Apr 2024 09:06:20 -0700 Subject: [PATCH 41/67] Support release configs with only aconfig flags Release configs with `aconfig_flags_only: true` can inherit build flag values, but cannot set them. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I2bdc88761d61fb20f10dc734f2ba87114f51b859 Change-Id: I2bdc88761d61fb20f10dc734f2ba87114f51b859 --- cmd/release_config/build_flag/main.go | 3 + cmd/release_config/crunch_flags/main.go | 33 ++++++--- .../release_config_lib/release_config.go | 7 ++ .../release_config_lib/release_configs.go | 3 + .../build_flags_src.pb.go | 72 +++++++++++-------- .../build_flags_src.proto | 3 + 6 files changed, 83 insertions(+), 38 deletions(-) diff --git a/cmd/release_config/build_flag/main.go b/cmd/release_config/build_flag/main.go index a8e632658..67edc3517 100644 --- a/cmd/release_config/build_flag/main.go +++ b/cmd/release_config/build_flag/main.go @@ -160,6 +160,9 @@ func SetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, a if err != nil { return err } + if release.AconfigFlagsOnly { + return fmt.Errorf("%s does not allow build flag overrides", targetRelease) + } flagArtifact, ok := release.FlagArtifacts[name] if !ok { return fmt.Errorf("Unknown build flag %s", name) diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index b67374abf..e107b9fbb 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -15,18 +15,29 @@ import ( "google.golang.org/protobuf/proto" ) -// When a flag declaration has an initial value that is a string, the default workflow is PREBUILT. -// If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is MANUAL. -var manualFlagNamePrefixes []string = []string{ - "RELEASE_ACONFIG_", - "RELEASE_PLATFORM_", -} +var ( + // When a flag declaration has an initial value that is a string, the default workflow is PREBUILT. + // If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is MANUAL. + manualFlagNamePrefixes []string = []string{ + "RELEASE_ACONFIG_", + "RELEASE_PLATFORM_", + } -var defaultFlagNamespace string = "android_UNKNOWN" + // Set `aconfig_flags_only: true` in these release configs. + aconfigFlagsOnlyConfigs map[string]bool = map[string]bool{ + "trunk_food": true, + } + + // Default namespace value. This is intentionally invalid. + defaultFlagNamespace string = "android_UNKNOWN" + + // What is the current name for "next". + nextName string = "ap3a" +) func RenameNext(name string) string { if name == "next" { - return "ap3a" + return nextName } return name } @@ -205,6 +216,9 @@ func ProcessBuildConfigs(dir, name string, paths []string, releaseProto *rc_prot fmt.Printf("%s: Unexpected value %s=%s\n", path, valName, valValue) } if flagValue != nil { + if releaseProto.AconfigFlagsOnly { + return fmt.Errorf("%s does not allow build flag overrides", RenameNext(name)) + } valPath := filepath.Join(dir, "flag_values", RenameNext(name), fmt.Sprintf("%s.textproto", valName)) err := WriteFile(valPath, flagValue) if err != nil { @@ -285,6 +299,9 @@ func ProcessReleaseConfigMap(dir string, descriptionMap map[string]string) error releaseConfig := &rc_proto.ReleaseConfig{ Name: proto.String(RenameNext(name)), } + if aconfigFlagsOnlyConfigs[name] { + releaseConfig.AconfigFlagsOnly = true + } configFiles := config[configRegexp.SubexpIndex("files")] files := strings.Split(strings.ReplaceAll(configFiles, "$(local_dir)", dir+"/"), " ") configInherits := config[configRegexp.SubexpIndex("inherits")] diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index 5996c469c..e51ff08b2 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -62,6 +62,10 @@ type ReleaseConfig struct { // The names of release configs that we inherit InheritNames []string + // True if this release config only allows inheritance and aconfig flag + // overrides. Build flag value overrides are an error. + AconfigFlagsOnly bool + // Unmarshalled flag artifacts FlagArtifacts FlagArtifacts @@ -174,6 +178,9 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro }) myDirsMap[contrib.DeclarationIndex] = true + if config.AconfigFlagsOnly && len(contrib.FlagValues) > 0 { + return fmt.Errorf("%s does not allow build flag overrides", config.Name) + } for _, value := range contrib.FlagValues { name := *value.proto.Name fa, ok := config.FlagArtifacts[name] diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 6b4709107..e5fd99e7c 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -206,6 +206,9 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex if err2 != nil { return err2 } + if releaseConfigContribution.proto.GetAconfigFlagsOnly() { + config.AconfigFlagsOnly = true + } m.ReleaseConfigContributions[name] = releaseConfigContribution config.Contributions = append(config.Contributions, releaseConfigContribution) return nil diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go index 8054bd9ea..dded97566 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go @@ -387,6 +387,8 @@ type ReleaseConfig struct { // List of names of the aconfig_value_set soong module(s) for this // contribution. AconfigValueSets []string `protobuf:"bytes,3,rep,name=aconfig_value_sets,json=aconfigValueSets" json:"aconfig_value_sets,omitempty"` + // Only aconfig flags are allowed in this release config. + AconfigFlagsOnly *bool `protobuf:"varint,4,opt,name=aconfig_flags_only,json=aconfigFlagsOnly" json:"aconfig_flags_only,omitempty"` } func (x *ReleaseConfig) Reset() { @@ -442,6 +444,13 @@ func (x *ReleaseConfig) GetAconfigValueSets() []string { return nil } +func (x *ReleaseConfig) GetAconfigFlagsOnly() bool { + if x != nil && x.AconfigFlagsOnly != nil { + return *x.AconfigFlagsOnly + } + return false +} + // Any aliases. These are used for continuous integration builder config. type ReleaseAlias struct { state protoimpl.MessageState @@ -609,36 +618,39 @@ var file_build_flags_src_proto_rawDesc = []byte{ 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x0a, 0x08, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, 0x64, 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, - 0x64, 0x22, 0x6e, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, - 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, - 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74, - 0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, - 0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xac, - 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, - 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, - 0x69, 0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, - 0x0a, 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, - 0x6e, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x4a, 0x0a, - 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x53, - 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, - 0x77, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, - 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, - 0x06, 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, - 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x64, 0x22, 0x9c, 0x01, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, + 0x72, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, + 0x72, 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, + 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x66, 0x6c, + 0x61, 0x67, 0x73, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, + 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x4f, 0x6e, 0x6c, 0x79, + 0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, + 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xac, 0x01, + 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, + 0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, + 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, + 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x4a, 0x0a, 0x08, + 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, + 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, 0x0c, + 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, + 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, + 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, } var ( diff --git a/cmd/release_config/release_config_proto/build_flags_src.proto b/cmd/release_config/release_config_proto/build_flags_src.proto index 017e5d400..0ef1a5ffa 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.proto +++ b/cmd/release_config/release_config_proto/build_flags_src.proto @@ -119,6 +119,9 @@ message release_config { // List of names of the aconfig_value_set soong module(s) for this // contribution. repeated string aconfig_value_sets = 3; + + // Only aconfig flags are allowed in this release config. + optional bool aconfig_flags_only = 4; } // Any aliases. These are used for continuous integration builder config. From ec4761aeee26bc07db7618cc97549b3a9021d1b1 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Mon, 29 Apr 2024 16:20:59 -0700 Subject: [PATCH 42/67] release_config: various cleanup - Allow scl and textproto data to coexist for now - Print warnings to stderr instead of stdout. - Improve formatting of output - Set displays the new value for all configs, and what file changed. - Use prettier error messages for better UX - put build-flag on the path. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I4c38860c2fb24db5111e0cecf790660a4ff2b8b2 Change-Id: I4c38860c2fb24db5111e0cecf790660a4ff2b8b2 --- bin/build-flag | 28 +++ cmd/release_config/build_flag/main.go | 181 ++++++++++++++---- cmd/release_config/crunch_flags/main.go | 26 ++- .../release_config_lib/release_configs.go | 9 +- cmd/release_config/release_config_lib/util.go | 6 +- 5 files changed, 205 insertions(+), 45 deletions(-) create mode 100755 bin/build-flag diff --git a/bin/build-flag b/bin/build-flag new file mode 100755 index 000000000..dc404bc97 --- /dev/null +++ b/bin/build-flag @@ -0,0 +1,28 @@ +#!/bin/bash -eu +# +# Copyright 2017 Google Inc. All rights reserved. +# +# 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. + +source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../make/shell_utils.sh +require_top + +# Save the current PWD for use in soong_ui +export ORIGINAL_PWD=${PWD} +export TOP=$(gettop) +source ${TOP}/build/soong/scripts/microfactory.bash + +soong_build_go build-flag android/soong/cmd/release_config/build_flag + +cd ${TOP} +exec "$(getoutdir)/build-flag" "$@" diff --git a/cmd/release_config/build_flag/main.go b/cmd/release_config/build_flag/main.go index 67edc3517..ec7d64f1e 100644 --- a/cmd/release_config/build_flag/main.go +++ b/cmd/release_config/build_flag/main.go @@ -1,10 +1,12 @@ package main import ( + "cmp" "flag" "fmt" "os" "path/filepath" + "slices" "strings" rc_lib "android/soong/cmd/release_config/release_config_lib" @@ -36,6 +38,16 @@ type Flags struct { // Disable warning messages quiet bool + + // Show all release configs + allReleases bool + + // Call get_build_var PRODUCT_RELEASE_CONFIG_MAPS to get the + // product-specific map directories. + useGetBuildVar bool + + // Panic on errors. + debug bool } type CommandFunc func(*rc_lib.ReleaseConfigs, Flags, string, []string) error @@ -60,6 +72,14 @@ func GetMapDir(path string) (string, error) { return "", fmt.Errorf("Could not determine directory from %s", path) } +func MarshalFlagDefaultValue(config *rc_lib.ReleaseConfig, name string) (ret string, err error) { + fa, ok := config.FlagArtifacts[name] + if !ok { + return "", fmt.Errorf("%s not found in %s", name, config.Name) + } + return rc_lib.MarshalValue(fa.Traces[0].Value), nil +} + func MarshalFlagValue(config *rc_lib.ReleaseConfig, name string) (ret string, err error) { fa, ok := config.FlagArtifacts[name] if !ok { @@ -68,19 +88,41 @@ func MarshalFlagValue(config *rc_lib.ReleaseConfig, name string) (ret string, er return rc_lib.MarshalValue(fa.Value), nil } +// Returns a list of ReleaseConfig objects for which to process flags. func GetReleaseArgs(configs *rc_lib.ReleaseConfigs, commonFlags Flags) ([]*rc_lib.ReleaseConfig, error) { var all bool - relFlags := flag.NewFlagSet("set", flag.ExitOnError) - relFlags.BoolVar(&all, "all", false, "Display all flags") + relFlags := flag.NewFlagSet("releaseFlags", flag.ExitOnError) + relFlags.BoolVar(&all, "all", false, "Display all releases") relFlags.Parse(commonFlags.targetReleases) var ret []*rc_lib.ReleaseConfig - if all { + if all || commonFlags.allReleases { + sortMap := map[string]int{ + "trunk_staging": 0, + "trunk_food": 10, + "trunk": 20, + // Anything not listed above, uses this for key 1 in the sort. + "-default": 100, + } + for _, config := range configs.ReleaseConfigs { ret = append(ret, config) } + slices.SortFunc(ret, func(a, b *rc_lib.ReleaseConfig) int { + mapValue := func(v *rc_lib.ReleaseConfig) int { + if v, ok := sortMap[v.Name]; ok { + return v + } + return sortMap["-default"] + } + if n := cmp.Compare(mapValue(a), mapValue(b)); n != 0 { + return n + } + return cmp.Compare(a.Name, b.Name) + }) return ret, nil } for _, arg := range relFlags.Args() { + // Return releases in the order that they were given. config, err := configs.GetReleaseConfig(arg) if err != nil { return nil, err @@ -92,12 +134,17 @@ func GetReleaseArgs(configs *rc_lib.ReleaseConfigs, commonFlags Flags) ([]*rc_li func GetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, args []string) error { isTrace := cmd == "trace" + isSet := cmd == "set" + var all bool - getFlags := flag.NewFlagSet("set", flag.ExitOnError) + getFlags := flag.NewFlagSet("get", flag.ExitOnError) getFlags.BoolVar(&all, "all", false, "Display all flags") getFlags.Parse(args) args = getFlags.Args() + if isSet { + commonFlags.allReleases = true + } releaseConfigList, err := GetReleaseArgs(configs, commonFlags) if err != nil { return err @@ -113,21 +160,72 @@ func GetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, a } } - showName := len(releaseConfigList) > 1 || len(args) > 1 - for _, config := range releaseConfigList { - var configName string - if len(releaseConfigList) > 1 { - configName = fmt.Sprintf("%s.", config.Name) - } + var maxVariableNameLen, maxReleaseNameLen int + var releaseNameFormat, variableNameFormat string + valueFormat := "%s" + showReleaseName := len(releaseConfigList) > 1 + showVariableName := len(args) > 1 + if showVariableName { for _, arg := range args { - val, err := MarshalFlagValue(config, arg) - if err != nil { - return err + maxVariableNameLen = max(len(arg), maxVariableNameLen) + } + variableNameFormat = fmt.Sprintf("%%-%ds ", maxVariableNameLen) + valueFormat = "'%s'" + } + if showReleaseName { + for _, config := range releaseConfigList { + maxReleaseNameLen = max(len(config.Name), maxReleaseNameLen) + } + releaseNameFormat = fmt.Sprintf("%%-%ds ", maxReleaseNameLen) + valueFormat = "'%s'" + } + + outputOneLine := func(variable, release, value, valueFormat string) { + var outStr string + if showVariableName { + outStr += fmt.Sprintf(variableNameFormat, variable) + } + if showReleaseName { + outStr += fmt.Sprintf(releaseNameFormat, release) + } + outStr += fmt.Sprintf(valueFormat, value) + fmt.Println(outStr) + } + + for _, arg := range args { + if _, ok := configs.FlagArtifacts[arg]; !ok { + return fmt.Errorf("%s is not a defined build flag", arg) + } + } + + for _, arg := range args { + for _, config := range releaseConfigList { + if isSet { + // If this is from the set command, format the output as: + // "" + // trunk_staging "" + // trunk "" + // + // ap1a "" + // ... + switch { + case config.Name == "trunk_staging": + defaultValue, err := MarshalFlagDefaultValue(config, arg) + if err != nil { + return err + } + outputOneLine(arg, "", defaultValue, valueFormat) + case config.AconfigFlagsOnly: + continue + case config.Name == "trunk": + fmt.Println() + } } - if showName { - fmt.Printf("%s%s=%s\n", configName, arg, val) + val, err := MarshalFlagValue(config, arg) + if err == nil { + outputOneLine(arg, config.Name, val, valueFormat) } else { - fmt.Printf("%s\n", val) + outputOneLine(arg, config.Name, "REDACTED", "%s") } if isTrace { for _, trace := range config.FlagArtifacts[arg].Traces { @@ -180,28 +278,48 @@ func SetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, a Value: rc_lib.UnmarshalValue(value), } flagPath := filepath.Join(valueDir, "flag_values", targetRelease, fmt.Sprintf("%s.textproto", name)) - return rc_lib.WriteMessage(flagPath, flagValue) + err = rc_lib.WriteMessage(flagPath, flagValue) + if err != nil { + return err + } + + // Reload the release configs. + configs, err = rc_lib.ReadReleaseConfigMaps(commonFlags.maps, commonFlags.targetReleases[0], commonFlags.useGetBuildVar) + if err != nil { + return err + } + err = GetCommand(configs, commonFlags, cmd, args[0:1]) + if err != nil { + return err + } + fmt.Printf("Updated: %s\n", flagPath) + return nil } func main() { - var err error var commonFlags Flags var configs *rc_lib.ReleaseConfigs - var useBuildVar bool + topDir, err := rc_lib.GetTopDir() - outEnv := os.Getenv("OUT_DIR") - if outEnv == "" { - outEnv = "out" - } // Handle the common arguments - flag.StringVar(&commonFlags.top, "top", ".", "path to top of workspace") + flag.StringVar(&commonFlags.top, "top", topDir, "path to top of workspace") flag.BoolVar(&commonFlags.quiet, "quiet", false, "disable warning messages") flag.Var(&commonFlags.maps, "map", "path to a release_config_map.textproto. may be repeated") - flag.StringVar(&commonFlags.outDir, "out_dir", rc_lib.GetDefaultOutDir(), "basepath for the output. Multiple formats are created") + flag.StringVar(&commonFlags.outDir, "out-dir", rc_lib.GetDefaultOutDir(), "basepath for the output. Multiple formats are created") flag.Var(&commonFlags.targetReleases, "release", "TARGET_RELEASE for this build") - flag.BoolVar(&useBuildVar, "use_get_build_var", true, "use get_build_var PRODUCT_RELEASE_CONFIG_MAPS") + flag.BoolVar(&commonFlags.allReleases, "all-releases", false, "operate on all releases. (Ignored for set command)") + flag.BoolVar(&commonFlags.useGetBuildVar, "use-get-build-var", true, "use get_build_var PRODUCT_RELEASE_CONFIG_MAPS to get needed maps") + flag.BoolVar(&commonFlags.debug, "debug", false, "turn on debugging output for errors") flag.Parse() + errorExit := func(err error) { + if commonFlags.debug { + panic(err) + } + fmt.Fprintf(os.Stderr, "%s\n", err) + os.Exit(1) + } + if commonFlags.quiet { rc_lib.DisableWarnings() } @@ -211,24 +329,23 @@ func main() { } if err = os.Chdir(commonFlags.top); err != nil { - panic(err) + errorExit(err) } // Get the current state of flagging. relName := commonFlags.targetReleases[0] if relName == "--all" || relName == "-all" { - // If the users said `--release --all`, grab trunk staging for simplicity. - relName = "trunk_staging" + commonFlags.allReleases = true } - configs, err = rc_lib.ReadReleaseConfigMaps(commonFlags.maps, relName, true) + configs, err = rc_lib.ReadReleaseConfigMaps(commonFlags.maps, relName, commonFlags.useGetBuildVar) if err != nil { - panic(err) + errorExit(err) } if cmd, ok := commandMap[flag.Arg(0)]; ok { args := flag.Args() if err = cmd(configs, commonFlags, args[0], args[1:]); err != nil { - panic(err) + errorExit(err) } } } diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index e107b9fbb..95342b1d0 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -216,7 +216,7 @@ func ProcessBuildConfigs(dir, name string, paths []string, releaseProto *rc_prot fmt.Printf("%s: Unexpected value %s=%s\n", path, valName, valValue) } if flagValue != nil { - if releaseProto.AconfigFlagsOnly { + if releaseProto.GetAconfigFlagsOnly() { return fmt.Errorf("%s does not allow build flag overrides", RenameNext(name)) } valPath := filepath.Join(dir, "flag_values", RenameNext(name), fmt.Sprintf("%s.textproto", valName)) @@ -300,7 +300,7 @@ func ProcessReleaseConfigMap(dir string, descriptionMap map[string]string) error Name: proto.String(RenameNext(name)), } if aconfigFlagsOnlyConfigs[name] { - releaseConfig.AconfigFlagsOnly = true + releaseConfig.AconfigFlagsOnly = proto.Bool(true) } configFiles := config[configRegexp.SubexpIndex("files")] files := strings.Split(strings.ReplaceAll(configFiles, "$(local_dir)", dir+"/"), " ") @@ -328,16 +328,26 @@ func main() { var dirs rc_lib.StringList var namespacesFile string var descriptionsFile string + var debug bool defaultTopDir, err := rc_lib.GetTopDir() flag.StringVar(&top, "top", defaultTopDir, "path to top of workspace") flag.Var(&dirs, "dir", "directory to process, relative to the top of the workspace") flag.StringVar(&namespacesFile, "namespaces", "", "location of file with 'flag_name namespace' information") flag.StringVar(&descriptionsFile, "descriptions", "", "location of file with 'directory description' information") + flag.BoolVar(&debug, "debug", false, "turn on debugging output for errors") flag.Parse() + errorExit := func(err error) { + if debug { + panic(err) + } + fmt.Fprintf(os.Stderr, "%s\n", err) + os.Exit(1) + } + if err = os.Chdir(top); err != nil { - panic(err) + errorExit(err) } if len(dirs) == 0 { dirs = rc_lib.StringList{"build/release", "vendor/google_shared/build/release", "vendor/google/release"} @@ -347,12 +357,12 @@ func main() { if namespacesFile != "" { data, err := os.ReadFile(namespacesFile) if err != nil { - panic(err) + errorExit(err) } for idx, line := range strings.Split(string(data), "\n") { fields := strings.Split(line, " ") if len(fields) > 2 { - panic(fmt.Errorf("line %d: too many fields: %s", idx, line)) + errorExit(fmt.Errorf("line %d: too many fields: %s", idx, line)) } namespaceMap[fields[0]] = fields[1] } @@ -364,7 +374,7 @@ func main() { if descriptionsFile != "" { data, err := os.ReadFile(descriptionsFile) if err != nil { - panic(err) + errorExit(err) } for _, line := range strings.Split(string(data), "\n") { if strings.TrimSpace(line) != "" { @@ -378,12 +388,12 @@ func main() { for _, dir := range dirs { err = ProcessBuildFlags(dir, namespaceMap) if err != nil { - panic(err) + errorExit(err) } err = ProcessReleaseConfigMap(dir, descriptionMap) if err != nil { - panic(err) + errorExit(err) } } } diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index e5fd99e7c..cedf247f8 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -117,9 +117,12 @@ func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { } func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex int) error { + if _, err := os.Stat(path); err != nil { + return fmt.Errorf("%s does not exist\n", path) + } m := ReleaseConfigMapFactory(path) if m.proto.DefaultContainers == nil { - return fmt.Errorf("Release config map %s lacks default_container", path) + return fmt.Errorf("Release config map %s lacks default_containers", path) } for _, container := range m.proto.DefaultContainers { if !validContainer(container) { @@ -379,7 +382,7 @@ func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease strin if len(releaseConfigMapPaths) == 0 { return nil, fmt.Errorf("No maps found") } - fmt.Printf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) + warnf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) } configs := ReleaseConfigsFactory() @@ -393,6 +396,8 @@ func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease strin mapsRead[configDir] = true configs.configDirIndexes[configDir] = idx configs.configDirs = append(configs.configDirs, configDir) + // Force the path to be the textproto path, so that both the scl and textproto formats can coexist. + releaseConfigMapPath = filepath.Join(configDir, "release_config_map.textproto") err = configs.LoadReleaseConfigMap(releaseConfigMapPath, idx) if err != nil { return nil, err diff --git a/cmd/release_config/release_config_lib/util.go b/cmd/release_config/release_config_lib/util.go index 52a1f85de..c0ea7897b 100644 --- a/cmd/release_config/release_config_lib/util.go +++ b/cmd/release_config/release_config_lib/util.go @@ -128,7 +128,7 @@ func DisableWarnings() { func warnf(format string, args ...any) (n int, err error) { if !disableWarnings { - return fmt.Printf(format, args...) + return fmt.Fprintf(os.Stderr, format, args...) } return 0, nil } @@ -164,8 +164,8 @@ func GetTopDir() (topDir string, err error) { } // Return the default list of map files to use. -func GetDefaultMapPaths(queryMaps bool) (defaultLocations StringList, err error) { - var defaultMapPaths StringList +func GetDefaultMapPaths(queryMaps bool) (defaultMapPaths StringList, err error) { + var defaultLocations StringList workingDir, err := os.Getwd() if err != nil { return From b914711070050dda5e1e29052c2a66eba08069d3 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 1 May 2024 10:06:32 -0700 Subject: [PATCH 43/67] Guard with RELEASE_BUILD_FLAGS_IN_PROTOBUF If false, then we output an empty file, which will cause release_config.mk to do the old process. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I4aa82301f3bbb29633a275a801431a6667feb48d Change-Id: I4aa82301f3bbb29633a275a801431a6667feb48d --- cmd/release_config/crunch_flags/main.go | 1 + cmd/release_config/release_config/main.go | 21 ++++--- .../release_config_lib/flag_value.go | 3 + .../release_config_lib/flag_value_test.go | 55 +++++++++++++++++-- 4 files changed, 69 insertions(+), 11 deletions(-) diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index 95342b1d0..4d763c8d7 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -21,6 +21,7 @@ var ( manualFlagNamePrefixes []string = []string{ "RELEASE_ACONFIG_", "RELEASE_PLATFORM_", + "RELEASE_BUILD_FLAGS_", } // Set `aconfig_flags_only: true` in these release configs. diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index c443257c6..fac31f092 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -35,6 +35,7 @@ func main() { var product string var allMake bool var useBuildVar bool + var guard bool defaultRelease := os.Getenv("TARGET_RELEASE") if defaultRelease == "" { @@ -52,6 +53,7 @@ func main() { flag.BoolVar(&pb, "pb", true, "write artifacts as binary protobuf") flag.BoolVar(&allMake, "all_make", true, "write makefiles for all release configs") flag.BoolVar(&useBuildVar, "use_get_build_var", false, "use get_build_var PRODUCT_RELEASE_CONFIG_MAPS") + flag.BoolVar(&guard, "guard", true, "whether to guard with RELEASE_BUILD_FLAGS_IN_PROTOBUF") flag.Parse() @@ -76,20 +78,21 @@ func main() { panic(err) } - if err = config.WritePartitionBuildFlags(outputDir, product, targetRelease); err != nil { - panic(err) - } - - if allMake { + makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, releaseName)) + useProto, ok := config.FlagArtifacts["RELEASE_BUILD_FLAGS_IN_PROTOBUF"] + if guard && (!ok || rc_lib.MarshalValue(useProto.Value) == "") { + // We were told to guard operation and either we have no build flag, or it is False. + // Write an empty file so that release_config.mk will use the old process. + os.WriteFile(makefilePath, []byte{}, 0644) + } else if allMake { for k, _ := range configs.ReleaseConfigs { - makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k)) + makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k)) err = configs.WriteMakefile(makefilePath, k) if err != nil { panic(err) } } } else { - makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, releaseName)) err = configs.WriteMakefile(makefilePath, targetRelease) if err != nil { panic(err) @@ -113,4 +116,8 @@ func main() { panic(err) } } + if err = config.WritePartitionBuildFlags(outputDir, product, targetRelease); err != nil { + panic(err) + } + } diff --git a/cmd/release_config/release_config_lib/flag_value.go b/cmd/release_config/release_config_lib/flag_value.go index e155e7782..59021e260 100644 --- a/cmd/release_config/release_config_lib/flag_value.go +++ b/cmd/release_config/release_config_lib/flag_value.go @@ -52,6 +52,9 @@ func UnmarshalValue(str string) *rc_proto.Value { } func MarshalValue(value *rc_proto.Value) string { + if value == nil { + return "" + } switch val := value.Val.(type) { case *rc_proto.Value_UnspecifiedValue: // Value was never set. diff --git a/cmd/release_config/release_config_lib/flag_value_test.go b/cmd/release_config/release_config_lib/flag_value_test.go index aaa4cafeb..8a98baf6a 100644 --- a/cmd/release_config/release_config_lib/flag_value_test.go +++ b/cmd/release_config/release_config_lib/flag_value_test.go @@ -24,7 +24,7 @@ import ( "google.golang.org/protobuf/proto" ) -type testCaseFlagValue struct { +type testCaseFlagValueFactory struct { protoPath string name string data []byte @@ -32,14 +32,14 @@ type testCaseFlagValue struct { err error } -func (tc testCaseFlagValue) assertProtoEqual(t *testing.T, expected, actual proto.Message) { +func (tc testCaseFlagValueFactory) assertProtoEqual(t *testing.T, expected, actual proto.Message) { if !proto.Equal(expected, actual) { t.Errorf("Expected %q found %q", expected, actual) } } -func TestFlagValue(t *testing.T) { - testCases := []testCaseFlagValue{ +func TestFlagValueFactory(t *testing.T) { + testCases := []testCaseFlagValueFactory{ { name: "stringVal", protoPath: "build/release/flag_values/test/RELEASE_FOO.textproto", @@ -65,3 +65,50 @@ func TestFlagValue(t *testing.T) { tc.assertProtoEqual(t, &tc.expected, &actual.proto) } } + +type testCaseMarshalValue struct { + name string + value *rc_proto.Value + expected string +} + +func TestMarshalValue(t *testing.T) { + testCases := []testCaseMarshalValue{ + { + name: "nil", + value: nil, + expected: "", + }, + { + name: "unspecified", + value: &rc_proto.Value{}, + expected: "", + }, + { + name: "false", + value: &rc_proto.Value{Val: &rc_proto.Value_BoolValue{false}}, + expected: "", + }, + { + name: "true", + value: &rc_proto.Value{Val: &rc_proto.Value_BoolValue{true}}, + expected: "true", + }, + { + name: "string", + value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{"BAR"}}, + expected: "BAR", + }, + { + name: "obsolete", + value: &rc_proto.Value{Val: &rc_proto.Value_Obsolete{true}}, + expected: " #OBSOLETE", + }, + } + for _, tc := range testCases { + actual := MarshalValue(tc.value) + if actual != tc.expected { + t.Errorf("Expected %q found %q", tc.expected, actual) + } + } +} From ccc96dff5ec6274411eabbbe0d4b1c10a08030c1 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 30 Apr 2024 16:53:09 -0700 Subject: [PATCH 44/67] RELEASE_ACONFIG_VALUE_SETS is a reserved flag Disallow setting the flag via protobuf files, and adjust it internally to be more like any other build flag. This makes the generated output more consistent. Also default to TARGET_RELEASE if no release is given to `build-flag`. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I9db57137fc4e5ed42a38adc939c430826afe4f63 Change-Id: I9db57137fc4e5ed42a38adc939c430826afe4f63 --- cmd/release_config/build_flag/main.go | 7 ++- .../release_config_lib/release_config.go | 53 +++++++++---------- .../release_config_lib/release_configs.go | 29 ++++++++-- 3 files changed, 57 insertions(+), 32 deletions(-) diff --git a/cmd/release_config/build_flag/main.go b/cmd/release_config/build_flag/main.go index ec7d64f1e..56c49d883 100644 --- a/cmd/release_config/build_flag/main.go +++ b/cmd/release_config/build_flag/main.go @@ -325,7 +325,12 @@ func main() { } if len(commonFlags.targetReleases) == 0 { - commonFlags.targetReleases = rc_lib.StringList{"trunk_staging"} + release, ok := os.LookupEnv("TARGET_RELEASE") + if ok { + commonFlags.targetReleases = rc_lib.StringList{release} + } else { + commonFlags.targetReleases = rc_lib.StringList{"trunk_staging"} + } } if err = os.Chdir(commonFlags.top); err != nil { diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index e51ff08b2..f25cc6e66 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -90,7 +90,13 @@ func (config *ReleaseConfig) InheritConfig(iConfig *ReleaseConfig) error { if !ok { return fmt.Errorf("Could not inherit flag %s from %s", name, iConfig.Name) } - if len(fa.Traces) > 1 { + if name == "RELEASE_ACONFIG_VALUE_SETS" { + if len(fa.Traces) > 0 { + myFa.Traces = append(myFa.Traces, fa.Traces...) + myFa.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{ + myFa.Value.GetStringValue() + " " + fa.Value.GetStringValue()}} + } + } else if len(fa.Traces) > 1 { // A value was assigned. Set our value. myFa.Traces = append(myFa.Traces, fa.Traces[1:]...) myFa.Value = fa.Value @@ -111,21 +117,7 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro // Start with only the flag declarations. config.FlagArtifacts = configs.FlagArtifacts.Clone() - // Add RELEASE_ACONFIG_VALUE_SETS - workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) - releaseAconfigValueSets := FlagArtifact{ - FlagDeclaration: &rc_proto.FlagDeclaration{ - Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), - Namespace: proto.String("android_UNKNOWN"), - Description: proto.String("Aconfig value sets assembled by release-config"), - Workflow: &workflowManual, - Containers: []string{"system", "system_ext", "product", "vendor"}, - Value: &rc_proto.Value{Val: &rc_proto.Value_UnspecifiedValue{false}}, - }, - DeclarationIndex: -1, - Traces: []*rc_proto.Tracepoint{}, - } - config.FlagArtifacts["RELEASE_ACONFIG_VALUE_SETS"] = &releaseAconfigValueSets + releaseAconfigValueSets := config.FlagArtifacts["RELEASE_ACONFIG_VALUE_SETS"] // Generate any configs we need to inherit. This will detect loops in // the config. @@ -154,27 +146,22 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro } contributionsToApply = append(contributionsToApply, config.Contributions...) - myAconfigValueSets := strings.Split(releaseAconfigValueSets.Value.GetStringValue(), " ") - myAconfigValueSetsMap := map[string]bool{} - for _, v := range myAconfigValueSets { - myAconfigValueSetsMap[v] = true - } + workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) myDirsMap := make(map[int]bool) for _, contrib := range contributionsToApply { contribAconfigValueSets := []string{} - // Gather the aconfig_value_sets from this contribution that are not already in the list. + // Gather the aconfig_value_sets from this contribution, allowing duplicates for simplicity. for _, v := range contrib.proto.AconfigValueSets { - if _, ok := myAconfigValueSetsMap[v]; !ok { - contribAconfigValueSets = append(contribAconfigValueSets, v) - myAconfigValueSetsMap[v] = true - } + contribAconfigValueSets = append(contribAconfigValueSets, v) } - myAconfigValueSets = append(myAconfigValueSets, contribAconfigValueSets...) + contribAconfigValueSetsString := strings.Join(contribAconfigValueSets, " ") + releaseAconfigValueSets.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{ + releaseAconfigValueSets.Value.GetStringValue() + " " + contribAconfigValueSetsString}} releaseAconfigValueSets.Traces = append( releaseAconfigValueSets.Traces, &rc_proto.Tracepoint{ Source: proto.String(contrib.path), - Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.Join(contribAconfigValueSets, " ")}}, + Value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{contribAconfigValueSetsString}}, }) myDirsMap[contrib.DeclarationIndex] = true @@ -204,6 +191,16 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro } } } + // Now remove any duplicates from the actual value of RELEASE_ACONFIG_VALUE_SETS + myAconfigValueSets := []string{} + myAconfigValueSetsMap := map[string]bool{} + for _, v := range strings.Split(releaseAconfigValueSets.Value.GetStringValue(), " ") { + if myAconfigValueSetsMap[v] { + continue + } + myAconfigValueSetsMap[v] = true + myAconfigValueSets = append(myAconfigValueSets, v) + } releaseAconfigValueSets.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{strings.TrimSpace(strings.Join(myAconfigValueSets, " "))}} directories := []string{} diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index cedf247f8..34294002c 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -95,7 +95,7 @@ func (configs *ReleaseConfigs) WriteArtifact(outDir, product, format string) err } func ReleaseConfigsFactory() (c *ReleaseConfigs) { - return &ReleaseConfigs{ + configs := ReleaseConfigs{ Aliases: make(map[string]*string), FlagArtifacts: make(map[string]*FlagArtifact), ReleaseConfigs: make(map[string]*ReleaseConfig), @@ -103,6 +103,21 @@ func ReleaseConfigsFactory() (c *ReleaseConfigs) { configDirs: []string{}, configDirIndexes: make(ReleaseConfigDirMap), } + workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) + releaseAconfigValueSets := FlagArtifact{ + FlagDeclaration: &rc_proto.FlagDeclaration{ + Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), + Namespace: proto.String("android_UNKNOWN"), + Description: proto.String("Aconfig value sets assembled by release-config"), + Workflow: &workflowManual, + Containers: []string{"system", "system_ext", "product", "vendor"}, + Value: &rc_proto.Value{Val: &rc_proto.Value_UnspecifiedValue{false}}, + }, + DeclarationIndex: -1, + Traces: []*rc_proto.Tracepoint{}, + } + configs.FlagArtifacts["RELEASE_ACONFIG_VALUE_SETS"] = &releaseAconfigValueSets + return &configs } func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { @@ -166,6 +181,9 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex } m.FlagDeclarations = append(m.FlagDeclarations, *flagDeclaration) name := *flagDeclaration.Name + if name == "RELEASE_ACONFIG_VALUE_SETS" { + return fmt.Errorf("%s: %s is a reserved build flag", path, name) + } if def, ok := configs.FlagArtifacts[name]; !ok { configs.FlagArtifacts[name] = &FlagArtifact{FlagDeclaration: flagDeclaration, DeclarationIndex: ConfigDirIndex} } else if !proto.Equal(def.FlagDeclaration, flagDeclaration) { @@ -176,7 +194,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex FlagValue{path: path, proto: rc_proto.FlagValue{ Name: proto.String(name), Value: flagDeclaration.Value}}) if configs.FlagArtifacts[name].Redacted { - return fmt.Errorf("%s may not be redacted by default.", *flagDeclaration.Name) + return fmt.Errorf("%s may not be redacted by default.", name) } return nil }) @@ -203,6 +221,9 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex if fmt.Sprintf("%s.textproto", *flagValue.proto.Name) != filepath.Base(path) { return fmt.Errorf("%s incorrectly sets value for flag %s", path, *flagValue.proto.Name) } + if *flagValue.proto.Name == "RELEASE_ACONFIG_VALUE_SETS" { + return fmt.Errorf("%s: %s is a reserved build flag", path, *flagValue.proto.Name) + } releaseConfigContribution.FlagValues = append(releaseConfigContribution.FlagValues, flagValue) return nil }) @@ -382,7 +403,9 @@ func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease strin if len(releaseConfigMapPaths) == 0 { return nil, fmt.Errorf("No maps found") } - warnf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) + if !useBuildVar { + warnf("No --map argument provided. Using: --map %s\n", strings.Join(releaseConfigMapPaths, " --map ")) + } } configs := ReleaseConfigsFactory() From eb6826fe2825fab55ec679111a0723ac86325cb7 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 2 May 2024 15:19:18 -0700 Subject: [PATCH 45/67] release-config: use ${TARGET_RELEASE} for output When the passed release name is an alias, write release_config-PRODUCT-RELEASE.mk using the alias, since that is where core/release_config.mk is going to look for it. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I4e6909f43bf136974323754e06fa538e39e0faab Change-Id: I4e6909f43bf136974323754e06fa538e39e0faab --- cmd/release_config/release_config/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index fac31f092..101dbe381 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -72,19 +72,19 @@ func main() { if err != nil { panic(err) } - releaseName := config.Name err = os.MkdirAll(outputDir, 0775) if err != nil { panic(err) } - makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, releaseName)) + makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, targetRelease)) useProto, ok := config.FlagArtifacts["RELEASE_BUILD_FLAGS_IN_PROTOBUF"] if guard && (!ok || rc_lib.MarshalValue(useProto.Value) == "") { // We were told to guard operation and either we have no build flag, or it is False. // Write an empty file so that release_config.mk will use the old process. os.WriteFile(makefilePath, []byte{}, 0644) } else if allMake { + // Write one makefile per release config, using the canonical release name. for k, _ := range configs.ReleaseConfigs { makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k)) err = configs.WriteMakefile(makefilePath, k) From 784925ffbe9667671bc7980b7db183e86a9dd2fd Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 7 May 2024 12:42:34 -0700 Subject: [PATCH 46/67] build_flag: improve default flag value directory The default directory for flag values is the last of: - Where the flag is declared, - Where the release config is first declared, - Where the flag value is currently being set for this release config. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: Ida1f906b75704f658e7fa1de703e0c789dce06a6 Change-Id: Ida1f906b75704f658e7fa1de703e0c789dce06a6 --- cmd/release_config/build_flag/main.go | 2 +- .../release_config_lib/release_config.go | 2 +- .../release_config_lib/release_configs.go | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/cmd/release_config/build_flag/main.go b/cmd/release_config/build_flag/main.go index 56c49d883..cc2b57a27 100644 --- a/cmd/release_config/build_flag/main.go +++ b/cmd/release_config/build_flag/main.go @@ -266,7 +266,7 @@ func SetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, a return fmt.Errorf("Unknown build flag %s", name) } if valueDir == "" { - mapDir, err := GetMapDir(*flagArtifact.Traces[len(flagArtifact.Traces)-1].Source) + mapDir, err := configs.GetFlagValueDirectory(release, flagArtifact) if err != nil { return err } diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index f25cc6e66..820482239 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -29,7 +29,7 @@ import ( // One directory's contribution to the a release config. type ReleaseConfigContribution struct { - // Paths to files providing this config. + // Path of the file providing this config contribution. path string // The index of the config directory where this release config diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 34294002c..8a4e2d58b 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -131,6 +131,32 @@ func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { return m } +// Find the top of the release config contribution directory. +// Returns the parent of the flag_declarations and flag_values directories. +func (configs *ReleaseConfigs) GetDirIndex(path string) (int, error) { + for p := path; p != "."; p = filepath.Dir(p) { + if idx, ok := configs.configDirIndexes[p]; ok { + return idx, nil + } + } + return -1, fmt.Errorf("Could not determine release config directory from %s", path) +} + +// Determine the default directory for writing a flag value. +// +// Returns the path of the highest-Indexed one of: +// - Where the flag is declared +// - Where the release config is first declared +// - The last place the value is being written. +func (configs *ReleaseConfigs) GetFlagValueDirectory(config *ReleaseConfig, flag *FlagArtifact) (string, error) { + current, err := configs.GetDirIndex(*flag.Traces[len(flag.Traces)-1].Source) + if err != nil { + return "", err + } + index := max(flag.DeclarationIndex, config.DeclarationIndex, current) + return configs.configDirs[index], nil +} + func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex int) error { if _, err := os.Stat(path); err != nil { return fmt.Errorf("%s does not exist\n", path) From 57f0fe545736b5e310391dcb46b31ad920b1a7f1 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 8 May 2024 09:13:13 -0700 Subject: [PATCH 47/67] Always write makefile for ${TARGET_RELEASE} When writing all makefiles, we also need to write the makefile for ${TARGET_RELEASE}. We can skip writing it a second time if it is not an alias. Bug: 328495189 Test: manual, TH Ignore-AOSP-First: cherry-pick Merged-In: Ia5d1955f419312c76eb9c8a33b1c8a6bcc5efe0b Change-Id: Ia5d1955f419312c76eb9c8a33b1c8a6bcc5efe0b --- cmd/release_config/release_config/main.go | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index 101dbe381..54328068a 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -83,20 +83,24 @@ func main() { // We were told to guard operation and either we have no build flag, or it is False. // Write an empty file so that release_config.mk will use the old process. os.WriteFile(makefilePath, []byte{}, 0644) - } else if allMake { + return + } + // Write the makefile where release_config.mk is going to look for it. + err = configs.WriteMakefile(makefilePath, targetRelease) + if err != nil { + panic(err) + } + if allMake { // Write one makefile per release config, using the canonical release name. for k, _ := range configs.ReleaseConfigs { - makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k)) - err = configs.WriteMakefile(makefilePath, k) - if err != nil { - panic(err) + if k != targetRelease { + makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k)) + err = configs.WriteMakefile(makefilePath, k) + if err != nil { + panic(err) + } } } - } else { - err = configs.WriteMakefile(makefilePath, targetRelease) - if err != nil { - panic(err) - } } if json { err = configs.WriteArtifact(outputDir, product, "json") From 7ca4a9953bb5ba9e46a6c7aeff4979164a467663 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 9 May 2024 15:24:27 -0700 Subject: [PATCH 48/67] sort _all_release_configs variable before we write it Bug: 339707888 Test: manual, TH Ignore-AOSP-First: cherry-pick Merged-In: Icbf9a8f84a62b60469ed636f69818c9179d2ddf6 Change-Id: Icbf9a8f84a62b60469ed636f69818c9179d2ddf6 --- cmd/release_config/release_config_lib/release_configs.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 8a4e2d58b..2487f2e99 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -291,6 +291,9 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro allReleaseNames = append(allReleaseNames, v.Name) allReleaseNames = append(allReleaseNames, v.OtherNames...) } + slices.SortFunc(allReleaseNames, func(a, b string) int { + return cmp.Compare(a, b) + }) config, err := configs.GetReleaseConfig(targetRelease) if err != nil { return err From 4fe89fdfbc1e910bad5223f723a6cc0fa8994a7a Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 8 May 2024 17:24:51 -0700 Subject: [PATCH 49/67] crunch_flags: handle non-string ACONFIG_VALUE_SETS If the default value for RELEASE_ACONFIG_VALUE_SETS is not a string, the resulting value is the empty string. Bug: 328495189 Test: manual Ignore-AOSP-First: cherrypick Merged-In: Ie8f262d6408b1564ec7a3918f8654ccfa9bc5940 Change-Id: Ie8f262d6408b1564ec7a3918f8654ccfa9bc5940 --- cmd/release_config/crunch_flags/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index 4d763c8d7..cd39ffd11 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -137,7 +137,9 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { workflow := rc_proto.Workflow(rc_proto.Workflow_PREBUILT) switch { case declName == "RELEASE_ACONFIG_VALUE_SETS": - rootAconfigModule = declValue[1 : len(declValue)-1] + if strings.HasPrefix(declValue, "\"") { + rootAconfigModule = declValue[1 : len(declValue)-1] + } continue case strings.HasPrefix(declValue, "\""): // String values mean that the flag workflow is (most likely) either MANUAL or PREBUILT. From ef3de5188fa01af6ef15ffc6a001cda00c36d983 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 14 May 2024 09:21:10 -0700 Subject: [PATCH 50/67] clean up RELEASE_ACONFIG_VALUE_SETS Only add a repository to the trace when it actually specifies aconfig_value_sets. Also default to only generating the release config .mk file for the current TARGET_RELEASE (rather than all), to reduce kati reruns. Bug: 340126861 Test: manual, TH Merged-In: I671d4b5f57c9bdd252d98e048f16aa9c7b3b2ffa Change-Id: I671d4b5f57c9bdd252d98e048f16aa9c7b3b2ffa --- cmd/release_config/release_config/main.go | 2 +- cmd/release_config/release_config_lib/release_config.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index 54328068a..a41183f97 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -51,7 +51,7 @@ func main() { flag.BoolVar(&textproto, "textproto", true, "write artifacts as text protobuf") flag.BoolVar(&json, "json", true, "write artifacts as json") flag.BoolVar(&pb, "pb", true, "write artifacts as binary protobuf") - flag.BoolVar(&allMake, "all_make", true, "write makefiles for all release configs") + flag.BoolVar(&allMake, "all_make", false, "write makefiles for all release configs") flag.BoolVar(&useBuildVar, "use_get_build_var", false, "use get_build_var PRODUCT_RELEASE_CONFIG_MAPS") flag.BoolVar(&guard, "guard", true, "whether to guard with RELEASE_BUILD_FLAGS_IN_PROTOBUF") diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index 820482239..93410a616 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -91,7 +91,8 @@ func (config *ReleaseConfig) InheritConfig(iConfig *ReleaseConfig) error { return fmt.Errorf("Could not inherit flag %s from %s", name, iConfig.Name) } if name == "RELEASE_ACONFIG_VALUE_SETS" { - if len(fa.Traces) > 0 { + // If there is a value assigned, add the trace. + if len(fa.Value.GetStringValue()) > 0 { myFa.Traces = append(myFa.Traces, fa.Traces...) myFa.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{ myFa.Value.GetStringValue() + " " + fa.Value.GetStringValue()}} From cdbe0acfbd7530b1ea995447e196e9d1a231988c Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 14 May 2024 15:53:37 -0700 Subject: [PATCH 51/67] Don't panic when a map is included twice If a map was included twice, we had side effects when skipping the extra inclusion. Bug: 340659219 Test: manual, TH Merged-In: I90c55a800ecad932f8f67cf6f9f60dba571f7c48 Change-Id: I90c55a800ecad932f8f67cf6f9f60dba571f7c48 --- cmd/release_config/release_config_lib/release_configs.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 2487f2e99..0b6565822 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -439,7 +439,8 @@ func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease strin configs := ReleaseConfigsFactory() mapsRead := make(map[string]bool) - for idx, releaseConfigMapPath := range releaseConfigMapPaths { + var idx int + for _, releaseConfigMapPath := range releaseConfigMapPaths { // Maintain an ordered list of release config directories. configDir := filepath.Dir(releaseConfigMapPath) if mapsRead[configDir] { @@ -454,6 +455,7 @@ func ReadReleaseConfigMaps(releaseConfigMapPaths StringList, targetRelease strin if err != nil { return nil, err } + idx += 1 } // Now that we have all of the release config maps, can meld them and generate the artifacts. From d394c08aa8c21bdf07e0fa04eb622736b5b140a7 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Thu, 2 May 2024 16:40:08 +0000 Subject: [PATCH 52/67] Set strict_mode to true The default strict_mode is now set to true. We are encourage teams to write tests in strict_mode to make tests Bivalent (able to run on device and devicelessly) Ignore-AOSP-First: Due to merge conflicts, will submit in AOSP later after these batch of CLs are merged in git_main Test: atest MyRoboTests Bug: 334089788 Change-Id: I3098e2c1ef1b5fd2ee1a98950db5e4f2e8d87d1e --- java/robolectric.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/robolectric.go b/java/robolectric.go index 18386c90c..039e439ce 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -116,7 +116,7 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { if v := String(r.robolectricProperties.Robolectric_prebuilt_version); v != "" { ctx.AddVariationDependencies(nil, libTag, fmt.Sprintf(robolectricPrebuiltLibPattern, v)) - } else if !proptools.Bool(r.robolectricProperties.Strict_mode) { + } else if !proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) { if proptools.Bool(r.robolectricProperties.Upstream) { ctx.AddVariationDependencies(nil, libTag, robolectricCurrentLib+"_upstream") } else { @@ -124,7 +124,7 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { } } - if proptools.Bool(r.robolectricProperties.Strict_mode) { + if proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) { ctx.AddVariationDependencies(nil, roboRuntimeOnlyTag, robolectricCurrentLib+"_upstream") } From cadcb0daa4ced9ff7d675c47209233cae243281e Mon Sep 17 00:00:00 2001 From: Gurpreet Singh Date: Mon, 13 May 2024 17:09:44 +0000 Subject: [PATCH 53/67] VanillaIceCream/35 is now REL Ignore-AOSP-First: VanillaIceCream Finalization Bug: 335304236 Test: build Change-Id: I0d09813b7772a4a2fdb436d0f31856900967d48b --- java/droidstubs.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index 04a71fa90..ca81343f0 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -596,8 +596,7 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a } if apiVersions != nil { cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion().String()) - // STOPSHIP: RESTORE THIS LOGIC WHEN DECLARING "REL" BUILD - // cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) + cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) cmd.FlagWithInput("--apply-api-levels ", apiVersions) } } From 1a625b2a5b4b32a58fafd785ceb6668ad5a89ee6 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 15 May 2024 11:44:26 -0700 Subject: [PATCH 54/67] sort release configs when creating artifacts Bug: 328495189 Test: manual Merged-In: I0b579c6fdbee5bb09826854dadb9f89955980ca8 Change-Id: I0b579c6fdbee5bb09826854dadb9f89955980ca8 --- cmd/release_config/release_config/main.go | 8 ++-- .../release_config_lib/release_configs.go | 46 ++++++++++++------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index a41183f97..67b57cc5b 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -92,10 +92,10 @@ func main() { } if allMake { // Write one makefile per release config, using the canonical release name. - for k, _ := range configs.ReleaseConfigs { - if k != targetRelease { - makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k)) - err = configs.WriteMakefile(makefilePath, k) + for _, c := range configs.GetSortedReleaseConfigs() { + if c.Name != targetRelease { + makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, c.Name)) + err = configs.WriteMakefile(makefilePath, c.Name) if err != nil { panic(err) } diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 0b6565822..461ee106c 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -120,6 +120,16 @@ func ReleaseConfigsFactory() (c *ReleaseConfigs) { return &configs } +func (configs *ReleaseConfigs) GetSortedReleaseConfigs() (ret []*ReleaseConfig) { + for _, config := range configs.ReleaseConfigs { + ret = append(ret, config) + } + slices.SortFunc(ret, func(a, b *ReleaseConfig) int { + return cmp.Compare(a.Name, b.Name) + }) + return ret +} + func ReleaseConfigMapFactory(protoPath string) (m *ReleaseConfigMap) { m = &ReleaseConfigMap{ path: protoPath, @@ -283,9 +293,7 @@ func (configs *ReleaseConfigs) GetReleaseConfig(name string) (*ReleaseConfig, er return nil, fmt.Errorf("Missing config %s. Trace=%v", name, trace) } -// Write the makefile for this targetRelease. -func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) error { - makeVars := make(map[string]string) +func (configs *ReleaseConfigs) GetAllReleaseNames() []string { var allReleaseNames []string for _, v := range configs.ReleaseConfigs { allReleaseNames = append(allReleaseNames, v.Name) @@ -294,6 +302,12 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro slices.SortFunc(allReleaseNames, func(a, b string) int { return cmp.Compare(a, b) }) + return allReleaseNames +} + +// Write the makefile for this targetRelease. +func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) error { + makeVars := make(map[string]string) config, err := configs.GetReleaseConfig(targetRelease) if err != nil { return err @@ -356,7 +370,7 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro data += fmt.Sprintf("# User specified TARGET_RELEASE=%s\n", targetRelease) } // The variable _all_release_configs will get deleted during processing, so do not mark it read-only. - data += fmt.Sprintf("_all_release_configs := %s\n", strings.Join(allReleaseNames, " ")) + data += fmt.Sprintf("_all_release_configs := %s\n", strings.Join(configs.GetAllReleaseNames(), " ")) data += fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " ")) for _, pName := range pNames { data += fmt.Sprintf("_ALL_RELEASE_FLAGS.PARTITIONS.%s :=$= %s\n", pName, strings.Join(partitions[pName], " ")) @@ -388,8 +402,9 @@ func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) erro configs.ReleaseConfigs[name].OtherNames = aliases } - for _, config := range configs.ReleaseConfigs { - err := config.GenerateReleaseConfig(configs) + sortedReleaseConfigs := configs.GetSortedReleaseConfigs() + for _, c := range sortedReleaseConfigs { + err := c.GenerateReleaseConfig(configs) if err != nil { return err } @@ -399,17 +414,16 @@ func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) erro if err != nil { return err } + orc := []*rc_proto.ReleaseConfigArtifact{} + for _, c := range sortedReleaseConfigs { + if c.Name != releaseConfig.Name { + orc = append(orc, c.ReleaseConfigArtifact) + } + } + configs.Artifact = rc_proto.ReleaseConfigsArtifact{ - ReleaseConfig: releaseConfig.ReleaseConfigArtifact, - OtherReleaseConfigs: func() []*rc_proto.ReleaseConfigArtifact { - orc := []*rc_proto.ReleaseConfigArtifact{} - for name, config := range configs.ReleaseConfigs { - if name != releaseConfig.Name { - orc = append(orc, config.ReleaseConfigArtifact) - } - } - return orc - }(), + ReleaseConfig: releaseConfig.ReleaseConfigArtifact, + OtherReleaseConfigs: orc, ReleaseConfigMapsMap: func() map[string]*rc_proto.ReleaseConfigMap { ret := make(map[string]*rc_proto.ReleaseConfigMap) for k, v := range configs.releaseConfigMapsMap { From 32c8f497d07bc8fdda3f9e97331495197b0f54d6 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 16 May 2024 10:47:22 -0700 Subject: [PATCH 55/67] export list of files used by the release config Also use a different name for the output. Bug: 341117082 Bug: 328495189 Bug: 339707888 Test: manual, TH Merged-In: Ib98d487f57cf8b55dff61a7969139a6e199fee90 Change-Id: Ib98d487f57cf8b55dff61a7969139a6e199fee90 --- cmd/release_config/release_config/main.go | 4 +-- .../release_config_lib/release_config.go | 32 ++++++++++++++++++- .../release_config_lib/release_configs.go | 9 ++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/cmd/release_config/release_config/main.go b/cmd/release_config/release_config/main.go index 67b57cc5b..061783828 100644 --- a/cmd/release_config/release_config/main.go +++ b/cmd/release_config/release_config/main.go @@ -77,7 +77,7 @@ func main() { panic(err) } - makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, targetRelease)) + makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.varmk", product, targetRelease)) useProto, ok := config.FlagArtifacts["RELEASE_BUILD_FLAGS_IN_PROTOBUF"] if guard && (!ok || rc_lib.MarshalValue(useProto.Value) == "") { // We were told to guard operation and either we have no build flag, or it is False. @@ -94,7 +94,7 @@ func main() { // Write one makefile per release config, using the canonical release name. for _, c := range configs.GetSortedReleaseConfigs() { if c.Name != targetRelease { - makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, c.Name)) + makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.varmk", product, c.Name)) err = configs.WriteMakefile(makefilePath, c.Name) if err != nil { panic(err) diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index 93410a616..547f0dcd4 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -69,6 +69,9 @@ type ReleaseConfig struct { // Unmarshalled flag artifacts FlagArtifacts FlagArtifacts + // The files used by this release config + FilesUsedMap map[string]bool + // Generated release config ReleaseConfigArtifact *rc_proto.ReleaseConfigArtifact @@ -80,10 +83,17 @@ type ReleaseConfig struct { } func ReleaseConfigFactory(name string, index int) (c *ReleaseConfig) { - return &ReleaseConfig{Name: name, DeclarationIndex: index} + return &ReleaseConfig{ + Name: name, + DeclarationIndex: index, + FilesUsedMap: make(map[string]bool), + } } func (config *ReleaseConfig) InheritConfig(iConfig *ReleaseConfig) error { + for f := range iConfig.FilesUsedMap { + config.FilesUsedMap[f] = true + } for _, fa := range iConfig.FlagArtifacts { name := *fa.FlagDeclaration.Name myFa, ok := config.FlagArtifacts[name] @@ -106,6 +116,17 @@ func (config *ReleaseConfig) InheritConfig(iConfig *ReleaseConfig) error { return nil } +func (config *ReleaseConfig) GetSortedFileList() []string { + ret := []string{} + for k := range config.FilesUsedMap { + ret = append(ret, k) + } + slices.SortFunc(ret, func(a, b string) int { + return cmp.Compare(a, b) + }) + return ret +} + func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) error { if config.ReleaseConfigArtifact != nil { return nil @@ -145,6 +166,15 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro return err } } + + // If we inherited nothing, then we need to mark the global files as used for this + // config. If we inherited, then we already marked them as part of inheritance. + if len(config.InheritNames) == 0 { + for f := range configs.FilesUsedMap { + config.FilesUsedMap[f] = true + } + } + contributionsToApply = append(contributionsToApply, config.Contributions...) workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 461ee106c..a11c7927d 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -67,6 +67,9 @@ type ReleaseConfigs struct { // Map of directory to *ReleaseConfigMap releaseConfigMapsMap map[string]*ReleaseConfigMap + // The files used by all release configs + FilesUsedMap map[string]bool + // The list of config directories used. configDirs []string @@ -102,6 +105,7 @@ func ReleaseConfigsFactory() (c *ReleaseConfigs) { releaseConfigMapsMap: make(map[string]*ReleaseConfigMap), configDirs: []string{}, configDirIndexes: make(ReleaseConfigDirMap), + FilesUsedMap: make(map[string]bool), } workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) releaseAconfigValueSets := FlagArtifact{ @@ -180,6 +184,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex return fmt.Errorf("Release config map %s has invalid container %s", path, container) } } + configs.FilesUsedMap[path] = true dir := filepath.Dir(path) // Record any aliases, checking for duplicates. for _, alias := range m.proto.Aliases { @@ -226,6 +231,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex return fmt.Errorf("Duplicate definition of %s", *flagDeclaration.Name) } // Set the initial value in the flag artifact. + configs.FilesUsedMap[path] = true configs.FlagArtifacts[name].UpdateValue( FlagValue{path: path, proto: rc_proto.FlagValue{ Name: proto.String(name), Value: flagDeclaration.Value}}) @@ -249,6 +255,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex configs.ReleaseConfigs[name] = ReleaseConfigFactory(name, ConfigDirIndex) } config := configs.ReleaseConfigs[name] + config.FilesUsedMap[path] = true config.InheritNames = append(config.InheritNames, releaseConfigContribution.proto.Inherits...) // Only walk flag_values/{RELEASE} for defined releases. @@ -260,6 +267,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex if *flagValue.proto.Name == "RELEASE_ACONFIG_VALUE_SETS" { return fmt.Errorf("%s: %s is a reserved build flag", path, *flagValue.proto.Name) } + config.FilesUsedMap[path] = true releaseConfigContribution.FlagValues = append(releaseConfigContribution.FlagValues, flagValue) return nil }) @@ -371,6 +379,7 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro } // The variable _all_release_configs will get deleted during processing, so do not mark it read-only. data += fmt.Sprintf("_all_release_configs := %s\n", strings.Join(configs.GetAllReleaseNames(), " ")) + data += fmt.Sprintf("_used_files := %s\n", strings.Join(config.GetSortedFileList(), " ")) data += fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " ")) for _, pName := range pNames { data += fmt.Sprintf("_ALL_RELEASE_FLAGS.PARTITIONS.%s :=$= %s\n", pName, strings.Join(partitions[pName], " ")) From 3982936ec4d0ac0cd205af698b3d50e9e617c8c4 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 16 May 2024 15:45:57 -0700 Subject: [PATCH 56/67] rename workflow enum for lint Bug: 339672075 Test: manual Merged-In: I55f7fff9f1f367e13566fc23fb5379f6732a8e8d Change-Id: I55f7fff9f1f367e13566fc23fb5379f6732a8e8d --- cmd/release_config/crunch_flags/main.go | 18 +++---- .../release_config_lib/release_config.go | 6 +-- .../release_config_lib/release_configs.go | 2 +- .../build_flags_out.pb.go | 2 +- .../build_flags_src.pb.go | 48 ++++++++++--------- .../build_flags_src.proto | 8 ++-- 6 files changed, 43 insertions(+), 41 deletions(-) diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index cd39ffd11..8a80a0271 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -16,8 +16,8 @@ import ( ) var ( - // When a flag declaration has an initial value that is a string, the default workflow is PREBUILT. - // If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is MANUAL. + // When a flag declaration has an initial value that is a string, the default workflow is WorkflowPrebuilt. + // If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is WorkflowManual. manualFlagNamePrefixes []string = []string{ "RELEASE_ACONFIG_", "RELEASE_PLATFORM_", @@ -133,8 +133,8 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { Containers: containers, } description = "" - // Most build flags are `workflow: PREBUILT`. - workflow := rc_proto.Workflow(rc_proto.Workflow_PREBUILT) + // Most build flags are `workflow: WorkflowPrebuilt`. + workflow := rc_proto.Workflow(rc_proto.Workflow_WorkflowPrebuilt) switch { case declName == "RELEASE_ACONFIG_VALUE_SETS": if strings.HasPrefix(declValue, "\"") { @@ -142,21 +142,21 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { } continue case strings.HasPrefix(declValue, "\""): - // String values mean that the flag workflow is (most likely) either MANUAL or PREBUILT. + // String values mean that the flag workflow is (most likely) either WorkflowManual or WorkflowPrebuilt. declValue = declValue[1 : len(declValue)-1] flagDeclaration.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{declValue}} for _, prefix := range manualFlagNamePrefixes { if strings.HasPrefix(declName, prefix) { - workflow = rc_proto.Workflow(rc_proto.Workflow_MANUAL) + workflow = rc_proto.Workflow(rc_proto.Workflow_WorkflowManual) break } } case declValue == "False" || declValue == "True": - // Boolean values are LAUNCH flags. + // Boolean values are WorkflowLaunch flags. flagDeclaration.Value = &rc_proto.Value{Val: &rc_proto.Value_BoolValue{declValue == "True"}} - workflow = rc_proto.Workflow(rc_proto.Workflow_LAUNCH) + workflow = rc_proto.Workflow(rc_proto.Workflow_WorkflowLaunch) case declValue == "None": - // Use PREBUILT workflow with no initial value. + // Use WorkflowPrebuilt workflow with no initial value. default: fmt.Printf("%s: Unexpected value %s=%s\n", path, declName, declValue) } diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index 547f0dcd4..82adc34aa 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -177,7 +177,7 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro contributionsToApply = append(contributionsToApply, config.Contributions...) - workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) + workflowManual := rc_proto.Workflow(rc_proto.Workflow_WorkflowManual) myDirsMap := make(map[int]bool) for _, contrib := range contributionsToApply { contribAconfigValueSets := []string{} @@ -211,8 +211,8 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro return fmt.Errorf("Setting value for flag %s not allowed in %s\n", name, value.path) } if isRoot && *fa.FlagDeclaration.Workflow != workflowManual { - // The "root" release config can only contain workflow: MANUAL flags. - return fmt.Errorf("Setting value for non-MANUAL flag %s is not allowed in %s", name, value.path) + // The "root" release config can only contain workflow: WorkflowManual flags. + return fmt.Errorf("Setting value for non-WorkflowManual flag %s is not allowed in %s", name, value.path) } if err := fa.UpdateValue(*value); err != nil { return err diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index a11c7927d..65e6d90ab 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -107,7 +107,7 @@ func ReleaseConfigsFactory() (c *ReleaseConfigs) { configDirIndexes: make(ReleaseConfigDirMap), FilesUsedMap: make(map[string]bool), } - workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) + workflowManual := rc_proto.Workflow(rc_proto.Workflow_WorkflowManual) releaseAconfigValueSets := FlagArtifact{ FlagDeclaration: &rc_proto.FlagDeclaration{ Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), diff --git a/cmd/release_config/release_config_proto/build_flags_out.pb.go b/cmd/release_config/release_config_proto/build_flags_out.pb.go index 483cffac1..8fa75aa8b 100644 --- a/cmd/release_config/release_config_proto/build_flags_out.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_out.pb.go @@ -11,7 +11,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc v3.21.12 // source: build_flags_out.proto diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go index dded97566..c52a238ed 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go @@ -11,7 +11,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc v3.21.12 // source: build_flags_src.proto @@ -34,30 +34,30 @@ const ( type Workflow int32 const ( - Workflow_UNSPECIFIED_workflow Workflow = 0 + Workflow_WorkflowUnspecified Workflow = 0 // Boolean value flags that progress from false to true. - Workflow_LAUNCH Workflow = 1 + Workflow_WorkflowLaunch Workflow = 1 // String value flags that get updated with new version strings to control // prebuilt inclusion. - Workflow_PREBUILT Workflow = 2 + Workflow_WorkflowPrebuilt Workflow = 2 // Manually managed outside flags. These are likely to be found in a // different directory than flags with other workflows. - Workflow_MANUAL Workflow = 3 + Workflow_WorkflowManual Workflow = 3 ) // Enum value maps for Workflow. var ( Workflow_name = map[int32]string{ - 0: "UNSPECIFIED_workflow", - 1: "LAUNCH", - 2: "PREBUILT", - 3: "MANUAL", + 0: "WorkflowUnspecified", + 1: "WorkflowLaunch", + 2: "WorkflowPrebuilt", + 3: "WorkflowManual", } Workflow_value = map[string]int32{ - "UNSPECIFIED_workflow": 0, - "LAUNCH": 1, - "PREBUILT": 2, - "MANUAL": 3, + "WorkflowUnspecified": 0, + "WorkflowLaunch": 1, + "WorkflowPrebuilt": 2, + "WorkflowManual": 3, } ) @@ -295,7 +295,7 @@ func (x *FlagDeclaration) GetWorkflow() Workflow { if x != nil && x.Workflow != nil { return *x.Workflow } - return Workflow_UNSPECIFIED_workflow + return Workflow_WorkflowUnspecified } func (x *FlagDeclaration) GetContainers() []string { @@ -642,15 +642,17 @@ var file_build_flags_src_proto_rawDesc = []byte{ 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x4a, 0x0a, 0x08, - 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, - 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, 0x0c, - 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, - 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, - 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x61, 0x0a, 0x08, + 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x17, 0x0a, 0x13, 0x57, 0x6f, 0x72, 0x6b, + 0x66, 0x6c, 0x6f, 0x77, 0x55, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x10, + 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4c, 0x61, 0x75, + 0x6e, 0x63, 0x68, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, + 0x77, 0x50, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x57, + 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x10, 0x03, 0x42, + 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, + 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, } var ( diff --git a/cmd/release_config/release_config_proto/build_flags_src.proto b/cmd/release_config/release_config_proto/build_flags_src.proto index 0ef1a5ffa..81c6ae3b7 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.proto +++ b/cmd/release_config/release_config_proto/build_flags_src.proto @@ -39,18 +39,18 @@ option go_package = "android/soong/release_config/release_config_proto"; // com.android.1mypackage are invalid enum workflow { - UNSPECIFIED_workflow = 0; + WorkflowUnspecified = 0; // Boolean value flags that progress from false to true. - LAUNCH = 1; + WorkflowLaunch = 1; // String value flags that get updated with new version strings to control // prebuilt inclusion. - PREBUILT = 2; + WorkflowPrebuilt = 2; // Manually managed outside flags. These are likely to be found in a // different directory than flags with other workflows. - MANUAL = 3; + WorkflowManual = 3; } message value { From 3ca687a15798ebcec27bf496c8a68b1e0185b998 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Mon, 20 May 2024 10:44:16 -0700 Subject: [PATCH 57/67] Add Factory methods, WriteFormattedMessage Adds: - FlagArtifactFactory() - FlagArtifactsFactory() - WriteFormattedMessage() Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I8b3c1e1e7ea3e52e9e7e8b1f8162fedd3e83dd33 Change-Id: I8b3c1e1e7ea3e52e9e7e8b1f8162fedd3e83dd33 --- .../release_config_lib/flag_artifact.go | 59 +++++++++++++++++++ cmd/release_config/release_config_lib/util.go | 33 +++++++++-- 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/cmd/release_config/release_config_lib/flag_artifact.go b/cmd/release_config/release_config_lib/flag_artifact.go index cba1b5cd8..cdd5af99b 100644 --- a/cmd/release_config/release_config_lib/flag_artifact.go +++ b/cmd/release_config/release_config_lib/flag_artifact.go @@ -15,7 +15,9 @@ package release_config_lib import ( + "cmp" "fmt" + "slices" rc_proto "android/soong/cmd/release_config/release_config_proto" @@ -45,6 +47,63 @@ type FlagArtifact struct { // Key is flag name. type FlagArtifacts map[string]*FlagArtifact +func FlagArtifactFactory(declPath string) *FlagArtifact { + fd := &rc_proto.FlagDeclaration{} + fa := &FlagArtifact{ + FlagDeclaration: fd, + DeclarationIndex: -1, + Traces: []*rc_proto.Tracepoint{}, + } + if declPath != "" { + LoadMessage(declPath, fd) + fa.Value = fd.GetValue() + fa.Traces = append(fa.Traces, &rc_proto.Tracepoint{Source: proto.String(declPath), Value: fa.Value}) + } + return fa +} + +func FlagArtifactsFactory(artifactsPath string) *FlagArtifacts { + ret := make(FlagArtifacts) + if artifactsPath != "" { + fas := &rc_proto.FlagArtifacts{} + LoadMessage(artifactsPath, fas) + for _, fa_pb := range fas.FlagArtifacts { + fa := &FlagArtifact{} + fa.FlagDeclaration = fa_pb.GetFlagDeclaration() + if val := fa_pb.GetValue(); val != nil { + fa.Value = val + } + if traces := fa_pb.GetTraces(); traces != nil { + fa.Traces = traces + } + ret[*fa.FlagDeclaration.Name] = fa + } + } + return &ret +} + +func (fa *FlagArtifact) GenerateFlagArtifact() *rc_proto.FlagArtifact { + ret := &rc_proto.FlagArtifact{FlagDeclaration: fa.FlagDeclaration} + if fa.Value != nil { + ret.Value = fa.Value + } + if len(fa.Traces) > 0 { + ret.Traces = fa.Traces + } + return ret +} + +func (fas *FlagArtifacts) GenerateFlagArtifacts() *rc_proto.FlagArtifacts { + ret := &rc_proto.FlagArtifacts{FlagArtifacts: []*rc_proto.FlagArtifact{}} + for _, fa := range *fas { + ret.FlagArtifacts = append(ret.FlagArtifacts, fa.GenerateFlagArtifact()) + } + slices.SortFunc(ret.FlagArtifacts, func(a, b *rc_proto.FlagArtifact) int { + return cmp.Compare(*a.FlagDeclaration.Name, *b.FlagDeclaration.Name) + }) + return ret +} + // Create a clone of the flag artifact. // // Returns: diff --git a/cmd/release_config/release_config_lib/util.go b/cmd/release_config/release_config_lib/util.go index c0ea7897b..040820b09 100644 --- a/cmd/release_config/release_config_lib/util.go +++ b/cmd/release_config/release_config_lib/util.go @@ -58,13 +58,36 @@ func (l *StringList) String() string { // // error: any error encountered. func WriteMessage(path string, message proto.Message) (err error) { + format := filepath.Ext(path) + if len(format) > 1 { + // Strip any leading dot. + format = format[1:] + } + return WriteFormattedMessage(path, format, message) +} + +// Write a marshalled message to a file. +// +// Marshal the message using the given format. +// +// Args: +// +// path string: the path of the file to write to. Directories are not created. +// Supported extensions are: ".json", ".pb", and ".textproto". +// format string: one of "json", "pb", or "textproto". +// message proto.Message: the message to write. +// +// Returns: +// +// error: any error encountered. +func WriteFormattedMessage(path, format string, message proto.Message) (err error) { var data []byte - switch filepath.Ext(path) { - case ".json": + switch format { + case "json": data, err = json.MarshalIndent(message, "", " ") - case ".pb": + case "pb", "binaryproto", "protobuf": data, err = proto.Marshal(message) - case ".textproto": + case "textproto": data, err = prototext.MarshalOptions{Multiline: true}.Marshal(message) default: return fmt.Errorf("Unknown message format for %s", path) @@ -95,7 +118,7 @@ func LoadMessage(path string, message proto.Message) error { switch filepath.Ext(path) { case ".json": return json.Unmarshal(data, message) - case ".pb": + case ".pb", ".protobuf", ".binaryproto": return proto.Unmarshal(data, message) case ".textproto": return prototext.Unmarshal(data, message) From 705536a14968b0742cc5585449f9054a6097036c Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 8 May 2024 09:15:25 -0700 Subject: [PATCH 58/67] Add build-flag-declarations tool This will be used to gather build flag declarations Bug: 328495189 Test: manual, TH Ignore-AOSP-First: cherry-pick Merged-In: I155c26b1442347c4d433c9cbf22b94d944636702 Change-Id: I155c26b1442347c4d433c9cbf22b94d944636702 --- bin/build-flag-declarations | 28 +++++++ .../build_flag_declarations/Android.bp | 32 ++++++++ .../build_flag_declarations/main.go | 81 +++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100755 bin/build-flag-declarations create mode 100644 cmd/release_config/build_flag_declarations/Android.bp create mode 100644 cmd/release_config/build_flag_declarations/main.go diff --git a/bin/build-flag-declarations b/bin/build-flag-declarations new file mode 100755 index 000000000..222f0836a --- /dev/null +++ b/bin/build-flag-declarations @@ -0,0 +1,28 @@ +#!/bin/bash -eu +# +# Copyright 2017 Google Inc. All rights reserved. +# +# 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. + +source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../make/shell_utils.sh +require_top + +# Save the current PWD for use in soong_ui +export ORIGINAL_PWD=${PWD} +export TOP=$(gettop) +source ${TOP}/build/soong/scripts/microfactory.bash + +soong_build_go build-flag-declarations android/soong/cmd/release_config/build_flag_declarations + +cd ${TOP} +exec "$(getoutdir)/build-flag-declarations" "$@" diff --git a/cmd/release_config/build_flag_declarations/Android.bp b/cmd/release_config/build_flag_declarations/Android.bp new file mode 100644 index 000000000..e4f999fd0 --- /dev/null +++ b/cmd/release_config/build_flag_declarations/Android.bp @@ -0,0 +1,32 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +blueprint_go_binary { + name: "build-flag-declarations", + deps: [ + "golang-protobuf-encoding-prototext", + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + "soong-cmd-release_config-proto", + "soong-cmd-release_config-lib", + ], + srcs: [ + "main.go", + ], +} + +bootstrap_go_package { + name: "soong-cmd-release_config-build_flag_declarations", + pkgPath: "android/soong/cmd/release_config/build_flag_declarations", + deps: [ + "golang-protobuf-encoding-prototext", + "golang-protobuf-reflect-protoreflect", + "golang-protobuf-runtime-protoimpl", + "soong-cmd-release_config-proto", + "soong-cmd-release_config-lib", + ], + srcs: [ + "main.go", + ], +} diff --git a/cmd/release_config/build_flag_declarations/main.go b/cmd/release_config/build_flag_declarations/main.go new file mode 100644 index 000000000..8315f5917 --- /dev/null +++ b/cmd/release_config/build_flag_declarations/main.go @@ -0,0 +1,81 @@ +package main + +import ( + "flag" + "fmt" + "os" + + rc_lib "android/soong/cmd/release_config/release_config_lib" +) + +type Flags struct { + // The path to the top of the workspace. Default: ".". + top string + + // Output file. + output string + + // Format for output file + format string + + // List of flag_declaration files to add. + decls rc_lib.StringList + + // List of flag_artifacts files to merge. + intermediates rc_lib.StringList + + // Disable warning messages + quiet bool + + // Panic on errors. + debug bool +} + +func main() { + var flags Flags + topDir, err := rc_lib.GetTopDir() + + // Handle the common arguments + flag.StringVar(&flags.top, "top", topDir, "path to top of workspace") + flag.Var(&flags.decls, "decl", "path to a flag_declaration file. May be repeated") + flag.Var(&flags.intermediates, "intermediate", "path to a flag_artifacts file (output from a prior run). May be repeated") + flag.StringVar(&flags.format, "format", "pb", "output file format") + flag.StringVar(&flags.output, "output", "build_flags.pb", "output file") + flag.BoolVar(&flags.debug, "debug", false, "turn on debugging output for errors") + flag.BoolVar(&flags.quiet, "quiet", false, "disable warning messages") + flag.Parse() + + errorExit := func(err error) { + if flags.debug { + panic(err) + } + fmt.Fprintf(os.Stderr, "%s\n", err) + os.Exit(1) + } + + if flags.quiet { + rc_lib.DisableWarnings() + } + + if err = os.Chdir(flags.top); err != nil { + errorExit(err) + } + + flagArtifacts := rc_lib.FlagArtifactsFactory("") + for _, intermediate := range flags.intermediates { + fas := rc_lib.FlagArtifactsFactory(intermediate) + for _, fa := range *fas { + (*flagArtifacts)[*fa.FlagDeclaration.Name] = fa + } + } + for _, decl := range flags.decls { + fa := rc_lib.FlagArtifactFactory(decl) + (*flagArtifacts)[*fa.FlagDeclaration.Name] = fa + } + + message := flagArtifacts.GenerateFlagArtifacts() + err = rc_lib.WriteFormattedMessage(flags.output, flags.format, message) + if err != nil { + errorExit(err) + } +} From 0a9b643c6ec86af099a2e3c79747b85db1fc3313 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Mon, 20 May 2024 10:37:25 -0700 Subject: [PATCH 59/67] Add build_flag_declarations module And generate build-flags/build_flags.{pb,textproto} files Bug: 328495189 Test: manual,TH Ignore-AOSP-First: cherry-pick Merged-In: I97eb864e2d84bc606fef7e9077554894338edaa0 Change-Id: I97eb864e2d84bc606fef7e9077554894338edaa0 --- aconfig/build_flags/Android.bp | 23 ++++ .../all_build_flag_declarations.go | 78 ++++++++++++ aconfig/build_flags/declarations.go | 118 ++++++++++++++++++ aconfig/build_flags/init.go | 78 ++++++++++++ 4 files changed, 297 insertions(+) create mode 100644 aconfig/build_flags/Android.bp create mode 100644 aconfig/build_flags/all_build_flag_declarations.go create mode 100644 aconfig/build_flags/declarations.go create mode 100644 aconfig/build_flags/init.go diff --git a/aconfig/build_flags/Android.bp b/aconfig/build_flags/Android.bp new file mode 100644 index 000000000..69e431606 --- /dev/null +++ b/aconfig/build_flags/Android.bp @@ -0,0 +1,23 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +bootstrap_go_package { + name: "soong-aconfig-build_flags", + pkgPath: "android/soong/aconfig/build_flags", + deps: [ + "blueprint", + "blueprint-pathtools", + "sbox_proto", + "soong", + "soong-android", + ], + srcs: [ + "all_build_flag_declarations.go", + "declarations.go", + "init.go", + ], + testSrcs: [ + ], + pluginFor: ["soong_build"], +} diff --git a/aconfig/build_flags/all_build_flag_declarations.go b/aconfig/build_flags/all_build_flag_declarations.go new file mode 100644 index 000000000..282c9dcf8 --- /dev/null +++ b/aconfig/build_flags/all_build_flag_declarations.go @@ -0,0 +1,78 @@ +// Copyright 2023 Google Inc. All rights reserved. +// +// 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 build_flags + +import ( + "android/soong/android" +) + +// A singleton module that collects all of the build flags declared in the +// tree into a single combined file for export to the external flag setting +// server (inside Google it's Gantry). +// +// Note that this is ALL build_declarations modules present in the tree, not just +// ones that are relevant to the product currently being built, so that that infra +// doesn't need to pull from multiple builds and merge them. +func AllBuildFlagDeclarationsFactory() android.Singleton { + return &allBuildFlagDeclarationsSingleton{} +} + +type allBuildFlagDeclarationsSingleton struct { + intermediateBinaryProtoPath android.OutputPath + intermediateTextProtoPath android.OutputPath +} + +func (this *allBuildFlagDeclarationsSingleton) GenerateBuildActions(ctx android.SingletonContext) { + // Find all of the build_flag_declarations modules + var intermediateFiles android.Paths + ctx.VisitAllModules(func(module android.Module) { + decl, ok := android.SingletonModuleProvider(ctx, module, BuildFlagDeclarationsProviderKey) + if !ok { + return + } + intermediateFiles = append(intermediateFiles, decl.IntermediateCacheOutputPath) + }) + + // Generate build action for build_flag (binary proto output) + this.intermediateBinaryProtoPath = android.PathForIntermediates(ctx, "all_build_flag_declarations.pb") + ctx.Build(pctx, android.BuildParams{ + Rule: allDeclarationsRule, + Inputs: intermediateFiles, + Output: this.intermediateBinaryProtoPath, + Description: "all_build_flag_declarations", + Args: map[string]string{ + "intermediates": android.JoinPathsWithPrefix(intermediateFiles, "--intermediate "), + }, + }) + ctx.Phony("all_build_flag_declarations", this.intermediateBinaryProtoPath) + + // Generate build action for build_flag (text proto output) + this.intermediateTextProtoPath = android.PathForIntermediates(ctx, "all_build_flag_declarations.textproto") + ctx.Build(pctx, android.BuildParams{ + Rule: allDeclarationsRuleTextProto, + Input: this.intermediateBinaryProtoPath, + Output: this.intermediateTextProtoPath, + Description: "all_build_flag_declarations_textproto", + }) + ctx.Phony("all_build_flag_declarations_textproto", this.intermediateTextProtoPath) +} + +func (this *allBuildFlagDeclarationsSingleton) MakeVars(ctx android.MakeVarsContext) { + ctx.DistForGoal("droid", this.intermediateBinaryProtoPath) + for _, goal := range []string{"docs", "droid", "sdk"} { + ctx.DistForGoalWithFilename(goal, this.intermediateBinaryProtoPath, "build_flags/all_flags.pb") + ctx.DistForGoalWithFilename(goal, this.intermediateTextProtoPath, "build_flags/all_flags.textproto") + } +} diff --git a/aconfig/build_flags/declarations.go b/aconfig/build_flags/declarations.go new file mode 100644 index 000000000..f6a6ee1a8 --- /dev/null +++ b/aconfig/build_flags/declarations.go @@ -0,0 +1,118 @@ +// Copyright 2023 Google Inc. All rights reserved. +// +// 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 build_flags + +import ( + "fmt" + "strings" + + "android/soong/android" + + "github.com/google/blueprint" +) + +type BuildFlagDeclarationsProviderData struct { + IntermediateCacheOutputPath android.WritablePath + IntermediateDumpOutputPath android.WritablePath +} + +var BuildFlagDeclarationsProviderKey = blueprint.NewProvider[BuildFlagDeclarationsProviderData]() + +type DeclarationsModule struct { + android.ModuleBase + android.DefaultableModuleBase + + // Properties for "aconfig_declarations" + properties struct { + // aconfig files, relative to this Android.bp file + Srcs []string `android:"path"` + } + + intermediatePath android.WritablePath +} + +func DeclarationsFactory() android.Module { + module := &DeclarationsModule{} + + android.InitAndroidModule(module) + android.InitDefaultableModule(module) + module.AddProperties(&module.properties) + + return module +} + +func (module *DeclarationsModule) OutputFiles(tag string) (android.Paths, error) { + switch tag { + case "": + // The default output of this module is the intermediates format, which is + // not installable and in a private format that no other rules can handle + // correctly. + return []android.Path{module.intermediatePath}, nil + default: + return nil, fmt.Errorf("unsupported build_flags_declarations module reference tag %q", tag) + } +} + +func joinAndPrefix(prefix string, values []string) string { + var sb strings.Builder + for _, v := range values { + sb.WriteString(prefix) + sb.WriteString(v) + } + return sb.String() +} + +func optionalVariable(prefix string, value string) string { + var sb strings.Builder + if value != "" { + sb.WriteString(prefix) + sb.WriteString(value) + } + return sb.String() +} + +func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { + // Intermediate format + declarationFiles := android.PathsForModuleSrc(ctx, module.properties.Srcs) + intermediateCacheFilePath := android.PathForModuleOut(ctx, "build_flag_intermediate.pb") + inputFiles := make([]android.Path, len(declarationFiles)) + copy(inputFiles, declarationFiles) + + // TODO(lamont): generate the rc_proto.FlagArtifacts message for the sources. + args := map[string]string{ + "release_version": ctx.Config().ReleaseVersion(), + "declarations": android.JoinPathsWithPrefix(declarationFiles, "--decl "), + } + ctx.Build(pctx, android.BuildParams{ + Rule: buildFlagRule, + Output: intermediateCacheFilePath, + Inputs: inputFiles, + Description: "build_flag_declarations", + Args: args, + }) + + intermediateDumpFilePath := android.PathForModuleOut(ctx, "build_flag_intermediate.textproto") + ctx.Build(pctx, android.BuildParams{ + Rule: buildFlagTextRule, + Output: intermediateDumpFilePath, + Input: intermediateCacheFilePath, + Description: "build_flag_declarations_text", + }) + + android.SetProvider(ctx, BuildFlagDeclarationsProviderKey, BuildFlagDeclarationsProviderData{ + IntermediateCacheOutputPath: intermediateCacheFilePath, + IntermediateDumpOutputPath: intermediateDumpFilePath, + }) +} diff --git a/aconfig/build_flags/init.go b/aconfig/build_flags/init.go new file mode 100644 index 000000000..5907f4eb3 --- /dev/null +++ b/aconfig/build_flags/init.go @@ -0,0 +1,78 @@ +// Copyright 2023 Google Inc. All rights reserved. +// +// 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 build_flags + +import ( + "android/soong/android" + + "github.com/google/blueprint" +) + +var ( + pctx = android.NewPackageContext("android/soong/aconfig/build_flags") + + // For build_flag_declarations: Generate cache file + buildFlagRule = pctx.AndroidStaticRule("build-flag-declarations", + blueprint.RuleParams{ + Command: `${buildFlagDeclarations} ` + + ` ${declarations}` + + ` --format pb` + + ` --output ${out}.tmp` + + ` && ( if cmp -s ${out}.tmp ${out} ; then rm ${out}.tmp ; else mv ${out}.tmp ${out} ; fi )`, + CommandDeps: []string{ + "${buildFlagDeclarations}", + }, + Restat: true, + }, "release_version", "declarations") + + buildFlagTextRule = pctx.AndroidStaticRule("build-flag-declarations-text", + blueprint.RuleParams{ + Command: `${buildFlagDeclarations} --format=textproto` + + ` --intermediate ${in}` + + ` --format textproto` + + ` --output ${out}.tmp` + + ` && ( if cmp -s ${out}.tmp ${out} ; then rm ${out}.tmp ; else mv ${out}.tmp ${out} ; fi )`, + CommandDeps: []string{ + "${buildFlagDeclarations}", + }, + Restat: true, + }) + + allDeclarationsRule = pctx.AndroidStaticRule("all-build-flag-declarations-dump", + blueprint.RuleParams{ + Command: `${buildFlagDeclarations} ${intermediates} --format pb --output ${out}`, + CommandDeps: []string{ + "${buildFlagDeclarations}", + }, + }, "intermediates") + + allDeclarationsRuleTextProto = pctx.AndroidStaticRule("All_build_flag_declarations_dump_textproto", + blueprint.RuleParams{ + Command: `${buildFlagDeclarations} --intermediate ${in} --format textproto --output ${out}`, + CommandDeps: []string{ + "${buildFlagDeclarations}", + }, + }) +) + +func init() { + RegisterBuildComponents(android.InitRegistrationContext) + pctx.HostBinToolVariable("buildFlagDeclarations", "build-flag-declarations") +} + +func RegisterBuildComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("build_flag_declarations", DeclarationsFactory) + ctx.RegisterParallelSingletonType("all_build_flag_declarations", AllBuildFlagDeclarationsFactory) +} From 51cee24d6dc588bf2c4eddf64a67dc3a7d98ad0b Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 21 May 2024 11:06:34 -0700 Subject: [PATCH 60/67] Minor flagging cleanup Add an underscore to make the linter more happy. Bug: 339672075 Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I6b1d6dcd0aff3c82551021b3f4768a34f27d6fb2 Change-Id: I6b1d6dcd0aff3c82551021b3f4768a34f27d6fb2 --- cmd/release_config/crunch_flags/main.go | 18 +++---- .../release_config_lib/release_config.go | 6 +-- .../release_config_lib/release_configs.go | 2 +- .../build_flags_out.pb.go | 4 ++ .../build_flags_out.proto | 4 ++ .../build_flags_src.pb.go | 52 ++++++++++--------- .../build_flags_src.proto | 12 +++-- 7 files changed, 57 insertions(+), 41 deletions(-) diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index 8a80a0271..44e553941 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -16,8 +16,8 @@ import ( ) var ( - // When a flag declaration has an initial value that is a string, the default workflow is WorkflowPrebuilt. - // If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is WorkflowManual. + // When a flag declaration has an initial value that is a string, the default workflow is Workflow_Prebuilt. + // If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is Workflow_Manual. manualFlagNamePrefixes []string = []string{ "RELEASE_ACONFIG_", "RELEASE_PLATFORM_", @@ -133,8 +133,8 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { Containers: containers, } description = "" - // Most build flags are `workflow: WorkflowPrebuilt`. - workflow := rc_proto.Workflow(rc_proto.Workflow_WorkflowPrebuilt) + // Most build flags are `workflow: Workflow_Prebuilt`. + workflow := rc_proto.Workflow(rc_proto.Workflow_Workflow_Prebuilt) switch { case declName == "RELEASE_ACONFIG_VALUE_SETS": if strings.HasPrefix(declValue, "\"") { @@ -142,21 +142,21 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { } continue case strings.HasPrefix(declValue, "\""): - // String values mean that the flag workflow is (most likely) either WorkflowManual or WorkflowPrebuilt. + // String values mean that the flag workflow is (most likely) either Workflow_Manual or Workflow_Prebuilt. declValue = declValue[1 : len(declValue)-1] flagDeclaration.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{declValue}} for _, prefix := range manualFlagNamePrefixes { if strings.HasPrefix(declName, prefix) { - workflow = rc_proto.Workflow(rc_proto.Workflow_WorkflowManual) + workflow = rc_proto.Workflow(rc_proto.Workflow_Workflow_Manual) break } } case declValue == "False" || declValue == "True": - // Boolean values are WorkflowLaunch flags. + // Boolean values are Workflow_Launch flags. flagDeclaration.Value = &rc_proto.Value{Val: &rc_proto.Value_BoolValue{declValue == "True"}} - workflow = rc_proto.Workflow(rc_proto.Workflow_WorkflowLaunch) + workflow = rc_proto.Workflow(rc_proto.Workflow_Workflow_Launch) case declValue == "None": - // Use WorkflowPrebuilt workflow with no initial value. + // Use Workflow_Prebuilt workflow with no initial value. default: fmt.Printf("%s: Unexpected value %s=%s\n", path, declName, declValue) } diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index 82adc34aa..a1b10f567 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -177,7 +177,7 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro contributionsToApply = append(contributionsToApply, config.Contributions...) - workflowManual := rc_proto.Workflow(rc_proto.Workflow_WorkflowManual) + workflowManual := rc_proto.Workflow(rc_proto.Workflow_Workflow_Manual) myDirsMap := make(map[int]bool) for _, contrib := range contributionsToApply { contribAconfigValueSets := []string{} @@ -211,8 +211,8 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro return fmt.Errorf("Setting value for flag %s not allowed in %s\n", name, value.path) } if isRoot && *fa.FlagDeclaration.Workflow != workflowManual { - // The "root" release config can only contain workflow: WorkflowManual flags. - return fmt.Errorf("Setting value for non-WorkflowManual flag %s is not allowed in %s", name, value.path) + // The "root" release config can only contain workflow: Workflow_Manual flags. + return fmt.Errorf("Setting value for non-Workflow_Manual flag %s is not allowed in %s", name, value.path) } if err := fa.UpdateValue(*value); err != nil { return err diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 65e6d90ab..403ba1a58 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -107,7 +107,7 @@ func ReleaseConfigsFactory() (c *ReleaseConfigs) { configDirIndexes: make(ReleaseConfigDirMap), FilesUsedMap: make(map[string]bool), } - workflowManual := rc_proto.Workflow(rc_proto.Workflow_WorkflowManual) + workflowManual := rc_proto.Workflow(rc_proto.Workflow_Workflow_Manual) releaseAconfigValueSets := FlagArtifact{ FlagDeclaration: &rc_proto.FlagDeclaration{ Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), diff --git a/cmd/release_config/release_config_proto/build_flags_out.pb.go b/cmd/release_config/release_config_proto/build_flags_out.pb.go index 8fa75aa8b..73cc1dc95 100644 --- a/cmd/release_config/release_config_proto/build_flags_out.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_out.pb.go @@ -1,3 +1,7 @@ +// +// Copyright (C) 2024 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 // diff --git a/cmd/release_config/release_config_proto/build_flags_out.proto b/cmd/release_config/release_config_proto/build_flags_out.proto index 6f34d6f67..8c3be5fa4 100644 --- a/cmd/release_config/release_config_proto/build_flags_out.proto +++ b/cmd/release_config/release_config_proto/build_flags_out.proto @@ -1,3 +1,7 @@ +// +// Copyright (C) 2024 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 // diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go index c52a238ed..1a3fb802d 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go @@ -1,3 +1,7 @@ +// +// Copyright (C) 2024 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 // @@ -34,30 +38,30 @@ const ( type Workflow int32 const ( - Workflow_WorkflowUnspecified Workflow = 0 + Workflow_Workflow_Unspecified Workflow = 0 // Boolean value flags that progress from false to true. - Workflow_WorkflowLaunch Workflow = 1 + Workflow_Workflow_Launch Workflow = 1 // String value flags that get updated with new version strings to control // prebuilt inclusion. - Workflow_WorkflowPrebuilt Workflow = 2 + Workflow_Workflow_Prebuilt Workflow = 2 // Manually managed outside flags. These are likely to be found in a // different directory than flags with other workflows. - Workflow_WorkflowManual Workflow = 3 + Workflow_Workflow_Manual Workflow = 3 ) // Enum value maps for Workflow. var ( Workflow_name = map[int32]string{ - 0: "WorkflowUnspecified", - 1: "WorkflowLaunch", - 2: "WorkflowPrebuilt", - 3: "WorkflowManual", + 0: "Workflow_Unspecified", + 1: "Workflow_Launch", + 2: "Workflow_Prebuilt", + 3: "Workflow_Manual", } Workflow_value = map[string]int32{ - "WorkflowUnspecified": 0, - "WorkflowLaunch": 1, - "WorkflowPrebuilt": 2, - "WorkflowManual": 3, + "Workflow_Unspecified": 0, + "Workflow_Launch": 1, + "Workflow_Prebuilt": 2, + "Workflow_Manual": 3, } ) @@ -295,7 +299,7 @@ func (x *FlagDeclaration) GetWorkflow() Workflow { if x != nil && x.Workflow != nil { return *x.Workflow } - return Workflow_WorkflowUnspecified + return Workflow_Workflow_Unspecified } func (x *FlagDeclaration) GetContainers() []string { @@ -642,17 +646,17 @@ var file_build_flags_src_proto_rawDesc = []byte{ 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x61, 0x0a, 0x08, - 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x17, 0x0a, 0x13, 0x57, 0x6f, 0x72, 0x6b, - 0x66, 0x6c, 0x6f, 0x77, 0x55, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x10, - 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4c, 0x61, 0x75, - 0x6e, 0x63, 0x68, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, - 0x77, 0x50, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x57, - 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x10, 0x03, 0x42, - 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, - 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, - 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, + 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x65, 0x0a, 0x08, + 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x57, 0x6f, 0x72, 0x6b, + 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x55, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, + 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x4c, + 0x61, 0x75, 0x6e, 0x63, 0x68, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x57, 0x6f, 0x72, 0x6b, 0x66, + 0x6c, 0x6f, 0x77, 0x5f, 0x50, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x10, 0x02, 0x12, 0x13, + 0x0a, 0x0f, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x4d, 0x61, 0x6e, 0x75, 0x61, + 0x6c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, + 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, } var ( diff --git a/cmd/release_config/release_config_proto/build_flags_src.proto b/cmd/release_config/release_config_proto/build_flags_src.proto index 81c6ae3b7..6a8e96eec 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.proto +++ b/cmd/release_config/release_config_proto/build_flags_src.proto @@ -1,3 +1,7 @@ +// +// Copyright (C) 2024 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 // @@ -39,18 +43,18 @@ option go_package = "android/soong/release_config/release_config_proto"; // com.android.1mypackage are invalid enum workflow { - WorkflowUnspecified = 0; + Workflow_Unspecified = 0; // Boolean value flags that progress from false to true. - WorkflowLaunch = 1; + Workflow_Launch = 1; // String value flags that get updated with new version strings to control // prebuilt inclusion. - WorkflowPrebuilt = 2; + Workflow_Prebuilt = 2; // Manually managed outside flags. These are likely to be found in a // different directory than flags with other workflows. - WorkflowManual = 3; + Workflow_Manual = 3; } message value { From 2f75608ebc15d53d0bfeb64fda75d473cce6218c Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 21 May 2024 16:40:07 -0700 Subject: [PATCH 61/67] Better errors from build-flag When `get_build_var` fails, output the error. Bug: none Test: manual Ignore-AOSP-First: cherry-pick Merged-In: If4dc13e0e895823f50de1f5c7e929bb05eac69a0 Change-Id: If4dc13e0e895823f50de1f5c7e929bb05eac69a0 --- cmd/release_config/release_config_lib/util.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/release_config/release_config_lib/util.go b/cmd/release_config/release_config_lib/util.go index 040820b09..6190b449e 100644 --- a/cmd/release_config/release_config_lib/util.go +++ b/cmd/release_config/release_config_lib/util.go @@ -216,6 +216,7 @@ func GetDefaultMapPaths(queryMaps bool) (defaultMapPaths StringList, err error) var stdout strings.Builder getBuildVar.Stdin = strings.NewReader("") getBuildVar.Stdout = &stdout + getBuildVar.Stderr = os.Stderr err = getBuildVar.Run() if err != nil { return From d2c2f4091cc4114aceea6f85576f2fc85267be7d Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 22 May 2024 06:42:59 -0700 Subject: [PATCH 62/67] release_config_proto: revert enum rename This caused the existing textproto files to be misparsed. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I53dc5045839b575e5fcaace39a435c28648010f6 Change-Id: I53dc5045839b575e5fcaace39a435c28648010f6 --- cmd/release_config/crunch_flags/main.go | 18 +++++----- .../release_config_lib/release_config.go | 6 ++-- .../release_config_lib/release_configs.go | 2 +- .../build_flags_src.pb.go | 34 +++++++++---------- .../build_flags_src.proto | 6 ++-- 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go index 44e553941..cd39ffd11 100644 --- a/cmd/release_config/crunch_flags/main.go +++ b/cmd/release_config/crunch_flags/main.go @@ -16,8 +16,8 @@ import ( ) var ( - // When a flag declaration has an initial value that is a string, the default workflow is Workflow_Prebuilt. - // If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is Workflow_Manual. + // When a flag declaration has an initial value that is a string, the default workflow is PREBUILT. + // If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is MANUAL. manualFlagNamePrefixes []string = []string{ "RELEASE_ACONFIG_", "RELEASE_PLATFORM_", @@ -133,8 +133,8 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { Containers: containers, } description = "" - // Most build flags are `workflow: Workflow_Prebuilt`. - workflow := rc_proto.Workflow(rc_proto.Workflow_Workflow_Prebuilt) + // Most build flags are `workflow: PREBUILT`. + workflow := rc_proto.Workflow(rc_proto.Workflow_PREBUILT) switch { case declName == "RELEASE_ACONFIG_VALUE_SETS": if strings.HasPrefix(declValue, "\"") { @@ -142,21 +142,21 @@ func ProcessBuildFlags(dir string, namespaceMap map[string]string) error { } continue case strings.HasPrefix(declValue, "\""): - // String values mean that the flag workflow is (most likely) either Workflow_Manual or Workflow_Prebuilt. + // String values mean that the flag workflow is (most likely) either MANUAL or PREBUILT. declValue = declValue[1 : len(declValue)-1] flagDeclaration.Value = &rc_proto.Value{Val: &rc_proto.Value_StringValue{declValue}} for _, prefix := range manualFlagNamePrefixes { if strings.HasPrefix(declName, prefix) { - workflow = rc_proto.Workflow(rc_proto.Workflow_Workflow_Manual) + workflow = rc_proto.Workflow(rc_proto.Workflow_MANUAL) break } } case declValue == "False" || declValue == "True": - // Boolean values are Workflow_Launch flags. + // Boolean values are LAUNCH flags. flagDeclaration.Value = &rc_proto.Value{Val: &rc_proto.Value_BoolValue{declValue == "True"}} - workflow = rc_proto.Workflow(rc_proto.Workflow_Workflow_Launch) + workflow = rc_proto.Workflow(rc_proto.Workflow_LAUNCH) case declValue == "None": - // Use Workflow_Prebuilt workflow with no initial value. + // Use PREBUILT workflow with no initial value. default: fmt.Printf("%s: Unexpected value %s=%s\n", path, declName, declValue) } diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index a1b10f567..547f0dcd4 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -177,7 +177,7 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro contributionsToApply = append(contributionsToApply, config.Contributions...) - workflowManual := rc_proto.Workflow(rc_proto.Workflow_Workflow_Manual) + workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) myDirsMap := make(map[int]bool) for _, contrib := range contributionsToApply { contribAconfigValueSets := []string{} @@ -211,8 +211,8 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro return fmt.Errorf("Setting value for flag %s not allowed in %s\n", name, value.path) } if isRoot && *fa.FlagDeclaration.Workflow != workflowManual { - // The "root" release config can only contain workflow: Workflow_Manual flags. - return fmt.Errorf("Setting value for non-Workflow_Manual flag %s is not allowed in %s", name, value.path) + // The "root" release config can only contain workflow: MANUAL flags. + return fmt.Errorf("Setting value for non-MANUAL flag %s is not allowed in %s", name, value.path) } if err := fa.UpdateValue(*value); err != nil { return err diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go index 403ba1a58..a11c7927d 100644 --- a/cmd/release_config/release_config_lib/release_configs.go +++ b/cmd/release_config/release_config_lib/release_configs.go @@ -107,7 +107,7 @@ func ReleaseConfigsFactory() (c *ReleaseConfigs) { configDirIndexes: make(ReleaseConfigDirMap), FilesUsedMap: make(map[string]bool), } - workflowManual := rc_proto.Workflow(rc_proto.Workflow_Workflow_Manual) + workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) releaseAconfigValueSets := FlagArtifact{ FlagDeclaration: &rc_proto.FlagDeclaration{ Name: proto.String("RELEASE_ACONFIG_VALUE_SETS"), diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go index 1a3fb802d..a53823684 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go @@ -40,28 +40,28 @@ type Workflow int32 const ( Workflow_Workflow_Unspecified Workflow = 0 // Boolean value flags that progress from false to true. - Workflow_Workflow_Launch Workflow = 1 + Workflow_LAUNCH Workflow = 1 // String value flags that get updated with new version strings to control // prebuilt inclusion. - Workflow_Workflow_Prebuilt Workflow = 2 + Workflow_PREBUILT Workflow = 2 // Manually managed outside flags. These are likely to be found in a // different directory than flags with other workflows. - Workflow_Workflow_Manual Workflow = 3 + Workflow_MANUAL Workflow = 3 ) // Enum value maps for Workflow. var ( Workflow_name = map[int32]string{ 0: "Workflow_Unspecified", - 1: "Workflow_Launch", - 2: "Workflow_Prebuilt", - 3: "Workflow_Manual", + 1: "LAUNCH", + 2: "PREBUILT", + 3: "MANUAL", } Workflow_value = map[string]int32{ "Workflow_Unspecified": 0, - "Workflow_Launch": 1, - "Workflow_Prebuilt": 2, - "Workflow_Manual": 3, + "LAUNCH": 1, + "PREBUILT": 2, + "MANUAL": 3, } ) @@ -646,17 +646,15 @@ var file_build_flags_src_proto_rawDesc = []byte{ 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x65, 0x0a, 0x08, + 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x4a, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x55, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, - 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x4c, - 0x61, 0x75, 0x6e, 0x63, 0x68, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x57, 0x6f, 0x72, 0x6b, 0x66, - 0x6c, 0x6f, 0x77, 0x5f, 0x50, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x10, 0x02, 0x12, 0x13, - 0x0a, 0x0f, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x4d, 0x61, 0x6e, 0x75, 0x61, - 0x6c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, - 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, 0x0c, + 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, + 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, + 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, } var ( diff --git a/cmd/release_config/release_config_proto/build_flags_src.proto b/cmd/release_config/release_config_proto/build_flags_src.proto index 6a8e96eec..cb0d9d9bb 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.proto +++ b/cmd/release_config/release_config_proto/build_flags_src.proto @@ -46,15 +46,15 @@ enum workflow { Workflow_Unspecified = 0; // Boolean value flags that progress from false to true. - Workflow_Launch = 1; + LAUNCH = 1; // String value flags that get updated with new version strings to control // prebuilt inclusion. - Workflow_Prebuilt = 2; + PREBUILT = 2; // Manually managed outside flags. These are likely to be found in a // different directory than flags with other workflows. - Workflow_Manual = 3; + MANUAL = 3; } message value { From a2cbf72b2abcc36fb60e1aa97a5b3da042704f8d Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 22 May 2024 13:14:40 -0700 Subject: [PATCH 63/67] Generate specific message for build flag declarations artifact Many of the fields in `flag_artifact` are not valid in the all_build_flag_definitions artifact. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I00eab1ef76f67f7db2118a6fc0d5771e3dd39fbb Change-Id: I00eab1ef76f67f7db2118a6fc0d5771e3dd39fbb --- .../build_flag_declarations/main.go | 2 +- .../release_config_lib/flag_artifact.go | 31 +- .../release_config_proto/Android.bp | 2 + .../build_flags_common.pb.go | 169 ++++++++++ .../build_flags_common.proto | 36 +++ .../build_flags_declarations.pb.go | 301 ++++++++++++++++++ .../build_flags_declarations.proto | 75 +++++ .../build_flags_out.pb.go | 2 +- .../build_flags_src.pb.go | 231 +++++--------- .../build_flags_src.proto | 17 +- .../release_config_proto/regen.sh | 2 +- 11 files changed, 688 insertions(+), 180 deletions(-) create mode 100644 cmd/release_config/release_config_proto/build_flags_common.pb.go create mode 100644 cmd/release_config/release_config_proto/build_flags_common.proto create mode 100644 cmd/release_config/release_config_proto/build_flags_declarations.pb.go create mode 100644 cmd/release_config/release_config_proto/build_flags_declarations.proto diff --git a/cmd/release_config/build_flag_declarations/main.go b/cmd/release_config/build_flag_declarations/main.go index 8315f5917..7fdd084d9 100644 --- a/cmd/release_config/build_flag_declarations/main.go +++ b/cmd/release_config/build_flag_declarations/main.go @@ -73,7 +73,7 @@ func main() { (*flagArtifacts)[*fa.FlagDeclaration.Name] = fa } - message := flagArtifacts.GenerateFlagArtifacts() + message := flagArtifacts.GenerateFlagDeclarationArtifacts() err = rc_lib.WriteFormattedMessage(flags.output, flags.format, message) if err != nil { errorExit(err) diff --git a/cmd/release_config/release_config_lib/flag_artifact.go b/cmd/release_config/release_config_lib/flag_artifact.go index cdd5af99b..6919ff5af 100644 --- a/cmd/release_config/release_config_lib/flag_artifact.go +++ b/cmd/release_config/release_config_lib/flag_artifact.go @@ -82,24 +82,33 @@ func FlagArtifactsFactory(artifactsPath string) *FlagArtifacts { return &ret } -func (fa *FlagArtifact) GenerateFlagArtifact() *rc_proto.FlagArtifact { - ret := &rc_proto.FlagArtifact{FlagDeclaration: fa.FlagDeclaration} - if fa.Value != nil { - ret.Value = fa.Value +func (fa *FlagArtifact) GenerateFlagDeclarationArtifact() *rc_proto.FlagDeclarationArtifact { + ret := &rc_proto.FlagDeclarationArtifact{ + Name: fa.FlagDeclaration.Name, + DeclarationPath: fa.Traces[0].Source, } - if len(fa.Traces) > 0 { - ret.Traces = fa.Traces + if namespace := fa.FlagDeclaration.GetNamespace(); namespace != "" { + ret.Namespace = proto.String(namespace) + } + if description := fa.FlagDeclaration.GetDescription(); description != "" { + ret.Description = proto.String(description) + } + if workflow := fa.FlagDeclaration.GetWorkflow(); workflow != rc_proto.Workflow_Workflow_Unspecified { + ret.Workflow = &workflow + } + if containers := fa.FlagDeclaration.GetContainers(); containers != nil { + ret.Containers = containers } return ret } -func (fas *FlagArtifacts) GenerateFlagArtifacts() *rc_proto.FlagArtifacts { - ret := &rc_proto.FlagArtifacts{FlagArtifacts: []*rc_proto.FlagArtifact{}} +func (fas *FlagArtifacts) GenerateFlagDeclarationArtifacts() *rc_proto.FlagDeclarationArtifacts { + ret := &rc_proto.FlagDeclarationArtifacts{FlagDeclarationArtifacts: []*rc_proto.FlagDeclarationArtifact{}} for _, fa := range *fas { - ret.FlagArtifacts = append(ret.FlagArtifacts, fa.GenerateFlagArtifact()) + ret.FlagDeclarationArtifacts = append(ret.FlagDeclarationArtifacts, fa.GenerateFlagDeclarationArtifact()) } - slices.SortFunc(ret.FlagArtifacts, func(a, b *rc_proto.FlagArtifact) int { - return cmp.Compare(*a.FlagDeclaration.Name, *b.FlagDeclaration.Name) + slices.SortFunc(ret.FlagDeclarationArtifacts, func(a, b *rc_proto.FlagDeclarationArtifact) int { + return cmp.Compare(*a.Name, *b.Name) }) return ret } diff --git a/cmd/release_config/release_config_proto/Android.bp b/cmd/release_config/release_config_proto/Android.bp index 8c47f2ac0..c34d2030e 100644 --- a/cmd/release_config/release_config_proto/Android.bp +++ b/cmd/release_config/release_config_proto/Android.bp @@ -24,6 +24,8 @@ bootstrap_go_package { "golang-protobuf-runtime-protoimpl", ], srcs: [ + "build_flags_common.pb.go", + "build_flags_declarations.pb.go", "build_flags_src.pb.go", "build_flags_out.pb.go", ], diff --git a/cmd/release_config/release_config_proto/build_flags_common.pb.go b/cmd/release_config/release_config_proto/build_flags_common.pb.go new file mode 100644 index 000000000..1e927db6c --- /dev/null +++ b/cmd/release_config/release_config_proto/build_flags_common.pb.go @@ -0,0 +1,169 @@ +// +// Copyright (C) 2024 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. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.21.12 +// source: build_flags_common.proto + +package release_config_proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Workflow int32 + +const ( + Workflow_Workflow_Unspecified Workflow = 0 + // Boolean value flags that progress from false to true. + Workflow_LAUNCH Workflow = 1 + // String value flags that get updated with new version strings to control + // prebuilt inclusion. + Workflow_PREBUILT Workflow = 2 + // Manually managed outside flags. These are likely to be found in a + // different directory than flags with other workflows. + Workflow_MANUAL Workflow = 3 +) + +// Enum value maps for Workflow. +var ( + Workflow_name = map[int32]string{ + 0: "Workflow_Unspecified", + 1: "LAUNCH", + 2: "PREBUILT", + 3: "MANUAL", + } + Workflow_value = map[string]int32{ + "Workflow_Unspecified": 0, + "LAUNCH": 1, + "PREBUILT": 2, + "MANUAL": 3, + } +) + +func (x Workflow) Enum() *Workflow { + p := new(Workflow) + *p = x + return p +} + +func (x Workflow) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Workflow) Descriptor() protoreflect.EnumDescriptor { + return file_build_flags_common_proto_enumTypes[0].Descriptor() +} + +func (Workflow) Type() protoreflect.EnumType { + return &file_build_flags_common_proto_enumTypes[0] +} + +func (x Workflow) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Workflow) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) + if err != nil { + return err + } + *x = Workflow(num) + return nil +} + +// Deprecated: Use Workflow.Descriptor instead. +func (Workflow) EnumDescriptor() ([]byte, []int) { + return file_build_flags_common_proto_rawDescGZIP(), []int{0} +} + +var File_build_flags_common_proto protoreflect.FileDescriptor + +var file_build_flags_common_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x5f, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x61, 0x6e, 0x64, 0x72, + 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2a, 0x4a, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, + 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, + 0x5f, 0x55, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x10, 0x00, 0x12, 0x0a, + 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x52, + 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x41, 0x4e, 0x55, + 0x41, 0x4c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, + 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, +} + +var ( + file_build_flags_common_proto_rawDescOnce sync.Once + file_build_flags_common_proto_rawDescData = file_build_flags_common_proto_rawDesc +) + +func file_build_flags_common_proto_rawDescGZIP() []byte { + file_build_flags_common_proto_rawDescOnce.Do(func() { + file_build_flags_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_build_flags_common_proto_rawDescData) + }) + return file_build_flags_common_proto_rawDescData +} + +var file_build_flags_common_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_build_flags_common_proto_goTypes = []interface{}{ + (Workflow)(0), // 0: android.release_config_proto.workflow +} +var file_build_flags_common_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_build_flags_common_proto_init() } +func file_build_flags_common_proto_init() { + if File_build_flags_common_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_build_flags_common_proto_rawDesc, + NumEnums: 1, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_build_flags_common_proto_goTypes, + DependencyIndexes: file_build_flags_common_proto_depIdxs, + EnumInfos: file_build_flags_common_proto_enumTypes, + }.Build() + File_build_flags_common_proto = out.File + file_build_flags_common_proto_rawDesc = nil + file_build_flags_common_proto_goTypes = nil + file_build_flags_common_proto_depIdxs = nil +} diff --git a/cmd/release_config/release_config_proto/build_flags_common.proto b/cmd/release_config/release_config_proto/build_flags_common.proto new file mode 100644 index 000000000..d5d6101e2 --- /dev/null +++ b/cmd/release_config/release_config_proto/build_flags_common.proto @@ -0,0 +1,36 @@ +// +// Copyright (C) 2024 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. + +syntax = "proto2"; +package android.release_config_proto; +option go_package = "android/soong/release_config/release_config_proto"; + +// This protobuf file defines common messages used in the rest of the build flag +// protos. + +enum workflow { + Workflow_Unspecified = 0; + + // Boolean value flags that progress from false to true. + LAUNCH = 1; + + // String value flags that get updated with new version strings to control + // prebuilt inclusion. + PREBUILT = 2; + + // Manually managed outside flags. These are likely to be found in a + // different directory than flags with other workflows. + MANUAL = 3; +} diff --git a/cmd/release_config/release_config_proto/build_flags_declarations.pb.go b/cmd/release_config/release_config_proto/build_flags_declarations.pb.go new file mode 100644 index 000000000..c0573edf3 --- /dev/null +++ b/cmd/release_config/release_config_proto/build_flags_declarations.pb.go @@ -0,0 +1,301 @@ +// +// Copyright (C) 2024 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. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.21.12 +// source: build_flags_declarations.proto + +package release_config_proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type FlagDeclarationArtifact struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The name of the flag. + // See # name for format detail + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // Namespace the flag belongs to (required) + // See # namespace for format detail + Namespace *string `protobuf:"bytes,2,opt,name=namespace" json:"namespace,omitempty"` + // Text description of the flag's purpose. + Description *string `protobuf:"bytes,3,opt,name=description" json:"description,omitempty"` + // Where the flag was declared. + DeclarationPath *string `protobuf:"bytes,5,opt,name=declaration_path,json=declarationPath" json:"declaration_path,omitempty"` + // Workflow for this flag. + Workflow *Workflow `protobuf:"varint,205,opt,name=workflow,enum=android.release_config_proto.Workflow" json:"workflow,omitempty"` + // The container for this flag. This overrides any default container given + // in the release_config_map message. + Containers []string `protobuf:"bytes,206,rep,name=containers" json:"containers,omitempty"` +} + +func (x *FlagDeclarationArtifact) Reset() { + *x = FlagDeclarationArtifact{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_declarations_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FlagDeclarationArtifact) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FlagDeclarationArtifact) ProtoMessage() {} + +func (x *FlagDeclarationArtifact) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_declarations_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FlagDeclarationArtifact.ProtoReflect.Descriptor instead. +func (*FlagDeclarationArtifact) Descriptor() ([]byte, []int) { + return file_build_flags_declarations_proto_rawDescGZIP(), []int{0} +} + +func (x *FlagDeclarationArtifact) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *FlagDeclarationArtifact) GetNamespace() string { + if x != nil && x.Namespace != nil { + return *x.Namespace + } + return "" +} + +func (x *FlagDeclarationArtifact) GetDescription() string { + if x != nil && x.Description != nil { + return *x.Description + } + return "" +} + +func (x *FlagDeclarationArtifact) GetDeclarationPath() string { + if x != nil && x.DeclarationPath != nil { + return *x.DeclarationPath + } + return "" +} + +func (x *FlagDeclarationArtifact) GetWorkflow() Workflow { + if x != nil && x.Workflow != nil { + return *x.Workflow + } + return Workflow_Workflow_Unspecified +} + +func (x *FlagDeclarationArtifact) GetContainers() []string { + if x != nil { + return x.Containers + } + return nil +} + +type FlagDeclarationArtifacts struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The artifacts + FlagDeclarationArtifacts []*FlagDeclarationArtifact `protobuf:"bytes,1,rep,name=flag_declaration_artifacts,json=flagDeclarationArtifacts" json:"flag_declaration_artifacts,omitempty"` +} + +func (x *FlagDeclarationArtifacts) Reset() { + *x = FlagDeclarationArtifacts{} + if protoimpl.UnsafeEnabled { + mi := &file_build_flags_declarations_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FlagDeclarationArtifacts) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FlagDeclarationArtifacts) ProtoMessage() {} + +func (x *FlagDeclarationArtifacts) ProtoReflect() protoreflect.Message { + mi := &file_build_flags_declarations_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FlagDeclarationArtifacts.ProtoReflect.Descriptor instead. +func (*FlagDeclarationArtifacts) Descriptor() ([]byte, []int) { + return file_build_flags_declarations_proto_rawDescGZIP(), []int{1} +} + +func (x *FlagDeclarationArtifacts) GetFlagDeclarationArtifacts() []*FlagDeclarationArtifact { + if x != nil { + return x.FlagDeclarationArtifacts + } + return nil +} + +var File_build_flags_declarations_proto protoreflect.FileDescriptor + +var file_build_flags_declarations_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x5f, 0x64, 0x65, + 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x1c, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, + 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8e, 0x02, 0x0a, 0x19, 0x66, 0x6c, 0x61, + 0x67, 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x72, + 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x65, + 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x50, 0x61, 0x74, 0x68, 0x12, 0x43, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, + 0x77, 0x18, 0xcd, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, + 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, + 0x52, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x1f, 0x0a, 0x0a, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0xce, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x4a, 0x04, 0x08, 0x04, 0x10, + 0x05, 0x4a, 0x06, 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x93, 0x01, 0x0a, 0x1a, 0x66, 0x6c, + 0x61, 0x67, 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, + 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x12, 0x75, 0x0a, 0x1a, 0x66, 0x6c, 0x61, 0x67, + 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x72, 0x74, + 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x61, + 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x66, 0x6c, 0x61, 0x67, + 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x72, 0x74, + 0x69, 0x66, 0x61, 0x63, 0x74, 0x52, 0x18, 0x66, 0x6c, 0x61, 0x67, 0x44, 0x65, 0x63, 0x6c, 0x61, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x42, + 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, + 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, +} + +var ( + file_build_flags_declarations_proto_rawDescOnce sync.Once + file_build_flags_declarations_proto_rawDescData = file_build_flags_declarations_proto_rawDesc +) + +func file_build_flags_declarations_proto_rawDescGZIP() []byte { + file_build_flags_declarations_proto_rawDescOnce.Do(func() { + file_build_flags_declarations_proto_rawDescData = protoimpl.X.CompressGZIP(file_build_flags_declarations_proto_rawDescData) + }) + return file_build_flags_declarations_proto_rawDescData +} + +var file_build_flags_declarations_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_build_flags_declarations_proto_goTypes = []interface{}{ + (*FlagDeclarationArtifact)(nil), // 0: android.release_config_proto.flag_declaration_artifact + (*FlagDeclarationArtifacts)(nil), // 1: android.release_config_proto.flag_declaration_artifacts + (Workflow)(0), // 2: android.release_config_proto.workflow +} +var file_build_flags_declarations_proto_depIdxs = []int32{ + 2, // 0: android.release_config_proto.flag_declaration_artifact.workflow:type_name -> android.release_config_proto.workflow + 0, // 1: android.release_config_proto.flag_declaration_artifacts.flag_declaration_artifacts:type_name -> android.release_config_proto.flag_declaration_artifact + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_build_flags_declarations_proto_init() } +func file_build_flags_declarations_proto_init() { + if File_build_flags_declarations_proto != nil { + return + } + file_build_flags_common_proto_init() + if !protoimpl.UnsafeEnabled { + file_build_flags_declarations_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FlagDeclarationArtifact); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_build_flags_declarations_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FlagDeclarationArtifacts); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_build_flags_declarations_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_build_flags_declarations_proto_goTypes, + DependencyIndexes: file_build_flags_declarations_proto_depIdxs, + MessageInfos: file_build_flags_declarations_proto_msgTypes, + }.Build() + File_build_flags_declarations_proto = out.File + file_build_flags_declarations_proto_rawDesc = nil + file_build_flags_declarations_proto_goTypes = nil + file_build_flags_declarations_proto_depIdxs = nil +} diff --git a/cmd/release_config/release_config_proto/build_flags_declarations.proto b/cmd/release_config/release_config_proto/build_flags_declarations.proto new file mode 100644 index 000000000..e0cf09926 --- /dev/null +++ b/cmd/release_config/release_config_proto/build_flags_declarations.proto @@ -0,0 +1,75 @@ +// +// Copyright (C) 2024 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. + +syntax = "proto2"; +package android.release_config_proto; +option go_package = "android/soong/release_config/release_config_proto"; + +import "build_flags_common.proto"; + +// This protobuf file defines messages used to represent the +// all_build_flag_declarations artifact for use in automated systems, such as +// Gantry. +// +// The following format requirements apply across various message fields: +// +// # name: name of the flag +// +// format: an uppercase string in SNAKE_CASE format starting with RELEASE_, +// no consecutive underscores, and no leading digit. For example +// RELEASE_MY_PACKAGE_FLAG is a valid name, while MY_PACKAGE_FLAG, and +// RELEASE_MY_PACKAGE__FLAG are invalid. +// +// # package: package to which the flag belongs +// +// format: lowercase strings in snake_case format, delimited by dots, no +// consecutive underscores and no leading digit in each string. For example +// com.android.mypackage is a valid name while com.android.myPackage, +// com.android.1mypackage are invalid + +message flag_declaration_artifact { + // The name of the flag. + // See # name for format detail + optional string name = 1; + + // Namespace the flag belongs to (required) + // See # namespace for format detail + optional string namespace = 2; + + // Text description of the flag's purpose. + optional string description = 3; + + // reserve this for bug, if needed. + reserved 4; + + // Where the flag was declared. + optional string declaration_path = 5; + + // Workflow for this flag. + optional workflow workflow = 205; + + // The container for this flag. This overrides any default container given + // in the release_config_map message. + repeated string containers = 206; + + // The package associated with this flag. + // (when Gantry is ready for it) optional string package = 207; + reserved 207; +} + +message flag_declaration_artifacts { + // The artifacts + repeated flag_declaration_artifact flag_declaration_artifacts = 1; +} diff --git a/cmd/release_config/release_config_proto/build_flags_out.pb.go b/cmd/release_config/release_config_proto/build_flags_out.pb.go index 73cc1dc95..42ae6f9cb 100644 --- a/cmd/release_config/release_config_proto/build_flags_out.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_out.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.30.0 // protoc v3.21.12 // source: build_flags_out.proto diff --git a/cmd/release_config/release_config_proto/build_flags_src.pb.go b/cmd/release_config/release_config_proto/build_flags_src.pb.go index a53823684..1b6396172 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.pb.go +++ b/cmd/release_config/release_config_proto/build_flags_src.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.30.0 // protoc v3.21.12 // source: build_flags_src.proto @@ -35,73 +35,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type Workflow int32 - -const ( - Workflow_Workflow_Unspecified Workflow = 0 - // Boolean value flags that progress from false to true. - Workflow_LAUNCH Workflow = 1 - // String value flags that get updated with new version strings to control - // prebuilt inclusion. - Workflow_PREBUILT Workflow = 2 - // Manually managed outside flags. These are likely to be found in a - // different directory than flags with other workflows. - Workflow_MANUAL Workflow = 3 -) - -// Enum value maps for Workflow. -var ( - Workflow_name = map[int32]string{ - 0: "Workflow_Unspecified", - 1: "LAUNCH", - 2: "PREBUILT", - 3: "MANUAL", - } - Workflow_value = map[string]int32{ - "Workflow_Unspecified": 0, - "LAUNCH": 1, - "PREBUILT": 2, - "MANUAL": 3, - } -) - -func (x Workflow) Enum() *Workflow { - p := new(Workflow) - *p = x - return p -} - -func (x Workflow) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Workflow) Descriptor() protoreflect.EnumDescriptor { - return file_build_flags_src_proto_enumTypes[0].Descriptor() -} - -func (Workflow) Type() protoreflect.EnumType { - return &file_build_flags_src_proto_enumTypes[0] -} - -func (x Workflow) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Do not use. -func (x *Workflow) UnmarshalJSON(b []byte) error { - num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) - if err != nil { - return err - } - *x = Workflow(num) - return nil -} - -// Deprecated: Use Workflow.Descriptor instead. -func (Workflow) EnumDescriptor() ([]byte, []int) { - return file_build_flags_src_proto_rawDescGZIP(), []int{0} -} - type Value struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -586,75 +519,72 @@ var file_build_flags_src_proto_rawDesc = []byte{ 0x0a, 0x15, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x5f, 0x73, 0x72, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa5, 0x01, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, - 0x2e, 0x0a, 0x11, 0x75, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x10, 0x75, - 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, - 0x24, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0xc9, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x20, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, - 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x6f, 0x6c, - 0x65, 0x74, 0x65, 0x18, 0xcb, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x08, 0x6f, 0x62, - 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x96, 0x02, - 0x0a, 0x10, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, - 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x12, 0x43, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x18, 0xcd, - 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, - 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x52, 0x08, 0x77, - 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x1f, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0xce, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x06, - 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, 0x22, 0x79, 0x0a, 0x0a, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, - 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x0a, 0x08, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, 0x64, - 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, - 0x64, 0x22, 0x9c, 0x01, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, - 0x72, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, - 0x72, 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, - 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x66, 0x6c, - 0x61, 0x67, 0x73, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, - 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x4f, 0x6e, 0x6c, 0x79, - 0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, - 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xac, 0x01, - 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, - 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, - 0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, - 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, - 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x4a, 0x0a, 0x08, - 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x57, 0x6f, 0x72, 0x6b, - 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x55, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, - 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, 0x0c, - 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, - 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, - 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x66, 0x6c, 0x61, + 0x67, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0xa5, 0x01, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2e, 0x0a, 0x11, 0x75, 0x6e, 0x73, + 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc8, + 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x10, 0x75, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x69, + 0x66, 0x69, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x24, 0x0a, 0x0c, 0x73, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, + 0x20, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0xca, 0x01, + 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x12, 0x1d, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x18, 0xcb, 0x01, + 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, + 0x42, 0x05, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x96, 0x02, 0x0a, 0x10, 0x66, 0x6c, 0x61, 0x67, + 0x5f, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x43, 0x0a, 0x08, + 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x18, 0xcd, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x26, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x77, + 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x52, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, + 0x77, 0x12, 0x1f, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, + 0xce, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x73, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x06, 0x08, 0xcf, 0x01, 0x10, 0xd0, 0x01, + 0x22, 0x79, 0x0a, 0x0a, 0x66, 0x6c, 0x61, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0xc9, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, + 0x0a, 0x08, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, 0x64, 0x18, 0xca, 0x01, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x08, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, 0x64, 0x22, 0x9c, 0x01, 0x0a, 0x0e, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x73, 0x12, 0x2c, + 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, + 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, + 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x5f, 0x6f, 0x6e, + 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xac, 0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, + 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, + 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, + 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, + 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, } var ( @@ -669,22 +599,21 @@ func file_build_flags_src_proto_rawDescGZIP() []byte { return file_build_flags_src_proto_rawDescData } -var file_build_flags_src_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_build_flags_src_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_build_flags_src_proto_goTypes = []interface{}{ - (Workflow)(0), // 0: android.release_config_proto.workflow - (*Value)(nil), // 1: android.release_config_proto.value - (*FlagDeclaration)(nil), // 2: android.release_config_proto.flag_declaration - (*FlagValue)(nil), // 3: android.release_config_proto.flag_value - (*ReleaseConfig)(nil), // 4: android.release_config_proto.release_config - (*ReleaseAlias)(nil), // 5: android.release_config_proto.release_alias - (*ReleaseConfigMap)(nil), // 6: android.release_config_proto.release_config_map + (*Value)(nil), // 0: android.release_config_proto.value + (*FlagDeclaration)(nil), // 1: android.release_config_proto.flag_declaration + (*FlagValue)(nil), // 2: android.release_config_proto.flag_value + (*ReleaseConfig)(nil), // 3: android.release_config_proto.release_config + (*ReleaseAlias)(nil), // 4: android.release_config_proto.release_alias + (*ReleaseConfigMap)(nil), // 5: android.release_config_proto.release_config_map + (Workflow)(0), // 6: android.release_config_proto.workflow } var file_build_flags_src_proto_depIdxs = []int32{ - 1, // 0: android.release_config_proto.flag_declaration.value:type_name -> android.release_config_proto.value - 0, // 1: android.release_config_proto.flag_declaration.workflow:type_name -> android.release_config_proto.workflow - 1, // 2: android.release_config_proto.flag_value.value:type_name -> android.release_config_proto.value - 5, // 3: android.release_config_proto.release_config_map.aliases:type_name -> android.release_config_proto.release_alias + 0, // 0: android.release_config_proto.flag_declaration.value:type_name -> android.release_config_proto.value + 6, // 1: android.release_config_proto.flag_declaration.workflow:type_name -> android.release_config_proto.workflow + 0, // 2: android.release_config_proto.flag_value.value:type_name -> android.release_config_proto.value + 4, // 3: android.release_config_proto.release_config_map.aliases:type_name -> android.release_config_proto.release_alias 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name @@ -697,6 +626,7 @@ func file_build_flags_src_proto_init() { if File_build_flags_src_proto != nil { return } + file_build_flags_common_proto_init() if !protoimpl.UnsafeEnabled { file_build_flags_src_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Value); i { @@ -782,14 +712,13 @@ func file_build_flags_src_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_build_flags_src_proto_rawDesc, - NumEnums: 1, + NumEnums: 0, NumMessages: 6, NumExtensions: 0, NumServices: 0, }, GoTypes: file_build_flags_src_proto_goTypes, DependencyIndexes: file_build_flags_src_proto_depIdxs, - EnumInfos: file_build_flags_src_proto_enumTypes, MessageInfos: file_build_flags_src_proto_msgTypes, }.Build() File_build_flags_src_proto = out.File diff --git a/cmd/release_config/release_config_proto/build_flags_src.proto b/cmd/release_config/release_config_proto/build_flags_src.proto index cb0d9d9bb..662329465 100644 --- a/cmd/release_config/release_config_proto/build_flags_src.proto +++ b/cmd/release_config/release_config_proto/build_flags_src.proto @@ -17,6 +17,8 @@ syntax = "proto2"; package android.release_config_proto; option go_package = "android/soong/release_config/release_config_proto"; +import "build_flags_common.proto"; + // This protobuf file defines messages used to represent the build flags used by // a release in a more human-editable form. It is used for on-disk files in the // source tree. @@ -42,21 +44,6 @@ option go_package = "android/soong/release_config/release_config_proto"; // com.android.mypackage is a valid name while com.android.myPackage, // com.android.1mypackage are invalid -enum workflow { - Workflow_Unspecified = 0; - - // Boolean value flags that progress from false to true. - LAUNCH = 1; - - // String value flags that get updated with new version strings to control - // prebuilt inclusion. - PREBUILT = 2; - - // Manually managed outside flags. These are likely to be found in a - // different directory than flags with other workflows. - MANUAL = 3; -} - message value { oneof val { bool unspecified_value = 200; diff --git a/cmd/release_config/release_config_proto/regen.sh b/cmd/release_config/release_config_proto/regen.sh index 1846c4d87..23e311532 100644 --- a/cmd/release_config/release_config_proto/regen.sh +++ b/cmd/release_config/release_config_proto/regen.sh @@ -1,3 +1,3 @@ #!/bin/bash -aprotoc --go_out=paths=source_relative:. build_flags_src.proto build_flags_out.proto +aprotoc --go_out=paths=source_relative:. build_flags_src.proto build_flags_out.proto build_flags_common.proto build_flags_declarations.proto From 4ba41f0effebe9461d0316f038f7179ce42921c9 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 28 May 2024 13:23:01 -0700 Subject: [PATCH 64/67] all_flags.pb: Properly handle intermediate files Bug: 343203557 Test: manual, TH Ignore-AOSP-First: cherry-pick Merged-In: I9a4ef39b0c2a641ccd996187ce5f7629520dffc0 Change-Id: I9a4ef39b0c2a641ccd996187ce5f7629520dffc0 --- .../build_flag_declarations/main.go | 10 +++++----- .../release_config_lib/flag_artifact.go | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cmd/release_config/build_flag_declarations/main.go b/cmd/release_config/build_flag_declarations/main.go index 7fdd084d9..cc286b6a9 100644 --- a/cmd/release_config/build_flag_declarations/main.go +++ b/cmd/release_config/build_flag_declarations/main.go @@ -6,6 +6,7 @@ import ( "os" rc_lib "android/soong/cmd/release_config/release_config_lib" + rc_proto "android/soong/cmd/release_config/release_config_proto" ) type Flags struct { @@ -62,18 +63,17 @@ func main() { } flagArtifacts := rc_lib.FlagArtifactsFactory("") + intermediates := []*rc_proto.FlagDeclarationArtifacts{} for _, intermediate := range flags.intermediates { - fas := rc_lib.FlagArtifactsFactory(intermediate) - for _, fa := range *fas { - (*flagArtifacts)[*fa.FlagDeclaration.Name] = fa - } + fda := rc_lib.FlagDeclarationArtifactsFactory(intermediate) + intermediates = append(intermediates, fda) } for _, decl := range flags.decls { fa := rc_lib.FlagArtifactFactory(decl) (*flagArtifacts)[*fa.FlagDeclaration.Name] = fa } - message := flagArtifacts.GenerateFlagDeclarationArtifacts() + message := flagArtifacts.GenerateFlagDeclarationArtifacts(intermediates) err = rc_lib.WriteFormattedMessage(flags.output, flags.format, message) if err != nil { errorExit(err) diff --git a/cmd/release_config/release_config_lib/flag_artifact.go b/cmd/release_config/release_config_lib/flag_artifact.go index 6919ff5af..6d365952c 100644 --- a/cmd/release_config/release_config_lib/flag_artifact.go +++ b/cmd/release_config/release_config_lib/flag_artifact.go @@ -102,11 +102,24 @@ func (fa *FlagArtifact) GenerateFlagDeclarationArtifact() *rc_proto.FlagDeclarat return ret } -func (fas *FlagArtifacts) GenerateFlagDeclarationArtifacts() *rc_proto.FlagDeclarationArtifacts { +func FlagDeclarationArtifactsFactory(path string) *rc_proto.FlagDeclarationArtifacts { + ret := &rc_proto.FlagDeclarationArtifacts{} + if path != "" { + LoadMessage(path, ret) + } else { + ret.FlagDeclarationArtifacts = []*rc_proto.FlagDeclarationArtifact{} + } + return ret +} + +func (fas *FlagArtifacts) GenerateFlagDeclarationArtifacts(intermediates []*rc_proto.FlagDeclarationArtifacts) *rc_proto.FlagDeclarationArtifacts { ret := &rc_proto.FlagDeclarationArtifacts{FlagDeclarationArtifacts: []*rc_proto.FlagDeclarationArtifact{}} for _, fa := range *fas { ret.FlagDeclarationArtifacts = append(ret.FlagDeclarationArtifacts, fa.GenerateFlagDeclarationArtifact()) } + for _, fda := range intermediates { + ret.FlagDeclarationArtifacts = append(ret.FlagDeclarationArtifacts, fda.FlagDeclarationArtifacts...) + } slices.SortFunc(ret.FlagDeclarationArtifacts, func(a, b *rc_proto.FlagDeclarationArtifact) int { return cmp.Compare(*a.Name, *b.Name) }) From 97974dfa041501baf222e11b379cff282e8c3c66 Mon Sep 17 00:00:00 2001 From: Kiyoung Kim Date: Wed, 22 May 2024 16:50:34 +0900 Subject: [PATCH 65/67] VNDK is fully deprecated from Soong VNDK is fully deprecated, so KeepVndk variable will have fixed value. This change removes KeepVndk config value, and updates any logic using the value as VNDK is always deprecated. Bug: 330100430 Test: Soong tests passed Ignore-AOSP-First: Resolve merge conflict Change-Id: I98b7590c059883e06bf3fb236d88966de64991d7 --- android/config.go | 4 ---- android/variable.go | 2 -- apex/apex.go | 22 +--------------------- cc/cc.go | 10 +--------- cc/library.go | 6 ------ 5 files changed, 2 insertions(+), 42 deletions(-) diff --git a/android/config.go b/android/config.go index 89f99c6c8..1105534a1 100644 --- a/android/config.go +++ b/android/config.go @@ -1400,10 +1400,6 @@ func (c *config) PrebuiltHiddenApiDir(_ PathContext) string { return String(c.productVariables.PrebuiltHiddenApiDir) } -func (c *config) IsVndkDeprecated() bool { - return !Bool(c.productVariables.KeepVndk) -} - func (c *config) VendorApiLevel() string { return String(c.productVariables.VendorApiLevel) } diff --git a/android/variable.go b/android/variable.go index 9a9556314..6e7c9798f 100644 --- a/android/variable.go +++ b/android/variable.go @@ -487,8 +487,6 @@ type ProductVariables struct { ReleaseDefaultModuleBuildFromSource *bool `json:",omitempty"` - KeepVndk *bool `json:",omitempty"` - CheckVendorSeappViolations *bool `json:",omitempty"` BuildFlags map[string]string `json:",omitempty"` diff --git a/apex/apex.go b/apex/apex.go index 5f711cd7b..37cb1c266 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -953,7 +953,6 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) { // the non-system APEXes because the VNDK libraries won't be included (and duped) in the // APEX, but shared across APEXes via the VNDK APEX. useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface()) - excludeVndkLibs := useVndk && a.useVndkAsStable(mctx) if proptools.Bool(a.properties.Use_vndk_as_stable) { if !useVndk { mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes") @@ -987,13 +986,8 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) { if !android.IsDepInSameApex(mctx, parent, child) { return false } - if excludeVndkLibs { - if c, ok := child.(*cc.Module); ok && c.IsVndk() { - return false - } - } - if useVndk && mctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" { + if useVndk && child.Name() == "libbinder" { mctx.ModuleErrorf("Module %s in the vendor APEX %s should not use libbinder. Use libbinder_ndk instead.", parent.Name(), a.Name()) } @@ -2190,11 +2184,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, // tags used below are private (e.g. `cc.sharedDepTag`). if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) { if ch, ok := child.(*cc.Module); ok { - if ch.UseVndk() && a.useVndkAsStable(ctx) && ch.IsVndk() { - vctx.requireNativeLibs = append(vctx.requireNativeLibs, ":vndk") - return false - } - af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs) af.transitiveDep = true @@ -3015,12 +3004,3 @@ func rBcpPackages() map[string][]string { func (a *apexBundle) IsTestApex() bool { return a.testApex } - -func (a *apexBundle) useVndkAsStable(ctx android.BaseModuleContext) bool { - // VNDK cannot be linked if it is deprecated - if ctx.Config().IsVndkDeprecated() { - return false - } - - return proptools.Bool(a.properties.Use_vndk_as_stable) -} diff --git a/cc/cc.go b/cc/cc.go index cb82f8610..5e15381eb 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -1623,14 +1623,6 @@ func (ctx *moduleContextImpl) useSdk() bool { func (ctx *moduleContextImpl) sdkVersion() string { if ctx.ctx.Device() { - config := ctx.ctx.Config() - if !config.IsVndkDeprecated() && ctx.useVndk() { - vndkVer := ctx.mod.VndkVersion() - if inList(vndkVer, config.PlatformVersionActiveCodenames()) { - return "current" - } - return vndkVer - } return String(ctx.mod.Properties.Sdk_version) } return "" @@ -1647,7 +1639,7 @@ func (ctx *moduleContextImpl) minSdkVersion() string { if ctx.ctx.Device() { config := ctx.ctx.Config() - if config.IsVndkDeprecated() && ctx.inVendor() { + if ctx.inVendor() { // If building for vendor with final API, then use the latest _stable_ API as "current". if config.VendorApiLevelFrozen() && (ver == "" || ver == "current") { ver = config.PlatformSdkVersion().String() diff --git a/cc/library.go b/cc/library.go index b9c1466b6..7a5683493 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1761,12 +1761,6 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) { library.baseInstaller.subDir = "vndk" } } - - // do not install vndk libs - // vndk libs are packaged into VNDK APEX - if ctx.isVndk() && !ctx.IsVndkExt() && !ctx.Config().IsVndkDeprecated() && !ctx.inProduct() { - return - } } else if library.hasStubsVariants() && !ctx.Host() && ctx.directlyInAnyApex() { // Bionic libraries (e.g. libc.so) is installed to the bootstrap subdirectory. // The original path becomes a symlink to the corresponding file in the From 6a20769a5018cdf99c706bc0a31473a9020f550a Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Thu, 30 May 2024 18:18:45 +0000 Subject: [PATCH 66/67] Revert "Set strict_mode to true" Revert submission 27234948-default_strict_mode Reason for revert: b/343559188 Reverted changes: /q/submissionid:27234948-default_strict_mode Change-Id: Ib06e3d269e606477d5e8f8acc9a26ebf332447a8 --- java/robolectric.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/robolectric.go b/java/robolectric.go index 039e439ce..18386c90c 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -116,7 +116,7 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { if v := String(r.robolectricProperties.Robolectric_prebuilt_version); v != "" { ctx.AddVariationDependencies(nil, libTag, fmt.Sprintf(robolectricPrebuiltLibPattern, v)) - } else if !proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) { + } else if !proptools.Bool(r.robolectricProperties.Strict_mode) { if proptools.Bool(r.robolectricProperties.Upstream) { ctx.AddVariationDependencies(nil, libTag, robolectricCurrentLib+"_upstream") } else { @@ -124,7 +124,7 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { } } - if proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) { + if proptools.Bool(r.robolectricProperties.Strict_mode) { ctx.AddVariationDependencies(nil, roboRuntimeOnlyTag, robolectricCurrentLib+"_upstream") } From 3d530c24d72dd6170c147ee99294cc3f7361188a Mon Sep 17 00:00:00 2001 From: Adam Seaton Date: Mon, 3 Jun 2024 18:26:34 +0000 Subject: [PATCH 67/67] Change default version code for Mainline modules building from source to start with 3520 BUG:344610650 Ignore-AOSP-First: We are currently blocked on internal testing of mainline modules by these version code issues, but are unclear if this is correct behavior for AOSP. We'd like to submit this in the interest of unblocking the testing, and will resolve the question in AOSP thereafter. Change-Id: I64ddf6215ddfe33e180a54bf8a98092da8286808 --- android/updatable_modules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/updatable_modules.go b/android/updatable_modules.go index dd7dc2c2f..d2595ed14 100644 --- a/android/updatable_modules.go +++ b/android/updatable_modules.go @@ -33,4 +33,4 @@ package android // * AOSP - xx9990000 // * x-mainline-prod - xx9990000 // * master - 990090000 -const DefaultUpdatableModuleVersion = "350090000" +const DefaultUpdatableModuleVersion = "352090000"