Merge "Move coverage builds prebuilt special case to make" into main
diff --git a/aconfig/codegen/cc_aconfig_library.go b/aconfig/codegen/cc_aconfig_library.go
index 8e516b4..f3e9599 100644
--- a/aconfig/codegen/cc_aconfig_library.go
+++ b/aconfig/codegen/cc_aconfig_library.go
@@ -22,6 +22,7 @@
"github.com/google/blueprint/proptools"
"fmt"
+ "strconv"
"strings"
)
@@ -152,6 +153,7 @@
Args: map[string]string{
"gendir": this.generatedDir.String(),
"mode": mode,
+ "debug": strconv.FormatBool(ctx.Config().ReleaseReadFromNewStorageCc()),
},
})
diff --git a/aconfig/codegen/init.go b/aconfig/codegen/init.go
index 73a8951..6182e14 100644
--- a/aconfig/codegen/init.go
+++ b/aconfig/codegen/init.go
@@ -49,11 +49,12 @@
` && ${aconfig} create-cpp-lib` +
` --mode ${mode}` +
` --cache ${in}` +
- ` --out ${gendir}`,
+ ` --out ${gendir}` +
+ ` --allow-instrumentation ${debug}`,
CommandDeps: []string{
"$aconfig",
},
- }, "gendir", "mode")
+ }, "gendir", "mode", "debug")
// For rust_aconfig_library: Generate Rust library
rustRule = pctx.AndroidStaticRule("rust_aconfig_library",
diff --git a/android/config.go b/android/config.go
index 75d135f..b60eb5c 100644
--- a/android/config.go
+++ b/android/config.go
@@ -229,6 +229,11 @@
return c.config.productVariables.GetBuildFlagBool("RELEASE_NDK_ABI_MONITORED")
}
+// Enable read flag from new storage, for C/C++
+func (c Config) ReleaseReadFromNewStorageCc() bool {
+ return c.config.productVariables.GetBuildFlagBool("RELEASE_READ_FROM_NEW_STORAGE_CC")
+}
+
func (c Config) ReleaseHiddenApiExportableStubs() bool {
return c.config.productVariables.GetBuildFlagBool("RELEASE_HIDDEN_API_EXPORTABLE_STUBS") ||
Bool(c.config.productVariables.HiddenapiExportableStubs)
diff --git a/android/module.go b/android/module.go
index 5fe379c..effca03 100644
--- a/android/module.go
+++ b/android/module.go
@@ -2142,13 +2142,13 @@
func (e configurationEvalutor) EvaluateConfiguration(condition proptools.ConfigurableCondition, property string) proptools.ConfigurableValue {
ctx := e.ctx
m := e.m
- switch condition.FunctionName {
+ switch condition.FunctionName() {
case "release_variable":
- if len(condition.Args) != 1 {
- ctx.OtherModulePropertyErrorf(m, property, "release_variable requires 1 argument, found %d", len(condition.Args))
+ if condition.NumArgs() != 1 {
+ ctx.OtherModulePropertyErrorf(m, property, "release_variable requires 1 argument, found %d", condition.NumArgs())
return proptools.ConfigurableValueUndefined()
}
- if v, ok := ctx.Config().productVariables.BuildFlags[condition.Args[0]]; ok {
+ if v, ok := ctx.Config().productVariables.BuildFlags[condition.Arg(0)]; ok {
return proptools.ConfigurableValueString(v)
}
return proptools.ConfigurableValueUndefined()
@@ -2157,12 +2157,12 @@
ctx.OtherModulePropertyErrorf(m, property, "TODO(b/323382414): Product variables are not yet supported in selects")
return proptools.ConfigurableValueUndefined()
case "soong_config_variable":
- if len(condition.Args) != 2 {
- ctx.OtherModulePropertyErrorf(m, property, "soong_config_variable requires 2 arguments, found %d", len(condition.Args))
+ if condition.NumArgs() != 2 {
+ ctx.OtherModulePropertyErrorf(m, property, "soong_config_variable requires 2 arguments, found %d", condition.NumArgs())
return proptools.ConfigurableValueUndefined()
}
- namespace := condition.Args[0]
- variable := condition.Args[1]
+ namespace := condition.Arg(0)
+ variable := condition.Arg(1)
if n, ok := ctx.Config().productVariables.VendorVars[namespace]; ok {
if v, ok := n[variable]; ok {
return proptools.ConfigurableValueString(v)
@@ -2170,8 +2170,8 @@
}
return proptools.ConfigurableValueUndefined()
case "arch":
- if len(condition.Args) != 0 {
- ctx.OtherModulePropertyErrorf(m, property, "arch requires no arguments, found %d", len(condition.Args))
+ if condition.NumArgs() != 0 {
+ ctx.OtherModulePropertyErrorf(m, property, "arch requires no arguments, found %d", condition.NumArgs())
return proptools.ConfigurableValueUndefined()
}
if !m.base().ArchReady() {
@@ -2180,8 +2180,8 @@
}
return proptools.ConfigurableValueString(m.base().Arch().ArchType.Name)
case "os":
- if len(condition.Args) != 0 {
- ctx.OtherModulePropertyErrorf(m, property, "os requires no arguments, found %d", len(condition.Args))
+ if condition.NumArgs() != 0 {
+ ctx.OtherModulePropertyErrorf(m, property, "os requires no arguments, found %d", condition.NumArgs())
return proptools.ConfigurableValueUndefined()
}
// the arch mutator runs after the os mutator, we can just use this to enforce that os is ready.
@@ -2194,8 +2194,8 @@
// We currently don't have any other boolean variables (we should add support for typing
// the soong config variables), so add this fake one for testing the boolean select
// functionality.
- if len(condition.Args) != 0 {
- ctx.OtherModulePropertyErrorf(m, property, "boolean_var_for_testing requires 0 arguments, found %d", len(condition.Args))
+ if condition.NumArgs() != 0 {
+ ctx.OtherModulePropertyErrorf(m, property, "boolean_var_for_testing requires 0 arguments, found %d", condition.NumArgs())
return proptools.ConfigurableValueUndefined()
}
diff --git a/android/module_context.go b/android/module_context.go
index d3e2770..dea22ba 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -476,6 +476,7 @@
executable: executable,
effectiveLicenseFiles: &licenseFiles,
partition: fullInstallPath.partition,
+ skipInstall: m.skipInstall(),
}
m.packagingSpecs = append(m.packagingSpecs, spec)
return spec
@@ -599,6 +600,7 @@
symlinkTarget: relPath,
executable: false,
partition: fullInstallPath.partition,
+ skipInstall: m.skipInstall(),
})
return fullInstallPath
@@ -640,6 +642,7 @@
symlinkTarget: absPath,
executable: false,
partition: fullInstallPath.partition,
+ skipInstall: m.skipInstall(),
})
return fullInstallPath
diff --git a/android/packaging.go b/android/packaging.go
index a8fb28d..6677218 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -43,6 +43,11 @@
effectiveLicenseFiles *Paths
partition string
+
+ // Whether this packaging spec represents an installation of the srcPath (i.e. this struct
+ // is created via InstallFile or InstallSymlink) or a simple packaging (i.e. created via
+ // PackageFile).
+ skipInstall bool
}
// Get file name of installed package
@@ -74,6 +79,10 @@
return p.partition
}
+func (p *PackagingSpec) SkipInstall() bool {
+ return p.skipInstall
+}
+
type PackageModule interface {
Module
packagingBase() *PackagingBase
diff --git a/android/selects_test.go b/android/selects_test.go
index f912ce6..8563285 100644
--- a/android/selects_test.go
+++ b/android/selects_test.go
@@ -28,6 +28,7 @@
name string
bp string
provider selectsTestProvider
+ providers map[string]selectsTestProvider
vendorVars map[string]map[string]string
expectedError string
}{
@@ -411,6 +412,42 @@
},
},
{
+ name: "defaults applied to multiple modules",
+ bp: `
+ my_module_type {
+ name: "foo2",
+ defaults: ["bar"],
+ my_string_list: select(soong_config_variable("my_namespace", "my_variable"), {
+ "a": ["a1"],
+ default: ["b1"],
+ }),
+ }
+ my_module_type {
+ name: "foo",
+ defaults: ["bar"],
+ my_string_list: select(soong_config_variable("my_namespace", "my_variable"), {
+ "a": ["a1"],
+ default: ["b1"],
+ }),
+ }
+ my_defaults {
+ name: "bar",
+ my_string_list: select(soong_config_variable("my_namespace", "my_variable2"), {
+ "a": ["a2"],
+ default: ["b2"],
+ }),
+ }
+ `,
+ providers: map[string]selectsTestProvider{
+ "foo": {
+ my_string_list: &[]string{"b2", "b1"},
+ },
+ "foo2": {
+ my_string_list: &[]string{"b2", "b1"},
+ },
+ },
+ },
+ {
name: "Replacing string list",
bp: `
my_module_type {
@@ -617,10 +654,19 @@
result := fixtures.RunTestWithBp(t, tc.bp)
if tc.expectedError == "" {
- m := result.ModuleForTests("foo", "android_arm64_armv8-a")
- p, _ := OtherModuleProvider(result.testContext.OtherModuleProviderAdaptor(), m.Module(), selectsTestProviderKey)
- if !reflect.DeepEqual(p, tc.provider) {
- t.Errorf("Expected:\n %q\ngot:\n %q", tc.provider.String(), p.String())
+ if len(tc.providers) == 0 {
+ tc.providers = map[string]selectsTestProvider{
+ "foo": tc.provider,
+ }
+ }
+
+ for moduleName := range tc.providers {
+ expected := tc.providers[moduleName]
+ m := result.ModuleForTests(moduleName, "android_arm64_armv8-a")
+ p, _ := OtherModuleProvider(result.testContext.OtherModuleProviderAdaptor(), m.Module(), selectsTestProviderKey)
+ if !reflect.DeepEqual(p, expected) {
+ t.Errorf("Expected:\n %q\ngot:\n %q", expected.String(), p.String())
+ }
}
}
})
diff --git a/cmd/release_config/build_flag/main.go b/cmd/release_config/build_flag/main.go
index 6f909af..a8e6326 100644
--- a/cmd/release_config/build_flag/main.go
+++ b/cmd/release_config/build_flag/main.go
@@ -184,6 +184,7 @@
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 @@
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 @@
// 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 5b64062..b67374a 100644
--- a/cmd/release_config/crunch_flags/main.go
+++ b/cmd/release_config/crunch_flags/main.go
@@ -311,8 +311,9 @@
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 22e72a5..c443257 100644
--- a/cmd/release_config/release_config/main.go
+++ b/cmd/release_config/release_config/main.go
@@ -34,6 +34,7 @@
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 @@
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 @@
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 d7d4a8c..6b47091 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 @@
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 d55cf29..52a1f85 100644
--- a/cmd/release_config/release_config_lib/util.go
+++ b/cmd/release_config/release_config_lib/util.go
@@ -19,6 +19,7 @@
"fmt"
"io/fs"
"os"
+ "os/exec"
"path/filepath"
"regexp"
"strings"
@@ -145,22 +146,64 @@
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
}
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index 3a5071d..1215048 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -299,43 +299,6 @@
cmd, "--include_descriptors_from_image ")
}
-func TestFileSystemShouldInstallCoreVariantIfTargetBuildAppsIsSet(t *testing.T) {
- context := android.GroupFixturePreparers(
- fixture,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.Unbundled_build_apps = []string{"bar"}
- }),
- )
- result := context.RunTestWithBp(t, `
- android_system_image {
- name: "myfilesystem",
- deps: [
- "libfoo",
- ],
- linker_config_src: "linker.config.json",
- }
-
- cc_library {
- name: "libfoo",
- shared_libs: [
- "libbar",
- ],
- stl: "none",
- }
-
- cc_library {
- name: "libbar",
- sdk_version: "9",
- stl: "none",
- }
- `)
-
- inputs := result.ModuleForTests("myfilesystem", "android_common").Output("myfilesystem.img").Implicits
- android.AssertStringListContains(t, "filesystem should have libbar even for unbundled build",
- inputs.Strings(),
- "out/soong/.intermediates/libbar/android_arm64_armv8-a_shared/libbar.so")
-}
-
func TestFileSystemWithCoverageVariants(t *testing.T) {
context := android.GroupFixturePreparers(
fixture,
diff --git a/python/scripts/precompile_python.py b/python/scripts/precompile_python.py
index 07b8fe9..b3cf950 100644
--- a/python/scripts/precompile_python.py
+++ b/python/scripts/precompile_python.py
@@ -30,6 +30,7 @@
# Date was chosen to be the same as
# https://cs.android.com/android/platform/superproject/main/+/main:build/soong/jar/jar.go;l=36;drc=2863e4535eb65e15f955dc8ed48fa99b1d2a1db5
info = zipfile.ZipInfo(filename=name, date_time=(2008, 1, 1, 0, 0, 0))
+ info.compress_type = zipfile.ZIP_DEFLATED
if not info.filename.endswith('.py'):
outzip.writestr(info, infile.read())
diff --git a/tradefed_modules/test_module_config.go b/tradefed_modules/test_module_config.go
index 9127f67..b2d5631 100644
--- a/tradefed_modules/test_module_config.go
+++ b/tradefed_modules/test_module_config.go
@@ -160,35 +160,17 @@
}
-// Any test suites in base should not be repeated in the derived class, except "general-tests".
-// We may restrict derived tests to only be "general-tests" as it doesn't make sense to add a slice
-// of a test to compatibility suite.
+// Ensure at least one test_suite is listed. Ideally it should be general-tests
+// or device-tests, whichever is listed in base and prefer general-tests if both are listed.
+// However this is not enforced yet.
//
-// Returns ErrorMessage, false on problems
-// Returns _, true if okay.
+// Returns true if okay and reports errors via ModuleErrorf.
func (m *testModuleConfigModule) validateTestSuites(ctx android.ModuleContext) bool {
if len(m.tradefedProperties.Test_suites) == 0 {
- ctx.ModuleErrorf("At least one test-suite must be set or this won't run. Use \"general-tests\"")
+ ctx.ModuleErrorf("At least one test-suite must be set or this won't run. Use \"general-tests\" or \"device-tests\"")
return false
}
- derivedSuites := make(map[string]bool)
- // See if any suites in base is also in derived (other than general-tests)
- for _, s := range m.tradefedProperties.Test_suites {
- if s != "general-tests" {
- derivedSuites[s] = true
- }
- }
- if len(derivedSuites) == 0 {
- return true
- }
- for _, baseSuite := range m.provider.TestSuites {
- if derivedSuites[baseSuite] {
- ctx.ModuleErrorf("TestSuite %s exists in the base, do not add it here", baseSuite)
- return false
- }
- }
-
return true
}
diff --git a/tradefed_modules/test_module_config_test.go b/tradefed_modules/test_module_config_test.go
index 6997228..b2049b1 100644
--- a/tradefed_modules/test_module_config_test.go
+++ b/tradefed_modules/test_module_config_test.go
@@ -325,30 +325,6 @@
RunTestWithBp(t, badBp)
}
-func TestModuleConfigHostDuplicateTestSuitesGiveErrors(t *testing.T) {
- badBp := `
- java_test_host {
- name: "base",
- srcs: ["a.java"],
- test_suites: ["general-tests", "some-compat"],
- }
-
- test_module_config_host {
- name: "derived_test",
- base: "base",
- exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
- include_annotations: ["android.platform.test.annotations.LargeTest"],
- test_suites: ["general-tests", "some-compat"],
- }`
-
- android.GroupFixturePreparers(
- java.PrepareForTestWithJavaDefaultModules,
- android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
- ).ExtendWithErrorHandler(
- android.FixtureExpectsAtLeastOneErrorMatchingPattern("TestSuite some-compat exists in the base")).
- RunTestWithBp(t, badBp)
-}
-
func TestTestOnlyProvider(t *testing.T) {
t.Parallel()
ctx := android.GroupFixturePreparers(