Merge "Build VNDK APEX for VNDK-Lite" into rvc-dev
diff --git a/README.md b/README.md
index b1bb425..3eac87b 100644
--- a/README.md
+++ b/README.md
@@ -419,7 +419,8 @@
name: "acme_cc_defaults",
module_type: "cc_defaults",
config_namespace: "acme",
- variables: ["board", "feature"],
+ variables: ["board"],
+ bool_variables: ["feature"],
properties: ["cflags", "srcs"],
}
@@ -427,10 +428,6 @@
name: "board",
values: ["soc_a", "soc_b"],
}
-
-soong_config_bool_variable {
- name: "feature",
-}
```
This example describes a new `acme_cc_defaults` module type that extends the
diff --git a/android/apex.go b/android/apex.go
index 205ec95..2b5072b 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -92,12 +92,10 @@
// APEX as this module
DepIsInSameApex(ctx BaseModuleContext, dep Module) bool
- // Returns the highest version which is <= min_sdk_version.
- // For example, with min_sdk_version is 10 and versionList is [9,11]
- // it returns 9.
- ChooseSdkVersion(versionList []string, useLatest bool) (string, error)
-
- ShouldSupportAndroid10() bool
+ // Returns the highest version which is <= maxSdkVersion.
+ // For example, with maxSdkVersion is 10 and versionList is [9,11]
+ // it returns 9 as string
+ ChooseSdkVersion(versionList []string, maxSdkVersion int) (string, error)
}
type ApexProperties struct {
@@ -189,22 +187,14 @@
return true
}
-func (m *ApexModuleBase) ChooseSdkVersion(versionList []string, useLatest bool) (string, error) {
- if useLatest {
- return versionList[len(versionList)-1], nil
- }
- minSdkVersion := m.ApexProperties.Info.MinSdkVersion
+func (m *ApexModuleBase) ChooseSdkVersion(versionList []string, maxSdkVersion int) (string, error) {
for i := range versionList {
ver, _ := strconv.Atoi(versionList[len(versionList)-i-1])
- if ver <= minSdkVersion {
+ if ver <= maxSdkVersion {
return versionList[len(versionList)-i-1], nil
}
}
- return "", fmt.Errorf("min_sdk_version is set %v, but not found in %v", minSdkVersion, versionList)
-}
-
-func (m *ApexModuleBase) ShouldSupportAndroid10() bool {
- return !m.IsForPlatform() && (m.ApexProperties.Info.MinSdkVersion <= SdkVersion_Android10)
+ return "", fmt.Errorf("not found a version(<=%d) in versionList: %v", maxSdkVersion, versionList)
}
func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) {
diff --git a/android/api_levels.go b/android/api_levels.go
index 4f6efee..62a5fce 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -16,6 +16,7 @@
import (
"encoding/json"
+ "fmt"
"strconv"
)
@@ -84,14 +85,19 @@
// Converts an API level string into its numeric form.
// * Codenames are decoded.
// * Numeric API levels are simply converted.
-// * "minimum" and "current" are not currently handled since the former is
-// NDK specific and the latter has inconsistent meaning.
+// * "current" is mapped to FutureApiLevel(10000)
+// * "minimum" is NDK specific and not handled with this. (refer normalizeNdkApiLevel in cc.go)
func ApiStrToNum(ctx BaseModuleContext, apiLevel string) (int, error) {
- num, ok := getApiLevelsMap(ctx.Config())[apiLevel]
- if ok {
+ if apiLevel == "current" {
+ return FutureApiLevel, nil
+ }
+ if num, ok := getApiLevelsMap(ctx.Config())[apiLevel]; ok {
return num, nil
}
- return strconv.Atoi(apiLevel)
+ if num, err := strconv.Atoi(apiLevel); err == nil {
+ return num, nil
+ }
+ return 0, fmt.Errorf("SDK version should be one of \"current\", <number> or <codename>: %q", apiLevel)
}
func (a *apiLevelsSingleton) GenerateBuildActions(ctx SingletonContext) {
diff --git a/android/config.go b/android/config.go
index 32e32ae..c9d7dab 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1031,6 +1031,10 @@
return c.config.productVariables.DeviceKernelHeaders
}
+func (c *deviceConfig) SamplingPGO() bool {
+ return Bool(c.config.productVariables.SamplingPGO)
+}
+
func (c *config) NativeLineCoverage() bool {
return Bool(c.productVariables.NativeLineCoverage)
}
diff --git a/android/module.go b/android/module.go
index 665a30f..f668cc3 100644
--- a/android/module.go
+++ b/android/module.go
@@ -830,6 +830,40 @@
return Bool(m.commonProperties.System_ext_specific)
}
+func (m *ModuleBase) PartitionTag(config DeviceConfig) string {
+ partition := "system"
+ if m.SocSpecific() {
+ // A SoC-specific module could be on the vendor partition at
+ // "vendor" or the system partition at "system/vendor".
+ if config.VendorPath() == "vendor" {
+ partition = "vendor"
+ }
+ } else if m.DeviceSpecific() {
+ // A device-specific module could be on the odm partition at
+ // "odm", the vendor partition at "vendor/odm", or the system
+ // partition at "system/vendor/odm".
+ if config.OdmPath() == "odm" {
+ partition = "odm"
+ } else if strings.HasPrefix(config.OdmPath (), "vendor/") {
+ partition = "vendor"
+ }
+ } else if m.ProductSpecific() {
+ // A product-specific module could be on the product partition
+ // at "product" or the system partition at "system/product".
+ if config.ProductPath() == "product" {
+ partition = "product"
+ }
+ } else if m.SystemExtSpecific() {
+ // A system_ext-specific module could be on the system_ext
+ // partition at "system_ext" or the system partition at
+ // "system/system_ext".
+ if config.SystemExtPath() == "system_ext" {
+ partition = "system_ext"
+ }
+ }
+ return partition
+}
+
func (m *ModuleBase) Enabled() bool {
if m.commonProperties.Enabled == nil {
return !m.Os().DefaultDisabled
diff --git a/android/neverallow.go b/android/neverallow.go
index 73cd6e3..8fcfb8a 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -52,7 +52,6 @@
AddNeverAllowRules(createTrebleRules()...)
AddNeverAllowRules(createLibcoreRules()...)
AddNeverAllowRules(createMediaRules()...)
- AddNeverAllowRules(createMediaProviderRules()...)
AddNeverAllowRules(createJavaDeviceForHostRules()...)
}
@@ -161,14 +160,6 @@
}
}
-func createMediaProviderRules() []Rule {
- return []Rule{
- NeverAllow().
- With("libs", "framework-mediaprovider").
- Because("framework-mediaprovider includes private APIs. Use framework_mediaprovider_stubs instead."),
- }
-}
-
func createJavaDeviceForHostRules() []Rule {
javaDeviceForHostProjectsWhitelist := []string{
"external/guava",
diff --git a/android/neverallow_test.go b/android/neverallow_test.go
index b57bb3f..6f07a4a 100644
--- a/android/neverallow_test.go
+++ b/android/neverallow_test.go
@@ -203,19 +203,6 @@
},
},
{
- name: "dependency on framework-mediaprovider",
- fs: map[string][]byte{
- "Android.bp": []byte(`
- java_library {
- name: "needs_framework_mediaprovider",
- libs: ["framework-mediaprovider"],
- }`),
- },
- expectedErrors: []string{
- "framework-mediaprovider includes private APIs. Use framework_mediaprovider_stubs instead.",
- },
- },
- {
name: "java_device_for_host",
fs: map[string][]byte{
"Android.bp": []byte(`
diff --git a/android/soong_config_modules.go b/android/soong_config_modules.go
index 198108d..fa1e204 100644
--- a/android/soong_config_modules.go
+++ b/android/soong_config_modules.go
@@ -88,7 +88,8 @@
// name: "acme_cc_defaults",
// module_type: "cc_defaults",
// config_namespace: "acme",
-// variables: ["board", "feature"],
+// variables: ["board"],
+// bool_variables: ["feature"],
// properties: ["cflags", "srcs"],
// }
//
@@ -97,10 +98,6 @@
// values: ["soc_a", "soc_b"],
// }
//
-// soong_config_bool_variable {
-// name: "feature",
-// }
-//
// If an acme BoardConfig.mk file contained:
//
// SOONG_CONFIG_NAMESPACES += acme
@@ -149,7 +146,8 @@
// name: "acme_cc_defaults",
// module_type: "cc_defaults",
// config_namespace: "acme",
-// variables: ["board", "feature"],
+// variables: ["board"],
+// bool_variables: ["feature"],
// properties: ["cflags", "srcs"],
// }
//
@@ -158,10 +156,6 @@
// values: ["soc_a", "soc_b"],
// }
//
-// soong_config_bool_variable {
-// name: "feature",
-// }
-//
// acme_cc_defaults {
// name: "acme_defaults",
// cflags: ["-DGENERIC"],
diff --git a/android/soong_config_modules_test.go b/android/soong_config_modules_test.go
index 6ad88a2..1cf060d 100644
--- a/android/soong_config_modules_test.go
+++ b/android/soong_config_modules_test.go
@@ -43,7 +43,8 @@
name: "acme_test_defaults",
module_type: "test_defaults",
config_namespace: "acme",
- variables: ["board", "feature1", "feature2", "FEATURE3"],
+ variables: ["board", "feature1", "FEATURE3"],
+ bool_variables: ["feature2"],
properties: ["cflags", "srcs"],
}
@@ -57,10 +58,6 @@
}
soong_config_bool_variable {
- name: "feature2",
- }
-
- soong_config_bool_variable {
name: "FEATURE3",
}
`
diff --git a/android/soongconfig/modules.go b/android/soongconfig/modules.go
index aa4f5c5..2d6063d 100644
--- a/android/soongconfig/modules.go
+++ b/android/soongconfig/modules.go
@@ -109,6 +109,9 @@
// the list of SOONG_CONFIG variables that this module type will read
Variables []string
+ // the list of boolean SOONG_CONFIG variables that this module type will read
+ Bool_variables []string
+
// the list of properties that this module type will extend.
Properties []string
}
@@ -146,6 +149,18 @@
}
v.ModuleTypes[props.Name] = mt
+ for _, name := range props.Bool_variables {
+ if name == "" {
+ return []error{fmt.Errorf("bool_variable name must not be blank")}
+ }
+
+ mt.Variables = append(mt.Variables, &boolVariable{
+ baseVariable: baseVariable{
+ variable: name,
+ },
+ })
+ }
+
return nil
}
diff --git a/android/variable.go b/android/variable.go
index 9cbe624..06bd4ed 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -251,6 +251,8 @@
ClangTidy *bool `json:",omitempty"`
TidyChecks *string `json:",omitempty"`
+ SamplingPGO *bool `json:",omitempty"`
+
NativeLineCoverage *bool `json:",omitempty"`
Native_coverage *bool `json:",omitempty"`
ClangCoverage *bool `json:",omitempty"`
diff --git a/android/vts_config.go b/android/vts_config.go
index 9a1df7c..77fb9fe 100644
--- a/android/vts_config.go
+++ b/android/vts_config.go
@@ -53,7 +53,7 @@
fmt.Fprintf(w, "LOCAL_TEST_CONFIG := %s\n",
*me.properties.Test_config)
}
- fmt.Fprintf(w, "LOCAL_COMPATIBILITY_SUITE := vts %s\n",
+ fmt.Fprintf(w, "LOCAL_COMPATIBILITY_SUITE := vts10 %s\n",
strings.Join(me.properties.Test_suites, " "))
},
}
@@ -64,7 +64,7 @@
me.AddProperties(&me.properties)
}
-// vts_config generates a Vendor Test Suite (VTS) configuration file from the
+// vts_config generates a Vendor Test Suite (VTS10) configuration file from the
// <test_config> xml file and stores it in a subdirectory of $(HOST_OUT).
func VtsConfigFactory() Module {
module := &VtsConfig{}
diff --git a/apex/androidmk.go b/apex/androidmk.go
index 9a29687..2303efe 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -22,6 +22,7 @@
"android/soong/android"
"android/soong/cc"
+ "android/soong/java"
"github.com/google/blueprint/proptools"
)
@@ -181,6 +182,9 @@
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
// we will have foo.apk.apk
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.builtFile.Base(), ".apk"))
+ if app, ok := fi.module.(*java.AndroidApp); ok && len(app.JniCoverageOutputs()) > 0 {
+ fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", strings.Join(app.JniCoverageOutputs().Strings(), " "))
+ }
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_app_prebuilt.mk")
} else if fi.class == nativeSharedLib || fi.class == nativeExecutable || fi.class == nativeTest {
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base())
diff --git a/apex/apex.go b/apex/apex.go
index 0096365..8e3e562 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -19,7 +19,6 @@
"path"
"path/filepath"
"sort"
- "strconv"
"strings"
"sync"
@@ -1995,14 +1994,11 @@
func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int {
ver := proptools.StringDefault(a.properties.Min_sdk_version, "current")
- if ver != "current" {
- minSdkVersion, err := strconv.Atoi(ver)
- if err != nil {
- ctx.PropertyErrorf("min_sdk_version", "should be \"current\" or <number>, but %q", ver)
- }
- return minSdkVersion
+ intVer, err := android.ApiStrToNum(ctx, ver)
+ if err != nil {
+ ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
}
- return android.FutureApiLevel
+ return intVer
}
// Ensures that the dependencies are marked as available for this APEX
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 704bad6..80d8153 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -856,7 +856,7 @@
shouldNotLink []string
}{
{
- name: "should link to test latest",
+ name: "should link to the latest",
minSdkVersion: "current",
shouldLink: "30",
shouldNotLink: []string{"29"},
@@ -1106,6 +1106,60 @@
expectNoLink("liba", "shared_otherapex", "libz", "shared")
}
+func TestApexMinSdkVersion_SupportsCodeNames(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ native_shared_libs: ["libx"],
+ min_sdk_version: "R",
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library {
+ name: "libx",
+ shared_libs: ["libz"],
+ system_shared_libs: [],
+ stl: "none",
+ apex_available: [ "myapex" ],
+ }
+
+ cc_library {
+ name: "libz",
+ system_shared_libs: [],
+ stl: "none",
+ stubs: {
+ versions: ["29", "R"],
+ },
+ }
+ `, func(fs map[string][]byte, config android.Config) {
+ config.TestProductVariables.Platform_version_active_codenames = []string{"R"}
+ })
+
+ expectLink := func(from, from_variant, to, to_variant string) {
+ ldArgs := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld").Args["libFlags"]
+ ensureContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
+ }
+ expectNoLink := func(from, from_variant, to, to_variant string) {
+ ldArgs := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld").Args["libFlags"]
+ ensureNotContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
+ }
+ // 9000 is quite a magic number.
+ // Finalized SDK codenames are mapped as P(28), Q(29), ...
+ // And, codenames which are not finalized yet(active_codenames + future_codenames) are numbered from 9000, 9001, ...
+ // to distinguish them from finalized and future_api(10000)
+ // In this test, "R" is assumed not finalized yet( listed in Platform_version_active_codenames) and translated into 9000
+ // (refer android/api_levels.go)
+ expectLink("libx", "shared_myapex", "libz", "shared_9000")
+ expectNoLink("libx", "shared_myapex", "libz", "shared_29")
+ expectNoLink("libx", "shared_myapex", "libz", "shared")
+}
+
func TestApexMinSdkVersionDefaultsToLatest(t *testing.T) {
ctx, _ := testApex(t, `
apex {
@@ -1196,7 +1250,7 @@
expectNoLink("libz", "shared", "libz", "shared")
}
-func TestQApexesUseLatestStubsInBundledBuilds(t *testing.T) {
+func TestQApexesUseLatestStubsInBundledBuildsAndHWASAN(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
@@ -1223,16 +1277,18 @@
versions: ["29", "30"],
},
}
- `)
+ `, func(fs map[string][]byte, config android.Config) {
+ config.TestProductVariables.SanitizeDevice = []string{"hwaddress"}
+ })
expectLink := func(from, from_variant, to, to_variant string) {
ld := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld")
libFlags := ld.Args["libFlags"]
ensureContains(t, libFlags, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
}
- expectLink("libx", "shared_myapex", "libbar", "shared_30")
+ expectLink("libx", "shared_hwasan_myapex", "libbar", "shared_30")
}
-func TestQTargetApexUseStaticUnwinder(t *testing.T) {
+func TestQTargetApexUsesStaticUnwinder(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
@@ -1251,8 +1307,7 @@
name: "libx",
apex_available: [ "myapex" ],
}
-
- `, withUnbundledBuild)
+ `)
// ensure apex variant of c++ is linked with static unwinder
cm := ctx.ModuleForTests("libc++", "android_arm64_armv8-a_shared_myapex").Module().(*cc.Module)
@@ -1263,7 +1318,7 @@
}
func TestInvalidMinSdkVersion(t *testing.T) {
- testApexError(t, `"libz" .*: min_sdk_version is set 29.*`, `
+ testApexError(t, `"libz" .*: not found a version\(<=29\)`, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1293,13 +1348,13 @@
versions: ["30"],
},
}
- `, withUnbundledBuild)
+ `)
- testApexError(t, `"myapex" .*: min_sdk_version: should be .*`, `
+ testApexError(t, `"myapex" .*: min_sdk_version: SDK version should be .*`, `
apex {
name: "myapex",
key: "myapex.key",
- min_sdk_version: "R",
+ min_sdk_version: "abc",
}
apex_key {
@@ -1758,7 +1813,7 @@
// non-APEX variant does not have __ANDROID_APEX__ defined
mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
- ensureNotContains(t, mylibCFlags, "-D__ANDROID_SDK_VERSION__=10000")
+ ensureNotContains(t, mylibCFlags, "-D__ANDROID_SDK_VERSION__")
// APEX variant has __ANDROID_APEX__ and __ANDROID_APEX_SDK__ defined
mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_myapex").Rule("cc").Args["cFlags"]
diff --git a/apex/key.go b/apex/key.go
index ffde315..607cac5 100644
--- a/apex/key.go
+++ b/apex/key.go
@@ -133,17 +133,18 @@
module := apexModulesMap[key]
if m, ok := module.(*apexBundle); ok {
fmt.Fprintf(&filecontent,
- "name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q\\n",
+ "name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q partition=%q\\n",
m.Name()+".apex",
m.public_key_file.String(),
m.private_key_file.String(),
m.container_certificate_file.String(),
- m.container_private_key_file.String())
+ m.container_private_key_file.String(),
+ m.PartitionTag(ctx.DeviceConfig()))
} else if m, ok := module.(*Prebuilt); ok {
fmt.Fprintf(&filecontent,
- "name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q\\n",
+ "name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q partition=%q\\n",
m.InstallFilename(),
- "PRESIGNED", "PRESIGNED", "PRESIGNED", "PRESIGNED")
+ "PRESIGNED", "PRESIGNED", "PRESIGNED", "PRESIGNED", m.PartitionTag(ctx.DeviceConfig()))
}
}
diff --git a/bpfix/bpfix/bpfix.go b/bpfix/bpfix/bpfix.go
index 0516279..a1c5de1 100644
--- a/bpfix/bpfix/bpfix.go
+++ b/bpfix/bpfix/bpfix.go
@@ -124,6 +124,10 @@
Name: "removeHidlInterfaceTypes",
Fix: removeHidlInterfaceTypes,
},
+ {
+ Name: "removeSoongConfigBoolVariable",
+ Fix: removeSoongConfigBoolVariable,
+ },
}
func NewFixRequest() FixRequest {
@@ -714,6 +718,78 @@
return nil
}
+func removeSoongConfigBoolVariable(f *Fixer) error {
+ found := map[string]bool{}
+ newDefs := make([]parser.Definition, 0, len(f.tree.Defs))
+ for _, def := range f.tree.Defs {
+ if mod, ok := def.(*parser.Module); ok && mod.Type == "soong_config_bool_variable" {
+ if name, ok := getLiteralStringPropertyValue(mod, "name"); ok {
+ found[name] = true
+ } else {
+ return fmt.Errorf("Found soong_config_bool_variable without a name")
+ }
+ } else {
+ newDefs = append(newDefs, def)
+ }
+ }
+ f.tree.Defs = newDefs
+
+ if len(found) == 0 {
+ return nil
+ }
+
+ return runPatchListMod(func(mod *parser.Module, buf []byte, patchList *parser.PatchList) error {
+ if mod.Type != "soong_config_module_type" {
+ return nil
+ }
+
+ variables, ok := getLiteralListProperty(mod, "variables")
+ if !ok {
+ return nil
+ }
+
+ boolValues := strings.Builder{}
+ empty := true
+ for _, item := range variables.Values {
+ nameValue, ok := item.(*parser.String)
+ if !ok {
+ empty = false
+ continue
+ }
+ if found[nameValue.Value] {
+ patchList.Add(item.Pos().Offset, item.End().Offset+2, "")
+
+ boolValues.WriteString(`"`)
+ boolValues.WriteString(nameValue.Value)
+ boolValues.WriteString(`",`)
+ } else {
+ empty = false
+ }
+ }
+ if empty {
+ *patchList = parser.PatchList{}
+
+ prop, _ := mod.GetProperty("variables")
+ patchList.Add(prop.Pos().Offset, prop.End().Offset+2, "")
+ }
+ if boolValues.Len() == 0 {
+ return nil
+ }
+
+ bool_variables, ok := getLiteralListProperty(mod, "bool_variables")
+ if ok {
+ patchList.Add(bool_variables.RBracePos.Offset, bool_variables.RBracePos.Offset, ","+boolValues.String())
+ } else {
+ patchList.Add(variables.RBracePos.Offset+2, variables.RBracePos.Offset+2,
+ fmt.Sprintf(`bool_variables: [%s],`, boolValues.String()))
+ }
+
+ return nil
+ })(f)
+
+ return nil
+}
+
// Converts the default source list property, 'srcs', to a single source property with a given name.
// "LOCAL_MODULE" reference is also resolved during the conversion process.
func convertToSingleSource(mod *parser.Module, srcPropertyName string) {
diff --git a/bpfix/bpfix/bpfix_test.go b/bpfix/bpfix/bpfix_test.go
index 38cefdd..64a7b93 100644
--- a/bpfix/bpfix/bpfix_test.go
+++ b/bpfix/bpfix/bpfix_test.go
@@ -918,3 +918,67 @@
})
}
}
+
+func TestRemoveSoongConfigBoolVariable(t *testing.T) {
+ tests := []struct {
+ name string
+ in string
+ out string
+ }{
+ {
+ name: "remove bool",
+ in: `
+ soong_config_module_type {
+ name: "foo",
+ variables: ["bar", "baz"],
+ }
+
+ soong_config_bool_variable {
+ name: "bar",
+ }
+
+ soong_config_string_variable {
+ name: "baz",
+ }
+ `,
+ out: `
+ soong_config_module_type {
+ name: "foo",
+ variables: [
+ "baz"
+ ],
+ bool_variables: ["bar"],
+ }
+
+ soong_config_string_variable {
+ name: "baz",
+ }
+ `,
+ },
+ {
+ name: "existing bool_variables",
+ in: `
+ soong_config_module_type {
+ name: "foo",
+ variables: ["baz"],
+ bool_variables: ["bar"],
+ }
+
+ soong_config_bool_variable {
+ name: "baz",
+ }
+ `,
+ out: `
+ soong_config_module_type {
+ name: "foo",
+ bool_variables: ["bar", "baz"],
+ }
+ `,
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ runPass(t, test.in, test.out, removeSoongConfigBoolVariable)
+ })
+ }
+}
diff --git a/cc/cc.go b/cc/cc.go
index 62e861f..930c19c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -476,6 +476,9 @@
makeLinkType string
// Kythe (source file indexer) paths for this compilation module
kytheFiles android.Paths
+
+ // For apex variants, this is set as apex.min_sdk_version
+ apexSdkVersion int
}
func (c *Module) Toc() android.OptionalPath {
@@ -1197,7 +1200,7 @@
}
func (ctx *moduleContextImpl) apexSdkVersion() int {
- return ctx.mod.ApexProperties.Info.MinSdkVersion
+ return ctx.mod.apexSdkVersion
}
func (ctx *moduleContextImpl) hasStubsVariants() bool {
@@ -1828,7 +1831,10 @@
}, depTag, lib)
}
- if deps.StaticUnwinderIfLegacy && ctx.Config().UnbundledBuild() {
+ // staticUnwinderDep is treated as staticDep for Q apexes
+ // so that native libraries/binaries are linked with static unwinder
+ // because Q libc doesn't have unwinder APIs
+ if deps.StaticUnwinderIfLegacy {
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, staticUnwinderDepTag, staticUnwinder(actx))
@@ -2212,9 +2218,22 @@
}
}
+ // For the dependency from platform to apex, use the latest stubs
+ c.apexSdkVersion = android.FutureApiLevel
+ if !c.IsForPlatform() {
+ c.apexSdkVersion = c.ApexProperties.Info.MinSdkVersion
+ }
+
+ if android.InList("hwaddress", ctx.Config().SanitizeDevice()) {
+ // In hwasan build, we override apexSdkVersion to the FutureApiLevel(10000)
+ // so that even Q(29/Android10) apexes could use the dynamic unwinder by linking the newer stubs(e.g libc(R+)).
+ // (b/144430859)
+ c.apexSdkVersion = android.FutureApiLevel
+ }
+
if depTag == staticUnwinderDepTag {
- // Use static unwinder for legacy (min_sdk_version = 29) apexes (b/144430859)
- if c.ShouldSupportAndroid10() {
+ // Use static unwinder for legacy (min_sdk_version = 29) apexes (b/144430859)
+ if c.apexSdkVersion <= android.SdkVersion_Android10 {
depTag = StaticDepTag
} else {
return
@@ -2268,8 +2287,7 @@
// when to use (unspecified) stubs, check min_sdk_version and choose the right one
if useThisDep && depIsStubs && !explicitlyVersioned {
- useLatest := c.IsForPlatform() || (c.ShouldSupportAndroid10() && !ctx.Config().UnbundledBuild())
- versionToUse, err := c.ChooseSdkVersion(ccDep.StubsVersions(), useLatest)
+ versionToUse, err := c.ChooseSdkVersion(ccDep.StubsVersions(), c.apexSdkVersion)
if err != nil {
ctx.OtherModuleErrorf(dep, err.Error())
return
@@ -2292,8 +2310,7 @@
// if this is for use_vendor apex && dep has stubsVersions
// apply the same rule of apex sdk enforcement to choose right version
var err error
- useLatest := c.ShouldSupportAndroid10() && !ctx.Config().UnbundledBuild()
- versionToUse, err = c.ChooseSdkVersion(versions, useLatest)
+ versionToUse, err = c.ChooseSdkVersion(versions, c.apexSdkVersion)
if err != nil {
ctx.OtherModuleErrorf(dep, err.Error())
return
diff --git a/cc/config/x86_darwin_host.go b/cc/config/x86_darwin_host.go
index 25225b5..8eb79e3 100644
--- a/cc/config/x86_darwin_host.go
+++ b/cc/config/x86_darwin_host.go
@@ -15,9 +15,11 @@
package config
import (
+ "fmt"
"os/exec"
"path/filepath"
"strings"
+ "sync"
"android/soong/android"
)
@@ -89,28 +91,20 @@
)
func init() {
- pctx.VariableFunc("macSdkPath", func(ctx android.PackageVarContext) string {
- xcodeselect := ctx.Config().HostSystemTool("xcode-select")
- bytes, err := exec.Command(xcodeselect, "--print-path").Output()
- if err != nil {
- ctx.Errorf("xcode-select failed with: %q", err.Error())
- }
- return strings.TrimSpace(string(bytes))
- })
pctx.VariableFunc("macSdkRoot", func(ctx android.PackageVarContext) string {
- return xcrunSdk(ctx, "--show-sdk-path")
+ return getMacTools(ctx).sdkRoot
})
pctx.StaticVariable("macMinVersion", "10.10")
pctx.VariableFunc("MacArPath", func(ctx android.PackageVarContext) string {
- return xcrun(ctx, "--find", "ar")
+ return getMacTools(ctx).arPath
})
pctx.VariableFunc("MacStripPath", func(ctx android.PackageVarContext) string {
- return xcrun(ctx, "--find", "strip")
+ return getMacTools(ctx).stripPath
})
pctx.VariableFunc("MacToolPath", func(ctx android.PackageVarContext) string {
- return filepath.Dir(xcrun(ctx, "--find", "ld"))
+ return getMacTools(ctx).toolPath
})
pctx.StaticVariable("DarwinGccVersion", darwinGccVersion)
@@ -126,38 +120,66 @@
pctx.StaticVariable("DarwinYasmFlags", "-f macho -m amd64")
}
-func xcrun(ctx android.PackageVarContext, args ...string) string {
- xcrun := ctx.Config().HostSystemTool("xcrun")
- bytes, err := exec.Command(xcrun, args...).Output()
- if err != nil {
- ctx.Errorf("xcrun failed with: %q", err.Error())
- }
- return strings.TrimSpace(string(bytes))
+type macPlatformTools struct {
+ once sync.Once
+ err error
+
+ sdkRoot string
+ arPath string
+ stripPath string
+ toolPath string
}
-func xcrunSdk(ctx android.PackageVarContext, arg string) string {
- xcrun := ctx.Config().HostSystemTool("xcrun")
- if selected := ctx.Config().Getenv("MAC_SDK_VERSION"); selected != "" {
- if !inList(selected, darwinSupportedSdkVersions) {
- ctx.Errorf("MAC_SDK_VERSION %s isn't supported: %q", selected, darwinSupportedSdkVersions)
+var macTools = &macPlatformTools{}
+
+func getMacTools(ctx android.PackageVarContext) *macPlatformTools {
+ macTools.once.Do(func() {
+ xcrunTool := ctx.Config().HostSystemTool("xcrun")
+
+ xcrun := func(args ...string) string {
+ if macTools.err != nil {
+ return ""
+ }
+
+ bytes, err := exec.Command(xcrunTool, args...).Output()
+ if err != nil {
+ macTools.err = fmt.Errorf("xcrun %q failed with: %q", args, err)
+ return ""
+ }
+
+ return strings.TrimSpace(string(bytes))
+ }
+
+ xcrunSdk := func(arg string) string {
+ if selected := ctx.Config().Getenv("MAC_SDK_VERSION"); selected != "" {
+ if !inList(selected, darwinSupportedSdkVersions) {
+ macTools.err = fmt.Errorf("MAC_SDK_VERSION %s isn't supported: %q", selected, darwinSupportedSdkVersions)
+ return ""
+ }
+
+ return xcrun("--sdk", "macosx"+selected, arg)
+ }
+
+ for _, sdk := range darwinSupportedSdkVersions {
+ bytes, err := exec.Command(xcrunTool, "--sdk", "macosx"+sdk, arg).Output()
+ if err == nil {
+ return strings.TrimSpace(string(bytes))
+ }
+ }
+ macTools.err = fmt.Errorf("Could not find a supported mac sdk: %q", darwinSupportedSdkVersions)
return ""
}
- bytes, err := exec.Command(xcrun, "--sdk", "macosx"+selected, arg).Output()
- if err != nil {
- ctx.Errorf("MAC_SDK_VERSION %s is not installed", selected)
- }
- return strings.TrimSpace(string(bytes))
- }
+ macTools.sdkRoot = xcrunSdk("--show-sdk-path")
- for _, sdk := range darwinSupportedSdkVersions {
- bytes, err := exec.Command(xcrun, "--sdk", "macosx"+sdk, arg).Output()
- if err == nil {
- return strings.TrimSpace(string(bytes))
- }
+ macTools.arPath = xcrun("--find", "ar")
+ macTools.stripPath = xcrun("--find", "strip")
+ macTools.toolPath = filepath.Dir(xcrun("--find", "ld"))
+ })
+ if macTools.err != nil {
+ ctx.Errorf("%q", macTools.err)
}
- ctx.Errorf("Could not find a supported mac sdk: %q", darwinSupportedSdkVersions)
- return ""
+ return macTools
}
type toolchainDarwin struct {
diff --git a/cc/library.go b/cc/library.go
index 10bf27f..c7488ee 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1004,8 +1004,9 @@
}
func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
+ // The logic must be consistent with classifySourceAbiDump.
isNdk := ctx.isNdk()
- isLlndkOrVndk := ctx.isLlndkPublic(ctx.Config()) || ctx.isVndk()
+ isLlndkOrVndk := ctx.isLlndkPublic(ctx.Config()) || (ctx.useVndk() && ctx.isVndk())
refAbiDumpTextFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isNdk, isLlndkOrVndk, false)
refAbiDumpGzipFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isNdk, isLlndkOrVndk, true)
@@ -1454,18 +1455,22 @@
return ""
}
-func checkVersions(ctx android.BaseModuleContext, versions []string) {
+func normalizeVersions(ctx android.BaseModuleContext, versions []string) {
numVersions := make([]int, len(versions))
for i, v := range versions {
- numVer, err := strconv.Atoi(v)
+ numVer, err := android.ApiStrToNum(ctx, v)
if err != nil {
- ctx.PropertyErrorf("versions", "%q is not a number", v)
+ ctx.PropertyErrorf("versions", "%s", err.Error())
+ return
}
numVersions[i] = numVer
}
if !sort.IsSorted(sort.IntSlice(numVersions)) {
ctx.PropertyErrorf("versions", "not sorted: %v", versions)
}
+ for i, v := range numVersions {
+ versions[i] = strconv.Itoa(v)
+ }
}
func createVersionVariations(mctx android.BottomUpMutatorContext, versions []string) {
@@ -1487,7 +1492,7 @@
if library, ok := mctx.Module().(LinkableInterface); ok && !library.InRecovery() {
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 {
versions := library.StubsVersions()
- checkVersions(mctx, versions)
+ normalizeVersions(mctx, versions)
if mctx.Failed() {
return
}
diff --git a/cc/library_test.go b/cc/library_test.go
index b8d8895..cb16725 100644
--- a/cc/library_test.go
+++ b/cc/library_test.go
@@ -17,6 +17,8 @@
import (
"reflect"
"testing"
+
+ "android/soong/android"
)
func TestLibraryReuse(t *testing.T) {
@@ -186,3 +188,55 @@
}
})
}
+
+func TestStubsVersions(t *testing.T) {
+ bp := `
+ cc_library {
+ name: "libfoo",
+ srcs: ["foo.c"],
+ stubs: {
+ versions: ["29", "R", "10000"],
+ },
+ }
+ `
+ config := TestConfig(buildDir, android.Android, nil, bp, nil)
+ config.TestProductVariables.Platform_version_active_codenames = []string{"R"}
+ ctx := testCcWithConfig(t, config)
+
+ variants := ctx.ModuleVariantsForTests("libfoo")
+ for _, expectedVer := range []string{"29", "9000", "10000"} {
+ expectedVariant := "android_arm_armv7-a-neon_shared_" + expectedVer
+ if !inList(expectedVariant, variants) {
+ t.Errorf("missing expected variant: %q", expectedVariant)
+ }
+ }
+}
+
+func TestStubsVersions_NotSorted(t *testing.T) {
+ bp := `
+ cc_library {
+ name: "libfoo",
+ srcs: ["foo.c"],
+ stubs: {
+ versions: ["29", "10000", "R"],
+ },
+ }
+ `
+ config := TestConfig(buildDir, android.Android, nil, bp, nil)
+ config.TestProductVariables.Platform_version_active_codenames = []string{"R"}
+ testCcErrorWithConfig(t, `"libfoo" .*: versions: not sorted`, config)
+}
+
+func TestStubsVersions_ParseError(t *testing.T) {
+ bp := `
+ cc_library {
+ name: "libfoo",
+ srcs: ["foo.c"],
+ stubs: {
+ versions: ["29", "10000", "X"],
+ },
+ }
+ `
+
+ testCcError(t, `"libfoo" .*: versions: SDK version should be`, bp)
+}
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 00338b9..eb8e9d3 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -96,6 +96,8 @@
Unversioned_until *string
// Private property for use by the mutator that splits per-API level.
+ // can be one of <number:sdk_version> or <codename> or "current"
+ // passed to "gen_stub_libs.py" as it is
ApiLevel string `blueprint:"mutated"`
// True if this API is not yet ready to be shipped in the NDK. It will be
diff --git a/cc/pgo.go b/cc/pgo.go
index d5c4b87..88903bb 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -88,20 +88,21 @@
return []interface{}{&pgo.Properties}
}
-func (props *PgoProperties) addProfileGatherFlags(ctx ModuleContext, flags Flags) Flags {
+func (props *PgoProperties) addInstrumentationProfileGatherFlags(ctx ModuleContext, flags Flags) Flags {
flags.Local.CFlags = append(flags.Local.CFlags, props.Pgo.Cflags...)
- if props.isInstrumentation() {
- flags.Local.CFlags = append(flags.Local.CFlags, profileInstrumentFlag)
- // The profile runtime is added below in deps(). Add the below
- // flag, which is the only other link-time action performed by
- // the Clang driver during link.
- flags.Local.LdFlags = append(flags.Local.LdFlags, "-u__llvm_profile_runtime")
- }
- if props.isSampling() {
- flags.Local.CFlags = append(flags.Local.CFlags, profileSamplingFlag)
- flags.Local.LdFlags = append(flags.Local.LdFlags, profileSamplingFlag)
- }
+ flags.Local.CFlags = append(flags.Local.CFlags, profileInstrumentFlag)
+ // The profile runtime is added below in deps(). Add the below
+ // flag, which is the only other link-time action performed by
+ // the Clang driver during link.
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-u__llvm_profile_runtime")
+ return flags
+}
+func (props *PgoProperties) addSamplingProfileGatherFlags(ctx ModuleContext, flags Flags) Flags {
+ flags.Local.CFlags = append(flags.Local.CFlags, props.Pgo.Cflags...)
+
+ flags.Local.CFlags = append(flags.Local.CFlags, profileSamplingFlag)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, profileSamplingFlag)
return flags
}
@@ -286,8 +287,12 @@
props := pgo.Properties
// Add flags to profile this module based on its profile_kind
- if props.ShouldProfileModule {
- return props.addProfileGatherFlags(ctx, flags)
+ if props.ShouldProfileModule && props.isInstrumentation() {
+ return props.addInstrumentationProfileGatherFlags(ctx, flags)
+ } else if props.ShouldProfileModule && props.isSampling() {
+ return props.addSamplingProfileGatherFlags(ctx, flags)
+ } else if ctx.DeviceConfig().SamplingPGO() {
+ return props.addSamplingProfileGatherFlags(ctx, flags)
}
if !ctx.Config().IsEnvTrue("ANDROID_PGO_NO_PROFILE_USE") {
diff --git a/cc/testing.go b/cc/testing.go
index 7b0305f..e5be7da 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -66,6 +66,20 @@
src: "",
}
+ cc_prebuilt_library_shared {
+ name: "libclang_rt.hwasan-aarch64-android",
+ nocrt: true,
+ vendor_available: true,
+ recovery_available: true,
+ system_shared_libs: [],
+ stl: "none",
+ srcs: [""],
+ check_elf_files: false,
+ sanitize: {
+ never: true,
+ },
+ }
+
toolchain_library {
name: "libclang_rt.builtins-i686-android",
vendor_available: true,
diff --git a/cmd/zipsync/zipsync.go b/cmd/zipsync/zipsync.go
index a6023d3..294e5ef 100644
--- a/cmd/zipsync/zipsync.go
+++ b/cmd/zipsync/zipsync.go
@@ -115,7 +115,7 @@
filename := filepath.Join(*outputDir, name)
if f.FileInfo().IsDir() {
- must(os.MkdirAll(filename, f.FileInfo().Mode()))
+ must(os.MkdirAll(filename, 0777))
} else {
must(os.MkdirAll(filepath.Dir(filename), 0777))
in, err := f.Open()
diff --git a/java/androidmk.go b/java/androidmk.go
index a220cce..136bb36 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -72,6 +72,7 @@
if !hideFromMake {
mainEntries = android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
+ DistFile: android.OptionalPathForPath(library.distFile),
OutputFile: android.OptionalPathForPath(library.outputFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
@@ -275,7 +276,7 @@
}
func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
- if !app.IsForPlatform() {
+ if !app.IsForPlatform() || app.appProperties.HideFromMake {
return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true,
}}
@@ -288,6 +289,7 @@
func(entries *android.AndroidMkEntries) {
// App module names can be overridden.
entries.SetString("LOCAL_MODULE", app.installApkName)
+ entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
if app.dexJarFile != nil {
entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
@@ -347,6 +349,9 @@
for _, jniLib := range app.installJniLibs {
entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
}
+ if len(app.jniCoverageOutputs) > 0 {
+ entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
+ }
if len(app.dexpreopter.builtInstalled) > 0 {
entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
}
diff --git a/java/androidmk_test.go b/java/androidmk_test.go
index acc6bf0..7daa624 100644
--- a/java/androidmk_test.go
+++ b/java/androidmk_test.go
@@ -16,6 +16,7 @@
import (
"reflect"
+ "strings"
"testing"
"android/soong/android"
@@ -133,3 +134,38 @@
t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual)
}
}
+
+func TestDistWithTag(t *testing.T) {
+ ctx, config := testJava(t, `
+ java_library {
+ name: "foo_without_tag",
+ srcs: ["a.java"],
+ compile_dex: true,
+ dist: {
+ targets: ["hi"],
+ },
+ }
+ java_library {
+ name: "foo_with_tag",
+ srcs: ["a.java"],
+ compile_dex: true,
+ dist: {
+ targets: ["hi"],
+ tag: ".jar",
+ },
+ }
+ `)
+
+ without_tag_entries := android.AndroidMkEntriesForTest(t, config, "", ctx.ModuleForTests("foo_without_tag", "android_common").Module())
+ with_tag_entries := android.AndroidMkEntriesForTest(t, config, "", ctx.ModuleForTests("foo_with_tag", "android_common").Module())
+
+ if len(without_tag_entries) != 2 || len(with_tag_entries) != 2 {
+ t.Errorf("two mk entries per module expected, got %d and %d", len(without_tag_entries), len(with_tag_entries))
+ }
+ if !with_tag_entries[0].DistFile.Valid() || !strings.Contains(with_tag_entries[0].DistFile.String(), "/javac/foo_with_tag.jar") {
+ t.Errorf("expected classes.jar DistFile, got %v", with_tag_entries[0].DistFile)
+ }
+ if without_tag_entries[0].DistFile.Valid() {
+ t.Errorf("did not expect explicit DistFile, got %v", without_tag_entries[0].DistFile)
+ }
+}
diff --git a/java/app.go b/java/app.go
index bfa25a2..f9992d8 100755
--- a/java/app.go
+++ b/java/app.go
@@ -105,6 +105,11 @@
// If set, find and merge all NOTICE files that this module and its dependencies have and store
// it in the APK as an asset.
Embed_notices *bool
+
+ // cc.Coverage related properties
+ PreventInstall bool `blueprint:"mutated"`
+ HideFromMake bool `blueprint:"mutated"`
+ IsCoverageVariant bool `blueprint:"mutated"`
}
// android_app properties that can be overridden by override_android_app
@@ -133,7 +138,8 @@
overridableAppProperties overridableAppProperties
- installJniLibs []jniLib
+ installJniLibs []jniLib
+ jniCoverageOutputs android.Paths
bundleFile android.Path
@@ -171,6 +177,10 @@
return a.certificate
}
+func (a *AndroidApp) JniCoverageOutputs() android.Paths {
+ return a.jniCoverageOutputs
+}
+
var _ AndroidLibraryDependency = (*AndroidApp)(nil)
type Certificate struct {
@@ -373,6 +383,11 @@
if a.shouldEmbedJnis(ctx) {
jniJarFile = android.PathForModuleOut(ctx, "jnilibs.zip")
TransformJniLibsToJar(ctx, jniJarFile, jniLibs, a.useEmbeddedNativeLibs(ctx))
+ for _, jni := range jniLibs {
+ if jni.coverageFile.Valid() {
+ a.jniCoverageOutputs = append(a.jniCoverageOutputs, jni.coverageFile.Path())
+ }
+ }
} else {
a.installJniLibs = jniLibs
}
@@ -510,14 +525,28 @@
// Build a final signed app package.
packageFile := android.PathForModuleOut(ctx, a.installApkName+".apk")
- CreateAndSignAppPackage(ctx, packageFile, a.exportPackage, jniJarFile, dexJarFile, certificates, apkDeps)
+ v4SigningRequested := Bool(a.Module.deviceProperties.V4_signature)
+ var v4SignatureFile android.WritablePath = nil
+ if v4SigningRequested {
+ v4SignatureFile = android.PathForModuleOut(ctx, a.installApkName+".apk.idsig")
+ }
+ CreateAndSignAppPackage(ctx, packageFile, a.exportPackage, jniJarFile, dexJarFile, certificates, apkDeps, v4SignatureFile)
a.outputFile = packageFile
+ if v4SigningRequested {
+ a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile)
+ }
for _, split := range a.aapt.splits {
// Sign the split APKs
packageFile := android.PathForModuleOut(ctx, a.installApkName+"_"+split.suffix+".apk")
- CreateAndSignAppPackage(ctx, packageFile, split.path, nil, nil, certificates, apkDeps)
+ if v4SigningRequested {
+ v4SignatureFile = android.PathForModuleOut(ctx, a.installApkName+"_"+split.suffix+".apk.idsig")
+ }
+ CreateAndSignAppPackage(ctx, packageFile, split.path, nil, nil, certificates, apkDeps, v4SignatureFile)
a.extraOutputFiles = append(a.extraOutputFiles, packageFile)
+ if v4SigningRequested {
+ a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile)
+ }
}
// Build an app bundle.
@@ -558,9 +587,10 @@
if lib.Valid() {
jniLibs = append(jniLibs, jniLib{
- name: ctx.OtherModuleName(module),
- path: path,
- target: module.Target(),
+ name: ctx.OtherModuleName(module),
+ path: path,
+ target: module.Target(),
+ coverageFile: dep.CoverageOutputFile(),
})
} else {
ctx.ModuleErrorf("dependency %q missing output file", otherName)
@@ -614,6 +644,24 @@
return Bool(a.appProperties.Privileged)
}
+func (a *AndroidApp) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
+ return ctx.Device() && (ctx.DeviceConfig().NativeCoverageEnabled() || ctx.DeviceConfig().ClangCoverageEnabled())
+}
+
+func (a *AndroidApp) PreventInstall() {
+ a.appProperties.PreventInstall = true
+}
+
+func (a *AndroidApp) HideFromMake() {
+ a.appProperties.HideFromMake = true
+}
+
+func (a *AndroidApp) MarkAsCoverageVariant(coverage bool) {
+ a.appProperties.IsCoverageVariant = coverage
+}
+
+var _ cc.Coverage = (*AndroidApp)(nil)
+
// android_app compiles sources and Android resources into an Android application package `.apk` file.
func AndroidAppFactory() android.Module {
module := &AndroidApp{}
@@ -1105,7 +1153,7 @@
}
a.certificate = certificates[0]
signed := android.PathForModuleOut(ctx, "signed", ctx.ModuleName()+".apk")
- SignAppPackage(ctx, signed, dexOutput, certificates)
+ SignAppPackage(ctx, signed, dexOutput, certificates, nil)
a.outputFile = signed
} else {
alignedApk := android.PathForModuleOut(ctx, "zip-aligned", ctx.ModuleName()+".apk")
@@ -1310,7 +1358,7 @@
_, certificates := collectAppDeps(ctx, false)
certificates = processMainCert(r.ModuleBase, String(r.properties.Certificate), certificates, ctx)
signed := android.PathForModuleOut(ctx, "signed", r.Name()+".apk")
- SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates)
+ SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates, nil)
r.certificate = certificates[0]
r.outputFile = signed
diff --git a/java/app_builder.go b/java/app_builder.go
index 5e7fbe6..b2780bc 100644
--- a/java/app_builder.go
+++ b/java/app_builder.go
@@ -45,7 +45,7 @@
})
func CreateAndSignAppPackage(ctx android.ModuleContext, outputFile android.WritablePath,
- packageFile, jniJarFile, dexJarFile android.Path, certificates []Certificate, deps android.Paths) {
+ packageFile, jniJarFile, dexJarFile android.Path, certificates []Certificate, deps android.Paths, v4SignatureFile android.WritablePath) {
unsignedApkName := strings.TrimSuffix(outputFile.Base(), ".apk") + "-unsigned.apk"
unsignedApk := android.PathForModuleOut(ctx, unsignedApkName)
@@ -66,10 +66,10 @@
Implicits: deps,
})
- SignAppPackage(ctx, outputFile, unsignedApk, certificates)
+ SignAppPackage(ctx, outputFile, unsignedApk, certificates, v4SignatureFile)
}
-func SignAppPackage(ctx android.ModuleContext, signedApk android.WritablePath, unsignedApk android.Path, certificates []Certificate) {
+func SignAppPackage(ctx android.ModuleContext, signedApk android.WritablePath, unsignedApk android.Path, certificates []Certificate, v4SignatureFile android.WritablePath) {
var certificateArgs []string
var deps android.Paths
@@ -78,14 +78,22 @@
deps = append(deps, c.Pem, c.Key)
}
+ outputFiles := android.WritablePaths{signedApk}
+ var flag string = ""
+ if v4SignatureFile != nil {
+ outputFiles = append(outputFiles, v4SignatureFile)
+ flag = "--enable-v4"
+ }
+
ctx.Build(pctx, android.BuildParams{
Rule: Signapk,
Description: "signapk",
- Output: signedApk,
+ Outputs: outputFiles,
Input: unsignedApk,
Implicits: deps,
Args: map[string]string{
"certificates": strings.Join(certificateArgs, " "),
+ "flags": flag,
},
})
}
diff --git a/java/app_test.go b/java/app_test.go
index dfd8571..10503e7 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -1073,6 +1073,66 @@
}
}
+func TestRequestV4SigningFlag(t *testing.T) {
+ testCases := []struct {
+ name string
+ bp string
+ expected string
+ }{
+ {
+ name: "default",
+ bp: `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ }
+ `,
+ expected: "",
+ },
+ {
+ name: "default",
+ bp: `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ v4_signature: false,
+ }
+ `,
+ expected: "",
+ },
+ {
+ name: "module certificate property",
+ bp: `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ v4_signature: true,
+ }
+ `,
+ expected: "--enable-v4",
+ },
+ }
+
+ for _, test := range testCases {
+ t.Run(test.name, func(t *testing.T) {
+ config := testAppConfig(nil, test.bp, nil)
+ ctx := testContext()
+
+ run(t, ctx, config)
+ foo := ctx.ModuleForTests("foo", "android_common")
+
+ signapk := foo.Output("foo.apk")
+ signFlags := signapk.Args["flags"]
+ if test.expected != signFlags {
+ t.Errorf("Incorrect signing flags, expected: %q, got: %q", test.expected, signFlags)
+ }
+ })
+ }
+}
+
func TestPackageNameOverride(t *testing.T) {
testCases := []struct {
name string
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 4313964..40cfe4f 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -132,28 +132,28 @@
bootImage = artBootImageConfig(ctx)
}
- var archs []android.ArchType
- for _, a := range ctx.MultiTargets() {
- archs = append(archs, a.Arch.ArchType)
- }
- if len(archs) == 0 {
+ targets := ctx.MultiTargets()
+ if len(targets) == 0 {
// assume this is a java library, dexpreopt for all arches for now
for _, target := range ctx.Config().Targets[android.Android] {
if target.NativeBridge == android.NativeBridgeDisabled {
- archs = append(archs, target.Arch.ArchType)
+ targets = append(targets, target)
}
}
if inList(ctx.ModuleName(), global.SystemServerJars) && !d.isSDKLibrary {
// If the module is not an SDK library and it's a system server jar, only preopt the primary arch.
- archs = archs[:1]
+ targets = targets[:1]
}
}
+ var archs []android.ArchType
var images android.Paths
var imagesDeps []android.OutputPaths
- for _, arch := range archs {
- images = append(images, bootImage.images[arch])
- imagesDeps = append(imagesDeps, bootImage.imagesDeps[arch])
+ for _, target := range targets {
+ archs = append(archs, target.Arch.ArchType)
+ variant := bootImage.getVariant(target)
+ images = append(images, variant.images)
+ imagesDeps = append(imagesDeps, variant.imagesDeps)
}
dexLocation := android.InstallPathToOnDevicePath(ctx, d.installPath)
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 489cbf2..76b1d69 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -48,6 +48,7 @@
// The location is passed as an argument to the ART tools like dex2oat instead of the real path. The ART tools
// will then reconstruct the real path, so the rules must have a dependency on the real path.
+// Target-independent description of pre-compiled boot image.
type bootImageConfig struct {
// Whether this image is an extension.
extension bool
@@ -67,9 +68,6 @@
// Subdirectory where the image files are installed.
installSubdir string
- // Targets for which the image is generated.
- targets []android.Target
-
// The names of jars that constitute this image.
modules []string
@@ -84,15 +82,43 @@
// The "locations" of the dependency images and in this image.
imageLocations []string
- // Paths to image files (grouped by target).
- images map[android.ArchType]android.OutputPath // first image file
- imagesDeps map[android.ArchType]android.OutputPaths // all files
-
- // Only for extensions, paths to the primary boot images (grouped by target).
- primaryImages map[android.ArchType]android.OutputPath
-
// File path to a zip archive with all image files (or nil, if not needed).
zip android.WritablePath
+
+ // Rules which should be used in make to install the outputs.
+ profileInstalls android.RuleBuilderInstalls
+
+ // Target-dependent fields.
+ variants []*bootImageVariant
+}
+
+// Target-dependent description of pre-compiled boot image.
+type bootImageVariant struct {
+ *bootImageConfig
+
+ // Target for which the image is generated.
+ target android.Target
+
+ // Paths to image files.
+ images android.OutputPath // first image file
+ imagesDeps android.OutputPaths // all files
+
+ // Only for extensions, paths to the primary boot images.
+ primaryImages android.OutputPath
+
+ // Rules which should be used in make to install the outputs.
+ installs android.RuleBuilderInstalls
+ vdexInstalls android.RuleBuilderInstalls
+ unstrippedInstalls android.RuleBuilderInstalls
+}
+
+func (image bootImageConfig) getVariant(target android.Target) *bootImageVariant {
+ for _, variant := range image.variants {
+ if variant.target.Os == target.Os && variant.target.Arch.ArchType == target.Arch.ArchType {
+ return variant
+ }
+ }
+ return nil
}
func (image bootImageConfig) moduleName(idx int) string {
@@ -126,28 +152,6 @@
return ret
}
-type bootImage struct {
- bootImageConfig
-
- installs map[android.ArchType]android.RuleBuilderInstalls
- vdexInstalls map[android.ArchType]android.RuleBuilderInstalls
- unstrippedInstalls map[android.ArchType]android.RuleBuilderInstalls
-
- profileInstalls android.RuleBuilderInstalls
-}
-
-func newBootImage(ctx android.PathContext, config bootImageConfig) *bootImage {
- image := &bootImage{
- bootImageConfig: config,
-
- installs: make(map[android.ArchType]android.RuleBuilderInstalls),
- vdexInstalls: make(map[android.ArchType]android.RuleBuilderInstalls),
- unstrippedInstalls: make(map[android.ArchType]android.RuleBuilderInstalls),
- }
-
- return image
-}
-
func concat(lists ...[]string) []string {
var size int
for _, l := range lists {
@@ -182,8 +186,8 @@
}
type dexpreoptBootJars struct {
- defaultBootImage *bootImage
- otherImages []*bootImage
+ defaultBootImage *bootImageConfig
+ otherImages []*bootImageConfig
dexpreoptConfigForMake android.WritablePath
}
@@ -193,10 +197,11 @@
if skipDexpreoptBootJars(ctx) {
return nil
}
-
// Include dexpreopt files for the primary boot image.
- files := artBootImageConfig(ctx).imagesDeps
-
+ files := map[android.ArchType]android.OutputPaths{}
+ for _, variant := range artBootImageConfig(ctx).variants {
+ files[variant.target.Arch.ArchType] = variant.imagesDeps
+ }
return files
}
@@ -233,10 +238,8 @@
dumpOatRules(ctx, d.defaultBootImage)
}
-// buildBootImage takes a bootImageConfig, creates rules to build it, and returns a *bootImage.
-func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootImage {
- image := newBootImage(ctx, config)
-
+// buildBootImage takes a bootImageConfig, creates rules to build it, and returns the image.
+func buildBootImage(ctx android.SingletonContext, image *bootImageConfig) *bootImageConfig {
bootDexJars := make(android.Paths, len(image.modules))
ctx.VisitAllModules(func(module android.Module) {
// Collect dex jar paths for the modules listed above.
@@ -275,10 +278,11 @@
profile := bootImageProfileRule(ctx, image, missingDeps)
bootFrameworkProfileRule(ctx, image, missingDeps)
+ updatableBcpPackagesRule(ctx, image, missingDeps)
var allFiles android.Paths
- for _, target := range image.targets {
- files := buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
+ for _, variant := range image.variants {
+ files := buildBootImageVariant(ctx, variant, profile, missingDeps)
allFiles = append(allFiles, files.Paths()...)
}
@@ -296,12 +300,13 @@
return image
}
-func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
- arch android.ArchType, profile android.Path, missingDeps []string) android.WritablePaths {
+func buildBootImageVariant(ctx android.SingletonContext, image *bootImageVariant,
+ profile android.Path, missingDeps []string) android.WritablePaths {
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
global := dexpreopt.GetGlobalConfig(ctx)
+ arch := image.target.Arch.ArchType
symbolsDir := image.symbolsDir.Join(ctx, image.installSubdir, arch.String())
symbolsFile := symbolsDir.Join(ctx, image.stem+".oat")
outputDir := image.dir.Join(ctx, image.installSubdir, arch.String())
@@ -351,7 +356,7 @@
}
if image.extension {
- artImage := image.primaryImages[arch]
+ artImage := image.primaryImages
cmd.
Flag("--runtime-arg").FlagWithInputList("-Xbootclasspath:", image.dexPathsDeps.Paths(), ":").
Flag("--runtime-arg").FlagWithList("-Xbootclasspath-locations:", image.dexLocationsDeps, ":").
@@ -427,9 +432,9 @@
rule.Build(pctx, ctx, image.name+"JarsDexpreopt_"+arch.String(), "dexpreopt "+image.name+" jars "+arch.String())
// save output and installed files for makevars
- image.installs[arch] = rule.Installs()
- image.vdexInstalls[arch] = vdexInstalls
- image.unstrippedInstalls[arch] = unstrippedInstalls
+ image.installs = rule.Installs()
+ image.vdexInstalls = vdexInstalls
+ image.unstrippedInstalls = unstrippedInstalls
return zipFiles
}
@@ -438,7 +443,7 @@
It is likely that the boot classpath is inconsistent.
Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see verification errors.`
-func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath {
+func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig, missingDeps []string) android.WritablePath {
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
global := dexpreopt.GetGlobalConfig(ctx)
@@ -493,7 +498,7 @@
var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule")
-func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath {
+func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConfig, missingDeps []string) android.WritablePath {
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
global := dexpreopt.GetGlobalConfig(ctx)
@@ -538,15 +543,65 @@
var bootFrameworkProfileRuleKey = android.NewOnceKey("bootFrameworkProfileRule")
-func dumpOatRules(ctx android.SingletonContext, image *bootImage) {
- var archs []android.ArchType
- for arch := range image.images {
- archs = append(archs, arch)
+func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConfig, missingDeps []string) android.WritablePath {
+ if ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
+ return nil
}
- sort.Slice(archs, func(i, j int) bool { return archs[i].String() < archs[j].String() })
+ return ctx.Config().Once(updatableBcpPackagesRuleKey, func() interface{} {
+ global := dexpreopt.GetGlobalConfig(ctx)
+ updatableModules := dexpreopt.GetJarsFromApexJarPairs(global.UpdatableBootJars)
+
+ // Collect `permitted_packages` for updatable boot jars.
+ var updatablePackages []string
+ ctx.VisitAllModules(func(module android.Module) {
+ if j, ok := module.(*Library); ok {
+ name := ctx.ModuleName(module)
+ if i := android.IndexList(name, updatableModules); i != -1 {
+ pp := j.properties.Permitted_packages
+ if len(pp) > 0 {
+ updatablePackages = append(updatablePackages, pp...)
+ } else {
+ ctx.Errorf("Missing permitted_packages for %s", name)
+ }
+ // Do not match the same library repeatedly.
+ updatableModules = append(updatableModules[:i], updatableModules[i+1:]...)
+ }
+ }
+ })
+
+ // Sort updatable packages to ensure deterministic ordering.
+ sort.Strings(updatablePackages)
+
+ updatableBcpPackagesName := "updatable-bcp-packages.txt"
+ updatableBcpPackages := image.dir.Join(ctx, updatableBcpPackagesName)
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.WriteFile,
+ Output: updatableBcpPackages,
+ Args: map[string]string{
+ // WriteFile automatically adds the last end-of-line.
+ "content": strings.Join(updatablePackages, "\\n"),
+ },
+ })
+
+ rule := android.NewRuleBuilder()
+ rule.MissingDeps(missingDeps)
+ rule.Install(updatableBcpPackages, "/system/etc/"+updatableBcpPackagesName)
+ // TODO: Rename `profileInstalls` to `extraInstalls`?
+ // Maybe even move the field out of the bootImageConfig into some higher level type?
+ image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
+
+ return updatableBcpPackages
+ }).(android.WritablePath)
+}
+
+var updatableBcpPackagesRuleKey = android.NewOnceKey("updatableBcpPackagesRule")
+
+func dumpOatRules(ctx android.SingletonContext, image *bootImageConfig) {
var allPhonies android.Paths
- for _, arch := range archs {
+ for _, image := range image.variants {
+ arch := image.target.Arch.ArchType
// Create a rule to call oatdump.
output := android.PathForOutput(ctx, "boot."+arch.String()+".oatdump.txt")
rule := android.NewRuleBuilder()
@@ -555,7 +610,7 @@
BuiltTool(ctx, "oatdumpd").
FlagWithInputList("--runtime-arg -Xbootclasspath:", image.dexPathsDeps.Paths(), ":").
FlagWithList("--runtime-arg -Xbootclasspath-locations:", image.dexLocationsDeps, ":").
- FlagWithArg("--image=", strings.Join(image.imageLocations, ":")).Implicits(image.imagesDeps[arch].Paths()).
+ FlagWithArg("--image=", strings.Join(image.imageLocations, ":")).Implicits(image.imagesDeps.Paths()).
FlagWithOutput("--output=", output).
FlagWithArg("--instruction-set=", arch.String())
rule.Build(pctx, ctx, "dump-oat-boot-"+arch.String(), "dump oat boot "+arch.String())
@@ -610,20 +665,13 @@
var imageNames []string
for _, current := range append(d.otherImages, image) {
imageNames = append(imageNames, current.name)
- var arches []android.ArchType
- for arch, _ := range current.images {
- arches = append(arches, arch)
- }
-
- sort.Slice(arches, func(i, j int) bool { return arches[i].String() < arches[j].String() })
-
- for _, arch := range arches {
- sfx := current.name + "_" + arch.String()
- ctx.Strict("DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_"+sfx, current.vdexInstalls[arch].String())
- ctx.Strict("DEXPREOPT_IMAGE_"+sfx, current.images[arch].String())
- ctx.Strict("DEXPREOPT_IMAGE_DEPS_"+sfx, strings.Join(current.imagesDeps[arch].Strings(), " "))
- ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, current.installs[arch].String())
- ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, current.unstrippedInstalls[arch].String())
+ for _, current := range current.variants {
+ sfx := current.name + "_" + current.target.Arch.ArchType.String()
+ ctx.Strict("DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_"+sfx, current.vdexInstalls.String())
+ ctx.Strict("DEXPREOPT_IMAGE_"+sfx, current.images.String())
+ ctx.Strict("DEXPREOPT_IMAGE_DEPS_"+sfx, strings.Join(current.imagesDeps.Strings(), " "))
+ ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, current.installs.String())
+ ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, current.unstrippedInstalls.String())
}
ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_"+current.name, strings.Join(current.imageLocations, ":"))
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index 5d74b21..f8356d1 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -139,8 +139,6 @@
// common to all configs
for _, c := range configs {
- c.targets = targets
-
c.dir = deviceDir.Join(ctx, "dex_"+c.name+"jars")
c.symbolsDir = deviceDir.Join(ctx, "dex_"+c.name+"jars_unstripped")
@@ -159,14 +157,17 @@
}
c.dexPathsDeps = c.dexPaths
- c.images = make(map[android.ArchType]android.OutputPath)
- c.imagesDeps = make(map[android.ArchType]android.OutputPaths)
-
+ // Create target-specific variants.
for _, target := range targets {
arch := target.Arch.ArchType
imageDir := c.dir.Join(ctx, c.installSubdir, arch.String())
- c.images[arch] = imageDir.Join(ctx, imageName)
- c.imagesDeps[arch] = c.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex")
+ variant := &bootImageVariant{
+ bootImageConfig: c,
+ target: target,
+ images: imageDir.Join(ctx, imageName),
+ imagesDeps: c.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex"),
+ }
+ c.variants = append(c.variants, variant)
}
c.zip = c.dir.Join(ctx, c.name+".zip")
@@ -174,19 +175,21 @@
// specific to the framework config
frameworkCfg.dexPathsDeps = append(artCfg.dexPathsDeps, frameworkCfg.dexPathsDeps...)
- frameworkCfg.primaryImages = artCfg.images
+ for i := range targets {
+ frameworkCfg.variants[i].primaryImages = artCfg.variants[i].images
+ }
frameworkCfg.imageLocations = append(artCfg.imageLocations, frameworkCfg.imageLocations...)
return configs
}).(map[string]*bootImageConfig)
}
-func artBootImageConfig(ctx android.PathContext) bootImageConfig {
- return *genBootImageConfigs(ctx)[artBootImageName]
+func artBootImageConfig(ctx android.PathContext) *bootImageConfig {
+ return genBootImageConfigs(ctx)[artBootImageName]
}
-func defaultBootImageConfig(ctx android.PathContext) bootImageConfig {
- return *genBootImageConfigs(ctx)[frameworkBootImageName]
+func defaultBootImageConfig(ctx android.PathContext) *bootImageConfig {
+ return genBootImageConfigs(ctx)[frameworkBootImageName]
}
func defaultBootclasspath(ctx android.PathContext) []string {
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index 7e7e955..c7f7cbd 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -211,23 +211,30 @@
// the greylists.
func flagsRule(ctx android.SingletonContext) android.Path {
var flagsCSV android.Paths
-
- var greylistIgnoreConflicts android.Path
+ var greylistRemovedApis android.Paths
ctx.VisitAllModules(func(module android.Module) {
if h, ok := module.(hiddenAPIIntf); ok {
if csv := h.flagsCSV(); csv != nil {
flagsCSV = append(flagsCSV, csv)
}
- } else if ds, ok := module.(*Droidstubs); ok && ctx.ModuleName(module) == "hiddenapi-lists-docs" {
- greylistIgnoreConflicts = ds.removedDexApiFile
+ } else if ds, ok := module.(*Droidstubs); ok {
+ // Track @removed public and system APIs via corresponding droidstubs targets.
+ // These APIs are not present in the stubs, however, we have to keep allowing access
+ // to them at runtime.
+ if m := ctx.ModuleName(module); m == "api-stubs-docs" || m == "system-api-stubs-docs" {
+ greylistRemovedApis = append(greylistRemovedApis, ds.removedDexApiFile)
+ }
}
})
- if greylistIgnoreConflicts == nil {
- ctx.Errorf("failed to find removed_dex_api_filename from hiddenapi-lists-docs module")
- return nil
- }
+ combinedRemovedApis := android.PathForOutput(ctx, "hiddenapi", "combined-removed-dex.txt")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cat,
+ Inputs: greylistRemovedApis,
+ Output: combinedRemovedApis,
+ Description: "Combine removed apis for " + combinedRemovedApis.String(),
+ })
rule := android.NewRuleBuilder()
@@ -242,8 +249,7 @@
Inputs(flagsCSV).
FlagWithInput("--greylist ",
android.PathForSource(ctx, "frameworks/base/config/hiddenapi-greylist.txt")).
- FlagWithInput("--greylist-ignore-conflicts ",
- greylistIgnoreConflicts).
+ FlagWithInput("--greylist-ignore-conflicts ", combinedRemovedApis).
FlagWithInput("--greylist-max-q ",
android.PathForSource(ctx, "frameworks/base/config/hiddenapi-greylist-max-q.txt")).
FlagWithInput("--greylist-max-p ",
diff --git a/java/java.go b/java/java.go
index 46adedc..d67ff87 100644
--- a/java/java.go
+++ b/java/java.go
@@ -319,6 +319,10 @@
UncompressDex bool `blueprint:"mutated"`
IsSDKLibrary bool `blueprint:"mutated"`
+
+ // If true, generate the signature file of APK Signing Scheme V4, along side the signed APK file.
+ // Defaults to false.
+ V4_signature *bool
}
func (me *CompilerDeviceProperties) EffectiveOptimizeEnabled() bool {
@@ -415,6 +419,8 @@
// list of the xref extraction files
kytheFiles android.Paths
+
+ distFile android.Path
}
func (j *Module) OutputFiles(tag string) (android.Paths, error) {
@@ -534,9 +540,10 @@
}
type jniLib struct {
- name string
- path android.Path
- target android.Target
+ name string
+ path android.Path
+ target android.Target
+ coverageFile android.OptionalPath
}
func (j *Module) shouldInstrument(ctx android.BaseModuleContext) bool {
@@ -1771,9 +1778,18 @@
// Java libraries (.jar file)
//
+type LibraryProperties struct {
+ Dist struct {
+ // The tag of the output of this module that should be output.
+ Tag *string `android:"arch_variant"`
+ } `android:"arch_variant"`
+}
+
type Library struct {
Module
+ libraryProperties LibraryProperties
+
InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.Paths)
}
@@ -1817,6 +1833,15 @@
j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
ctx.ModuleName()+".jar", j.outputFile, extraInstallDeps...)
}
+
+ // Verify Dist.Tag is set to a supported output
+ if j.libraryProperties.Dist.Tag != nil {
+ distFiles, err := j.OutputFiles(*j.libraryProperties.Dist.Tag)
+ if err != nil {
+ ctx.PropertyErrorf("dist.tag", "%s", err.Error())
+ }
+ j.distFile = distFiles[0]
+ }
}
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -1941,7 +1966,8 @@
&module.Module.properties,
&module.Module.deviceProperties,
&module.Module.dexpreoptProperties,
- &module.Module.protoProperties)
+ &module.Module.protoProperties,
+ &module.libraryProperties)
android.InitApexModule(module)
android.InitSdkAwareModule(module)
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 6921114..52c9004 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -18,7 +18,6 @@
"android/soong/android"
"fmt"
- "io"
"path"
"path/filepath"
"sort"
@@ -328,41 +327,6 @@
entriesList := module.Library.AndroidMkEntries()
entries := &entriesList[0]
entries.Required = append(entries.Required, module.xmlFileName())
-
- entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
- func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
- if !Bool(module.sdkLibraryProperties.No_dist) {
- // Create a phony module that installs the impl library, for the case when this lib is
- // in PRODUCT_PACKAGES.
- owner := module.ModuleBase.Owner()
- if owner == "" {
- if Bool(module.sdkLibraryProperties.Core_lib) {
- owner = "core"
- } else {
- owner = "android"
- }
- }
-
- // Create dist rules to install the stubs libs and api files to the dist dir
- for _, apiScope := range module.getActiveApiScopes() {
- if scopePaths, ok := module.scopePaths[apiScope]; ok {
- if len(scopePaths.stubsHeaderPath) == 1 {
- fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- scopePaths.stubsImplPath.Strings()[0]+
- ":"+path.Join("apistubs", owner, apiScope.name,
- module.BaseModuleName()+".jar")+")")
- }
- if scopePaths.apiFilePath != nil {
- fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- scopePaths.apiFilePath.String()+
- ":"+path.Join("apistubs", owner, apiScope.name, "api",
- module.BaseModuleName()+".txt")+")")
- }
- }
- }
- }
- },
- }
return entriesList
}
@@ -386,6 +350,17 @@
return module.BaseModuleName() + sdkXmlFileSuffix
}
+// The dist path of the stub artifacts
+func (module *SdkLibrary) apiDistPath(apiScope *apiScope) string {
+ if module.ModuleBase.Owner() != "" {
+ return path.Join("apistubs", module.ModuleBase.Owner(), apiScope.name)
+ } else if Bool(module.sdkLibraryProperties.Core_lib) {
+ return path.Join("apistubs", "core", apiScope.name)
+ } else {
+ return path.Join("apistubs", "android", apiScope.name)
+ }
+}
+
// Get the sdk version for use when compiling the stubs library.
func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.LoadHookContext, apiScope *apiScope) string {
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
@@ -438,6 +413,12 @@
Srcs []string
Javacflags []string
}
+ Dist struct {
+ Targets []string
+ Dest *string
+ Dir *string
+ Tag *string
+ }
}{}
props.Name = proptools.StringPtr(module.stubsName(apiScope))
@@ -466,6 +447,13 @@
} else if module.SystemExtSpecific() {
props.System_ext_specific = proptools.BoolPtr(true)
}
+ // Dist the class jar artifact for sdk builds.
+ if !Bool(module.sdkLibraryProperties.No_dist) {
+ props.Dist.Targets = []string{"sdk", "win_sdk"}
+ props.Dist.Dest = proptools.StringPtr(fmt.Sprintf("%v.jar", module.BaseModuleName()))
+ props.Dist.Dir = proptools.StringPtr(module.apiDistPath(apiScope))
+ props.Dist.Tag = proptools.StringPtr(".jar")
+ }
mctx.CreateModule(LibraryFactory, &props)
}
@@ -497,6 +485,11 @@
Include_dirs []string
Local_include_dirs []string
}
+ Dist struct {
+ Targets []string
+ Dest *string
+ Dir *string
+ }
}{}
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
@@ -578,6 +571,13 @@
module.latestRemovedApiFilegroupName(apiScope))
props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true)
+ // Dist the api txt artifact for sdk builds.
+ if !Bool(module.sdkLibraryProperties.No_dist) {
+ props.Dist.Targets = []string{"sdk", "win_sdk"}
+ props.Dist.Dest = proptools.StringPtr(fmt.Sprintf("%v.txt", module.BaseModuleName()))
+ props.Dist.Dir = proptools.StringPtr(path.Join(module.apiDistPath(apiScope), "api"))
+ }
+
mctx.CreateModule(DroidstubsFactory, &props)
}
diff --git a/ui/build/cleanbuild.go b/ui/build/cleanbuild.go
index 95d049a..0bcdccb 100644
--- a/ui/build/cleanbuild.go
+++ b/ui/build/cleanbuild.go
@@ -99,6 +99,7 @@
hostOut("sdk_addon"),
hostOut("testcases"),
hostOut("vts"),
+ hostOut("vts10"),
hostOut("vts-core"),
productOut("*.img"),
productOut("*.zip"),
diff --git a/ui/build/ninja.go b/ui/build/ninja.go
index 0749fe3..4fc1f01 100644
--- a/ui/build/ninja.go
+++ b/ui/build/ninja.go
@@ -38,6 +38,7 @@
executable := config.PrebuiltBuildTool("ninja")
args := []string{
"-d", "keepdepfile",
+ "-d", "keeprsp",
"--frontend_file", fifo,
}
diff --git a/ui/build/sandbox_linux.go b/ui/build/sandbox_linux.go
index 11ff667..2de772b 100644
--- a/ui/build/sandbox_linux.go
+++ b/ui/build/sandbox_linux.go
@@ -90,10 +90,7 @@
return
}
- c.ctx.Println("Build sandboxing disabled due to nsjail error. This may become fatal in the future.")
- c.ctx.Println("Please let us know why nsjail doesn't work in your environment at:")
- c.ctx.Println(" https://groups.google.com/forum/#!forum/android-building")
- c.ctx.Println(" https://issuetracker.google.com/issues/new?component=381517")
+ c.ctx.Println("Build sandboxing disabled due to nsjail error.")
for _, line := range strings.Split(strings.TrimSpace(string(data)), "\n") {
c.ctx.Verboseln(line)