Merge "Revert "Revert "Remove create_stubs and checkapi from droiddoc"""
diff --git a/android/api_levels.go b/android/api_levels.go
index b6296d8..0872066 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -73,6 +73,7 @@
"O-MR1": 27,
"P": 28,
"Q": 29,
+ "R": 30,
}
for i, codename := range config.PlatformVersionActiveCodenames() {
apiLevelsMap[codename] = baseApiLevel + i
diff --git a/android/arch.go b/android/arch.go
index 9a54614..66edf7e 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -551,6 +551,15 @@
}
}()
+var BuildArch = func() ArchType {
+ switch runtime.GOARCH {
+ case "amd64":
+ return X86_64
+ default:
+ panic(fmt.Sprintf("unsupported Arch: %s", runtime.GOARCH))
+ }
+}()
+
var (
OsTypeList []OsType
commonTargetMap = make(map[string]Target)
diff --git a/android/defaults.go b/android/defaults.go
index 81e340e..0892adf 100644
--- a/android/defaults.go
+++ b/android/defaults.go
@@ -115,11 +115,6 @@
type DefaultsModuleBase struct {
DefaultableModuleBase
-
- // Container for defaults of the common properties
- commonProperties commonProperties
-
- defaultsVisibilityProperties DefaultsVisibilityProperties
}
// The common pattern for defaults modules is to register separate instances of
@@ -153,12 +148,6 @@
properties() []interface{}
productVariableProperties() interface{}
-
- // Return the defaults common properties.
- common() *commonProperties
-
- // Return the defaults visibility properties.
- defaultsVisibility() *DefaultsVisibilityProperties
}
func (d *DefaultsModuleBase) isDefaults() bool {
@@ -178,24 +167,17 @@
return d.defaultableVariableProperties
}
-func (d *DefaultsModuleBase) common() *commonProperties {
- return &d.commonProperties
-}
-
-func (d *DefaultsModuleBase) defaultsVisibility() *DefaultsVisibilityProperties {
- return &d.defaultsVisibilityProperties
-}
-
func (d *DefaultsModuleBase) GenerateAndroidBuildActions(ctx ModuleContext) {
}
func InitDefaultsModule(module DefaultsModule) {
- commonProperties := module.common()
+ commonProperties := &commonProperties{}
module.AddProperties(
&hostAndDeviceProperties{},
commonProperties,
- &ApexProperties{})
+ &ApexProperties{},
+ &distProperties{})
initAndroidModuleBase(module)
initProductVariableModule(module)
@@ -204,7 +186,7 @@
// Add properties that will not have defaults applied to them.
base := module.base()
- defaultsVisibility := module.defaultsVisibility()
+ defaultsVisibility := &DefaultsVisibilityProperties{}
module.AddProperties(&base.nameProperties, defaultsVisibility)
// Unlike non-defaults modules the visibility property is not stored in m.base().commonProperties.
diff --git a/android/module.go b/android/module.go
index 17bc205..bfb87fa 100644
--- a/android/module.go
+++ b/android/module.go
@@ -198,7 +198,7 @@
InstallInRecovery() bool
InstallInRoot() bool
InstallBypassMake() bool
- InstallForceOS() *OsType
+ InstallForceOS() (*OsType, *ArchType)
RequiredModuleNames() []string
HostRequiredModuleNames() []string
@@ -247,6 +247,7 @@
Disable()
Enabled() bool
Target() Target
+ Owner() string
InstallInData() bool
InstallInTestcases() bool
InstallInSanitizerDir() bool
@@ -254,7 +255,7 @@
InstallInRecovery() bool
InstallInRoot() bool
InstallBypassMake() bool
- InstallForceOS() *OsType
+ InstallForceOS() (*OsType, *ArchType)
SkipInstall()
IsSkipInstall() bool
MakeUninstallable()
@@ -490,14 +491,6 @@
// relative path to a file to include in the list of notices for the device
Notice *string `android:"path"`
- // configuration to distribute output files from this module to the distribution
- // directory (default: $OUT/dist, configurable with $DIST_DIR)
- Dist Dist `android:"arch_variant"`
-
- // a list of configurations to distribute output files from this module to the
- // distribution directory (default: $OUT/dist, configurable with $DIST_DIR)
- Dists []Dist `android:"arch_variant"`
-
// The OsType of artifacts that this module variant is responsible for creating.
//
// Set by osMutator
@@ -566,6 +559,16 @@
ImageVariation string `blueprint:"mutated"`
}
+type distProperties struct {
+ // configuration to distribute output files from this module to the distribution
+ // directory (default: $OUT/dist, configurable with $DIST_DIR)
+ Dist Dist `android:"arch_variant"`
+
+ // a list of configurations to distribute output files from this module to the
+ // distribution directory (default: $OUT/dist, configurable with $DIST_DIR)
+ Dists []Dist `android:"arch_variant"`
+}
+
// A map of OutputFile tag keys to Paths, for disting purposes.
type TaggedDistFiles map[string]Paths
@@ -661,7 +664,8 @@
m.AddProperties(
&base.nameProperties,
- &base.commonProperties)
+ &base.commonProperties,
+ &base.distProperties)
initProductVariableModule(m)
@@ -752,6 +756,7 @@
nameProperties nameProperties
commonProperties commonProperties
+ distProperties distProperties
variableProperties interface{}
hostAndDeviceProperties hostAndDeviceProperties
generalProperties []interface{}
@@ -861,13 +866,13 @@
}
func (m *ModuleBase) Dists() []Dist {
- if len(m.commonProperties.Dist.Targets) > 0 {
+ if len(m.distProperties.Dist.Targets) > 0 {
// Make a copy of the underlying Dists slice to protect against
// backing array modifications with repeated calls to this method.
- distsCopy := append([]Dist(nil), m.commonProperties.Dists...)
- return append(distsCopy, m.commonProperties.Dist)
+ distsCopy := append([]Dist(nil), m.distProperties.Dists...)
+ return append(distsCopy, m.distProperties.Dist)
} else {
- return m.commonProperties.Dists
+ return m.distProperties.Dists
}
}
@@ -1116,8 +1121,8 @@
return false
}
-func (m *ModuleBase) InstallForceOS() *OsType {
- return nil
+func (m *ModuleBase) InstallForceOS() (*OsType, *ArchType) {
+ return nil, nil
}
func (m *ModuleBase) Owner() string {
@@ -1344,20 +1349,20 @@
ctx.Variable(pctx, "moduleDescSuffix", s)
// Some common property checks for properties that will be used later in androidmk.go
- if m.commonProperties.Dist.Dest != nil {
- _, err := validateSafePath(*m.commonProperties.Dist.Dest)
+ if m.distProperties.Dist.Dest != nil {
+ _, err := validateSafePath(*m.distProperties.Dist.Dest)
if err != nil {
ctx.PropertyErrorf("dist.dest", "%s", err.Error())
}
}
- if m.commonProperties.Dist.Dir != nil {
- _, err := validateSafePath(*m.commonProperties.Dist.Dir)
+ if m.distProperties.Dist.Dir != nil {
+ _, err := validateSafePath(*m.distProperties.Dist.Dir)
if err != nil {
ctx.PropertyErrorf("dist.dir", "%s", err.Error())
}
}
- if m.commonProperties.Dist.Suffix != nil {
- if strings.Contains(*m.commonProperties.Dist.Suffix, "/") {
+ if m.distProperties.Dist.Suffix != nil {
+ if strings.Contains(*m.distProperties.Dist.Suffix, "/") {
ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
}
}
@@ -2017,7 +2022,7 @@
return m.module.InstallBypassMake()
}
-func (m *moduleContext) InstallForceOS() *OsType {
+func (m *moduleContext) InstallForceOS() (*OsType, *ArchType) {
return m.module.InstallForceOS()
}
diff --git a/android/neverallow.go b/android/neverallow.go
index aaea920..8b8e1ac 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -199,6 +199,7 @@
"prebuilts/ndk",
"tools/test/graphicsbenchmark/apps/sample_app",
"tools/test/graphicsbenchmark/functional_tests/java",
+ "vendor/xts/gts-tests/hostsidetests/gamedevicecert/apps/javatests",
}
platformVariantPropertiesAllowedList := []string{
@@ -274,6 +275,10 @@
continue
}
+ if !n.appliesToBootclasspathJar(ctx) {
+ continue
+ }
+
ctx.ModuleErrorf("violates " + n.String())
}
}
@@ -332,6 +337,18 @@
return ".regexp(" + m.re.String() + ")"
}
+type notInListMatcher struct {
+ allowed []string
+}
+
+func (m *notInListMatcher) Test(value string) bool {
+ return !InList(value, m.allowed)
+}
+
+func (m *notInListMatcher) String() string {
+ return ".not-in-list(" + strings.Join(m.allowed, ",") + ")"
+}
+
type isSetMatcher struct{}
func (m *isSetMatcher) Test(value string) bool {
@@ -363,6 +380,8 @@
NotModuleType(types ...string) Rule
+ BootclasspathJar() Rule
+
With(properties, value string) Rule
WithMatcher(properties string, matcher ValueMatcher) Rule
@@ -390,6 +409,8 @@
props []ruleProperty
unlessProps []ruleProperty
+
+ onlyBootclasspathJar bool
}
// Create a new NeverAllow rule.
@@ -465,6 +486,11 @@
return r
}
+func (r *rule) BootclasspathJar() Rule {
+ r.onlyBootclasspathJar = true
+ return r
+}
+
func (r *rule) String() string {
s := "neverallow"
for _, v := range r.paths {
@@ -491,6 +517,9 @@
for _, v := range r.osClasses {
s += " os:" + v.String()
}
+ if r.onlyBootclasspathJar {
+ s += " inBcp"
+ }
if len(r.reason) != 0 {
s += " which is restricted because " + r.reason
}
@@ -519,6 +548,14 @@
return matches
}
+func (r *rule) appliesToBootclasspathJar(ctx BottomUpMutatorContext) bool {
+ if !r.onlyBootclasspathJar {
+ return true
+ }
+
+ return InList(ctx.ModuleName(), ctx.Config().BootJars())
+}
+
func (r *rule) appliesToOsClass(osClass OsClass) bool {
if len(r.osClasses) == 0 {
return true
@@ -555,6 +592,10 @@
return ®exMatcher{r}
}
+func NotInList(allowed []string) ValueMatcher {
+ return ¬InListMatcher{allowed}
+}
+
// assorted utils
func cleanPaths(paths []string) []string {
diff --git a/android/paths.go b/android/paths.go
index 6b603ba..3825d45 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -61,7 +61,7 @@
InstallInRecovery() bool
InstallInRoot() bool
InstallBypassMake() bool
- InstallForceOS() *OsType
+ InstallForceOS() (*OsType, *ArchType)
}
var _ ModuleInstallPathContext = ModuleContext(nil)
@@ -1278,12 +1278,17 @@
// module appended with paths...
func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string) InstallPath {
os := ctx.Os()
- if forceOS := ctx.InstallForceOS(); forceOS != nil {
+ arch := ctx.Arch().ArchType
+ forceOS, forceArch := ctx.InstallForceOS()
+ if forceOS != nil {
os = *forceOS
}
+ if forceArch != nil {
+ arch = *forceArch
+ }
partition := modulePartition(ctx, os)
- ret := pathForInstall(ctx, os, partition, ctx.Debug(), pathComponents...)
+ ret := pathForInstall(ctx, os, arch, partition, ctx.Debug(), pathComponents...)
if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() {
ret = ret.ToMakePath()
@@ -1292,7 +1297,7 @@
return ret
}
-func pathForInstall(ctx PathContext, os OsType, partition string, debug bool,
+func pathForInstall(ctx PathContext, os OsType, arch ArchType, partition string, debug bool,
pathComponents ...string) InstallPath {
var outPaths []string
@@ -1300,15 +1305,21 @@
if os.Class == Device {
outPaths = []string{"target", "product", ctx.Config().DeviceName(), partition}
} else {
- switch os {
- case Linux:
- outPaths = []string{"host", "linux-x86", partition}
- case LinuxBionic:
- // TODO: should this be a separate top level, or shared with linux-x86?
- outPaths = []string{"host", "linux_bionic-x86", partition}
- default:
- outPaths = []string{"host", os.String() + "-x86", partition}
+ osName := os.String()
+ if os == Linux {
+ // instead of linux_glibc
+ osName = "linux"
}
+ // SOONG_HOST_OUT is set to out/host/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
+ // and HOST_PREBUILT_ARCH is forcibly set to x86 even on x86_64 hosts. We don't seem
+ // to have a plan to fix it (see the comment in build/make/core/envsetup.mk).
+ // Let's keep using x86 for the existing cases until we have a need to support
+ // other architectures.
+ archName := arch.String()
+ if os.Class == Host && (arch == X86_64 || arch == Common) {
+ archName = "x86"
+ }
+ outPaths = []string{"host", osName + "-" + archName, partition}
}
if debug {
outPaths = append([]string{"debug"}, outPaths...)
diff --git a/android/paths_test.go b/android/paths_test.go
index a9cd22b..d099f65 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -207,6 +207,7 @@
inRecovery bool
inRoot bool
forceOS *OsType
+ forceArch *ArchType
}
func (m moduleInstallPathContextImpl) Config() Config {
@@ -243,8 +244,8 @@
return false
}
-func (m moduleInstallPathContextImpl) InstallForceOS() *OsType {
- return m.forceOS
+func (m moduleInstallPathContextImpl) InstallForceOS() (*OsType, *ArchType) {
+ return m.forceOS, m.forceArch
}
func pathTestConfig(buildDir string) Config {
@@ -254,8 +255,8 @@
func TestPathForModuleInstall(t *testing.T) {
testConfig := pathTestConfig("")
- hostTarget := Target{Os: Linux}
- deviceTarget := Target{Os: Android}
+ hostTarget := Target{Os: Linux, Arch: Arch{ArchType: X86}}
+ deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}}
testCases := []struct {
name string
@@ -635,6 +636,7 @@
},
inTestcases: true,
forceOS: &Linux,
+ forceArch: &X86,
},
in: []string{"my_test", "my_test_bin"},
out: "host/linux-x86/testcases/my_test/my_test_bin",
diff --git a/android/test_suites.go b/android/test_suites.go
index 79d0fbc..34e487e 100644
--- a/android/test_suites.go
+++ b/android/test_suites.go
@@ -60,7 +60,7 @@
for _, module := range SortedStringKeys(files) {
installedPaths = append(installedPaths, files[module]...)
}
- testCasesDir := pathForInstall(ctx, BuildOs, "testcases", false).ToMakePath()
+ testCasesDir := pathForInstall(ctx, BuildOs, X86, "testcases", false).ToMakePath()
outputFile := PathForOutput(ctx, "packaging", "robolectric-tests.zip")
rule := NewRuleBuilder()
diff --git a/apex/Android.bp b/apex/Android.bp
index 144f441..1a5f683 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -5,6 +5,7 @@
"blueprint",
"soong",
"soong-android",
+ "soong-bpf",
"soong-cc",
"soong-java",
"soong-python",
diff --git a/apex/androidmk.go b/apex/androidmk.go
index 5c6d6cc..af2ec3d 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -108,6 +108,9 @@
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
}
fmt.Fprintln(w, "LOCAL_MODULE :=", moduleName)
+ if fi.module != nil && fi.module.Owner() != "" {
+ fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", fi.module.Owner())
+ }
// /apex/<apex_name>/{lib|framework|...}
pathWhenActivated := filepath.Join("$(PRODUCT_OUT)", "apex", apexName, fi.installDir)
var modulePath string
diff --git a/apex/apex.go b/apex/apex.go
index f3699b0..8c85555 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -26,6 +26,7 @@
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/bpf"
"android/soong/cc"
prebuilt_etc "android/soong/etc"
"android/soong/java"
@@ -66,6 +67,7 @@
usesTag = dependencyTag{name: "uses"}
androidAppTag = dependencyTag{name: "androidApp", payload: true}
rroTag = dependencyTag{name: "rro", payload: true}
+ bpfTag = dependencyTag{name: "bpf", payload: true}
apexAvailBaseline = makeApexAvailableBaseline()
@@ -98,6 +100,13 @@
//
// Module separator
//
+ m["com.android.appsearch"] = []string{
+ "icing-java-proto-lite",
+ "libprotobuf-java-lite",
+ }
+ //
+ // Module separator
+ //
m["com.android.bluetooth.updatable"] = []string{
"android.hardware.audio.common@5.0",
"android.hardware.bluetooth.a2dp@1.0",
@@ -180,6 +189,19 @@
//
// Module separator
//
+ m["com.android.extservices"] = []string{
+ "error_prone_annotations",
+ "ExtServices-core",
+ "ExtServices",
+ "libtextclassifier-java",
+ "libz_current",
+ "textclassifier-statsd",
+ "TextClassifierNotificationLibNoManifest",
+ "TextClassifierServiceLibNoManifest",
+ }
+ //
+ // Module separator
+ //
m["com.android.neuralnetworks"] = []string{
"android.hardware.neuralnetworks@1.0",
"android.hardware.neuralnetworks@1.1",
@@ -295,7 +317,6 @@
"libpdx_headers",
"libpdx_uds",
"libprocinfo",
- "libsonivox",
"libspeexresampler",
"libspeexresampler",
"libstagefright_esds",
@@ -332,6 +353,7 @@
"android.hardware.configstore@1.1",
"android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.allocator@3.0",
+ "android.hardware.graphics.allocator@4.0",
"android.hardware.graphics.bufferqueue@1.0",
"android.hardware.graphics.bufferqueue@2.0",
"android.hardware.graphics.common-ndk_platform",
@@ -344,6 +366,7 @@
"android.hardware.graphics.mapper@4.0",
"android.hardware.media.bufferpool@2.0",
"android.hardware.media.c2@1.0",
+ "android.hardware.media.c2@1.1",
"android.hardware.media.omx@1.0",
"android.hardware.media@1.0",
"android.hardware.media@1.0",
@@ -437,6 +460,7 @@
"libpdx_headers",
"libscudo_wrapper",
"libsfplugin_ccodec_utils",
+ "libspeexresampler",
"libstagefright_amrnb_common",
"libstagefright_amrnbdec",
"libstagefright_amrnbenc",
@@ -479,6 +503,8 @@
// Module separator
//
m["com.android.permission"] = []string{
+ "car-ui-lib",
+ "iconloader",
"kotlin-annotations",
"kotlin-stdlib",
"kotlin-stdlib-jdk7",
@@ -488,6 +514,17 @@
"kotlinx-coroutines-core",
"kotlinx-coroutines-core-nodeps",
"permissioncontroller-statsd",
+ "GooglePermissionController",
+ "PermissionController",
+ "SettingsLibActionBarShadow",
+ "SettingsLibAppPreference",
+ "SettingsLibBarChartPreference",
+ "SettingsLibLayoutPreference",
+ "SettingsLibProgressBar",
+ "SettingsLibSearchWidget",
+ "SettingsLibSettingsTheme",
+ "SettingsLibRestrictedLockUtils",
+ "SettingsLibHelpUtils",
}
//
// Module separator
@@ -646,6 +683,55 @@
return m
}
+// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART.
+// Adding code to the bootclasspath in new packages will cause issues on module update.
+func qModulesPackages() map[string][]string {
+ return map[string][]string{
+ "com.android.conscrypt": []string{
+ "android.net.ssl",
+ "com.android.org.conscrypt",
+ },
+ "com.android.media": []string{
+ "android.media",
+ },
+ }
+}
+
+// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART.
+// Adding code to the bootclasspath in new packages will cause issues on module update.
+func rModulesPackages() map[string][]string {
+ return map[string][]string{
+ "com.android.mediaprovider": []string{
+ "android.provider",
+ },
+ "com.android.permission": []string{
+ "android.permission",
+ "android.app.role",
+ "com.android.permission",
+ "com.android.role",
+ },
+ "com.android.sdkext": []string{
+ "android.os.ext",
+ },
+ "com.android.os.statsd": []string{
+ "android.app",
+ "android.os",
+ "android.util",
+ "com.android.internal.statsd",
+ "com.android.server.stats",
+ },
+ "com.android.wifi": []string{
+ "com.android.server.wifi",
+ "com.android.wifi.x",
+ "android.hardware.wifi",
+ "android.net.wifi",
+ },
+ "com.android.tethering": []string{
+ "android.net",
+ },
+ }
+}
+
func init() {
android.RegisterModuleType("apex", BundleFactory)
android.RegisterModuleType("apex_test", testApexBundleFactory)
@@ -663,6 +749,24 @@
sort.Strings(*apexFileContextsInfos)
ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " "))
})
+
+ android.AddNeverAllowRules(createApexPermittedPackagesRules(qModulesPackages())...)
+ android.AddNeverAllowRules(createApexPermittedPackagesRules(rModulesPackages())...)
+}
+
+func createApexPermittedPackagesRules(modules_packages map[string][]string) []android.Rule {
+ rules := make([]android.Rule, 0, len(modules_packages))
+ for module_name, module_packages := range modules_packages {
+ permitted_packages_rule := android.NeverAllow().
+ BootclasspathJar().
+ With("apex_available", module_name).
+ WithMatcher("permitted_packages", android.NotInList(module_packages)).
+ Because("jars that are part of the " + module_name +
+ " module may only allow these packages: " + strings.Join(module_packages, ",") +
+ ". Please jarjar or move code around.")
+ rules = append(rules, permitted_packages_rule)
+ }
+ return rules
}
func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
@@ -961,6 +1065,9 @@
// List of prebuilt files that are embedded inside this APEX bundle
Prebuilts []string
+ // List of BPF programs inside APEX
+ Bpfs []string
+
// Name of the apex_key module that provides the private key to sign APEX
Key *string
@@ -1184,6 +1291,8 @@
overriddenPackageName string // only for apps
isJniLib bool
+
+ noticeFiles android.Paths
}
func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidMkModuleName string, installDir string, class apexFileClass, module android.Module) apexFile {
@@ -1199,6 +1308,7 @@
ret.requiredModuleNames = module.RequiredModuleNames()
ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
+ ret.noticeFiles = module.NoticeFiles()
}
return ret
}
@@ -1336,26 +1446,30 @@
// conflicting variations with this module. This is required since
// arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
// for native shared libs.
- ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "image", Variation: imageVariation},
- {Mutator: "link", Variation: "shared"},
- {Mutator: "version", Variation: ""}, // "" is the non-stub variant
- }...), sharedLibTag, nativeModules.Native_shared_libs...)
- ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "image", Variation: imageVariation},
- {Mutator: "link", Variation: "shared"},
- {Mutator: "version", Variation: ""}, // "" is the non-stub variant
- }...), jniLibTag, nativeModules.Jni_libs...)
+ binVariations := target.Variations()
+ libVariations := append(target.Variations(),
+ blueprint.Variation{Mutator: "link", Variation: "shared"})
+ testVariations := append(target.Variations(),
+ blueprint.Variation{Mutator: "test_per_src", Variation: ""}) // "" is the all-tests variant
- ctx.AddFarVariationDependencies(append(target.Variations(),
- blueprint.Variation{Mutator: "image", Variation: imageVariation}),
- executableTag, nativeModules.Binaries...)
+ if ctx.Device() {
+ binVariations = append(binVariations,
+ blueprint.Variation{Mutator: "image", Variation: imageVariation})
+ libVariations = append(libVariations,
+ blueprint.Variation{Mutator: "image", Variation: imageVariation},
+ blueprint.Variation{Mutator: "version", Variation: ""}) // "" is the non-stub variant
+ testVariations = append(testVariations,
+ blueprint.Variation{Mutator: "image", Variation: imageVariation})
+ }
- ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "image", Variation: imageVariation},
- {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
- }...), testTag, nativeModules.Tests...)
+ ctx.AddFarVariationDependencies(libVariations, sharedLibTag, nativeModules.Native_shared_libs...)
+
+ ctx.AddFarVariationDependencies(libVariations, jniLibTag, nativeModules.Jni_libs...)
+
+ ctx.AddFarVariationDependencies(binVariations, executableTag, nativeModules.Binaries...)
+
+ ctx.AddFarVariationDependencies(testVariations, testTag, nativeModules.Tests...)
}
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
@@ -1473,6 +1587,9 @@
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
javaLibTag, a.properties.Java_libs...)
+ ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
+ bpfTag, a.properties.Bpfs...)
+
// With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
@@ -1740,7 +1857,7 @@
}
func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile {
- dirInApex := filepath.Join("etc", prebuilt.SubDir())
+ dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir())
fileToCopy := prebuilt.OutputFile()
return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
}
@@ -1793,6 +1910,11 @@
return af
}
+func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, bpfProgram bpf.BpfModule) apexFile {
+ dirInApex := filepath.Join("etc", "bpf")
+ return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram)
+}
+
// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
type flattenedApexContext struct {
android.ModuleContext
@@ -1951,13 +2073,6 @@
return false
}
- // TODO(jiyong) remove this check when R is published to AOSP. Currently, libstatssocket
- // is capable of providing a stub variant, but is being statically linked from the bluetooth
- // APEX.
- if toName == "libstatssocket" {
- return false
- }
-
// The dynamic linker and crash_dump tool in the runtime APEX is the only exception to this rule.
// It can't make the static dependencies dynamic because it can't
// do the dynamic linking for itself.
@@ -2128,6 +2243,15 @@
} else {
ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName)
}
+ case bpfTag:
+ if bpfProgram, ok := child.(bpf.BpfModule); ok {
+ filesToCopy, _ := bpfProgram.OutputFiles("")
+ for _, bpfFile := range filesToCopy {
+ filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, bpfProgram))
+ }
+ } else {
+ ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName)
+ }
case prebuiltTag:
if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
diff --git a/apex/apex_test.go b/apex/apex_test.go
index e9843fc..610f667 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -27,6 +27,7 @@
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/bpf"
"android/soong/cc"
"android/soong/dexpreopt"
prebuilt_etc "android/soong/etc"
@@ -248,7 +249,7 @@
ctx.RegisterModuleType("cc_test", cc.TestFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory)
ctx.RegisterModuleType("vndk_libraries_txt", cc.VndkLibrariesTxtFactory)
- ctx.RegisterModuleType("prebuilt_etc", prebuilt_etc.PrebuiltEtcFactory)
+ prebuilt_etc.RegisterPrebuiltEtcBuildComponents(ctx)
ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory)
ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
@@ -257,6 +258,7 @@
java.RegisterAppBuildComponents(ctx)
java.RegisterSdkLibraryBuildComponents(ctx)
ctx.RegisterSingletonType("apex_keys_text", apexKeysTextFactory)
+ ctx.RegisterModuleType("bpf", bpf.BpfFactory)
ctx.PreDepsMutators(RegisterPreDepsMutators)
ctx.PostDepsMutators(RegisterPostDepsMutators)
@@ -606,6 +608,7 @@
java_libs: ["myjar"],
apps: ["AppFoo"],
rros: ["rro"],
+ bpfs: ["bpf"],
}
prebuilt_etc {
@@ -652,6 +655,11 @@
theme: "blue",
}
+ bpf {
+ name: "bpf",
+ srcs: ["bpf.c", "bpf2.c"],
+ }
+
`)
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
"etc/myetc",
@@ -659,6 +667,8 @@
"lib64/mylib.so",
"app/AppFoo/AppFoo.apk",
"overlay/blue/rro.apk",
+ "etc/bpf/bpf.o",
+ "etc/bpf/bpf2.o",
})
}
@@ -2272,6 +2282,32 @@
ensureListContains(t, requireNativeLibs, ":vndk")
}
+func TestVendorApex_withPrebuiltFirmware(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ prebuilts: ["myfirmware"],
+ vendor: true,
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ prebuilt_firmware {
+ name: "myfirmware",
+ src: "myfirmware.bin",
+ filename_from_src: true,
+ vendor: true,
+ }
+ `)
+
+ ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
+ "firmware/myfirmware.bin",
+ })
+}
+
func TestAndroidMk_UseVendorRequired(t *testing.T) {
ctx, config := testApex(t, `
apex {
@@ -5704,6 +5740,141 @@
})
}
+func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, apexBootJars []string, rules []android.Rule) {
+ t.Helper()
+ android.ClearApexDependency()
+ bp += `
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }`
+ fs := map[string][]byte{
+ "lib1/src/A.java": nil,
+ "lib2/src/B.java": nil,
+ "system/sepolicy/apex/myapex-file_contexts": nil,
+ }
+
+ ctx := android.NewTestArchContext()
+ ctx.RegisterModuleType("apex", BundleFactory)
+ ctx.RegisterModuleType("apex_key", ApexKeyFactory)
+ ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
+ cc.RegisterRequiredBuildComponentsForTest(ctx)
+ java.RegisterJavaBuildComponents(ctx)
+ java.RegisterSystemModulesBuildComponents(ctx)
+ java.RegisterDexpreoptBootJarsComponents(ctx)
+ ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
+ ctx.PreDepsMutators(RegisterPreDepsMutators)
+ ctx.PostDepsMutators(RegisterPostDepsMutators)
+ ctx.PostDepsMutators(android.RegisterNeverallowMutator)
+
+ config := android.TestArchConfig(buildDir, nil, bp, fs)
+ android.SetTestNeverallowRules(config, rules)
+ updatableBootJars := make([]string, 0, len(apexBootJars))
+ for _, apexBootJar := range apexBootJars {
+ updatableBootJars = append(updatableBootJars, "myapex:"+apexBootJar)
+ }
+ config.TestProductVariables.UpdatableBootJars = updatableBootJars
+
+ ctx.Register(config)
+
+ _, errs := ctx.ParseBlueprintsFiles("Android.bp")
+ android.FailIfErrored(t, errs)
+
+ _, errs = ctx.PrepareBuildActions(config)
+ if errmsg == "" {
+ android.FailIfErrored(t, errs)
+ } else if len(errs) > 0 {
+ android.FailIfNoMatchingErrors(t, errmsg, errs)
+ return
+ } else {
+ t.Fatalf("missing expected error %q (0 errors are returned)", errmsg)
+ }
+}
+
+func TestApexPermittedPackagesRules(t *testing.T) {
+ testcases := []struct {
+ name string
+ expectedError string
+ bp string
+ bootJars []string
+ modulesPackages map[string][]string
+ }{
+
+ {
+ name: "Non-Bootclasspath apex jar not satisfying allowed module packages.",
+ expectedError: "",
+ bp: `
+ java_library {
+ name: "bcp_lib1",
+ srcs: ["lib1/src/*.java"],
+ permitted_packages: ["foo.bar"],
+ apex_available: ["myapex"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ java_library {
+ name: "nonbcp_lib2",
+ srcs: ["lib2/src/*.java"],
+ apex_available: ["myapex"],
+ permitted_packages: ["a.b"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ java_libs: ["bcp_lib1", "nonbcp_lib2"],
+ }`,
+ bootJars: []string{"bcp_lib1"},
+ modulesPackages: map[string][]string{
+ "myapex": []string{
+ "foo.bar",
+ },
+ },
+ },
+ {
+ name: "Bootclasspath apex jar not satisfying allowed module packages.",
+ expectedError: `module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only allow these packages: foo.bar. Please jarjar or move code around.`,
+ bp: `
+ java_library {
+ name: "bcp_lib1",
+ srcs: ["lib1/src/*.java"],
+ apex_available: ["myapex"],
+ permitted_packages: ["foo.bar"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ java_library {
+ name: "bcp_lib2",
+ srcs: ["lib2/src/*.java"],
+ apex_available: ["myapex"],
+ permitted_packages: ["foo.bar", "bar.baz"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ java_libs: ["bcp_lib1", "bcp_lib2"],
+ }
+ `,
+ bootJars: []string{"bcp_lib1", "bcp_lib2"},
+ modulesPackages: map[string][]string{
+ "myapex": []string{
+ "foo.bar",
+ },
+ },
+ },
+ }
+ for _, tc := range testcases {
+ t.Run(tc.name, func(t *testing.T) {
+ rules := createApexPermittedPackagesRules(tc.modulesPackages)
+ testApexPermittedPackagesRules(t, tc.expectedError, tc.bp, tc.bootJars, rules)
+ })
+ }
+}
+
func TestTestFor(t *testing.T) {
ctx, _ := testApex(t, `
apex {
@@ -5771,8 +5942,10 @@
}
`, func(fs map[string][]byte, config android.Config) {
config.TestProductVariables.Platform_sdk_version = intPtr(30)
- config.TestProductVariables.DeviceArch = proptools.StringPtr("arm")
- config.TestProductVariables.DeviceSecondaryArch = proptools.StringPtr("arm64")
+ config.Targets[android.Android] = []android.Target{
+ {Os: android.Android, Arch: android.Arch{ArchType: android.Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}},
+ {Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}},
+ }
})
m := ctx.ModuleForTests("myapex", "android_common")
diff --git a/apex/builder.go b/apex/builder.go
index 22cd69b..c5680ad 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -286,6 +286,10 @@
return true
})
+ for _, fi := range a.filesInfo {
+ noticeFiles = append(noticeFiles, fi.noticeFiles...)
+ }
+
if len(noticeFiles) == 0 {
return android.NoticeOutputs{}
}
@@ -652,7 +656,7 @@
a.container_certificate_file,
a.container_private_key_file,
}
- if ctx.Config().IsEnvTrue("RBE_SIGNAPK") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_SIGNAPK") {
rule = java.SignapkRE
args["implicits"] = strings.Join(implicits.Strings(), ",")
args["outCommaList"] = a.outputFile.String()
@@ -686,7 +690,7 @@
apexBundleName := a.Name()
a.outputFile = android.PathForModuleInstall(&factx, "apex", apexBundleName)
- if a.installable() && a.GetOverriddenBy() == "" {
+ if a.installable() {
installPath := android.PathForModuleInstall(ctx, "apex", apexBundleName)
devicePath := android.InstallPathToOnDevicePath(ctx, installPath)
addFlattenedFileContextsInfos(ctx, apexBundleName+":"+devicePath+":"+a.fileContexts.String())
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index d459f87..37457e9 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -257,6 +257,9 @@
// list of commands to create symlinks for backward compatibility.
// these commands will be attached as LOCAL_POST_INSTALL_CMD
compatSymlinks []string
+
+ hostRequired []string
+ postInstallCommands []string
}
type ApexSetProperties struct {
@@ -343,21 +346,43 @@
for _, overridden := range a.properties.Overrides {
a.compatSymlinks = append(a.compatSymlinks, makeCompatSymlinks(overridden, ctx)...)
}
+
+ if ctx.Config().InstallExtraFlattenedApexes() {
+ // flattened apex should be in /system_ext/apex
+ flattenedApexDir := android.PathForModuleInstall(&systemExtContext{ctx}, "apex", a.BaseModuleName())
+ a.postInstallCommands = append(a.postInstallCommands,
+ fmt.Sprintf("$(HOST_OUT_EXECUTABLES)/deapexer --debugfs_path $(HOST_OUT_EXECUTABLES)/debugfs extract %s %s",
+ a.outputApex.String(),
+ flattenedApexDir.ToMakePath().String(),
+ ))
+ a.hostRequired = []string{"deapexer", "debugfs"}
+ }
+}
+
+type systemExtContext struct {
+ android.ModuleContext
+}
+
+func (*systemExtContext) SystemExtSpecific() bool {
+ return true
}
func (a *ApexSet) AndroidMkEntries() []android.AndroidMkEntries {
return []android.AndroidMkEntries{android.AndroidMkEntries{
- Class: "ETC",
- OutputFile: android.OptionalPathForPath(a.outputApex),
- Include: "$(BUILD_PREBUILT)",
+ Class: "ETC",
+ OutputFile: android.OptionalPathForPath(a.outputApex),
+ Include: "$(BUILD_PREBUILT)",
+ Host_required: a.hostRequired,
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(entries *android.AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_PATH", a.installDir.ToMakePath().String())
entries.SetString("LOCAL_MODULE_STEM", a.installFilename)
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !a.installable())
entries.AddStrings("LOCAL_OVERRIDES_MODULES", a.properties.Overrides...)
- if len(a.compatSymlinks) > 0 {
- entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(a.compatSymlinks, " && "))
+ postInstallCommands := append([]string{}, a.postInstallCommands...)
+ postInstallCommands = append(postInstallCommands, a.compatSymlinks...)
+ if len(postInstallCommands) > 0 {
+ entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(postInstallCommands, " && "))
}
},
},
diff --git a/bpf/bpf.go b/bpf/bpf.go
index 4cdfb31..297e13a 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -26,7 +26,7 @@
)
func init() {
- android.RegisterModuleType("bpf", bpfFactory)
+ android.RegisterModuleType("bpf", BpfFactory)
pctx.Import("android/soong/cc/config")
}
@@ -43,6 +43,13 @@
"ccCmd", "cFlags")
)
+// BpfModule interface is used by the apex package to gather information from a bpf module.
+type BpfModule interface {
+ android.Module
+
+ OutputFiles(tag string) (android.Paths, error)
+}
+
type BpfProperties struct {
Srcs []string `android:"path"`
Cflags []string
@@ -141,7 +148,7 @@
var _ android.OutputFileProducer = (*bpf)(nil)
-func bpfFactory() android.Module {
+func BpfFactory() android.Module {
module := &bpf{}
module.AddProperties(&module.properties)
diff --git a/bpf/bpf_test.go b/bpf/bpf_test.go
index eeca057..d06d7d1 100644
--- a/bpf/bpf_test.go
+++ b/bpf/bpf_test.go
@@ -59,7 +59,7 @@
func testContext(config android.Config) *android.TestContext {
ctx := cc.CreateTestContext()
- ctx.RegisterModuleType("bpf", bpfFactory)
+ ctx.RegisterModuleType("bpf", BpfFactory)
ctx.Register(config)
return ctx
diff --git a/cc/androidmk.go b/cc/androidmk.go
index c899cdd..380b4e9 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -377,6 +377,7 @@
if !BoolDefault(test.Properties.Auto_gen_config, true) {
entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
}
+ entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", test.Properties.Test_mainline_modules...)
})
androidMkWriteTestData(test.data, ctx, entries)
diff --git a/cc/binary_sdk_member.go b/cc/binary_sdk_member.go
index 337de55..a1abc72 100644
--- a/cc/binary_sdk_member.go
+++ b/cc/binary_sdk_member.go
@@ -46,9 +46,13 @@
if version == "" {
version = LatestStubsVersionFor(mctx.Config(), name)
}
- mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "version", Variation: version},
- }...), dependencyTag, name)
+ variations := target.Variations()
+ if mctx.Device() {
+ variations = append(variations,
+ blueprint.Variation{Mutator: "image", Variation: android.CoreVariation},
+ blueprint.Variation{Mutator: "version", Variation: version})
+ }
+ mctx.AddFarVariationDependencies(variations, dependencyTag, name)
}
}
}
diff --git a/cc/builder.go b/cc/builder.go
index 8f2da34..ef65348 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -69,12 +69,12 @@
&remoteexec.REParams{
Labels: map[string]string{"type": "link", "tool": "clang"},
ExecStrategy: "${config.RECXXLinksExecStrategy}",
- Inputs: []string{"${out}.rsp"},
+ Inputs: []string{"${out}.rsp", "$implicitInputs"},
RSPFile: "${out}.rsp",
OutputFiles: []string{"${out}", "$implicitOutputs"},
ToolchainInputs: []string{"$ldCmd"},
Platform: map[string]string{remoteexec.PoolKey: "${config.RECXXLinksPool}"},
- }, []string{"ldCmd", "crtBegin", "libFlags", "crtEnd", "ldFlags", "extraLibFlags"}, []string{"implicitOutputs"})
+ }, []string{"ldCmd", "crtBegin", "libFlags", "crtEnd", "ldFlags", "extraLibFlags"}, []string{"implicitInputs", "implicitOutputs"})
partialLd, partialLdRE = remoteexec.StaticRules(pctx, "partialLd",
blueprint.RuleParams{
@@ -83,12 +83,13 @@
Command: "$reTemplate$ldCmd -fuse-ld=lld -nostdlib -no-pie -Wl,-r ${in} -o ${out} ${ldFlags}",
CommandDeps: []string{"$ldCmd"},
}, &remoteexec.REParams{
- Labels: map[string]string{"type": "link", "tool": "clang"},
- ExecStrategy: "${config.RECXXLinksExecStrategy}", Inputs: []string{"$inCommaList"},
+ Labels: map[string]string{"type": "link", "tool": "clang"},
+ ExecStrategy: "${config.RECXXLinksExecStrategy}",
+ Inputs: []string{"$inCommaList", "$implicitInputs"},
OutputFiles: []string{"${out}", "$implicitOutputs"},
ToolchainInputs: []string{"$ldCmd"},
Platform: map[string]string{remoteexec.PoolKey: "${config.RECXXLinksPool}"},
- }, []string{"ldCmd", "ldFlags"}, []string{"inCommaList", "implicitOutputs"})
+ }, []string{"ldCmd", "ldFlags"}, []string{"implicitInputs", "inCommaList", "implicitOutputs"})
ar = pctx.AndroidStaticRule("ar",
blueprint.RuleParams{
@@ -236,12 +237,12 @@
}, &remoteexec.REParams{
Labels: map[string]string{"type": "tool", "name": "abi-linker"},
ExecStrategy: "${config.REAbiLinkerExecStrategy}",
- Inputs: []string{"$sAbiLinkerLibs", "${out}.rsp", "$implicits"},
+ Inputs: []string{"$sAbiLinkerLibs", "${out}.rsp", "$implicitInputs"},
RSPFile: "${out}.rsp",
OutputFiles: []string{"$out"},
ToolchainInputs: []string{"$sAbiLinker"},
Platform: map[string]string{remoteexec.PoolKey: "${config.RECXXPool}"},
- }, []string{"symbolFilter", "arch", "exportedHeaderFlags"}, []string{"implicits"})
+ }, []string{"symbolFilter", "arch", "exportedHeaderFlags"}, []string{"implicitInputs"})
_ = pctx.SourcePathVariable("sAbiDiffer", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/header-abi-diff")
@@ -583,7 +584,7 @@
tidyFiles = append(tidyFiles, tidyFile)
rule := clangTidy
- if ctx.Config().IsEnvTrue("RBE_CLANG_TIDY") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CLANG_TIDY") {
rule = clangTidyRE
}
@@ -609,7 +610,7 @@
sAbiDumpFiles = append(sAbiDumpFiles, sAbiDumpFile)
dumpRule := sAbiDump
- if ctx.Config().IsEnvTrue("RBE_ABI_DUMPER") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_ABI_DUMPER") {
dumpRule = sAbiDumpRE
}
ctx.Build(pctx, android.BuildParams{
@@ -744,9 +745,10 @@
"ldFlags": flags.globalLdFlags + " " + flags.localLdFlags,
"crtEnd": crtEnd.String(),
}
- if ctx.Config().IsEnvTrue("RBE_CXX_LINKS") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CXX_LINKS") {
rule = ldRE
args["implicitOutputs"] = strings.Join(implicitOutputs.Strings(), ",")
+ args["implicitInputs"] = strings.Join(deps.Strings(), ",")
}
ctx.Build(pctx, android.BuildParams{
@@ -787,7 +789,7 @@
"arch": ctx.Arch().ArchType.Name,
"exportedHeaderFlags": exportedHeaderFlags,
}
- if ctx.Config().IsEnvTrue("RBE_ABI_LINKER") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_ABI_LINKER") {
rule = sAbiLinkRE
rbeImplicits := implicits.Strings()
for _, p := range strings.Split(exportedHeaderFlags, " ") {
@@ -796,7 +798,7 @@
rbeImplicits = append(rbeImplicits, p[2:])
}
}
- args["implicits"] = strings.Join(rbeImplicits, ",")
+ args["implicitInputs"] = strings.Join(rbeImplicits, ",")
}
ctx.Build(pctx, android.BuildParams{
Rule: rule,
@@ -910,9 +912,10 @@
"ldCmd": ldCmd,
"ldFlags": flags.globalLdFlags + " " + flags.localLdFlags,
}
- if ctx.Config().IsEnvTrue("RBE_CXX_LINKS") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CXX_LINKS") {
rule = partialLdRE
args["inCommaList"] = strings.Join(objFiles.Strings(), ",")
+ args["implicitInputs"] = strings.Join(deps.Strings(), ",")
}
ctx.Build(pctx, android.BuildParams{
Rule: rule,
diff --git a/cc/cc.go b/cc/cc.go
index 9196d47..70229be 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -280,6 +280,13 @@
// Set when both SDK and platform variants are exported to Make to trigger renaming the SDK
// variant to have a ".sdk" suffix.
SdkAndPlatformVariantVisibleToMake bool `blueprint:"mutated"`
+
+ // Normally Soong uses the directory structure to decide which modules
+ // should be included (framework) or excluded (non-framework) from the
+ // vendor snapshot, but this property allows a partner to exclude a
+ // module normally thought of as a framework module from the vendor
+ // snapshot.
+ Exclude_from_vendor_snapshot *bool
}
type VendorProperties struct {
@@ -1108,6 +1115,10 @@
return nil
}
+func (c *Module) ExcludeFromVendorSnapshot() bool {
+ return Bool(c.Properties.Exclude_from_vendor_snapshot)
+}
+
func isBionic(name string) bool {
switch name {
case "libc", "libm", "libdl", "libdl_android", "linker":
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 77b5c52..a4c0677 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -258,7 +258,8 @@
}
}
-func checkSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
+func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string, include bool) {
+ t.Helper()
mod, ok := ctx.ModuleForTests(moduleName, variant).Module().(android.OutputFileProducer)
if !ok {
t.Errorf("%q must have output\n", moduleName)
@@ -271,12 +272,27 @@
}
snapshotPath := filepath.Join(subDir, snapshotFilename)
- out := singleton.Output(snapshotPath)
- if out.Input.String() != outputFiles[0].String() {
- t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFiles[0])
+ if include {
+ out := singleton.Output(snapshotPath)
+ if out.Input.String() != outputFiles[0].String() {
+ t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFiles[0])
+ }
+ } else {
+ out := singleton.MaybeOutput(snapshotPath)
+ if out.Rule != nil {
+ t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0])
+ }
}
}
+func checkSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
+ checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true)
+}
+
+func checkSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
+ checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, false)
+}
+
func checkWriteFileOutput(t *testing.T, params android.TestingBuildParams, expected []string) {
t.Helper()
assertString(t, params.Rule.String(), android.WriteFile.String())
@@ -930,7 +946,7 @@
`)
}
-func TestVendorSnapshot(t *testing.T) {
+func TestVendorSnapshotCapture(t *testing.T) {
bp := `
cc_library {
name: "libvndk",
@@ -1063,6 +1079,215 @@
}
}
+func TestVendorSnapshotUse(t *testing.T) {
+ frameworkBp := `
+ cc_library {
+ name: "libvndk",
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
+ nocrt: true,
+ compile_multilib: "64",
+ }
+
+ cc_library {
+ name: "libvendor",
+ vendor: true,
+ nocrt: true,
+ no_libcrt: true,
+ stl: "none",
+ system_shared_libs: [],
+ compile_multilib: "64",
+ }
+
+ cc_binary {
+ name: "bin",
+ vendor: true,
+ nocrt: true,
+ no_libcrt: true,
+ stl: "none",
+ system_shared_libs: [],
+ compile_multilib: "64",
+ }
+`
+
+ vndkBp := `
+ vndk_prebuilt_shared {
+ name: "libvndk",
+ version: "BOARD",
+ target_arch: "arm64",
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
+ arch: {
+ arm64: {
+ srcs: ["libvndk.so"],
+ },
+ },
+ }
+`
+
+ vendorProprietaryBp := `
+ cc_library {
+ name: "libvendor_without_snapshot",
+ vendor: true,
+ nocrt: true,
+ no_libcrt: true,
+ stl: "none",
+ system_shared_libs: [],
+ compile_multilib: "64",
+ }
+
+ cc_library_shared {
+ name: "libclient",
+ vendor: true,
+ nocrt: true,
+ no_libcrt: true,
+ stl: "none",
+ system_shared_libs: [],
+ shared_libs: ["libvndk"],
+ static_libs: ["libvendor", "libvendor_without_snapshot"],
+ compile_multilib: "64",
+ }
+
+ cc_binary {
+ name: "bin_without_snapshot",
+ vendor: true,
+ nocrt: true,
+ no_libcrt: true,
+ stl: "none",
+ system_shared_libs: [],
+ static_libs: ["libvndk"],
+ compile_multilib: "64",
+ }
+
+ vendor_snapshot_static {
+ name: "libvndk",
+ version: "BOARD",
+ target_arch: "arm64",
+ vendor: true,
+ arch: {
+ arm64: {
+ src: "libvndk.a",
+ },
+ },
+ }
+
+ vendor_snapshot_shared {
+ name: "libvendor",
+ version: "BOARD",
+ target_arch: "arm64",
+ vendor: true,
+ arch: {
+ arm64: {
+ src: "libvendor.so",
+ },
+ },
+ }
+
+ vendor_snapshot_static {
+ name: "libvendor",
+ version: "BOARD",
+ target_arch: "arm64",
+ vendor: true,
+ arch: {
+ arm64: {
+ src: "libvendor.a",
+ },
+ },
+ }
+
+ vendor_snapshot_binary {
+ name: "bin",
+ version: "BOARD",
+ target_arch: "arm64",
+ vendor: true,
+ arch: {
+ arm64: {
+ src: "bin",
+ },
+ },
+ }
+`
+ depsBp := GatherRequiredDepsForTest(android.Android)
+
+ mockFS := map[string][]byte{
+ "deps/Android.bp": []byte(depsBp),
+ "framework/Android.bp": []byte(frameworkBp),
+ "vendor/Android.bp": []byte(vendorProprietaryBp),
+ "vendor/libvndk.a": nil,
+ "vendor/libvendor.a": nil,
+ "vendor/libvendor.so": nil,
+ "vendor/bin": nil,
+ "vndk/Android.bp": []byte(vndkBp),
+ "vndk/libvndk.so": nil,
+ }
+
+ config := TestConfig(buildDir, android.Android, nil, "", mockFS)
+ config.TestProductVariables.DeviceVndkVersion = StringPtr("BOARD")
+ config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
+ ctx := CreateTestContext()
+ ctx.Register(config)
+
+ _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "vendor/Android.bp", "vndk/Android.bp"})
+ android.FailIfErrored(t, errs)
+ _, errs = ctx.PrepareBuildActions(config)
+ android.FailIfErrored(t, errs)
+
+ sharedVariant := "android_vendor.BOARD_arm64_armv8-a_shared"
+ staticVariant := "android_vendor.BOARD_arm64_armv8-a_static"
+ binaryVariant := "android_vendor.BOARD_arm64_armv8-a"
+
+ // libclient uses libvndk.vndk.BOARD.arm64, libvendor.vendor_static.BOARD.arm64, libvendor_without_snapshot
+ libclientLdRule := ctx.ModuleForTests("libclient", sharedVariant).Rule("ld")
+ libclientFlags := libclientLdRule.Args["libFlags"]
+
+ for _, input := range [][]string{
+ []string{sharedVariant, "libvndk.vndk.BOARD.arm64"},
+ []string{staticVariant, "libvendor.vendor_static.BOARD.arm64"},
+ []string{staticVariant, "libvendor_without_snapshot"},
+ } {
+ outputPaths := getOutputPaths(ctx, input[0] /* variant */, []string{input[1]} /* module name */)
+ if !strings.Contains(libclientFlags, outputPaths[0].String()) {
+ t.Errorf("libflags for libclient must contain %#v, but was %#v", outputPaths[0], libclientFlags)
+ }
+ }
+
+ // bin_without_snapshot uses libvndk.vendor_static.BOARD.arm64
+ binWithoutSnapshotLdRule := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("ld")
+ binWithoutSnapshotFlags := binWithoutSnapshotLdRule.Args["libFlags"]
+ libVndkStaticOutputPaths := getOutputPaths(ctx, staticVariant, []string{"libvndk.vendor_static.BOARD.arm64"})
+ if !strings.Contains(binWithoutSnapshotFlags, libVndkStaticOutputPaths[0].String()) {
+ t.Errorf("libflags for bin_without_snapshot must contain %#v, but was %#v",
+ libVndkStaticOutputPaths[0], binWithoutSnapshotFlags)
+ }
+
+ // libvendor.so is installed by libvendor.vendor_shared.BOARD.arm64
+ ctx.ModuleForTests("libvendor.vendor_shared.BOARD.arm64", sharedVariant).Output("libvendor.so")
+
+ // libvendor_without_snapshot.so is installed by libvendor_without_snapshot
+ ctx.ModuleForTests("libvendor_without_snapshot", sharedVariant).Output("libvendor_without_snapshot.so")
+
+ // bin is installed by bin.vendor_binary.BOARD.arm64
+ ctx.ModuleForTests("bin.vendor_binary.BOARD.arm64", binaryVariant).Output("bin")
+
+ // bin_without_snapshot is installed by bin_without_snapshot
+ ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Output("bin_without_snapshot")
+
+ // libvendor and bin don't have vendor.BOARD variant
+ libvendorVariants := ctx.ModuleVariantsForTests("libvendor")
+ if inList(sharedVariant, libvendorVariants) {
+ t.Errorf("libvendor must not have variant %#v, but it does", sharedVariant)
+ }
+
+ binVariants := ctx.ModuleVariantsForTests("bin")
+ if inList(binaryVariant, binVariants) {
+ t.Errorf("bin must not have variant %#v, but it does", sharedVariant)
+ }
+}
+
func TestVendorSnapshotSanitizer(t *testing.T) {
bp := `
vendor_snapshot_static {
@@ -1096,6 +1321,203 @@
assertString(t, staticCfiModule.outputFile.Path().Base(), "libsnapshot.cfi.a")
}
+func assertExcludeFromVendorSnapshotIs(t *testing.T, c *Module, expected bool) {
+ t.Helper()
+ if c.ExcludeFromVendorSnapshot() != expected {
+ t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", c.String(), expected)
+ }
+}
+
+func TestVendorSnapshotExclude(t *testing.T) {
+
+ // This test verifies that the exclude_from_vendor_snapshot property
+ // makes its way from the Android.bp source file into the module data
+ // structure. It also verifies that modules are correctly included or
+ // excluded in the vendor snapshot based on their path (framework or
+ // vendor) and the exclude_from_vendor_snapshot property.
+
+ frameworkBp := `
+ cc_library_shared {
+ name: "libinclude",
+ srcs: ["src/include.cpp"],
+ vendor_available: true,
+ }
+ cc_library_shared {
+ name: "libexclude",
+ srcs: ["src/exclude.cpp"],
+ vendor: true,
+ exclude_from_vendor_snapshot: true,
+ }
+ `
+
+ vendorProprietaryBp := `
+ cc_library_shared {
+ name: "libvendor",
+ srcs: ["vendor.cpp"],
+ vendor: true,
+ }
+ `
+
+ depsBp := GatherRequiredDepsForTest(android.Android)
+
+ mockFS := map[string][]byte{
+ "deps/Android.bp": []byte(depsBp),
+ "framework/Android.bp": []byte(frameworkBp),
+ "framework/include.cpp": nil,
+ "framework/exclude.cpp": nil,
+ "device/Android.bp": []byte(vendorProprietaryBp),
+ "device/vendor.cpp": nil,
+ }
+
+ config := TestConfig(buildDir, android.Android, nil, "", mockFS)
+ config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
+ config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
+ ctx := CreateTestContext()
+ ctx.Register(config)
+
+ _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"})
+ android.FailIfErrored(t, errs)
+ _, errs = ctx.PrepareBuildActions(config)
+ android.FailIfErrored(t, errs)
+
+ // Test an include and exclude framework module.
+ assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libinclude", coreVariant).Module().(*Module), false)
+ assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libinclude", vendorVariant).Module().(*Module), false)
+ assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libexclude", vendorVariant).Module().(*Module), true)
+
+ // A vendor module is excluded, but by its path, not the
+ // exclude_from_vendor_snapshot property.
+ assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libvendor", vendorVariant).Module().(*Module), false)
+
+ // Verify the content of the vendor snapshot.
+
+ snapshotDir := "vendor-snapshot"
+ snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64")
+ snapshotSingleton := ctx.SingletonForTests("vendor-snapshot")
+
+ var includeJsonFiles []string
+ var excludeJsonFiles []string
+
+ for _, arch := range [][]string{
+ []string{"arm64", "armv8-a"},
+ []string{"arm", "armv7-a-neon"},
+ } {
+ archType := arch[0]
+ archVariant := arch[1]
+ archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant)
+
+ sharedVariant := fmt.Sprintf("android_vendor.VER_%s_%s_shared", archType, archVariant)
+ sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared")
+
+ // Included modules
+ checkSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant)
+ includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json"))
+
+ // Excluded modules
+ checkSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant)
+ excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json"))
+ checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant)
+ excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json"))
+ }
+
+ // Verify that each json file for an included module has a rule.
+ for _, jsonFile := range includeJsonFiles {
+ if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil {
+ t.Errorf("include json file %q not found", jsonFile)
+ }
+ }
+
+ // Verify that each json file for an excluded module has no rule.
+ for _, jsonFile := range excludeJsonFiles {
+ if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil {
+ t.Errorf("exclude json file %q found", jsonFile)
+ }
+ }
+}
+
+func TestVendorSnapshotExcludeInVendorProprietaryPathErrors(t *testing.T) {
+
+ // This test verifies that using the exclude_from_vendor_snapshot
+ // property on a module in a vendor proprietary path generates an
+ // error. These modules are already excluded, so we prohibit using the
+ // property in this way, which could add to confusion.
+
+ vendorProprietaryBp := `
+ cc_library_shared {
+ name: "libvendor",
+ srcs: ["vendor.cpp"],
+ vendor: true,
+ exclude_from_vendor_snapshot: true,
+ }
+ `
+
+ depsBp := GatherRequiredDepsForTest(android.Android)
+
+ mockFS := map[string][]byte{
+ "deps/Android.bp": []byte(depsBp),
+ "device/Android.bp": []byte(vendorProprietaryBp),
+ "device/vendor.cpp": nil,
+ }
+
+ config := TestConfig(buildDir, android.Android, nil, "", mockFS)
+ config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
+ config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
+ ctx := CreateTestContext()
+ ctx.Register(config)
+
+ _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "device/Android.bp"})
+ android.FailIfErrored(t, errs)
+
+ _, errs = ctx.PrepareBuildActions(config)
+ android.CheckErrorsAgainstExpectations(t, errs, []string{
+ `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
+ `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
+ })
+}
+
+func TestVendorSnapshotExcludeWithVendorAvailable(t *testing.T) {
+
+ // This test verifies that using the exclude_from_vendor_snapshot
+ // property on a module that is vendor available generates an error. A
+ // vendor available module must be captured in the vendor snapshot and
+ // must not built from source when building the vendor image against
+ // the vendor snapshot.
+
+ frameworkBp := `
+ cc_library_shared {
+ name: "libinclude",
+ srcs: ["src/include.cpp"],
+ vendor_available: true,
+ exclude_from_vendor_snapshot: true,
+ }
+ `
+
+ depsBp := GatherRequiredDepsForTest(android.Android)
+
+ mockFS := map[string][]byte{
+ "deps/Android.bp": []byte(depsBp),
+ "framework/Android.bp": []byte(frameworkBp),
+ "framework/include.cpp": nil,
+ }
+
+ config := TestConfig(buildDir, android.Android, nil, "", mockFS)
+ config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
+ config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
+ ctx := CreateTestContext()
+ ctx.Register(config)
+
+ _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp"})
+ android.FailIfErrored(t, errs)
+
+ _, errs = ctx.PrepareBuildActions(config)
+ android.CheckErrorsAgainstExpectations(t, errs, []string{
+ `module "libinclude\{.+,image:,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
+ `module "libinclude\{.+,image:,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
+ `module "libinclude\{.+,image:vendor.+,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
+ `module "libinclude\{.+,image:vendor.+,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
+ })
+}
+
func TestDoubleLoadableDepError(t *testing.T) {
// Check whether an error is emitted when a LLNDK depends on a non-double_loadable VNDK lib.
testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", `
diff --git a/cc/config/vndk.go b/cc/config/vndk.go
index 54f693e..6f2e807 100644
--- a/cc/config/vndk.go
+++ b/cc/config/vndk.go
@@ -18,10 +18,12 @@
// For these libraries, the vendor variants must be installed even if the device
// has VndkUseCoreVariant set.
var VndkMustUseVendorVariantList = []string{
+ "android.hardware.automotive.occupant_awareness-ndk_platform",
"android.hardware.light-ndk_platform",
"android.hardware.identity-ndk_platform",
"android.hardware.nfc@1.2",
"android.hardware.power-ndk_platform",
+ "android.hardware.rebootescrow-ndk_platform",
"android.hardware.vibrator-ndk_platform",
"libbinder",
"libcrypto",
diff --git a/cc/config/x86_windows_host.go b/cc/config/x86_windows_host.go
index cd0a508..b5b5553 100644
--- a/cc/config/x86_windows_host.go
+++ b/cc/config/x86_windows_host.go
@@ -49,7 +49,11 @@
windowsClangCppflags = []string{}
- windowsX86ClangCppflags = []string{}
+ windowsX86ClangCppflags = []string{
+ // Use SjLj exceptions for 32-bit. libgcc_eh implements SjLj
+ // exception model for 32-bit.
+ "-fsjlj-exceptions",
+ }
windowsX8664ClangCppflags = []string{}
diff --git a/cc/genrule.go b/cc/genrule.go
index 66d1784..cce4a83 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -84,7 +84,7 @@
// If not, we assume modules under proprietary paths are compatible for
// BOARD_VNDK_VERSION. The other modules are regarded as AOSP, that is
// PLATFORM_VNDK_VERSION.
- if vndkVersion == "current" || !isVendorProprietaryPath(ctx.ModuleDir()) {
+ if vndkVersion == "current" || !isVendorProprietaryModule(ctx) {
variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
} else {
variants = append(variants, VendorVariationPrefix+vndkVersion)
diff --git a/cc/image.go b/cc/image.go
index 4daed7c..ea6f567 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -223,7 +223,7 @@
// We assume that modules under proprietary paths are compatible for
// BOARD_VNDK_VERSION. The other modules are regarded as AOSP, or
// PLATFORM_VNDK_VERSION.
- if isVendorProprietaryPath(mctx.ModuleDir()) {
+ if isVendorProprietaryModule(mctx) {
vendorVariants = append(vendorVariants, boardVndkVersion)
} else {
vendorVariants = append(vendorVariants, platformVndkVersion)
@@ -249,7 +249,7 @@
platformVndkVersion,
boardVndkVersion,
)
- } else if isVendorProprietaryPath(mctx.ModuleDir()) {
+ } else if isVendorProprietaryModule(mctx) {
vendorVariants = append(vendorVariants, boardVndkVersion)
} else {
vendorVariants = append(vendorVariants, platformVndkVersion)
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index 9328a25..c6b0bf0 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -82,18 +82,19 @@
if version == "" {
version = LatestStubsVersionFor(mctx.Config(), name)
}
+ variations := target.Variations()
+ if mctx.Device() {
+ variations = append(variations,
+ blueprint.Variation{Mutator: "image", Variation: android.CoreVariation},
+ blueprint.Variation{Mutator: "version", Variation: version})
+ }
if mt.linkTypes == nil {
- mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "image", Variation: android.CoreVariation},
- {Mutator: "version", Variation: version},
- }...), dependencyTag, name)
+ mctx.AddFarVariationDependencies(variations, dependencyTag, name)
} else {
for _, linkType := range mt.linkTypes {
- mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "image", Variation: android.CoreVariation},
- {Mutator: "link", Variation: linkType},
- {Mutator: "version", Variation: version},
- }...), dependencyTag, name)
+ libVariations := append(variations,
+ blueprint.Variation{Mutator: "link", Variation: linkType})
+ mctx.AddFarVariationDependencies(libVariations, dependencyTag, name)
}
}
}
@@ -118,6 +119,10 @@
ccModule := member.Variants()[0].(*Module)
+ if proptools.Bool(ccModule.VendorProperties.Vendor_available) {
+ pbm.AddProperty("vendor_available", true)
+ }
+
sdkVersion := ccModule.SdkVersion()
if sdkVersion != "" {
pbm.AddProperty("sdk_version", sdkVersion)
diff --git a/cc/pgo.go b/cc/pgo.go
index 674e1bb..6bf0ad0 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -290,17 +290,16 @@
// Add flags to profile this module based on its profile_kind
if props.ShouldProfileModule && props.isInstrumentation() {
- props.addInstrumentationProfileGatherFlags(ctx, flags)
// Instrumentation PGO use and gather flags cannot coexist.
- return flags
+ return props.addInstrumentationProfileGatherFlags(ctx, flags)
} else if props.ShouldProfileModule && props.isSampling() {
- props.addSamplingProfileGatherFlags(ctx, flags)
+ flags = props.addSamplingProfileGatherFlags(ctx, flags)
} else if ctx.DeviceConfig().SamplingPGO() {
- props.addSamplingProfileGatherFlags(ctx, flags)
+ flags = props.addSamplingProfileGatherFlags(ctx, flags)
}
if !ctx.Config().IsEnvTrue("ANDROID_PGO_NO_PROFILE_USE") {
- props.addProfileUseFlags(ctx, flags)
+ flags = props.addProfileUseFlags(ctx, flags)
}
return flags
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 2243082..174dcfe 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -48,6 +48,10 @@
// higher number of "optimized out" stack variables.
// b/112437883.
"-mllvm", "-instcombine-lower-dbg-declare=0",
+ // TODO(b/159343917): HWASan and GlobalISel don't play nicely, and
+ // GlobalISel is the default at -O0 on aarch64.
+ "-mllvm", "--aarch64-enable-global-isel-at-O=-1",
+ "-mllvm", "-fast-isel=false",
}
cfiCflags = []string{"-flto", "-fsanitize-cfi-cross-dso",
@@ -738,7 +742,7 @@
// as vendor snapshot. Such modules must create both cfi and non-cfi variants,
// except for ones which explicitly disable cfi.
func needsCfiForVendorSnapshot(mctx android.TopDownMutatorContext) bool {
- if isVendorProprietaryPath(mctx.ModuleDir()) {
+ if isVendorProprietaryModule(mctx) {
return false
}
@@ -1011,10 +1015,12 @@
// static executable gets static runtime libs
depTag := libraryDependencyTag{Kind: staticLibraryDependency}
- mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{
- {Mutator: "link", Variation: "static"},
- c.ImageVariation(),
- }...), depTag, deps...)
+ variations := append(mctx.Target().Variations(),
+ blueprint.Variation{Mutator: "link", Variation: "static"})
+ if c.Device() {
+ variations = append(variations, c.ImageVariation())
+ }
+ mctx.AddFarVariationDependencies(variations, depTag, deps...)
} else if !c.static() && !c.header() {
// If we're using snapshots and in vendor, redirect to snapshot whenever possible
if c.VndkVersion() == mctx.DeviceConfig().VndkVersion() {
@@ -1026,10 +1032,12 @@
// dynamic executable and shared libs get shared runtime libs
depTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: earlyLibraryDependency}
- mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{
- {Mutator: "link", Variation: "shared"},
- c.ImageVariation(),
- }...), depTag, runtimeLibrary)
+ variations := append(mctx.Target().Variations(),
+ blueprint.Variation{Mutator: "link", Variation: "shared"})
+ if c.Device() {
+ variations = append(variations, c.ImageVariation())
+ }
+ mctx.AddFarVariationDependencies(variations, depTag, runtimeLibrary)
}
// static lib does not have dependency to the runtime library. The
// dependency will be added to the executables or shared libs using
diff --git a/cc/snapshot_utils.go b/cc/snapshot_utils.go
index 4012def..f27d166 100644
--- a/cc/snapshot_utils.go
+++ b/cc/snapshot_utils.go
@@ -61,7 +61,7 @@
func isSnapshotAware(ctx android.ModuleContext, m *Module) bool {
if _, _, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m); ok {
return ctx.Config().VndkSnapshotBuildArtifacts()
- } else if isVendorSnapshotModule(m, ctx.ModuleDir()) {
+ } else if isVendorSnapshotModule(m, isVendorProprietaryPath(ctx.ModuleDir())) {
return true
}
return false
diff --git a/cc/stl.go b/cc/stl.go
index 4e74c7f..e18fe95 100644
--- a/cc/stl.go
+++ b/cc/stl.go
@@ -239,11 +239,6 @@
flags.Local.CppFlags = append(flags.Local.CppFlags, "-nostdinc++")
flags.extraLibFlags = append(flags.extraLibFlags, "-nostdlib++")
if ctx.Windows() {
- // Use SjLj exceptions for 32-bit. libgcc_eh implements SjLj
- // exception model for 32-bit.
- if ctx.Arch().ArchType == android.X86 {
- flags.Local.CppFlags = append(flags.Local.CppFlags, "-fsjlj-exceptions")
- }
flags.Local.CppFlags = append(flags.Local.CppFlags,
// Disable visiblity annotations since we're using static
// libc++.
diff --git a/cc/test.go b/cc/test.go
index a805647..ee103ff 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -344,6 +344,12 @@
}
func (test *testBinary) install(ctx ModuleContext, file android.Path) {
+ // TODO: (b/167308193) Switch to /data/local/tests/unrestricted as the default install base.
+ testInstallBase := "/data/local/tmp"
+ if ctx.inVendor() || ctx.useVndk() {
+ testInstallBase = "/data/local/tests/vendor"
+ }
+
dataSrcPaths := android.PathsForModuleSrc(ctx, test.Properties.Data)
for _, dataSrcPath := range dataSrcPaths {
@@ -411,7 +417,7 @@
}
test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config,
- test.Properties.Test_config_template, test.Properties.Test_suites, configs, test.Properties.Auto_gen_config)
+ test.Properties.Test_config_template, test.Properties.Test_suites, configs, test.Properties.Auto_gen_config, testInstallBase)
test.extraTestConfigs = android.PathsForModuleSrc(ctx, test.Properties.Test_options.Extra_test_configs)
diff --git a/cc/testing.go b/cc/testing.go
index 06e5f83..52f0829 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -527,7 +527,9 @@
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
+ ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
+ ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
android.RegisterPrebuiltMutators(ctx)
RegisterRequiredBuildComponentsForTest(ctx)
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index 93aece4..0219b84 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -508,18 +508,46 @@
return false
}
+func isVendorProprietaryModule(ctx android.BaseModuleContext) bool {
+
+ // Any module in a vendor proprietary path is a vendor proprietary
+ // module.
+
+ if isVendorProprietaryPath(ctx.ModuleDir()) {
+ return true
+ }
+
+ // However if the module is not in a vendor proprietary path, it may
+ // still be a vendor proprietary module. This happens for cc modules
+ // that are excluded from the vendor snapshot, and it means that the
+ // vendor has assumed control of the framework-provided module.
+
+ if c, ok := ctx.Module().(*Module); ok {
+ if c.ExcludeFromVendorSnapshot() {
+ return true
+ }
+ }
+
+ return false
+}
+
// Determine if a module is going to be included in vendor snapshot or not.
//
// Targets of vendor snapshot are "vendor: true" or "vendor_available: true" modules in
// AOSP. They are not guaranteed to be compatible with older vendor images. (e.g. might
// depend on newer VNDK) So they are captured as vendor snapshot To build older vendor
// image and newer system image altogether.
-func isVendorSnapshotModule(m *Module, moduleDir string) bool {
+func isVendorSnapshotModule(m *Module, inVendorProprietaryPath bool) bool {
if !m.Enabled() || m.Properties.HideFromMake {
return false
}
// skip proprietary modules, but include all VNDK (static)
- if isVendorProprietaryPath(moduleDir) && !m.IsVndk() {
+ if inVendorProprietaryPath && !m.IsVndk() {
+ return false
+ }
+ // If the module would be included based on its path, check to see if
+ // the module is marked to be excluded. If so, skip it.
+ if m.ExcludeFromVendorSnapshot() {
return false
}
if m.Target().Os.Class != android.Device {
@@ -791,7 +819,25 @@
}
moduleDir := ctx.ModuleDir(module)
- if !isVendorSnapshotModule(m, moduleDir) {
+ inVendorProprietaryPath := isVendorProprietaryPath(moduleDir)
+
+ if m.ExcludeFromVendorSnapshot() {
+ if inVendorProprietaryPath {
+ // Error: exclude_from_vendor_snapshot applies
+ // to framework-path modules only.
+ ctx.Errorf("module %q in vendor proprietary path %q may not use \"exclude_from_vendor_snapshot: true\"", m.String(), moduleDir)
+ return
+ }
+ if Bool(m.VendorProperties.Vendor_available) {
+ // Error: may not combine "vendor_available:
+ // true" with "exclude_from_vendor_snapshot:
+ // true".
+ ctx.Errorf("module %q may not use both \"vendor_available: true\" and \"exclude_from_vendor_snapshot: true\"", m.String())
+ return
+ }
+ }
+
+ if !isVendorSnapshotModule(m, inVendorProprietaryPath) {
return
}
diff --git a/cc/vndk.go b/cc/vndk.go
index 23bb095..9a2fa09 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -505,18 +505,25 @@
}}
}
+// PrebuiltEtcModule interface
func (txt *vndkLibrariesTxt) OutputFile() android.OutputPath {
return txt.outputFile
}
-func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) {
- return android.Paths{txt.outputFile}, nil
+// PrebuiltEtcModule interface
+func (txt *vndkLibrariesTxt) BaseDir() string {
+ return "etc"
}
+// PrebuiltEtcModule interface
func (txt *vndkLibrariesTxt) SubDir() string {
return ""
}
+func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) {
+ return android.Paths{txt.outputFile}, nil
+}
+
func VndkSnapshotSingleton() android.Singleton {
return &vndkSnapshotSingleton{}
}
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index f22ee47..3ef8b8d 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -130,14 +130,20 @@
// Add a new library path to the map. Ensure that the build path to the library exists.
func (libPaths LibraryPaths) AddLibraryPath(ctx android.PathContext, lib string, hostPath, installPath android.Path) {
- if hostPath != nil {
- // Add a library only if the build path to it is known.
+ if hostPath != nil && installPath != nil {
+ // Add a library only if the build and install path to it is known.
libPaths.addLibraryPath(ctx, lib, hostPath, installPath)
- } else if !ctx.Config().AllowMissingDependencies() {
- // Error on libraries with unknown build paths, unless missing dependencies are allowed.
- android.ReportPathErrorf(ctx, "unknown build path to <uses-library> '%s'", lib)
+ } else if ctx.Config().AllowMissingDependencies() {
+ // If missing dependencies are allowed, the build shouldn't fail when a <uses-library> is
+ // not found. However, this is likely to result is disabling dexpreopt, as it won't be
+ // possible to construct class loader context without on-host and on-device library paths.
} else {
- // Not adding a library to the map will likely result in disabling dexpreopt.
+ // Error on libraries with unknown paths.
+ if hostPath == nil {
+ android.ReportPathErrorf(ctx, "unknown build path to <uses-library> '%s'", lib)
+ } else {
+ android.ReportPathErrorf(ctx, "unknown install path to <uses-library> '%s'", lib)
+ }
}
}
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index 0f7b8df..5dd2a86 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -28,14 +28,17 @@
func init() {
pctx.Import("android/soong/android")
+ RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext)
+}
- android.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
- android.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
- android.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
- android.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
- android.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
- android.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
- android.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
+func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
+ ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
+ ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
+ ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
+ ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
+ ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
+ ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
}
type prebuiltEtcProperties struct {
@@ -70,6 +73,7 @@
type PrebuiltEtcModule interface {
android.Module
+ BaseDir() string
SubDir() string
OutputFile() android.OutputPath
}
@@ -167,6 +171,16 @@
return proptools.String(p.properties.Relative_install_path)
}
+func (p *PrebuiltEtc) BaseDir() string {
+ // If soc install dir was specified and SOC specific is set, set the installDirPath to the specified
+ // socInstallDirBase.
+ installBaseDir := p.installDirBase
+ if p.SocSpecific() && p.socInstallDirBase != "" {
+ installBaseDir = p.socInstallDirBase
+ }
+ return installBaseDir
+}
+
func (p *PrebuiltEtc) Installable() bool {
return p.properties.Installable == nil || android.Bool(p.properties.Installable)
}
@@ -191,13 +205,7 @@
ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
}
- // If soc install dir was specified and SOC specific is set, set the installDirPath to the specified
- // socInstallDirBase.
- installBaseDir := p.installDirBase
- if ctx.SocSpecific() && p.socInstallDirBase != "" {
- installBaseDir = p.socInstallDirBase
- }
- p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir())
+ p.installDirPath = android.PathForModuleInstall(ctx, p.BaseDir(), p.SubDir())
// This ensures that outputFilePath has the correct name for others to
// use, as the source file may have a different name.
diff --git a/java/aar.go b/java/aar.go
index 0f5e30d..667dd9d 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -378,6 +378,10 @@
exportPackage = aarDep.ExportPackage()
}
+ if dep, ok := module.(Dependency); ok {
+ sdkLibraries.AddLibraryPaths(dep.ExportedSdkLibs())
+ }
+
switch ctx.OtherModuleDependencyTag(module) {
case instrumentationForTag:
// Nothing, instrumentationForTag is treated as libTag for javac but not for aapt2.
@@ -399,9 +403,6 @@
sharedLibs = append(sharedLibs, exportPackage)
}
case staticLibTag:
- if dep, ok := module.(Dependency); ok {
- sdkLibraries.AddLibraryPaths(dep.ExportedSdkLibs())
- }
if exportPackage != nil {
transitiveStaticLibs = append(transitiveStaticLibs, aarDep.ExportedStaticPackages()...)
transitiveStaticLibs = append(transitiveStaticLibs, exportPackage)
diff --git a/java/android_manifest.go b/java/android_manifest.go
index f45ebe8..41fcafe 100644
--- a/java/android_manifest.go
+++ b/java/android_manifest.go
@@ -80,7 +80,7 @@
args = append(args, "--use-embedded-dex")
}
- for usesLib, _ := range sdkLibraries {
+ for _, usesLib := range android.SortedStringKeys(sdkLibraries) {
if inList(usesLib, optionalUsesLibs) {
args = append(args, "--optional-uses-library", usesLib)
} else {
diff --git a/java/androidmk.go b/java/androidmk.go
index 9d5885f..65c44a3 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -166,6 +166,7 @@
if !BoolDefault(j.testProperties.Auto_gen_config, true) {
entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
}
+ entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
})
return entriesList
@@ -440,6 +441,7 @@
}
androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
androidMkWriteTestData(a.data, entries)
+ entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
})
return entriesList
diff --git a/java/app.go b/java/app.go
index 34f96dd..dbc09e9 100755
--- a/java/app.go
+++ b/java/app.go
@@ -118,17 +118,17 @@
}
func SupportedAbis(ctx android.ModuleContext) []string {
- abiName := func(archVar string, deviceArch string) string {
+ abiName := func(targetIdx int, deviceArch string) string {
if abi, found := TargetCpuAbi[deviceArch]; found {
return abi
}
- ctx.ModuleErrorf("Invalid %s: %s", archVar, deviceArch)
+ ctx.ModuleErrorf("Target %d has invalid Arch: %s", targetIdx, deviceArch)
return "BAD_ABI"
}
- result := []string{abiName("TARGET_ARCH", ctx.DeviceConfig().DeviceArch())}
- if s := ctx.DeviceConfig().DeviceSecondaryArch(); s != "" {
- result = append(result, abiName("TARGET_2ND_ARCH", s))
+ var result []string
+ for i, target := range ctx.Config().Targets[android.Android] {
+ result = append(result, abiName(i, target.Arch.ArchType.String()))
}
return result
}
@@ -268,6 +268,9 @@
// the logging parent of this app.
Logging_parent *string
+
+ // Whether to rename the package in resources to the override name rather than the base name. Defaults to true.
+ Rename_resources_package *bool
}
// runtime_resource_overlay properties that can be overridden by override_runtime_resource_overlay
@@ -284,8 +287,6 @@
aapt
android.OverridableModuleBase
- usesLibrary usesLibrary
-
certificate Certificate
appProperties appProperties
@@ -507,10 +508,23 @@
!a.IsForPlatform() || a.appProperties.AlwaysPackageNativeLibs
}
+func generateAaptRenamePackageFlags(packageName string, renameResourcesPackage bool) []string {
+ aaptFlags := []string{"--rename-manifest-package " + packageName}
+ if renameResourcesPackage {
+ // Required to rename the package name in the resources table.
+ aaptFlags = append(aaptFlags, "--rename-resources-package "+packageName)
+ }
+ return aaptFlags
+}
+
func (a *AndroidApp) OverriddenManifestPackageName() string {
return a.overriddenManifestPackageName
}
+func (a *AndroidApp) renameResourcesPackage() bool {
+ return proptools.BoolDefault(a.overridableAppProperties.Rename_resources_package, true)
+}
+
func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
a.aapt.usesNonSdkApis = Bool(a.Module.deviceProperties.Platform_apis)
@@ -543,7 +557,7 @@
if !overridden {
manifestPackageName = *a.overridableAppProperties.Package_name
}
- aaptLinkFlags = append(aaptLinkFlags, "--rename-manifest-package "+manifestPackageName)
+ aaptLinkFlags = append(aaptLinkFlags, generateAaptRenamePackageFlags(manifestPackageName, a.renameResourcesPackage())...)
a.overriddenManifestPackageName = manifestPackageName
}
@@ -803,18 +817,32 @@
// Build a final signed app package.
packageFile := android.PathForModuleOut(ctx, a.installApkName+".apk")
+ v4SigningRequested := Bool(a.Module.deviceProperties.V4_signature)
+ var v4SignatureFile android.WritablePath = nil
+ if v4SigningRequested {
+ v4SignatureFile = android.PathForModuleOut(ctx, a.installApkName+".apk.idsig")
+ }
var lineageFile android.Path
if lineage := String(a.overridableAppProperties.Lineage); lineage != "" {
lineageFile = android.PathForModuleSrc(ctx, lineage)
}
- CreateAndSignAppPackage(ctx, packageFile, a.exportPackage, jniJarFile, dexJarFile, certificates, apkDeps, lineageFile)
+ CreateAndSignAppPackage(ctx, packageFile, a.exportPackage, jniJarFile, dexJarFile, certificates, apkDeps, v4SignatureFile, lineageFile)
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, lineageFile)
+ if v4SigningRequested {
+ v4SignatureFile = android.PathForModuleOut(ctx, a.installApkName+"_"+split.suffix+".apk.idsig")
+ }
+ CreateAndSignAppPackage(ctx, packageFile, split.path, nil, nil, certificates, apkDeps, v4SignatureFile, lineageFile)
a.extraOutputFiles = append(a.extraOutputFiles, packageFile)
+ if v4SigningRequested {
+ a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile)
+ }
}
// Build an app bundle.
@@ -1018,8 +1046,7 @@
module.AddProperties(
&module.aaptProperties,
&module.appProperties,
- &module.overridableAppProperties,
- &module.usesLibrary.usesLibraryProperties)
+ &module.overridableAppProperties)
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
@@ -1140,7 +1167,6 @@
&module.appProperties,
&module.appTestProperties,
&module.overridableAppProperties,
- &module.usesLibrary.usesLibraryProperties,
&module.testProperties)
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
@@ -1189,8 +1215,7 @@
&module.aaptProperties,
&module.appProperties,
&module.appTestHelperAppProperties,
- &module.overridableAppProperties,
- &module.usesLibrary.usesLibraryProperties)
+ &module.overridableAppProperties)
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
@@ -1533,7 +1558,7 @@
if lineage := String(a.properties.Lineage); lineage != "" {
lineageFile = android.PathForModuleSrc(ctx, lineage)
}
- SignAppPackage(ctx, signed, dexOutput, certificates, lineageFile)
+ SignAppPackage(ctx, signed, dexOutput, certificates, nil, lineageFile)
a.outputFile = signed
} else {
alignedApk := android.PathForModuleOut(ctx, "zip-aligned", apkFilename)
@@ -1704,7 +1729,6 @@
module := &AndroidTestImport{}
module.AddProperties(&module.properties)
module.AddProperties(&module.dexpreoptProperties)
- module.AddProperties(&module.usesLibrary.usesLibraryProperties)
module.AddProperties(&module.testProperties)
module.AddProperties(&module.testImportProperties)
module.populateAllVariantStructs()
@@ -1807,7 +1831,7 @@
if !overridden {
manifestPackageName = *r.overridableProperties.Package_name
}
- aaptLinkFlags = append(aaptLinkFlags, "--rename-manifest-package "+manifestPackageName)
+ aaptLinkFlags = append(aaptLinkFlags, generateAaptRenamePackageFlags(manifestPackageName, false)...)
}
if r.overridableProperties.Target_package_name != nil {
aaptLinkFlags = append(aaptLinkFlags,
@@ -1823,7 +1847,7 @@
if lineage := String(r.properties.Lineage); lineage != "" {
lineageFile = android.PathForModuleSrc(ctx, lineage)
}
- SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates, lineageFile)
+ SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates, nil, lineageFile)
r.certificate = certificates[0]
r.outputFile = signed
@@ -1888,6 +1912,11 @@
// If true, the list of uses_libs and optional_uses_libs modules must match the AndroidManifest.xml file. Defaults
// to true if either uses_libs or optional_uses_libs is set. Will unconditionally default to true in the future.
Enforce_uses_libs *bool
+
+ // Optional name of the <uses-library> provided by this module. This is needed for non-SDK
+ // libraries, because SDK ones are automatically picked up by Soong. The <uses-library> name
+ // normally is the same as the module name, but there are exceptions.
+ Provides_uses_lib *string
}
// usesLibrary provides properties and helper functions for AndroidApp and AndroidAppImport to verify that the
@@ -1918,11 +1947,11 @@
if hasFrameworkLibs {
// Dexpreopt needs paths to the dex jars of these libraries in order to construct
// class loader context for dex2oat. Add them as a dependency with a special tag.
- ctx.AddVariationDependencies(nil, usesLibTag,
+ ctx.AddVariationDependencies(nil, usesLibCompatTag,
"org.apache.http.legacy",
"android.hidl.base-V1.0-java",
"android.hidl.manager-V1.0-java")
- ctx.AddVariationDependencies(nil, usesLibTag, optionalUsesLibs...)
+ ctx.AddVariationDependencies(nil, usesLibCompatTag, optionalUsesLibs...)
}
}
}
@@ -1940,30 +1969,27 @@
usesLibPaths := make(dexpreopt.LibraryPaths)
if !ctx.Config().UnbundledBuild() {
- ctx.VisitDirectDepsWithTag(usesLibTag, func(m android.Module) {
- dep := ctx.OtherModuleName(m)
- if lib, ok := m.(Dependency); ok {
- buildPath := lib.DexJarBuildPath()
- if buildPath == nil {
- ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must"+
- " produce a dex jar, does it have installable: true?", dep)
- return
- }
+ ctx.VisitDirectDeps(func(m android.Module) {
+ tag := ctx.OtherModuleDependencyTag(m)
+ if tag == usesLibTag || tag == usesLibCompatTag {
+ dep := ctx.OtherModuleName(m)
- var devicePath string
- installPath := lib.DexJarInstallPath()
- if installPath == nil {
- devicePath = filepath.Join("/system/framework", dep+".jar")
+ if lib, ok := m.(Dependency); ok {
+ buildPath := lib.DexJarBuildPath()
+ installPath := lib.DexJarInstallPath()
+ if installPath == nil && tag == usesLibCompatTag {
+ // assume that compatibility libraries are in /system/framework
+ installPath = android.PathForModuleInstall(ctx, "framework", dep+".jar")
+ }
+ usesLibPaths.AddLibraryPath(ctx, dep, buildPath, installPath)
+
+ } else if ctx.Config().AllowMissingDependencies() {
+ ctx.AddMissingDependencies([]string{dep})
+
} else {
- devicePath = android.InstallPathToOnDevicePath(ctx, installPath.(android.InstallPath))
+ ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be "+
+ "a java library", dep)
}
-
- usesLibPaths[dep] = &dexpreopt.LibraryPath{buildPath, devicePath}
- } else if ctx.Config().AllowMissingDependencies() {
- ctx.AddMissingDependencies([]string{dep})
- } else {
- ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be "+
- "a java library", dep)
}
})
}
diff --git a/java/app_builder.go b/java/app_builder.go
index 014bd54..69e462c 100644
--- a/java/app_builder.go
+++ b/java/app_builder.go
@@ -52,7 +52,7 @@
})
func CreateAndSignAppPackage(ctx android.ModuleContext, outputFile android.WritablePath,
- packageFile, jniJarFile, dexJarFile android.Path, certificates []Certificate, deps android.Paths, lineageFile android.Path) {
+ packageFile, jniJarFile, dexJarFile android.Path, certificates []Certificate, deps android.Paths, v4SignatureFile android.WritablePath, lineageFile android.Path) {
unsignedApkName := strings.TrimSuffix(outputFile.Base(), ".apk") + "-unsigned.apk"
unsignedApk := android.PathForModuleOut(ctx, unsignedApkName)
@@ -73,10 +73,10 @@
Implicits: deps,
})
- SignAppPackage(ctx, outputFile, unsignedApk, certificates, lineageFile)
+ SignAppPackage(ctx, outputFile, unsignedApk, certificates, v4SignatureFile, lineageFile)
}
-func SignAppPackage(ctx android.ModuleContext, signedApk android.WritablePath, unsignedApk android.Path, certificates []Certificate, lineageFile android.Path) {
+func SignAppPackage(ctx android.ModuleContext, signedApk android.WritablePath, unsignedApk android.Path, certificates []Certificate, v4SignatureFile android.WritablePath, lineageFile android.Path) {
var certificateArgs []string
var deps android.Paths
@@ -87,6 +87,11 @@
outputFiles := android.WritablePaths{signedApk}
var flags []string
+ if v4SignatureFile != nil {
+ outputFiles = append(outputFiles, v4SignatureFile)
+ flags = append(flags, "--enable-v4")
+ }
+
if lineageFile != nil {
flags = append(flags, "--lineage", lineageFile.String())
deps = append(deps, lineageFile)
@@ -97,7 +102,7 @@
"certificates": strings.Join(certificateArgs, " "),
"flags": strings.Join(flags, " "),
}
- if ctx.Config().IsEnvTrue("RBE_SIGNAPK") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_SIGNAPK") {
rule = SignapkRE
args["implicits"] = strings.Join(deps.Strings(), ",")
args["outCommaList"] = strings.Join(outputFiles.Strings(), ",")
@@ -236,7 +241,7 @@
args := map[string]string{
"jarArgs": strings.Join(proptools.NinjaAndShellEscapeList(jarArgs), " "),
}
- if ctx.Config().IsEnvTrue("RBE_ZIP") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_ZIP") {
rule = zipRE
args["implicits"] = strings.Join(deps.Strings(), ",")
}
diff --git a/java/app_test.go b/java/app_test.go
index b8d8616..5367971 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -176,16 +176,17 @@
set: "prebuilts/apks/app.apks",
}`
testCases := []struct {
- name string
- deviceArch *string
- deviceSecondaryArch *string
- aaptPrebuiltDPI []string
- sdkVersion int
- expected map[string]string
+ name string
+ targets []android.Target
+ aaptPrebuiltDPI []string
+ sdkVersion int
+ expected map[string]string
}{
{
- name: "One",
- deviceArch: proptools.StringPtr("x86"),
+ name: "One",
+ targets: []android.Target{
+ {Os: android.Android, Arch: android.Arch{ArchType: android.X86}},
+ },
aaptPrebuiltDPI: []string{"ldpi", "xxhdpi"},
sdkVersion: 29,
expected: map[string]string{
@@ -197,11 +198,13 @@
},
},
{
- name: "Two",
- deviceArch: proptools.StringPtr("x86_64"),
- deviceSecondaryArch: proptools.StringPtr("x86"),
- aaptPrebuiltDPI: nil,
- sdkVersion: 30,
+ name: "Two",
+ targets: []android.Target{
+ {Os: android.Android, Arch: android.Arch{ArchType: android.X86_64}},
+ {Os: android.Android, Arch: android.Arch{ArchType: android.X86}},
+ },
+ aaptPrebuiltDPI: nil,
+ sdkVersion: 30,
expected: map[string]string{
"abis": "X86_64,X86",
"allow-prereleased": "false",
@@ -216,8 +219,7 @@
config := testAppConfig(nil, bp, nil)
config.TestProductVariables.AAPTPrebuiltDPI = test.aaptPrebuiltDPI
config.TestProductVariables.Platform_sdk_version = &test.sdkVersion
- config.TestProductVariables.DeviceArch = test.deviceArch
- config.TestProductVariables.DeviceSecondaryArch = test.deviceSecondaryArch
+ config.Targets[android.Android] = test.targets
ctx := testContext()
run(t, ctx, config)
module := ctx.ModuleForTests("foo", "android_common")
@@ -1655,6 +1657,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
@@ -1777,52 +1839,125 @@
base: "foo",
package_name: "org.dandroid.bp",
}
+
+ override_android_app {
+ name: "baz_no_rename_resources",
+ base: "foo",
+ package_name: "org.dandroid.bp",
+ rename_resources_package: false,
+ }
+
+ android_app {
+ name: "foo_no_rename_resources",
+ srcs: ["a.java"],
+ certificate: "expiredkey",
+ overrides: ["qux"],
+ rename_resources_package: false,
+ sdk_version: "current",
+ }
+
+ override_android_app {
+ name: "baz_base_no_rename_resources",
+ base: "foo_no_rename_resources",
+ package_name: "org.dandroid.bp",
+ }
+
+ override_android_app {
+ name: "baz_override_base_rename_resources",
+ base: "foo_no_rename_resources",
+ package_name: "org.dandroid.bp",
+ rename_resources_package: true,
+ }
`)
expectedVariants := []struct {
- moduleName string
- variantName string
- apkName string
- apkPath string
- certFlag string
- lineageFlag string
- overrides []string
- aaptFlag string
- logging_parent string
+ name string
+ moduleName string
+ variantName string
+ apkName string
+ apkPath string
+ certFlag string
+ lineageFlag string
+ overrides []string
+ packageFlag string
+ renameResources bool
+ logging_parent string
}{
{
- moduleName: "foo",
- variantName: "android_common",
- apkPath: "/target/product/test_device/system/app/foo/foo.apk",
- certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
- lineageFlag: "",
- overrides: []string{"qux"},
- aaptFlag: "",
- logging_parent: "",
+ name: "foo",
+ moduleName: "foo",
+ variantName: "android_common",
+ apkPath: "/target/product/test_device/system/app/foo/foo.apk",
+ certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
+ lineageFlag: "",
+ overrides: []string{"qux"},
+ packageFlag: "",
+ renameResources: false,
+ logging_parent: "",
},
{
- moduleName: "bar",
- variantName: "android_common_bar",
- apkPath: "/target/product/test_device/system/app/bar/bar.apk",
- certFlag: "cert/new_cert.x509.pem cert/new_cert.pk8",
- lineageFlag: "--lineage lineage.bin",
- overrides: []string{"qux", "foo"},
- aaptFlag: "",
- logging_parent: "bah",
+ name: "foo",
+ moduleName: "bar",
+ variantName: "android_common_bar",
+ apkPath: "/target/product/test_device/system/app/bar/bar.apk",
+ certFlag: "cert/new_cert.x509.pem cert/new_cert.pk8",
+ lineageFlag: "--lineage lineage.bin",
+ overrides: []string{"qux", "foo"},
+ packageFlag: "",
+ renameResources: false,
+ logging_parent: "bah",
},
{
- moduleName: "baz",
- variantName: "android_common_baz",
- apkPath: "/target/product/test_device/system/app/baz/baz.apk",
- certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
- lineageFlag: "",
- overrides: []string{"qux", "foo"},
- aaptFlag: "--rename-manifest-package org.dandroid.bp",
- logging_parent: "",
+ name: "foo",
+ moduleName: "baz",
+ variantName: "android_common_baz",
+ apkPath: "/target/product/test_device/system/app/baz/baz.apk",
+ certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
+ lineageFlag: "",
+ overrides: []string{"qux", "foo"},
+ packageFlag: "org.dandroid.bp",
+ renameResources: true,
+ logging_parent: "",
+ },
+ {
+ name: "foo",
+ moduleName: "baz_no_rename_resources",
+ variantName: "android_common_baz_no_rename_resources",
+ apkPath: "/target/product/test_device/system/app/baz_no_rename_resources/baz_no_rename_resources.apk",
+ certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
+ lineageFlag: "",
+ overrides: []string{"qux", "foo"},
+ packageFlag: "org.dandroid.bp",
+ renameResources: false,
+ logging_parent: "",
+ },
+ {
+ name: "foo_no_rename_resources",
+ moduleName: "baz_base_no_rename_resources",
+ variantName: "android_common_baz_base_no_rename_resources",
+ apkPath: "/target/product/test_device/system/app/baz_base_no_rename_resources/baz_base_no_rename_resources.apk",
+ certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
+ lineageFlag: "",
+ overrides: []string{"qux", "foo_no_rename_resources"},
+ packageFlag: "org.dandroid.bp",
+ renameResources: false,
+ logging_parent: "",
+ },
+ {
+ name: "foo_no_rename_resources",
+ moduleName: "baz_override_base_rename_resources",
+ variantName: "android_common_baz_override_base_rename_resources",
+ apkPath: "/target/product/test_device/system/app/baz_override_base_rename_resources/baz_override_base_rename_resources.apk",
+ certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
+ lineageFlag: "",
+ overrides: []string{"qux", "foo_no_rename_resources"},
+ packageFlag: "org.dandroid.bp",
+ renameResources: true,
+ logging_parent: "",
},
}
for _, expected := range expectedVariants {
- variant := ctx.ModuleForTests("foo", expected.variantName)
+ variant := ctx.ModuleForTests(expected.name, expected.variantName)
// Check the final apk name
outputs := variant.AllOutputs()
@@ -1868,9 +2003,12 @@
// Check the package renaming flag, if exists.
res := variant.Output("package-res.apk")
aapt2Flags := res.Args["flags"]
- if !strings.Contains(aapt2Flags, expected.aaptFlag) {
- t.Errorf("package renaming flag, %q is missing in aapt2 link flags, %q", expected.aaptFlag, aapt2Flags)
+ checkAapt2LinkFlag(t, aapt2Flags, "rename-manifest-package", expected.packageFlag)
+ expectedPackage := expected.packageFlag
+ if !expected.renameResources {
+ expectedPackage = ""
}
+ checkAapt2LinkFlag(t, aapt2Flags, "rename-resources-package", expectedPackage)
}
}
@@ -2007,6 +2145,7 @@
res := variant.Output("package-res.apk")
aapt2Flags := res.Args["flags"]
checkAapt2LinkFlag(t, aapt2Flags, "rename-manifest-package", expected.packageFlag)
+ checkAapt2LinkFlag(t, aapt2Flags, "rename-resources-package", expected.packageFlag)
checkAapt2LinkFlag(t, aapt2Flags, "rename-instrumentation-target-package", expected.targetPackageFlag)
}
}
@@ -3131,6 +3270,65 @@
}
}
+func TestRuntimeResourceOverlay_JavaDefaults(t *testing.T) {
+ ctx, config := testJava(t, `
+ java_defaults {
+ name: "rro_defaults",
+ theme: "default_theme",
+ product_specific: true,
+ aaptflags: ["--keep-raw-values"],
+ }
+
+ runtime_resource_overlay {
+ name: "foo_with_defaults",
+ defaults: ["rro_defaults"],
+ }
+
+ runtime_resource_overlay {
+ name: "foo_barebones",
+ }
+ `)
+
+ //
+ // RRO module with defaults
+ //
+ m := ctx.ModuleForTests("foo_with_defaults", "android_common")
+
+ // Check AAPT2 link flags.
+ aapt2Flags := strings.Split(m.Output("package-res.apk").Args["flags"], " ")
+ expectedFlags := []string{"--keep-raw-values", "--no-resource-deduping", "--no-resource-removal"}
+ absentFlags := android.RemoveListFromList(expectedFlags, aapt2Flags)
+ if len(absentFlags) > 0 {
+ t.Errorf("expected values, %q are missing in aapt2 link flags, %q", absentFlags, aapt2Flags)
+ }
+
+ // Check device location.
+ path := android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_MODULE_PATH"]
+ expectedPath := []string{"/tmp/target/product/test_device/product/overlay/default_theme"}
+ if !reflect.DeepEqual(path, expectedPath) {
+ t.Errorf("Unexpected LOCAL_MODULE_PATH value: %q, expected: %q", path, expectedPath)
+ }
+
+ //
+ // RRO module without defaults
+ //
+ m = ctx.ModuleForTests("foo_barebones", "android_common")
+
+ // Check AAPT2 link flags.
+ aapt2Flags = strings.Split(m.Output("package-res.apk").Args["flags"], " ")
+ unexpectedFlags := "--keep-raw-values"
+ if inList(unexpectedFlags, aapt2Flags) {
+ t.Errorf("unexpected value, %q is present in aapt2 link flags, %q", unexpectedFlags, aapt2Flags)
+ }
+
+ // Check device location.
+ path = android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_MODULE_PATH"]
+ expectedPath = []string{"/tmp/target/product/test_device/system/overlay"}
+ if !reflect.DeepEqual(path, expectedPath) {
+ t.Errorf("Unexpected LOCAL_MODULE_PATH value: %v, expected: %v", path, expectedPath)
+ }
+}
+
func TestOverrideRuntimeResourceOverlay(t *testing.T) {
ctx, _ := testJava(t, `
runtime_resource_overlay {
@@ -3202,65 +3400,7 @@
res := variant.Output("package-res.apk")
aapt2Flags := res.Args["flags"]
checkAapt2LinkFlag(t, aapt2Flags, "rename-manifest-package", expected.packageFlag)
+ checkAapt2LinkFlag(t, aapt2Flags, "rename-resources-package", "")
checkAapt2LinkFlag(t, aapt2Flags, "rename-overlay-target-package", expected.targetPackageFlag)
}
}
-
-func TestRuntimeResourceOverlay_JavaDefaults(t *testing.T) {
- ctx, config := testJava(t, `
- java_defaults {
- name: "rro_defaults",
- theme: "default_theme",
- product_specific: true,
- aaptflags: ["--keep-raw-values"],
- }
-
- runtime_resource_overlay {
- name: "foo_with_defaults",
- defaults: ["rro_defaults"],
- }
-
- runtime_resource_overlay {
- name: "foo_barebones",
- }
- `)
-
- //
- // RRO module with defaults
- //
- m := ctx.ModuleForTests("foo_with_defaults", "android_common")
-
- // Check AAPT2 link flags.
- aapt2Flags := strings.Split(m.Output("package-res.apk").Args["flags"], " ")
- expectedFlags := []string{"--keep-raw-values", "--no-resource-deduping", "--no-resource-removal"}
- absentFlags := android.RemoveListFromList(expectedFlags, aapt2Flags)
- if len(absentFlags) > 0 {
- t.Errorf("expected values, %q are missing in aapt2 link flags, %q", absentFlags, aapt2Flags)
- }
-
- // Check device location.
- path := android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_MODULE_PATH"]
- expectedPath := []string{"/tmp/target/product/test_device/product/overlay/default_theme"}
- if !reflect.DeepEqual(path, expectedPath) {
- t.Errorf("Unexpected LOCAL_MODULE_PATH value: %q, expected: %q", path, expectedPath)
- }
-
- //
- // RRO module without defaults
- //
- m = ctx.ModuleForTests("foo_barebones", "android_common")
-
- // Check AAPT2 link flags.
- aapt2Flags = strings.Split(m.Output("package-res.apk").Args["flags"], " ")
- unexpectedFlags := "--keep-raw-values"
- if inList(unexpectedFlags, aapt2Flags) {
- t.Errorf("unexpected value, %q is present in aapt2 link flags, %q", unexpectedFlags, aapt2Flags)
- }
-
- // Check device location.
- path = android.AndroidMkEntriesForTest(t, config, "", m.Module())[0].EntryMap["LOCAL_MODULE_PATH"]
- expectedPath = []string{"/tmp/target/product/test_device/system/overlay"}
- if !reflect.DeepEqual(path, expectedPath) {
- t.Errorf("Unexpected LOCAL_MODULE_PATH value: %v, expected: %v", path, expectedPath)
- }
-}
diff --git a/java/builder.go b/java/builder.go
index 7318fcb..3043e46 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -385,7 +385,7 @@
"outDir": android.PathForModuleOut(ctx, "turbine", "classes").String(),
"javaVersion": flags.javaVersion.String(),
}
- if ctx.Config().IsEnvTrue("RBE_TURBINE") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_TURBINE") {
rule = turbineRE
args["implicits"] = strings.Join(deps.Strings(), ",")
}
@@ -452,7 +452,7 @@
annoDir = filepath.Join(shardDir, annoDir)
}
rule := javac
- if ctx.Config().IsEnvTrue("RBE_JAVAC") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_JAVAC") {
rule = javacRE
}
ctx.Build(pctx, android.BuildParams{
@@ -480,7 +480,7 @@
jarArgs []string, deps android.Paths) {
rule := jar
- if ctx.Config().IsEnvTrue("RBE_JAR") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_JAR") {
rule = jarRE
}
ctx.Build(pctx, android.BuildParams{
diff --git a/java/config/config.go b/java/config/config.go
index 05da3b5..31e2b0f 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -41,6 +41,7 @@
InstrumentFrameworkModules = []string{
"framework",
+ "framework-minus-apex",
"telephony-common",
"services",
"android.car",
@@ -51,6 +52,7 @@
"core-libart",
// TODO: Could this be all updatable bootclasspath jars?
"updatable-media",
+ "framework-mediaprovider",
"framework-sdkextensions",
"android.net.ipsec.ike",
}
diff --git a/java/dex.go b/java/dex.go
index c85914c..15b4431 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -288,7 +288,7 @@
"outUsageZip": proguardUsageZip.String(),
"outDir": outDir.String(),
}
- if ctx.Config().IsEnvTrue("RBE_R8") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_R8") {
rule = r8RE
args["implicits"] = strings.Join(r8Deps.Strings(), ",")
}
@@ -304,7 +304,7 @@
} else {
d8Flags, d8Deps := d8Flags(flags)
rule := d8
- if ctx.Config().IsEnvTrue("RBE_D8") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_D8") {
rule = d8RE
}
ctx.Build(pctx, android.BuildParams{
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 5ccc306..7073eff 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -1277,7 +1277,7 @@
// Metalava uses lots of memory, restrict the number of metalava jobs that can run in parallel.
rule.HighMem()
cmd := rule.Command()
- if ctx.Config().IsEnvTrue("RBE_METALAVA") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_METALAVA") {
rule.Remoteable(android.RemoteRuleSupports{RBE: true})
pool := ctx.Config().GetenvWithDefault("RBE_METALAVA_POOL", "metalava")
execStrategy := ctx.Config().GetenvWithDefault("RBE_METALAVA_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
@@ -1413,6 +1413,15 @@
d.apiLintReport = android.PathForModuleOut(ctx, "api_lint_report.txt")
cmd.FlagWithOutput("--report-even-if-suppressed ", d.apiLintReport) // TODO: Change to ":api-lint"
+ // TODO(b/154317059): Clean up this whitelist by baselining and/or checking in last-released.
+ if d.Name() != "android.car-system-stubs-docs" &&
+ d.Name() != "android.car-stubs-docs" &&
+ d.Name() != "system-api-stubs-docs" &&
+ d.Name() != "test-api-stubs-docs" {
+ cmd.Flag("--lints-as-errors")
+ cmd.Flag("--warnings-as-errors") // Most lints are actually warnings.
+ }
+
baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.Baseline_file)
updatedBaselineOutput := android.PathForModuleOut(ctx, "api_lint_baseline.txt")
d.apiLintTimestamp = android.PathForModuleOut(ctx, "api_lint.timestamp")
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index ea3fbda..29b6bcd 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -207,6 +207,15 @@
rule.Build(pctx, ctx, "hiddenAPIStubFlagsFile", "hiddenapi stub flags")
}
+func moduleForGreyListRemovedApis(ctx android.SingletonContext, module android.Module) bool {
+ switch ctx.ModuleName(module) {
+ case "api-stubs-docs", "system-api-stubs-docs", "android.car-stubs-docs", "android.car-system-stubs-docs":
+ return true
+ default:
+ return false
+ }
+}
+
// flagsRule creates a rule to build hiddenapi-flags.csv out of flags.csv files generated for boot image modules and
// the unsupported API.
func flagsRule(ctx android.SingletonContext) android.Path {
@@ -222,7 +231,7 @@
// 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" {
+ if moduleForGreyListRemovedApis(ctx, module) {
greylistRemovedApis = append(greylistRemovedApis, ds.removedDexApiFile)
}
}
diff --git a/java/java.go b/java/java.go
index 27e425d..9830c51 100644
--- a/java/java.go
+++ b/java/java.go
@@ -324,6 +324,10 @@
Stem *string
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
}
// Functionality common to Module and Import
@@ -437,6 +441,7 @@
hiddenAPI
dexer
dexpreopter
+ usesLibrary
linter
// list of the xref extraction files
@@ -452,6 +457,7 @@
j.AddProperties(
&j.properties,
&j.protoProperties,
+ &j.usesLibraryProperties,
)
}
@@ -564,6 +570,7 @@
certificateTag = dependencyTag{name: "certificate"}
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
usesLibTag = dependencyTag{name: "uses-library"}
+ usesLibCompatTag = dependencyTag{name: "uses-library-compat"}
extraLintCheckTag = dependencyTag{name: "extra-lint-check"}
)
@@ -679,25 +686,29 @@
return j.ApexModuleBase.AvailableFor(what)
}
+func sdkDeps(ctx android.BottomUpMutatorContext, sdkContext sdkContext, d dexer) {
+ sdkDep := decodeSdkDep(ctx, sdkContext)
+ if sdkDep.useModule {
+ ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...)
+ ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...)
+ ctx.AddVariationDependencies(nil, libTag, sdkDep.classpath...)
+ if d.effectiveOptimizeEnabled() && sdkDep.hasStandardLibs() {
+ ctx.AddVariationDependencies(nil, proguardRaiseTag, config.LegacyCorePlatformBootclasspathLibraries...)
+ }
+ if d.effectiveOptimizeEnabled() && sdkDep.hasFrameworkLibs() {
+ ctx.AddVariationDependencies(nil, proguardRaiseTag, config.FrameworkLibraries...)
+ }
+ }
+ if sdkDep.systemModules != "" {
+ ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
+ }
+}
+
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
if ctx.Device() {
j.linter.deps(ctx)
- sdkDep := decodeSdkDep(ctx, sdkContext(j))
- if sdkDep.useModule {
- ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...)
- ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...)
- ctx.AddVariationDependencies(nil, libTag, sdkDep.classpath...)
- if j.effectiveOptimizeEnabled() && sdkDep.hasStandardLibs() {
- ctx.AddVariationDependencies(nil, proguardRaiseTag, config.LegacyCorePlatformBootclasspathLibraries...)
- }
- if j.effectiveOptimizeEnabled() && sdkDep.hasFrameworkLibs() {
- ctx.AddVariationDependencies(nil, proguardRaiseTag, config.FrameworkLibraries...)
- }
- }
- if sdkDep.systemModules != "" {
- ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
- }
+ sdkDeps(ctx, sdkContext(j), j.dexer)
}
syspropPublicStubs := syspropPublicStubs(ctx.Config())
@@ -1483,7 +1494,7 @@
args := map[string]string{
"jarArgs": "-P META-INF/services/ " + strings.Join(proptools.NinjaAndShellEscapeList(zipargs), " "),
}
- if ctx.Config().IsEnvTrue("RBE_ZIP") {
+ if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_ZIP") {
rule = zipRE
args["implicits"] = strings.Join(services.Strings(), ",")
}
@@ -1972,6 +1983,11 @@
// added to the Android manifest.
j.exportedSdkLibs.MaybeAddLibraryPath(ctx, j.OptionalImplicitSdkLibrary(), j.DexJarBuildPath(), j.DexJarInstallPath())
+ // A non-SDK library may provide a <uses-library> (the name may be different from the module name).
+ if lib := proptools.String(j.usesLibraryProperties.Provides_uses_lib); lib != "" {
+ j.exportedSdkLibs.AddLibraryPath(ctx, lib, j.DexJarBuildPath(), j.DexJarInstallPath())
+ }
+
j.distFiles = j.GenerateTaggedDistFiles(ctx)
}
@@ -2209,6 +2225,7 @@
prebuiltTestProperties prebuiltTestProperties
testConfig android.Path
+ dexJarFile android.Path
}
func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -2531,8 +2548,14 @@
// Functionality common to Module and Import.
embeddableInModuleAndImport
+ hiddenAPI
+ dexer
+
properties ImportProperties
+ // output file containing classes.dex and resources
+ dexJarFile android.Path
+
combinedClasspathFile android.Path
exportedSdkLibs dexpreopt.LibraryPaths
exportAidlIncludeDirs android.Paths
@@ -2546,10 +2569,18 @@
return j.sdkVersion().raw
}
+func (j *Import) systemModules() string {
+ return "none"
+}
+
func (j *Import) minSdkVersion() sdkSpec {
return j.sdkVersion()
}
+func (j *Import) targetSdkVersion() sdkSpec {
+ return j.sdkVersion()
+}
+
func (j *Import) MinSdkVersion() string {
return j.minSdkVersion().version.String()
}
@@ -2576,6 +2607,10 @@
func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
+
+ if ctx.Device() && Bool(j.dexProperties.Compile_dex) {
+ sdkDeps(ctx, sdkContext(j), j.dexer)
+ }
}
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -2593,6 +2628,8 @@
j.combinedClasspathFile = outputFile
j.exportedSdkLibs = make(dexpreopt.LibraryPaths)
+ var flags javaBuilderFlags
+
ctx.VisitDirectDeps(func(module android.Module) {
otherName := ctx.OtherModuleName(module)
tag := ctx.OtherModuleDependencyTag(module)
@@ -2601,12 +2638,16 @@
case Dependency:
switch tag {
case libTag, staticLibTag:
+ flags.classpath = append(flags.classpath, dep.HeaderJars()...)
// sdk lib names from dependencies are re-exported
j.exportedSdkLibs.AddLibraryPaths(dep.ExportedSdkLibs())
+ case bootClasspathTag:
+ flags.bootClasspath = append(flags.bootClasspath, dep.HeaderJars()...)
}
case SdkLibraryDependency:
switch tag {
case libTag:
+ flags.classpath = append(flags.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
// names of sdk libs that are directly depended are exported
j.exportedSdkLibs.AddLibraryPath(ctx, otherName, dep.DexJarBuildPath(), dep.DexJarInstallPath())
}
@@ -2626,6 +2667,26 @@
j.exportedSdkLibs.MaybeAddLibraryPath(ctx, j.OptionalImplicitSdkLibrary(), outputFile, installFile)
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs)
+
+ if ctx.Device() && Bool(j.dexProperties.Compile_dex) {
+ sdkDep := decodeSdkDep(ctx, sdkContext(j))
+ if sdkDep.invalidVersion {
+ ctx.AddMissingDependencies(sdkDep.bootclasspath)
+ ctx.AddMissingDependencies(sdkDep.java9Classpath)
+ } else if sdkDep.useFiles {
+ // sdkDep.jar is actually equivalent to turbine header.jar.
+ flags.classpath = append(flags.classpath, sdkDep.jars...)
+ }
+
+ // Dex compilation
+ var dexOutputFile android.ModuleOutPath
+ dexOutputFile = j.dexer.compileDex(ctx, flags, j.minSdkVersion(), outputFile, jarName)
+ if ctx.Failed() {
+ return
+ }
+
+ j.dexJarFile = dexOutputFile
+ }
}
var _ Dependency = (*Import)(nil)
@@ -2656,7 +2717,7 @@
}
func (j *Import) DexJarBuildPath() android.Path {
- return nil
+ return j.dexJarFile
}
func (j *Import) DexJarInstallPath() android.Path {
@@ -2724,10 +2785,15 @@
func ImportFactory() android.Module {
module := &Import{}
- module.AddProperties(&module.properties)
+ module.AddProperties(
+ &module.properties,
+ &module.dexer.dexProperties,
+ )
module.initModuleAndImport(&module.ModuleBase)
+ module.dexProperties.Optimize.EnabledByDefault = false
+
android.InitPrebuiltModule(module, &module.properties.Jars)
android.InitApexModule(module)
android.InitSdkAwareModule(module)
diff --git a/java/java_test.go b/java/java_test.go
index d75be18..9e63577 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -525,6 +525,8 @@
java_import {
name: "baz",
jars: ["b.jar"],
+ sdk_version: "current",
+ compile_dex: true,
}
dex_import {
@@ -555,8 +557,10 @@
fooModule := ctx.ModuleForTests("foo", "android_common")
javac := fooModule.Rule("javac")
combineJar := ctx.ModuleForTests("foo", "android_common").Description("for javac")
- barJar := ctx.ModuleForTests("bar", "android_common").Rule("combineJar").Output
- bazJar := ctx.ModuleForTests("baz", "android_common").Rule("combineJar").Output
+ barModule := ctx.ModuleForTests("bar", "android_common")
+ barJar := barModule.Rule("combineJar").Output
+ bazModule := ctx.ModuleForTests("baz", "android_common")
+ bazJar := bazModule.Rule("combineJar").Output
sdklibStubsJar := ctx.ModuleForTests("sdklib.stubs", "android_common").Rule("combineJar").Output
fooLibrary := fooModule.Module().(*Library)
@@ -571,6 +575,11 @@
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], barJar.String())
}
+ barDexJar := barModule.Module().(*Import).DexJarBuildPath()
+ if barDexJar != nil {
+ t.Errorf("bar dex jar build path expected to be nil, got %q", barDexJar)
+ }
+
if !strings.Contains(javac.Args["classpath"], sdklibStubsJar.String()) {
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], sdklibStubsJar.String())
}
@@ -579,6 +588,12 @@
t.Errorf("foo combineJar inputs %v does not contain %q", combineJar.Inputs, bazJar.String())
}
+ bazDexJar := bazModule.Module().(*Import).DexJarBuildPath().String()
+ expectedDexJar := buildDir + "/.intermediates/baz/android_common/dex/baz.jar"
+ if bazDexJar != expectedDexJar {
+ t.Errorf("baz dex jar build path expected %q, got %q", expectedDexJar, bazDexJar)
+ }
+
ctx.ModuleForTests("qux", "android_common").Rule("Cp")
}
diff --git a/java/legacy_core_platform_api_usage.go b/java/legacy_core_platform_api_usage.go
index 8af66d0..021920a 100644
--- a/java/legacy_core_platform_api_usage.go
+++ b/java/legacy_core_platform_api_usage.go
@@ -19,6 +19,10 @@
"android/soong/java/config"
)
+// This variable is effectively unused in pre-master branches, and is
+// included (with the same value as it has in AOSP) only to ease
+// merges between branches (see the comment in the
+// useLegacyCorePlatformApi() function):
var legacyCorePlatformApiModules = []string{
"ahat-test-dump",
"android.car",
@@ -132,6 +136,10 @@
"wifi-service",
}
+// This variable is effectively unused in pre-master branches, and is
+// included (with the same value as it has in AOSP) only to ease
+// merges between branches (see the comment in the
+// useLegacyCorePlatformApi() function):
var legacyCorePlatformApiLookup = make(map[string]struct{})
func init() {
@@ -141,8 +149,12 @@
}
func useLegacyCorePlatformApi(ctx android.EarlyModuleContext) bool {
- _, found := legacyCorePlatformApiLookup[ctx.ModuleName()]
- return found
+ // In pre-master branches, we don't attempt to force usage of the stable
+ // version of the core/platform API. Instead, we always use the legacy
+ // version --- except in tests, where we always use stable, so that we
+ // can make the test assertions the same as other branches.
+ // This should be false in tests and true otherwise:
+ return ctx.Config().TestProductVariables == nil
}
func corePlatformSystemModules(ctx android.EarlyModuleContext) string {
diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go
index ac8337d..bcc6cc0 100644
--- a/java/prebuilt_apis.go
+++ b/java/prebuilt_apis.go
@@ -38,6 +38,9 @@
// The sdk_version of java_import modules generated based on jar files.
// Defaults to "current"
Imports_sdk_version *string
+
+ // If set to true, compile dex for java_import modules. Defaults to false.
+ Imports_compile_dex *bool
}
type prebuiltApis struct {
@@ -78,17 +81,19 @@
return mctx.ModuleName() + "_" + scope + "_" + apiver + "_" + module
}
-func createImport(mctx android.LoadHookContext, module, scope, apiver, path, sdk_version string) {
+func createImport(mctx android.LoadHookContext, module, scope, apiver, path, sdkVersion string, compileDex bool) {
props := struct {
Name *string
Jars []string
Sdk_version *string
Installable *bool
+ Compile_dex *bool
}{}
props.Name = proptools.StringPtr(prebuiltApiModuleName(mctx, module, scope, apiver))
props.Jars = append(props.Jars, path)
- props.Sdk_version = proptools.StringPtr(sdk_version)
+ props.Sdk_version = proptools.StringPtr(sdkVersion)
props.Installable = proptools.BoolPtr(false)
+ props.Compile_dex = proptools.BoolPtr(compileDex)
mctx.CreateModule(ImportFactory, &props)
}
@@ -124,13 +129,14 @@
// <apiver>/<scope>/<module>.jar
files := getPrebuiltFiles(mctx, p, "*.jar")
- sdk_version := proptools.StringDefault(p.properties.Imports_sdk_version, "current")
+ sdkVersion := proptools.StringDefault(p.properties.Imports_sdk_version, "current")
+ compileDex := proptools.BoolDefault(p.properties.Imports_compile_dex, false)
for _, f := range files {
// create a Import module for each jar file
localPath := strings.TrimPrefix(f, mydir)
module, apiver, scope := parseJarPath(localPath)
- createImport(mctx, module, scope, apiver, localPath, sdk_version)
+ createImport(mctx, module, scope, apiver, localPath, sdkVersion, compileDex)
}
}
diff --git a/java/robolectric.go b/java/robolectric.go
index 3fe6626..ec112bc 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -326,9 +326,11 @@
return module
}
-func (r *robolectricTest) InstallBypassMake() bool { return true }
-func (r *robolectricTest) InstallInTestcases() bool { return true }
-func (r *robolectricTest) InstallForceOS() *android.OsType { return &android.BuildOs }
+func (r *robolectricTest) InstallBypassMake() bool { return true }
+func (r *robolectricTest) InstallInTestcases() bool { return true }
+func (r *robolectricTest) InstallForceOS() (*android.OsType, *android.ArchType) {
+ return &android.BuildOs, &android.BuildArch
+}
func robolectricRuntimesFactory() android.Module {
module := &robolectricRuntimes{}
@@ -390,6 +392,8 @@
}
}
-func (r *robolectricRuntimes) InstallBypassMake() bool { return true }
-func (r *robolectricRuntimes) InstallInTestcases() bool { return true }
-func (r *robolectricRuntimes) InstallForceOS() *android.OsType { return &android.BuildOs }
+func (r *robolectricRuntimes) InstallBypassMake() bool { return true }
+func (r *robolectricRuntimes) InstallInTestcases() bool { return true }
+func (r *robolectricRuntimes) InstallForceOS() (*android.OsType, *android.ArchType) {
+ return &android.BuildOs, &android.BuildArch
+}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index a5db56c..88cf468 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -419,6 +419,9 @@
// $(location <label>): the path to the droiddoc_option_files with name <label>
Droiddoc_options []string
+ // is set to true, Metalava will allow framework SDK to contain annotations.
+ Annotations_enabled *bool
+
// a list of top-level directories containing files to merge qualifier annotations
// (i.e. those intended to be included in the stubs written) from.
Merge_annotations_dirs []string
@@ -1086,11 +1089,25 @@
return ":" + module.BaseModuleName() + "-removed.api." + apiScope.name + ".latest"
}
+func childModuleVisibility(childVisibility []string) []string {
+ if childVisibility == nil {
+ // No child visibility set. The child will use the visibility of the sdk_library.
+ return nil
+ }
+
+ // Prepend an override to ignore the sdk_library's visibility, and rely on the child visibility.
+ var visibility []string
+ visibility = append(visibility, "//visibility:override")
+ visibility = append(visibility, childVisibility...)
+ return visibility
+}
+
// Creates the implementation java library
func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) {
-
moduleNamePtr := proptools.StringPtr(module.BaseModuleName())
+ visibility := childModuleVisibility(module.sdkLibraryProperties.Impl_library_visibility)
+
props := struct {
Name *string
Visibility []string
@@ -1098,7 +1115,7 @@
ConfigurationName *string
}{
Name: proptools.StringPtr(module.implLibraryModuleName()),
- Visibility: module.sdkLibraryProperties.Impl_library_visibility,
+ Visibility: visibility,
// Set the instrument property to ensure it is instrumented when instrumentation is required.
Instrument: true,
@@ -1145,12 +1162,7 @@
}{}
props.Name = proptools.StringPtr(module.stubsLibraryModuleName(apiScope))
-
- // If stubs_library_visibility is not set then the created module will use the
- // visibility of this module.
- visibility := module.sdkLibraryProperties.Stubs_library_visibility
- props.Visibility = visibility
-
+ props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
// sources are generated from the droiddoc
props.Srcs = []string{":" + module.stubsSourceModuleName(apiScope)}
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
@@ -1159,6 +1171,11 @@
props.Patch_module = module.properties.Patch_module
props.Installable = proptools.BoolPtr(false)
props.Libs = module.sdkLibraryProperties.Stub_only_libs
+ // The stub-annotations library contains special versions of the annotations
+ // with CLASS retention policy, so that they're kept.
+ if proptools.Bool(module.sdkLibraryProperties.Annotations_enabled) {
+ props.Libs = append(props.Libs, "stub-annotations")
+ }
props.Openjdk9.Srcs = module.properties.Openjdk9.Srcs
props.Openjdk9.Javacflags = module.properties.Openjdk9.Javacflags
// We compile the stubs for 1.8 in line with the main android.jar stubs, and potential
@@ -1193,6 +1210,7 @@
Arg_files []string
Args *string
Java_version *string
+ Annotations_enabled *bool
Merge_annotations_dirs []string
Merge_inclusion_annotations_dirs []string
Generate_stubs *bool
@@ -1225,12 +1243,7 @@
// * libs (static_libs/libs)
props.Name = proptools.StringPtr(name)
-
- // If stubs_source_visibility is not set then the created module will use the
- // visibility of this module.
- visibility := module.sdkLibraryProperties.Stubs_source_visibility
- props.Visibility = visibility
-
+ props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_source_visibility)
props.Srcs = append(props.Srcs, module.properties.Srcs...)
props.Sdk_version = module.deviceProperties.Sdk_version
props.System_modules = module.deviceProperties.System_modules
@@ -1243,6 +1256,7 @@
props.Aidl.Local_include_dirs = module.deviceProperties.Aidl.Local_include_dirs
props.Java_version = module.properties.Java_version
+ props.Annotations_enabled = module.sdkLibraryProperties.Annotations_enabled
props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs
props.Merge_inclusion_annotations_dirs = module.sdkLibraryProperties.Merge_inclusion_annotations_dirs
@@ -2070,6 +2084,11 @@
}
// from android.PrebuiltEtcModule
+func (module *sdkLibraryXml) BaseDir() string {
+ return "etc"
+}
+
+// from android.PrebuiltEtcModule
func (module *sdkLibraryXml) SubDir() string {
return "permissions"
}
diff --git a/java/testing.go b/java/testing.go
index 1db6ef2..70c857f 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -95,11 +95,10 @@
MAIN_FILE = '%main%'`),
// For java_sdk_library
- "api/module-lib-current.txt": nil,
- "api/module-lib-removed.txt": nil,
- "api/system-server-current.txt": nil,
- "api/system-server-removed.txt": nil,
- "build/soong/scripts/gen-java-current-api-files.sh": nil,
+ "api/module-lib-current.txt": nil,
+ "api/module-lib-removed.txt": nil,
+ "api/system-server-current.txt": nil,
+ "api/system-server-removed.txt": nil,
}
cc.GatherRequiredFilesForTest(mockFS)
diff --git a/rust/Android.bp b/rust/Android.bp
index ad2bbd8..8618207 100644
--- a/rust/Android.bp
+++ b/rust/Android.bp
@@ -19,6 +19,7 @@
"prebuilt.go",
"proc_macro.go",
"project_json.go",
+ "protobuf.go",
"rust.go",
"strip.go",
"source_provider.go",
@@ -34,6 +35,7 @@
"coverage_test.go",
"library_test.go",
"project_json_test.go",
+ "protobuf_test.go",
"rust_test.go",
"source_provider_test.go",
"test_test.go",
diff --git a/rust/androidmk.go b/rust/androidmk.go
index 10f10d8..edae0e6 100644
--- a/rust/androidmk.go
+++ b/rust/androidmk.go
@@ -165,14 +165,16 @@
stem, suffix, _ := android.SplitFileExt(file)
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)
fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
+ fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
})
}
func (bindgen *bindgenDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
ctx.SubAndroidMk(ret, bindgen.BaseSourceProvider)
- ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
- fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
- })
+}
+
+func (proto *protobufDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
+ ctx.SubAndroidMk(ret, proto.BaseSourceProvider)
}
func (compiler *baseCompiler) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 0336308..cafdb8b 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -27,15 +27,14 @@
defaultBindgenFlags = []string{""}
// bindgen should specify its own Clang revision so updating Clang isn't potentially blocked on bindgen failures.
- bindgenClangVersion = "clang-r383902c"
- bindgenLibClangSoGit = "11git"
+ bindgenClangVersion = "clang-r383902c"
//TODO(b/160803703) Use a prebuilt bindgen instead of the built bindgen.
_ = pctx.SourcePathVariable("bindgenCmd", "out/host/${config.HostPrebuiltTag}/bin/bindgen")
_ = pctx.SourcePathVariable("bindgenClang",
"${cc_config.ClangBase}/${config.HostPrebuiltTag}/"+bindgenClangVersion+"/bin/clang")
_ = pctx.SourcePathVariable("bindgenLibClang",
- "${cc_config.ClangBase}/${config.HostPrebuiltTag}/"+bindgenClangVersion+"/lib64/libclang.so."+bindgenLibClangSoGit)
+ "${cc_config.ClangBase}/${config.HostPrebuiltTag}/"+bindgenClangVersion+"/lib64/")
//TODO(ivanlozano) Switch this to RuleBuilder
bindgen = pctx.AndroidStaticRule("bindgen",
@@ -97,8 +96,7 @@
var cflags []string
var implicits android.Paths
- implicits = append(implicits, deps.depIncludePaths...)
- implicits = append(implicits, deps.depSystemIncludePaths...)
+ implicits = append(implicits, deps.depGeneratedHeaders...)
// Default clang flags
cflags = append(cflags, "${cc_config.CommonClangGlobalCflags}")
diff --git a/rust/builder.go b/rust/builder.go
index 45cd268..654b1e6 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -31,9 +31,14 @@
Command: "$envVars $rustcCmd " +
"-C linker=${config.RustLinker} " +
"-C link-args=\"${crtBegin} ${config.RustLinkerArgs} ${linkFlags} ${crtEnd}\" " +
- "--emit link -o $out --emit dep-info=$out.d $in ${libFlags} $rustcFlags",
+ "--emit link -o $out --emit dep-info=$out.d.raw $in ${libFlags} $rustcFlags" +
+ " && grep \"^$out:\" $out.d.raw > $out.d",
CommandDeps: []string{"$rustcCmd"},
// Rustc deps-info writes out make compatible dep files: https://github.com/rust-lang/rust/issues/7633
+ // Rustc emits unneeded dependency lines for the .d and input .rs files.
+ // Those extra lines cause ninja warning:
+ // "warning: depfile has multiple output paths"
+ // For ninja, we keep/grep only the dependency rule for the rust $out file.
Deps: blueprint.DepsGCC,
Depfile: "$out.d",
},
diff --git a/rust/config/arm64_device.go b/rust/config/arm64_device.go
index 180fd8b..a0c496d 100644
--- a/rust/config/arm64_device.go
+++ b/rust/config/arm64_device.go
@@ -23,12 +23,7 @@
var (
Arm64RustFlags = []string{}
Arm64ArchFeatureRustFlags = map[string][]string{}
- Arm64LinkFlags = []string{
- "-Wl,--icf=safe",
- "-Wl,-z,max-page-size=4096",
-
- "-Wl,-z,separate-code",
- }
+ Arm64LinkFlags = []string{}
Arm64ArchVariantRustFlags = map[string][]string{
"armv8-a": []string{},
@@ -59,7 +54,8 @@
}
func (t *toolchainArm64) ToolchainLinkFlags() string {
- return "${config.DeviceGlobalLinkFlags} ${config.Arm64ToolchainLinkFlags}"
+ // Prepend the lld flags from cc_config so we stay in sync with cc
+ return "${config.DeviceGlobalLinkFlags} ${cc_config.Arm64Lldflags} ${config.Arm64ToolchainLinkFlags}"
}
func (t *toolchainArm64) ToolchainRustFlags() string {
diff --git a/rust/config/arm_device.go b/rust/config/arm_device.go
index ac2580b..ac4f1c6 100644
--- a/rust/config/arm_device.go
+++ b/rust/config/arm_device.go
@@ -23,10 +23,7 @@
var (
ArmRustFlags = []string{}
ArmArchFeatureRustFlags = map[string][]string{}
- ArmLinkFlags = []string{
- "-Wl,--icf=safe",
- "-Wl,-m,armelf",
- }
+ ArmLinkFlags = []string{}
ArmArchVariantRustFlags = map[string][]string{
"armv7-a": []string{},
@@ -59,7 +56,8 @@
}
func (t *toolchainArm) ToolchainLinkFlags() string {
- return "${config.DeviceGlobalLinkFlags} ${config.ArmToolchainLinkFlags}"
+ // Prepend the lld flags from cc_config so we stay in sync with cc
+ return "${config.DeviceGlobalLinkFlags} ${cc_config.ArmLldflags} ${config.ArmToolchainLinkFlags}"
}
func (t *toolchainArm) ToolchainRustFlags() string {
diff --git a/rust/config/global.go b/rust/config/global.go
index 2f4d930..6a5251b 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -42,22 +42,18 @@
deviceGlobalRustFlags = []string{}
deviceGlobalLinkFlags = []string{
+ // Prepend the lld flags from cc_config so we stay in sync with cc
+ "${cc_config.DeviceGlobalLldflags}",
+
+ // Override cc's --no-undefined-version to allow rustc's generated alloc functions
+ "-Wl,--undefined-version",
+
"-Bdynamic",
"-nostdlib",
- "-Wl,-z,noexecstack",
- "-Wl,-z,relro",
- "-Wl,-z,now",
- "-Wl,--build-id=md5",
- "-Wl,--warn-shared-textrel",
- "-Wl,--fatal-warnings",
-
"-Wl,--pack-dyn-relocs=android+relr",
"-Wl,--use-android-relr-tags",
"-Wl,--no-undefined",
- "-Wl,--hash-style=gnu",
-
"-B${cc_config.ClangBin}",
- "-fuse-ld=lld",
}
)
diff --git a/rust/config/x86_64_device.go b/rust/config/x86_64_device.go
index 9a6c00b..5f6e85a 100644
--- a/rust/config/x86_64_device.go
+++ b/rust/config/x86_64_device.go
@@ -61,7 +61,8 @@
}
func (t *toolchainX86_64) ToolchainLinkFlags() string {
- return "${config.DeviceGlobalLinkFlags} ${config.X86_64ToolchainLinkFlags}"
+ // Prepend the lld flags from cc_config so we stay in sync with cc
+ return "${config.DeviceGlobalLinkFlags} ${cc_config.X86_64Lldflags} ${config.X86_64ToolchainLinkFlags}"
}
func (t *toolchainX86_64) ToolchainRustFlags() string {
diff --git a/rust/config/x86_darwin_host.go b/rust/config/x86_darwin_host.go
index a13a9a6..ddd93e8 100644
--- a/rust/config/x86_darwin_host.go
+++ b/rust/config/x86_darwin_host.go
@@ -77,7 +77,8 @@
}
func (t *toolchainDarwinX8664) ToolchainLinkFlags() string {
- return "${config.DarwinToolchainLinkFlags} ${config.DarwinToolchainX8664LinkFlags}"
+ // Prepend the lld flags from cc_config so we stay in sync with cc
+ return "${cc_config.DarwinClangLldflags} ${config.DarwinToolchainLinkFlags} ${config.DarwinToolchainX8664LinkFlags}"
}
func (t *toolchainDarwinX8664) ToolchainRustFlags() string {
diff --git a/rust/config/x86_device.go b/rust/config/x86_device.go
index ec19b3c..daeeb14 100644
--- a/rust/config/x86_device.go
+++ b/rust/config/x86_device.go
@@ -64,7 +64,8 @@
}
func (t *toolchainX86) ToolchainLinkFlags() string {
- return "${config.DeviceGlobalLinkFlags} ${config.X86ToolchainLinkFlags}"
+ // Prepend the lld flags from cc_config so we stay in sync with cc
+ return "${config.DeviceGlobalLinkFlags} ${cc_config.X86ClangLldflags} ${config.X86ToolchainLinkFlags}"
}
func (t *toolchainX86) ToolchainRustFlags() string {
diff --git a/rust/config/x86_linux_host.go b/rust/config/x86_linux_host.go
index b55b2f2..e7f26ce 100644
--- a/rust/config/x86_linux_host.go
+++ b/rust/config/x86_linux_host.go
@@ -25,6 +25,7 @@
LinuxRustLinkFlags = []string{
"-B${cc_config.ClangBin}",
"-fuse-ld=lld",
+ "-Wl,--undefined-version",
}
linuxX86Rustflags = []string{}
linuxX86Linkflags = []string{}
@@ -77,7 +78,9 @@
}
func (t *toolchainLinuxX8664) ToolchainLinkFlags() string {
- return "${config.LinuxToolchainLinkFlags} ${config.LinuxToolchainX8664LinkFlags}"
+ // Prepend the lld flags from cc_config so we stay in sync with cc
+ return "${cc_config.LinuxClangLldflags} ${cc_config.LinuxX8664ClangLldflags} " +
+ "${config.LinuxToolchainLinkFlags} ${config.LinuxToolchainX8664LinkFlags}"
}
func (t *toolchainLinuxX8664) ToolchainRustFlags() string {
@@ -105,7 +108,9 @@
}
func (t *toolchainLinuxX86) ToolchainLinkFlags() string {
- return "${config.LinuxToolchainLinkFlags} ${config.LinuxToolchainX86LinkFlags}"
+ // Prepend the lld flags from cc_config so we stay in sync with cc
+ return "${cc_config.LinuxClangLldflags} ${cc_config.LinuxX86ClangLldflags} " +
+ "${config.LinuxToolchainLinkFlags} ${config.LinuxToolchainX86LinkFlags}"
}
func (t *toolchainLinuxX86) ToolchainRustFlags() string {
diff --git a/rust/protobuf.go b/rust/protobuf.go
new file mode 100644
index 0000000..897300f
--- /dev/null
+++ b/rust/protobuf.go
@@ -0,0 +1,109 @@
+// Copyright 2020 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.
+
+package rust
+
+import (
+ "android/soong/android"
+)
+
+var (
+ defaultProtobufFlags = []string{""}
+)
+
+func init() {
+ android.RegisterModuleType("rust_protobuf", RustProtobufFactory)
+ android.RegisterModuleType("rust_protobuf_host", RustProtobufHostFactory)
+}
+
+var _ SourceProvider = (*protobufDecorator)(nil)
+
+type ProtobufProperties struct {
+ // Path to the proto file that will be used to generate the source
+ Proto *string `android:"path,arch_variant"`
+
+ // List of additional flags to pass to aprotoc
+ Proto_flags []string `android:"arch_variant"`
+}
+
+type protobufDecorator struct {
+ *BaseSourceProvider
+
+ Properties ProtobufProperties
+}
+
+func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) android.Path {
+ var protoFlags android.ProtoFlags
+ pluginPath := ctx.Config().HostToolPath(ctx, "protoc-gen-rust")
+
+ protoFlags.OutTypeFlag = "--rust_out"
+
+ protoFlags.Flags = append(protoFlags.Flags, " --plugin="+pluginPath.String())
+ protoFlags.Flags = append(protoFlags.Flags, defaultProtobufFlags...)
+ protoFlags.Flags = append(protoFlags.Flags, proto.Properties.Proto_flags...)
+
+ protoFlags.Deps = append(protoFlags.Deps, pluginPath)
+
+ protoFile := android.OptionalPathForModuleSrc(ctx, proto.Properties.Proto)
+ if !protoFile.Valid() {
+ ctx.PropertyErrorf("proto", "invalid path to proto file")
+ }
+
+ outDir := android.PathForModuleOut(ctx)
+ depFile := android.PathForModuleOut(ctx, proto.BaseSourceProvider.getStem(ctx)+".d")
+ outputs := android.WritablePaths{android.PathForModuleOut(ctx, proto.BaseSourceProvider.getStem(ctx)+".rs")}
+
+ rule := android.NewRuleBuilder()
+ android.ProtoRule(ctx, rule, protoFile.Path(), protoFlags, protoFlags.Deps, outDir, depFile, outputs)
+ rule.Build(pctx, ctx, "protoc_"+protoFile.Path().Rel(), "protoc "+protoFile.Path().Rel())
+
+ proto.BaseSourceProvider.OutputFile = outputs[0]
+ return outputs[0]
+}
+
+func (proto *protobufDecorator) SourceProviderProps() []interface{} {
+ return append(proto.BaseSourceProvider.SourceProviderProps(), &proto.Properties)
+}
+
+func (proto *protobufDecorator) SourceProviderDeps(ctx DepsContext, deps Deps) Deps {
+ deps = proto.BaseSourceProvider.SourceProviderDeps(ctx, deps)
+ deps.Rustlibs = append(deps.Rustlibs, "libprotobuf")
+ return deps
+}
+
+// rust_protobuf generates protobuf rust code from the provided proto file. This uses the protoc-gen-rust plugin for
+// protoc. Additional flags to the protoc command can be passed via the proto_flags property. This module type will
+// create library variants that can be used as a crate dependency by adding it to the rlibs, dylibs, and rustlibs
+// properties of other modules.
+func RustProtobufFactory() android.Module {
+ module, _ := NewRustProtobuf(android.HostAndDeviceSupported)
+ return module.Init()
+}
+
+// A host-only variant of rust_protobuf. Refer to rust_protobuf for more details.
+func RustProtobufHostFactory() android.Module {
+ module, _ := NewRustProtobuf(android.HostSupported)
+ return module.Init()
+}
+
+func NewRustProtobuf(hod android.HostOrDeviceSupported) (*Module, *protobufDecorator) {
+ protobuf := &protobufDecorator{
+ BaseSourceProvider: NewSourceProvider(),
+ Properties: ProtobufProperties{},
+ }
+
+ module := NewSourceProviderModule(hod, protobuf, false)
+
+ return module, protobuf
+}
diff --git a/rust/protobuf_test.go b/rust/protobuf_test.go
new file mode 100644
index 0000000..a9dbf39
--- /dev/null
+++ b/rust/protobuf_test.go
@@ -0,0 +1,39 @@
+// Copyright 2020 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.
+
+package rust
+
+import (
+ "android/soong/android"
+ "testing"
+)
+
+func TestRustProtobuf(t *testing.T) {
+ ctx := testRust(t, `
+ rust_protobuf {
+ name: "librust_proto",
+ proto: "buf.proto",
+ crate_name: "rust_proto",
+ source_stem: "buf",
+ }
+ `)
+ // Check that there's a rule to generate the expected output
+ _ = ctx.ModuleForTests("librust_proto", "android_arm64_armv8-a_dylib").Output("buf.rs")
+
+ // Check that libprotobuf is added as a dependency.
+ librust_proto := ctx.ModuleForTests("librust_proto", "android_arm64_armv8-a_dylib").Module().(*Module)
+ if !android.InList("libprotobuf", librust_proto.Properties.AndroidMkDylibs) {
+ t.Errorf("libprotobuf dependency missing for rust_protobuf (dependency missing from AndroidMkDylibs)")
+ }
+}
diff --git a/rust/rust.go b/rust/rust.go
index 5c6cdb7..4cba6d6 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -258,6 +258,7 @@
// Used by bindgen modules which call clang
depClangFlags []string
depIncludePaths android.Paths
+ depGeneratedHeaders android.Paths
depSystemIncludePaths android.Paths
coverageFiles android.Paths
@@ -875,6 +876,7 @@
if mod, ok := ccDep.(*cc.Module); ok {
depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, mod.ExportedSystemIncludeDirs()...)
depPaths.depClangFlags = append(depPaths.depClangFlags, mod.ExportedFlags()...)
+ depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, mod.ExportedGeneratedHeaders()...)
}
depPaths.coverageFiles = append(depPaths.coverageFiles, ccDep.CoverageFiles()...)
directStaticLibDeps = append(directStaticLibDeps, ccDep)
@@ -886,6 +888,7 @@
if mod, ok := ccDep.(*cc.Module); ok {
depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, mod.ExportedSystemIncludeDirs()...)
depPaths.depClangFlags = append(depPaths.depClangFlags, mod.ExportedFlags()...)
+ depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, mod.ExportedGeneratedHeaders()...)
}
directSharedLibDeps = append(directSharedLibDeps, ccDep)
mod.Properties.AndroidMkSharedLibs = append(mod.Properties.AndroidMkSharedLibs, depName)
diff --git a/rust/rust_test.go b/rust/rust_test.go
index f1a08a8..89ce359 100644
--- a/rust/rust_test.go
+++ b/rust/rust_test.go
@@ -62,6 +62,7 @@
"foo.c": nil,
"src/bar.rs": nil,
"src/any.h": nil,
+ "buf.proto": nil,
"liby.so": nil,
"libz.so": nil,
}
diff --git a/rust/testing.go b/rust/testing.go
index 80e4148..0144c82 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -91,6 +91,12 @@
host_supported: true,
native_coverage: false,
}
+ rust_library {
+ name: "libprotobuf",
+ crate_name: "protobuf",
+ srcs: ["foo.rs"],
+ host_supported: true,
+ }
` + cc.GatherRequiredDepsForTest(android.NoOsType)
return bp
@@ -120,6 +126,8 @@
ctx.RegisterModuleType("rust_ffi_host_shared", RustFFISharedHostFactory)
ctx.RegisterModuleType("rust_ffi_host_static", RustFFIStaticHostFactory)
ctx.RegisterModuleType("rust_proc_macro", ProcMacroFactory)
+ ctx.RegisterModuleType("rust_protobuf", RustProtobufFactory)
+ ctx.RegisterModuleType("rust_protobuf_host", RustProtobufHostFactory)
ctx.RegisterModuleType("rust_prebuilt_library", PrebuiltLibraryFactory)
ctx.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory)
ctx.RegisterModuleType("rust_prebuilt_rlib", PrebuiltRlibFactory)
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 84b905c..0811ef5 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -1672,6 +1672,7 @@
],
export_include_dirs: ["include"],
stl: "none",
+ vendor_available: true,
}
`)
@@ -1683,6 +1684,7 @@
name: "myexports_mynativelib@current",
sdk_member_name: "mynativelib",
installable: false,
+ vendor_available: true,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
@@ -1709,6 +1711,7 @@
cc_prebuilt_library {
name: "mynativelib",
prefer: false,
+ vendor_available: true,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
diff --git a/tradefed/autogen.go b/tradefed/autogen.go
index 798fc40..b35f831 100644
--- a/tradefed/autogen.go
+++ b/tradefed/autogen.go
@@ -40,9 +40,9 @@
}
var autogenTestConfig = pctx.StaticRule("autogenTestConfig", blueprint.RuleParams{
- Command: "sed 's&{MODULE}&${name}&g;s&{EXTRA_CONFIGS}&'${extraConfigs}'&g;s&{OUTPUT_FILENAME}&'${outputFileName}'&g' $template > $out",
+ Command: "sed 's&{MODULE}&${name}&g;s&{EXTRA_CONFIGS}&'${extraConfigs}'&g;s&{OUTPUT_FILENAME}&'${outputFileName}'&g;s&{TEST_INSTALL_BASE}&'${testInstallBase}'&g' $template > $out",
CommandDeps: []string{"$template"},
-}, "name", "template", "extraConfigs", "outputFileName")
+}, "name", "template", "extraConfigs", "outputFileName", "testInstallBase")
func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string, autoGenConfig *bool, testConfigTemplateProp *string) (path android.Path, autogenPath android.WritablePath) {
p := getTestConfig(ctx, prop)
@@ -107,15 +107,15 @@
}
-func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, template string, configs []Config) {
- autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), output, template, configs, "")
+func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, template string, configs []Config, testInstallBase string) {
+ autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), output, template, configs, "", testInstallBase)
}
-func autogenTemplateWithName(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config) {
- autogenTemplateWithNameAndOutputFile(ctx, name, output, template, configs, "")
+func autogenTemplateWithName(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, testInstallBase string) {
+ autogenTemplateWithNameAndOutputFile(ctx, name, output, template, configs, "", testInstallBase)
}
-func autogenTemplateWithNameAndOutputFile(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, outputFileName string) {
+func autogenTemplateWithNameAndOutputFile(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, outputFileName string, testInstallBase string) {
var configStrings []string
for _, config := range configs {
configStrings = append(configStrings, config.Config())
@@ -128,26 +128,28 @@
Description: "test config",
Output: output,
Args: map[string]string{
- "name": name,
- "template": template,
- "extraConfigs": extraConfigs,
- "outputFileName": outputFileName,
+ "name": name,
+ "template": template,
+ "extraConfigs": extraConfigs,
+ "outputFileName": outputFileName,
+ "testInstallBase": testInstallBase,
},
})
}
func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string,
- testConfigTemplateProp *string, testSuites []string, config []Config, autoGenConfig *bool) android.Path {
+ testConfigTemplateProp *string, testSuites []string, config []Config, autoGenConfig *bool, testInstallBase string) android.Path {
+
path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), config)
+ autogenTemplate(ctx, autogenPath, templatePath.String(), config, testInstallBase)
} else {
if ctx.Device() {
- autogenTemplate(ctx, autogenPath, "${NativeTestConfigTemplate}", config)
+ autogenTemplate(ctx, autogenPath, "${NativeTestConfigTemplate}", config, testInstallBase)
} else {
- autogenTemplate(ctx, autogenPath, "${NativeHostTestConfigTemplate}", config)
+ autogenTemplate(ctx, autogenPath, "${NativeHostTestConfigTemplate}", config, testInstallBase)
}
}
return autogenPath
@@ -161,9 +163,9 @@
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
- autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, templatePath.String(), config, outputFileName)
+ autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, templatePath.String(), config, outputFileName, "")
} else {
- autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, "${ShellTestConfigTemplate}", config, outputFileName)
+ autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, "${ShellTestConfigTemplate}", config, outputFileName, "")
}
return autogenPath
}
@@ -176,9 +178,9 @@
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), configs)
+ autogenTemplate(ctx, autogenPath, templatePath.String(), configs, "")
} else {
- autogenTemplate(ctx, autogenPath, "${NativeBenchmarkTestConfigTemplate}", configs)
+ autogenTemplate(ctx, autogenPath, "${NativeBenchmarkTestConfigTemplate}", configs, "")
}
return autogenPath
}
@@ -191,12 +193,12 @@
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), nil)
+ autogenTemplate(ctx, autogenPath, templatePath.String(), nil, "")
} else {
if ctx.Device() {
- autogenTemplate(ctx, autogenPath, "${JavaTestConfigTemplate}", nil)
+ autogenTemplate(ctx, autogenPath, "${JavaTestConfigTemplate}", nil, "")
} else {
- autogenTemplate(ctx, autogenPath, "${JavaHostTestConfigTemplate}", nil)
+ autogenTemplate(ctx, autogenPath, "${JavaHostTestConfigTemplate}", nil, "")
}
}
return autogenPath
@@ -211,9 +213,9 @@
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), nil)
+ autogenTemplate(ctx, autogenPath, templatePath.String(), nil, "")
} else {
- autogenTemplate(ctx, autogenPath, "${PythonBinaryHostTestConfigTemplate}", nil)
+ autogenTemplate(ctx, autogenPath, "${PythonBinaryHostTestConfigTemplate}", nil, "")
}
return autogenPath
}
@@ -226,12 +228,12 @@
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), config)
+ autogenTemplate(ctx, autogenPath, templatePath.String(), config, "")
} else {
if ctx.Device() {
- autogenTemplate(ctx, autogenPath, "${RustDeviceTestConfigTemplate}", config)
+ autogenTemplate(ctx, autogenPath, "${RustDeviceTestConfigTemplate}", config, "")
} else {
- autogenTemplate(ctx, autogenPath, "${RustHostTestConfigTemplate}", config)
+ autogenTemplate(ctx, autogenPath, "${RustHostTestConfigTemplate}", config, "")
}
}
return autogenPath
@@ -245,9 +247,9 @@
if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), nil)
+ autogenTemplate(ctx, autogenPath, templatePath.String(), nil, "")
} else {
- autogenTemplate(ctx, autogenPath, "${RobolectricTestConfigTemplate}", nil)
+ autogenTemplate(ctx, autogenPath, "${RobolectricTestConfigTemplate}", nil, "")
}
return autogenPath
}
diff --git a/ui/build/rbe.go b/ui/build/rbe.go
index 67bcebb..c4b829d 100644
--- a/ui/build/rbe.go
+++ b/ui/build/rbe.go
@@ -19,6 +19,7 @@
"math/rand"
"os"
"path/filepath"
+ "syscall"
"time"
"android/soong/ui/metrics"
@@ -50,8 +51,25 @@
return cmdPath
}
-func getRBEVars(ctx Context, config Config) map[string]string {
+func sockAddr(dir string) (string, error) {
+ maxNameLen := len(syscall.RawSockaddrUnix{}.Path)
rand.Seed(time.Now().UnixNano())
+ base := fmt.Sprintf("reproxy_%v.sock", rand.Intn(1000))
+
+ name := filepath.Join(dir, base)
+ if len(name) < maxNameLen {
+ return name, nil
+ }
+
+ name = filepath.Join("/tmp", base)
+ if len(name) < maxNameLen {
+ return name, nil
+ }
+
+ return "", fmt.Errorf("cannot generate a proxy socket address shorter than the limit of %v", maxNameLen)
+}
+
+func getRBEVars(ctx Context, config Config) map[string]string {
vars := map[string]string{
"RBE_log_path": config.rbeLogPath(),
"RBE_log_dir": config.logDir(),
@@ -60,7 +78,12 @@
"RBE_output_dir": config.rbeStatsOutputDir(),
}
if config.StartRBE() {
- vars["RBE_server_address"] = fmt.Sprintf("unix://%v/reproxy_%v.sock", absPath(ctx, config.TempDir()), rand.Intn(1000))
+ name, err := sockAddr(absPath(ctx, config.TempDir()))
+ if err != nil {
+ ctx.Fatalf("Error retrieving socket address: %v", err)
+ return nil
+ }
+ vars["RBE_server_address"] = fmt.Sprintf("unix://%v", name)
}
k, v := config.rbeAuth()
vars[k] = v