Merge "Add super_image module type and create super image module in fsgen" into main
diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go
index d9a862c..9a9e568 100644
--- a/aconfig/aconfig_declarations.go
+++ b/aconfig/aconfig_declarations.go
@@ -15,12 +15,12 @@
package aconfig
import (
+ "android/soong/android"
"path/filepath"
"slices"
+ "strconv"
"strings"
- "android/soong/android"
-
"github.com/google/blueprint"
)
@@ -185,6 +185,13 @@
defaultPermission = confPerm
}
}
+ var allowReadWrite bool
+ if requireAllReadOnly, ok := ctx.Config().GetBuildFlag("RELEASE_ACONFIG_REQUIRE_ALL_READ_ONLY"); ok {
+ // The build flag (RELEASE_ACONFIG_REQUIRE_ALL_READ_ONLY) is the negation of the aconfig flag
+ // (allow-read-write) for historical reasons.
+ // Bool build flags are always "" for false, and generally "true" for true.
+ allowReadWrite = requireAllReadOnly == ""
+ }
inputFiles := make([]android.Path, len(declarationFiles))
copy(inputFiles, declarationFiles)
inputFiles = append(inputFiles, valuesFiles[config]...)
@@ -194,6 +201,7 @@
"declarations": android.JoinPathsWithPrefix(declarationFiles, "--declarations "),
"values": joinAndPrefix(" --values ", values[config]),
"default-permission": optionalVariable(" --default-permission ", defaultPermission),
+ "allow-read-write": optionalVariable(" --allow-read-write ", strconv.FormatBool(allowReadWrite)),
}
if len(module.properties.Container) > 0 {
args["container"] = "--container " + module.properties.Container
diff --git a/aconfig/init.go b/aconfig/init.go
index 6f91d8e..621d619 100644
--- a/aconfig/init.go
+++ b/aconfig/init.go
@@ -32,6 +32,7 @@
` ${declarations}` +
` ${values}` +
` ${default-permission}` +
+ ` ${allow-read-write}` +
` --cache ${out}.tmp` +
` && ( if cmp -s ${out}.tmp ${out} ; then rm ${out}.tmp ; else mv ${out}.tmp ${out} ; fi )`,
// ` --build-id ${release_version}` +
@@ -39,7 +40,7 @@
"${aconfig}",
},
Restat: true,
- }, "release_version", "package", "container", "declarations", "values", "default-permission")
+ }, "release_version", "package", "container", "declarations", "values", "default-permission", "allow-read-write")
// For create-device-config-sysprops: Generate aconfig flag value map text file
aconfigTextRule = pctx.AndroidStaticRule("aconfig_text",
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index fbc8089..d49ac1f 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -53,6 +53,12 @@
})
}
+// Remember to add referenced files to implicits!
+var textFileProcessorRule = pctx.AndroidStaticRule("text_file_processing", blueprint.RuleParams{
+ Command: "build/soong/scripts/text_file_processor.py $in $out",
+ CommandDeps: []string{"build/soong/scripts/text_file_processor.py"},
+})
+
type filesystem struct {
android.ModuleBase
android.PackagingBase
@@ -107,6 +113,9 @@
// avbtool. Default used by avbtool is sha1.
Avb_hash_algorithm *string
+ // Whether or not to use forward-error-correction codes when signing with AVB. Defaults to true.
+ Use_fec *bool
+
// The index used to prevent rollback of the image. Only used if use_avb is true.
Rollback_index *int64
@@ -563,11 +572,21 @@
FlagWithArg("--out_system=", rootDir.String()+"/system")
propFile, toolDeps := f.buildPropFile(ctx)
+
+ // Most of the time, if build_image were to call a host tool, it accepts the path to the
+ // host tool in a field in the prop file. However, it doesn't have that option for fec, which
+ // it expects to just be on the PATH. Add fec to the PATH.
+ fec := ctx.Config().HostToolPath(ctx, "fec")
+ pathToolDirs := []string{filepath.Dir(fec.String())}
+
output := android.PathForModuleOut(ctx, f.installFileName())
- builder.Command().BuiltTool("build_image").
+ builder.Command().
+ Textf("PATH=%s:$PATH", strings.Join(pathToolDirs, ":")).
+ BuiltTool("build_image").
Text(rootDir.String()). // input directory
Input(propFile).
Implicits(toolDeps).
+ Implicit(fec).
Output(output).
Text(rootDir.String()) // directory where to find fs_config_files|dirs
@@ -634,10 +653,15 @@
addPath("avb_avbtool", ctx.Config().HostToolPath(ctx, "avbtool"))
algorithm := proptools.StringDefault(f.properties.Avb_algorithm, "SHA256_RSA4096")
addStr("avb_algorithm", algorithm)
- key := android.PathForModuleSrc(ctx, proptools.String(f.properties.Avb_private_key))
- addPath("avb_key_path", key)
+ if f.properties.Avb_private_key != nil {
+ key := android.PathForModuleSrc(ctx, *f.properties.Avb_private_key)
+ addPath("avb_key_path", key)
+ }
addStr("partition_name", f.partitionName())
- avb_add_hashtree_footer_args := "--do_not_generate_fec"
+ avb_add_hashtree_footer_args := ""
+ if !proptools.BoolDefault(f.properties.Use_fec, true) {
+ avb_add_hashtree_footer_args += " --do_not_generate_fec"
+ }
if hashAlgorithm := proptools.String(f.properties.Avb_hash_algorithm); hashAlgorithm != "" {
avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm
}
@@ -648,9 +672,9 @@
}
avb_add_hashtree_footer_args += " --rollback_index " + strconv.Itoa(rollbackIndex)
}
- securityPatchKey := "com.android.build." + f.partitionName() + ".security_patch"
- securityPatchValue := ctx.Config().PlatformSecurityPatch()
- avb_add_hashtree_footer_args += " --prop " + securityPatchKey + ":" + securityPatchValue
+ avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.os_version:%s", f.partitionName(), ctx.Config().PlatformVersionLastStable())
+ avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.fingerprint:{CONTENTS_OF:%s}", f.partitionName(), ctx.Config().BuildFingerprintFile(ctx))
+ avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.security_patch:%s", f.partitionName(), ctx.Config().PlatformSecurityPatch())
addStr("avb_add_hashtree_footer_args", avb_add_hashtree_footer_args)
addStr("avb_salt", f.salt())
}
@@ -694,8 +718,15 @@
}
f.checkFsTypePropertyError(ctx, fst, fsTypeStr(fst))
+ propFilePreProcessing := android.PathForModuleOut(ctx, "prop_pre_processing")
+ android.WriteFileRuleVerbatim(ctx, propFilePreProcessing, propFileString.String())
propFile := android.PathForModuleOut(ctx, "prop")
- android.WriteFileRuleVerbatim(ctx, propFile, propFileString.String())
+ ctx.Build(pctx, android.BuildParams{
+ Rule: textFileProcessorRule,
+ Input: propFilePreProcessing,
+ Output: propFile,
+ Implicit: ctx.Config().BuildFingerprintFile(ctx),
+ })
return propFile, deps
}
@@ -981,7 +1012,7 @@
ctx.WalkDeps(func(child, parent android.Module) bool {
for _, ps := range android.OtherModuleProviderOrDefault(
ctx, child, android.InstallFilesProvider).PackagingSpecs {
- if _, ok := deps[ps.RelPathInPackage()]; ok {
+ if _, ok := deps[ps.RelPathInPackage()]; ok && ps.Partition() == f.PartitionType() {
modulesInPackageByModule[child] = true
modulesInPackageByName[child.Name()] = true
return true
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index 72a5211..86496eb 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -593,7 +593,7 @@
`)
partition := result.ModuleForTests("erofs_partition", "android_common")
- buildImageConfig := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("prop"))
+ buildImageConfig := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("prop_pre_processing"))
android.AssertStringDoesContain(t, "erofs fs type", buildImageConfig, "fs_type=erofs")
android.AssertStringDoesContain(t, "erofs fs type compress algorithm", buildImageConfig, "erofs_default_compressor=lz4hc,9")
android.AssertStringDoesContain(t, "erofs fs type compress hint", buildImageConfig, "erofs_default_compress_hints=compress_hints.txt")
@@ -609,7 +609,7 @@
`)
partition := result.ModuleForTests("f2fs_partition", "android_common")
- buildImageConfig := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("prop"))
+ buildImageConfig := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("prop_pre_processing"))
android.AssertStringDoesContain(t, "f2fs fs type", buildImageConfig, "fs_type=f2fs")
android.AssertStringDoesContain(t, "f2fs fs type sparse", buildImageConfig, "f2fs_sparse_flag=-S")
}
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index 2acfb9c..8d355dd 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -18,6 +18,7 @@
"crypto/sha256"
"fmt"
"path/filepath"
+ "slices"
"strconv"
"strings"
@@ -772,6 +773,7 @@
fsProps.Avb_algorithm = avbInfo.avbAlgorithm
// BOARD_AVB_SYSTEM_ROLLBACK_INDEX
fsProps.Rollback_index = avbInfo.avbRollbackIndex
+ fsProps.Avb_hash_algorithm = avbInfo.avbHashAlgorithm
fsProps.Partition_name = proptools.StringPtr(partitionType)
@@ -805,6 +807,7 @@
avbAlgorithm *string
avbRollbackIndex *int64
avbMode *string
+ avbHashAlgorithm *string
}
func getAvbInfo(config android.Config, partitionType string) avbInfo {
@@ -814,10 +817,23 @@
boardAvbEnable := partitionVars.BoardAvbEnable
if boardAvbEnable {
result.avbEnable = proptools.BoolPtr(true)
+ // There are "global" and "specific" copies of a lot of these variables. Sometimes they
+ // choose the specific and then fall back to the global one if it's not set, other times
+ // the global one actually only applies to the vbmeta partition.
+ if partitionType == "vbmeta" {
+ if partitionVars.BoardAvbKeyPath != "" {
+ result.avbKeyPath = proptools.StringPtr(partitionVars.BoardAvbKeyPath)
+ }
+ if partitionVars.BoardAvbRollbackIndex != "" {
+ parsed, err := strconv.ParseInt(partitionVars.BoardAvbRollbackIndex, 10, 64)
+ if err != nil {
+ panic(fmt.Sprintf("Rollback index must be an int, got %s", partitionVars.BoardAvbRollbackIndex))
+ }
+ result.avbRollbackIndex = &parsed
+ }
+ }
if specificPartitionVars.BoardAvbKeyPath != "" {
result.avbKeyPath = proptools.StringPtr(specificPartitionVars.BoardAvbKeyPath)
- } else if partitionVars.BoardAvbKeyPath != "" {
- result.avbKeyPath = proptools.StringPtr(partitionVars.BoardAvbKeyPath)
}
if specificPartitionVars.BoardAvbAlgorithm != "" {
result.avbAlgorithm = proptools.StringPtr(specificPartitionVars.BoardAvbAlgorithm)
@@ -830,13 +846,24 @@
panic(fmt.Sprintf("Rollback index must be an int, got %s", specificPartitionVars.BoardAvbRollbackIndex))
}
result.avbRollbackIndex = &parsed
- } else if partitionVars.BoardAvbRollbackIndex != "" {
- parsed, err := strconv.ParseInt(partitionVars.BoardAvbRollbackIndex, 10, 64)
+ }
+ if specificPartitionVars.BoardAvbRollbackIndex != "" {
+ parsed, err := strconv.ParseInt(specificPartitionVars.BoardAvbRollbackIndex, 10, 64)
if err != nil {
- panic(fmt.Sprintf("Rollback index must be an int, got %s", partitionVars.BoardAvbRollbackIndex))
+ panic(fmt.Sprintf("Rollback index must be an int, got %s", specificPartitionVars.BoardAvbRollbackIndex))
}
result.avbRollbackIndex = &parsed
}
+
+ // Make allows you to pass arbitrary arguments to avbtool via this variable, but in practice
+ // it's only used for --hash_algorithm. The soong module has a dedicated property for the
+ // hashtree algorithm, and doesn't allow custom arguments, so just extract the hashtree
+ // algorithm out of the arbitrary arguments.
+ addHashtreeFooterArgs := strings.Split(specificPartitionVars.BoardAvbAddHashtreeFooterArgs, " ")
+ if i := slices.Index(addHashtreeFooterArgs, "--hash_algorithm"); i >= 0 {
+ result.avbHashAlgorithm = &addHashtreeFooterArgs[i+1]
+ }
+
result.avbMode = proptools.StringPtr("make_legacy")
}
if result.avbKeyPath != nil {
diff --git a/java/app.go b/java/app.go
index 8739d1c..bedb45c 100644
--- a/java/app.go
+++ b/java/app.go
@@ -1794,9 +1794,9 @@
android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
android.InitOverrideModule(m)
- android.AddLoadHook(m, func(ctx android.LoadHookContext) {
+ android.AddLoadHookWithPriority(m, func(ctx android.LoadHookContext) {
createInternalRuntimeOverlays(ctx, m.ModuleBase)
- })
+ }, 1) // Run after soong config load hoook
return m
}
diff --git a/java/app_test.go b/java/app_test.go
index 61b718d..11556b0 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -4798,3 +4798,76 @@
android.AssertBoolEquals(t, tc.desc, tc.overlayApkExpected, overrideVendorOverlayApk.Rule != nil)
}
}
+
+func TestNoAutogeneratedStaticRroForDisabledOverrideApps(t *testing.T) {
+ t.Parallel()
+ bp := `
+soong_config_module_type {
+ name: "my_custom_override_android_app",
+ module_type: "override_android_app",
+ config_namespace: "my_namespace",
+ value_variables: ["my_app_enabled"],
+ properties: ["enabled"],
+}
+soong_config_bool_variable {
+ name: "my_app_enabled",
+}
+android_app {
+ name: "foo",
+ srcs: ["foo.java"],
+ platform_apis: true,
+}
+my_custom_override_android_app {
+ name: "override_foo",
+ base: "foo",
+ soong_config_variables: {
+ my_app_enabled: {
+ enabled: true,
+ conditions_default: {
+ enabled: false
+ },
+ },
+ }
+}
+`
+ testCases := []struct {
+ desc string
+ preparer android.FixturePreparer
+ overlayApkExpected bool
+ }{
+ {
+ desc: "my_app_enabled is empty",
+ overlayApkExpected: false,
+ },
+ {
+ desc: "my_app_enabled is true",
+ overlayApkExpected: true,
+ preparer: android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.VendorVars = map[string]map[string]string{
+ "my_namespace": {
+ "my_app_enabled": "true",
+ },
+ }
+ }),
+ },
+ }
+ for _, tc := range testCases {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.PrepareForTestWithSoongConfigModuleBuildComponents,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.EnforceRROTargets = []string{"*"}
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.DeviceResourceOverlays = []string{"device/company/test_product"}
+ }),
+ android.MockFS{
+ "res/foo.xml": nil,
+ "device/company/test_product/res/foo.xml": nil,
+ }.AddToFixture(),
+ android.OptionalFixturePreparer(tc.preparer),
+ ).RunTestWithBp(t, bp)
+ overrideVendorOverlayApk := result.ModuleForTests("override_foo__test_product__auto_generated_rro_vendor", "android_arm64_armv8-a").Module().(*AutogenRuntimeResourceOverlay)
+ android.AssertBoolEquals(t, tc.desc, tc.overlayApkExpected, overrideVendorOverlayApk.exportPackage != nil)
+ }
+}
diff --git a/root.bp b/root.bp
index 7e0c1ed..8e621c4 100644
--- a/root.bp
+++ b/root.bp
@@ -2,3 +2,10 @@
// subdirs= and optional_subdirs= are obsolete and this file no longer
// needs a list of the top level directories that may contain Android.bp
// files.
+
+// TODO(b/253827323) Remove this. A module in internal builds needs to disable a new check,
+// IdentifierName, when errorprone is updated. In order to avoid having the update errorprone
+// in internal first, and then aosp, create this variable that we can fill out in internal in the
+// same topic as the errorprone update, then move the flag out of the variable after the update,
+// then remove the variable.
+disable_identifiername_for_errorprone_update = []
diff --git a/scripts/build-apex-bundle.py b/scripts/build-apex-bundle.py
index dcdd9ef..277e112 100644
--- a/scripts/build-apex-bundle.py
+++ b/scripts/build-apex-bundle.py
@@ -16,8 +16,6 @@
#
"""A tool to create an APEX bundle out of Soong-built base.zip"""
-from __future__ import print_function
-
import argparse
import sys
import tempfile
diff --git a/scripts/check_boot_jars/check_boot_jars.py b/scripts/check_boot_jars/check_boot_jars.py
index b711f9d..174b96e 100755
--- a/scripts/check_boot_jars/check_boot_jars.py
+++ b/scripts/check_boot_jars/check_boot_jars.py
@@ -4,7 +4,6 @@
Usage: check_boot_jars.py <dexdump_path> <package_allow_list_file> <jar1> \
<jar2> ...
"""
-from __future__ import print_function
import logging
import re
import subprocess
diff --git a/scripts/construct_context.py b/scripts/construct_context.py
index fc3a89e..882c2db 100755
--- a/scripts/construct_context.py
+++ b/scripts/construct_context.py
@@ -16,8 +16,6 @@
#
"""A tool for constructing class loader context."""
-from __future__ import print_function
-
import argparse
import json
import sys
diff --git a/scripts/manifest.py b/scripts/manifest.py
index 32603e8..87f4f0c 100755
--- a/scripts/manifest.py
+++ b/scripts/manifest.py
@@ -16,7 +16,6 @@
#
"""A tool for inserting values from the build system into a manifest or a test config."""
-from __future__ import print_function
from xml.dom import minidom
diff --git a/scripts/manifest_check.py b/scripts/manifest_check.py
index 1e32d1d..175451e 100755
--- a/scripts/manifest_check.py
+++ b/scripts/manifest_check.py
@@ -16,8 +16,6 @@
#
"""A tool for checking that a manifest agrees with the build system."""
-from __future__ import print_function
-
import argparse
import json
import re
diff --git a/scripts/manifest_fixer.py b/scripts/manifest_fixer.py
index 9847ad5..ad3b313 100755
--- a/scripts/manifest_fixer.py
+++ b/scripts/manifest_fixer.py
@@ -16,8 +16,6 @@
#
"""A tool for inserting values from the build system into a manifest."""
-from __future__ import print_function
-
import argparse
import sys
from xml.dom import minidom
diff --git a/scripts/modify_permissions_allowlist.py b/scripts/modify_permissions_allowlist.py
index 38ec7ec..4a0ca8f 100755
--- a/scripts/modify_permissions_allowlist.py
+++ b/scripts/modify_permissions_allowlist.py
@@ -16,8 +16,6 @@
#
"""A tool for modifying privileged permission allowlists."""
-from __future__ import print_function
-
import argparse
import sys
from xml.dom import minidom
diff --git a/scripts/modify_permissions_allowlist_test.py b/scripts/modify_permissions_allowlist_test.py
index ee8b12c..577388f 100755
--- a/scripts/modify_permissions_allowlist_test.py
+++ b/scripts/modify_permissions_allowlist_test.py
@@ -16,8 +16,6 @@
#
"""Unit tests for modify_permissions_allowlist.py."""
-from __future__ import print_function
-
import unittest
from xml.dom import minidom
diff --git a/scripts/test_config_fixer.py b/scripts/test_config_fixer.py
index 2876bcb..91a83f2 100644
--- a/scripts/test_config_fixer.py
+++ b/scripts/test_config_fixer.py
@@ -16,8 +16,6 @@
#
"""A tool for modifying values in a test config."""
-from __future__ import print_function
-
import argparse
import json
import sys
diff --git a/scripts/text_file_processor.py b/scripts/text_file_processor.py
new file mode 100755
index 0000000..10186ce
--- /dev/null
+++ b/scripts/text_file_processor.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# 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.
+
+import argparse
+import re
+
+def main():
+ parser = argparse.ArgumentParser(description='This script looks for '
+ '`{CONTENTS_OF:path/to/file}` markers in the input file and replaces them with the actual '
+ 'contents of that file, with leading/trailing whitespace stripped. The idea is that this '
+ 'script could be extended to support more types of markers in the future.')
+ parser.add_argument('input')
+ parser.add_argument('output')
+ args = parser.parse_args()
+
+ with open(args.input, 'r') as f:
+ contents = f.read()
+
+ i = 0
+ replacedContents = ''
+ for m in re.finditer(r'{CONTENTS_OF:([a-zA-Z0-9 _/.-]+)}', contents):
+ replacedContents += contents[i:m.start()]
+ with open(m.group(1), 'r') as f:
+ replacedContents += f.read().strip()
+ i = m.end()
+ replacedContents += contents[i:]
+
+ with open(args.output, 'w') as f:
+ f.write(replacedContents)
+
+
+if __name__ == '__main__':
+ main()