Merge "Correct tags on StaticSharedLibraryProperties.Cflags"
diff --git a/README.md b/README.md
index 531ef4c..60d7d5a 100644
--- a/README.md
+++ b/README.md
@@ -236,6 +236,11 @@
If no `default_visibility` property can be found then the module uses the
global default of `//visibility:legacy_public`.
+The `visibility` property has no effect on a defaults module although it does
+apply to any non-defaults module that uses it. To set the visibility of a
+defaults module, use the `defaults_visibility` property on the defaults module;
+not to be confused with the `default_visibility` property on the package module.
+
Once the build has been completely switched over to soong it is possible that a
global refactoring will be done to change this to `//visibility:private` at
which point all packages that do not currently specify a `default_visibility`
diff --git a/android/defaults.go b/android/defaults.go
index ae2c820..f489c02 100644
--- a/android/defaults.go
+++ b/android/defaults.go
@@ -42,9 +42,16 @@
d.defaultableProperties = props
}
+// Interface that must be supported by any module to which defaults can be applied.
type Defaultable interface {
+ // Get a pointer to the struct containing the Defaults property.
defaults() *defaultsProperties
+
+ // Set the property structures into which defaults will be added.
setProperties([]interface{})
+
+ // Apply defaults from the supplied Defaults to the property structures supplied to
+ // setProperties(...).
applyDefaults(TopDownMutatorContext, []Defaults)
}
@@ -56,13 +63,25 @@
var _ Defaultable = (*DefaultableModuleBase)(nil)
func InitDefaultableModule(module DefaultableModule) {
- module.(Defaultable).setProperties(module.(Module).GetProperties())
+ module.setProperties(module.(Module).GetProperties())
module.AddProperties(module.defaults())
}
+// The Defaults_visibility property.
+type DefaultsVisibilityProperties struct {
+
+ // Controls the visibility of the defaults module itself.
+ Defaults_visibility []string
+}
+
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
@@ -87,33 +106,75 @@
// rather than disabling the defaults module itself.
type Defaults interface {
Defaultable
+
+ // Although this function is unused it is actually needed to ensure that only modules that embed
+ // DefaultsModuleBase will type-assert to the Defaults interface.
isDefaults() bool
+
+ // Get the structures containing the properties for which defaults can be provided.
properties() []interface{}
+
+ // Return the defaults common properties.
+ common() *commonProperties
+
+ // Return the defaults visibility properties.
+ defaultsVisibility() *DefaultsVisibilityProperties
}
func (d *DefaultsModuleBase) isDefaults() bool {
return true
}
+type DefaultsModule interface {
+ Module
+ Defaults
+}
+
func (d *DefaultsModuleBase) properties() []interface{} {
return d.defaultableProperties
}
+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 DefaultableModule) {
+func InitDefaultsModule(module DefaultsModule) {
+ commonProperties := module.common()
+
module.AddProperties(
&hostAndDeviceProperties{},
- &commonProperties{},
+ commonProperties,
&variableProperties{})
InitArchModule(module)
InitDefaultableModule(module)
- module.AddProperties(&module.base().nameProperties)
+ // Add properties that will not have defaults applied to them.
+ base := module.base()
+ defaultsVisibility := module.defaultsVisibility()
+ module.AddProperties(&base.nameProperties, defaultsVisibility)
- module.base().module = module
+ // The defaults_visibility property controls the visibility of a defaults module.
+ base.primaryVisibilityProperty =
+ newVisibilityProperty("defaults_visibility", &defaultsVisibility.Defaults_visibility)
+
+ // Unlike non-defaults modules the visibility property is not stored in m.base().commonProperties.
+ // Instead it is stored in a separate instance of commonProperties created above so use that.
+ // The visibility property needs to be checked (but not parsed) by the visibility module during
+ // its checking phase and parsing phase.
+ base.visibilityPropertyInfo = []visibilityProperty{
+ base.primaryVisibilityProperty,
+ newVisibilityProperty("visibility", &commonProperties.Visibility),
+ }
+
+ base.module = module
}
var _ Defaults = (*DefaultsModuleBase)(nil)
diff --git a/android/module.go b/android/module.go
index adb9454..138b9cd 100644
--- a/android/module.go
+++ b/android/module.go
@@ -211,6 +211,9 @@
// Get information about the properties that can contain visibility rules.
visibilityProperties() []visibilityProperty
+
+ // Get the visibility rules that control the visibility of this module.
+ visibility() []string
}
// Qualified id for a module
@@ -302,6 +305,11 @@
// If no `default_visibility` property can be found then the module uses the
// global default of `//visibility:legacy_public`.
//
+ // The `visibility` property has no effect on a defaults module although it does
+ // apply to any non-defaults module that uses it. To set the visibility of a
+ // defaults module, use the `defaults_visibility` property on the defaults module;
+ // not to be confused with the `default_visibility` property on the package module.
+ //
// See https://android.googlesource.com/platform/build/soong/+/master/README.md#visibility for
// more details.
Visibility []string
@@ -503,6 +511,12 @@
&base.variableProperties)
base.generalProperties = m.GetProperties()
base.customizableProperties = m.GetProperties()
+
+ // The default_visibility property needs to be checked and parsed by the visibility module during
+ // its checking and parsing phases.
+ base.primaryVisibilityProperty =
+ newVisibilityProperty("visibility", &base.commonProperties.Visibility)
+ base.visibilityPropertyInfo = []visibilityProperty{base.primaryVisibilityProperty}
}
func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
@@ -582,6 +596,13 @@
archProperties [][]interface{}
customizableProperties []interface{}
+ // Information about all the properties on the module that contains visibility rules that need
+ // checking.
+ visibilityPropertyInfo []visibilityProperty
+
+ // The primary visibility property, may be nil, that controls access to the module.
+ primaryVisibilityProperty visibilityProperty
+
noAddressSanitizer bool
installFiles Paths
checkbuildFiles Paths
@@ -668,10 +689,15 @@
}
func (m *ModuleBase) visibilityProperties() []visibilityProperty {
- return []visibilityProperty{
- newVisibilityProperty("visibility", func() []string {
- return m.base().commonProperties.Visibility
- }),
+ return m.visibilityPropertyInfo
+}
+
+func (m *ModuleBase) visibility() []string {
+ // The soong_namespace module does not initialize the primaryVisibilityProperty.
+ if m.primaryVisibilityProperty != nil {
+ return m.primaryVisibilityProperty.getStrings()
+ } else {
+ return nil
}
}
diff --git a/android/package.go b/android/package.go
index 03f6a1e..880d6a9 100644
--- a/android/package.go
+++ b/android/package.go
@@ -64,16 +64,6 @@
return newPackageId(ctx.ModuleDir())
}
-// Override to ensure that the default_visibility rules are checked by the visibility module during
-// its checking phase.
-func (p *packageModule) visibilityProperties() []visibilityProperty {
- return []visibilityProperty{
- newVisibilityProperty("default_visibility", func() []string {
- return p.properties.Default_visibility
- }),
- }
-}
-
func (p *packageModule) Name() string {
return p.properties.Name
}
@@ -97,6 +87,13 @@
module.properties.Name = name
module.AddProperties(&module.properties)
+
+ // The default_visibility property needs to be checked and parsed by the visibility module during
+ // its checking and parsing phases.
+ module.primaryVisibilityProperty =
+ newVisibilityProperty("default_visibility", &module.properties.Default_visibility)
+ module.visibilityPropertyInfo = []visibilityProperty{module.primaryVisibilityProperty}
+
return module
}
diff --git a/android/paths.go b/android/paths.go
index 0ea4447..e3f0544 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -230,7 +230,7 @@
// references to OutputFileProducer modules using the ":name{.tag}" syntax. Properties passed as the paths or excludes
// argument must have been annotated with struct tag `android:"path"` so that dependencies on SourceFileProducer modules
// will have already been handled by the path_properties mutator. If ctx.Config().AllowMissingDependencies() is
-// truethen any missing SourceFileProducer or OutputFileProducer dependencies will cause the module to be marked as
+// true then any missing SourceFileProducer or OutputFileProducer dependencies will cause the module to be marked as
// having missing dependencies.
func PathsForModuleSrcExcludes(ctx ModuleContext, paths, excludes []string) Paths {
ret, missingDeps := PathsAndMissingDepsForModuleSrcExcludes(ctx, paths, excludes)
diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go
index 069e1f5..9722a25 100644
--- a/android/prebuilt_etc.go
+++ b/android/prebuilt_etc.go
@@ -91,6 +91,10 @@
return PathForModuleSrc(ctx, String(p.properties.Src))
}
+func (p *PrebuiltEtc) InstallDirPath() OutputPath {
+ return p.installDirPath
+}
+
// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
// additional steps (like validating the src) before the file is installed.
func (p *PrebuiltEtc) SetAdditionalDependencies(paths Paths) {
@@ -165,15 +169,16 @@
}
}
-func InitPrebuiltEtcModule(p *PrebuiltEtc) {
+func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
+ p.installDirBase = dirBase
p.AddProperties(&p.properties)
}
// prebuilt_etc is for a prebuilt artifact that is installed in
// <partition>/etc/<sub_dir> directory.
func PrebuiltEtcFactory() Module {
- module := &PrebuiltEtc{installDirBase: "etc"}
- InitPrebuiltEtcModule(module)
+ module := &PrebuiltEtc{}
+ InitPrebuiltEtcModule(module, "etc")
// This module is device-only
InitAndroidArchModule(module, DeviceSupported, MultilibFirst)
return module
@@ -182,8 +187,8 @@
// prebuilt_etc_host is for a host prebuilt artifact that is installed in
// $(HOST_OUT)/etc/<sub_dir> directory.
func PrebuiltEtcHostFactory() Module {
- module := &PrebuiltEtc{installDirBase: "etc"}
- InitPrebuiltEtcModule(module)
+ module := &PrebuiltEtc{}
+ InitPrebuiltEtcModule(module, "etc")
// This module is host-only
InitAndroidArchModule(module, HostSupported, MultilibCommon)
return module
@@ -192,8 +197,8 @@
// prebuilt_usr_share is for a prebuilt artifact that is installed in
// <partition>/usr/share/<sub_dir> directory.
func PrebuiltUserShareFactory() Module {
- module := &PrebuiltEtc{installDirBase: "usr/share"}
- InitPrebuiltEtcModule(module)
+ module := &PrebuiltEtc{}
+ InitPrebuiltEtcModule(module, "usr/share")
// This module is device-only
InitAndroidArchModule(module, DeviceSupported, MultilibFirst)
return module
@@ -202,8 +207,8 @@
// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
// $(HOST_OUT)/usr/share/<sub_dir> directory.
func PrebuiltUserShareHostFactory() Module {
- module := &PrebuiltEtc{installDirBase: "usr/share"}
- InitPrebuiltEtcModule(module)
+ module := &PrebuiltEtc{}
+ InitPrebuiltEtcModule(module, "usr/share")
// This module is host-only
InitAndroidArchModule(module, HostSupported, MultilibCommon)
return module
@@ -254,8 +259,8 @@
// prebuilt_font installs a font in <partition>/fonts directory.
func PrebuiltFontFactory() Module {
- module := &PrebuiltEtc{installDirBase: "fonts"}
- InitPrebuiltEtcModule(module)
+ module := &PrebuiltEtc{}
+ InitPrebuiltEtcModule(module, "fonts")
// This module is device-only
InitAndroidArchModule(module, DeviceSupported, MultilibFirst)
return module
@@ -265,8 +270,9 @@
// If soc_specific property is set to true, the firmware file is installed to the vendor <partition>/firmware
// directory for vendor image.
func PrebuiltFirmwareFactory() Module {
- module := &PrebuiltEtc{installDirBase: "etc/firmware", socInstallDirBase: "firmware"}
- InitPrebuiltEtcModule(module)
+ module := &PrebuiltEtc{}
+ module.socInstallDirBase = "firmware"
+ InitPrebuiltEtcModule(module, "etc/firmware")
// This module is device-only
InitAndroidArchModule(module, DeviceSupported, MultilibFirst)
return module
diff --git a/android/visibility.go b/android/visibility.go
index 94af343..a7e718b 100644
--- a/android/visibility.go
+++ b/android/visibility.go
@@ -67,8 +67,8 @@
// Describes the properties provided by a module that contain visibility rules.
type visibilityPropertyImpl struct {
- name string
- stringsGetter func() []string
+ name string
+ stringsProperty *[]string
}
type visibilityProperty interface {
@@ -76,10 +76,10 @@
getStrings() []string
}
-func newVisibilityProperty(name string, stringsGetter func() []string) visibilityProperty {
+func newVisibilityProperty(name string, stringsProperty *[]string) visibilityProperty {
return visibilityPropertyImpl{
- name: name,
- stringsGetter: stringsGetter,
+ name: name,
+ stringsProperty: stringsProperty,
}
}
@@ -88,7 +88,7 @@
}
func (p visibilityPropertyImpl) getStrings() []string {
- return p.stringsGetter()
+ return *p.stringsProperty
}
// A compositeRule is a visibility rule composed from a list of atomic visibility rules.
@@ -211,16 +211,7 @@
// Checks the per-module visibility rule lists before defaults expansion.
func visibilityRuleChecker(ctx BottomUpMutatorContext) {
qualified := createQualifiedModuleName(ctx)
- if d, ok := ctx.Module().(Defaults); ok {
- // Defaults modules don't store the payload properties in m.base().
- for _, props := range d.properties() {
- if cp, ok := props.(*commonProperties); ok {
- if visibility := cp.Visibility; visibility != nil {
- checkRules(ctx, qualified.pkg, "visibility", visibility)
- }
- }
- }
- } else if m, ok := ctx.Module().(Module); ok {
+ if m, ok := ctx.Module().(Module); ok {
visibilityProperties := m.visibilityProperties()
for _, p := range visibilityProperties {
if visibility := p.getStrings(); visibility != nil {
@@ -294,14 +285,12 @@
qualifiedModuleId := m.qualifiedModuleId(ctx)
currentPkg := qualifiedModuleId.pkg
- // Parse all the properties into rules and store them.
- visibilityProperties := m.visibilityProperties()
- for _, p := range visibilityProperties {
- if visibility := p.getStrings(); visibility != nil {
- rule := parseRules(ctx, currentPkg, visibility)
- if rule != nil {
- moduleToVisibilityRuleMap(ctx).Store(qualifiedModuleId, rule)
- }
+ // Parse the visibility rules that control access to the module and store them by id
+ // for use when enforcing the rules.
+ if visibility := m.visibility(); visibility != nil {
+ rule := parseRules(ctx, currentPkg, m.visibility())
+ if rule != nil {
+ moduleToVisibilityRuleMap(ctx).Store(qualifiedModuleId, rule)
}
}
}
diff --git a/android/visibility_test.go b/android/visibility_test.go
index af6acf4..c44dc9e 100644
--- a/android/visibility_test.go
+++ b/android/visibility_test.go
@@ -658,6 +658,40 @@
` visible to this module`,
},
},
+
+ // Defaults module's defaults_visibility tests
+ {
+ name: "defaults_visibility invalid",
+ fs: map[string][]byte{
+ "top/Blueprints": []byte(`
+ mock_defaults {
+ name: "top_defaults",
+ defaults_visibility: ["//visibility:invalid"],
+ }`),
+ },
+ expectedErrors: []string{
+ `defaults_visibility: unrecognized visibility rule "//visibility:invalid"`,
+ },
+ },
+ {
+ name: "defaults_visibility overrides package default",
+ fs: map[string][]byte{
+ "top/Blueprints": []byte(`
+ package {
+ default_visibility: ["//visibility:private"],
+ }
+ mock_defaults {
+ name: "top_defaults",
+ defaults_visibility: ["//visibility:public"],
+ }`),
+ "outsider/Blueprints": []byte(`
+ mock_library {
+ name: "liboutsider",
+ defaults: ["top_defaults"],
+ }`),
+ },
+ },
+
// Package default_visibility tests
{
name: "package default_visibility property is checked",
diff --git a/apex/apex_test.go b/apex/apex_test.go
index e44163e..bb0c4c5 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -91,8 +91,6 @@
ctx.RegisterModuleType("sh_binary", android.ModuleFactoryAdaptor(android.ShBinaryFactory))
ctx.RegisterModuleType("android_app_certificate", android.ModuleFactoryAdaptor(java.AndroidAppCertificateFactory))
ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(android.FileGroupFactory))
- ctx.RegisterModuleType("java_library", android.ModuleFactoryAdaptor(java.LibraryFactory))
-
ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
})
@@ -207,7 +205,6 @@
"mytest3.cpp": nil,
"myprebuilt": nil,
"my_include": nil,
- "foo/bar/MyClass.java": nil,
"vendor/foo/devkeys/test.x509.pem": nil,
"vendor/foo/devkeys/test.pk8": nil,
"testkey.x509.pem": nil,
@@ -283,8 +280,7 @@
both: {
binaries: ["foo",],
}
- },
- java_libs: ["myjar"],
+ }
}
apex {
@@ -342,23 +338,6 @@
stl: "none",
notice: "custom_notice",
}
-
- java_library {
- name: "myjar",
- srcs: ["foo/bar/MyClass.java"],
- sdk_version: "none",
- system_modules: "none",
- compile_dex: true,
- static_libs: ["myotherjar"],
- }
-
- java_library {
- name: "myotherjar",
- srcs: ["foo/bar/MyClass.java"],
- sdk_version: "none",
- system_modules: "none",
- compile_dex: true,
- }
`)
apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule")
@@ -375,24 +354,17 @@
// Ensure that apex variant is created for the direct dep
ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex")
- ensureListContains(t, ctx.ModuleVariantsForTests("myjar"), "android_common_myapex")
// Ensure that apex variant is created for the indirect dep
ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex")
- ensureListContains(t, ctx.ModuleVariantsForTests("myotherjar"), "android_common_myapex")
// Ensure that both direct and indirect deps are copied into apex
ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
ensureContains(t, copyCmds, "image.apex/lib64/mylib2.so")
- ensureContains(t, copyCmds, "image.apex/javalib/myjar.jar")
- // .. but not for java libs
- ensureNotContains(t, copyCmds, "image.apex/javalib/myotherjar.jar")
- // Ensure that the platform variant ends with _core_shared or _common
+ // Ensure that the platform variant ends with _core_shared
ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared")
ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared")
- ensureListContains(t, ctx.ModuleVariantsForTests("myjar"), "android_common")
- ensureListContains(t, ctx.ModuleVariantsForTests("myotherjar"), "android_common")
// Ensure that all symlinks are present.
found_foo_link_64 := false
diff --git a/cc/fuzz.go b/cc/fuzz.go
index 3b0c5c8..c1754b2 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -105,15 +105,19 @@
// The fuzzer runtime is not present for darwin host modules, disable cc_fuzz modules when targeting darwin.
android.AddLoadHook(module, func(ctx android.LoadHookContext) {
- disableDarwin := struct {
+ disableDarwinAndLinuxBionic := struct {
Target struct {
Darwin struct {
Enabled *bool
}
+ Linux_bionic struct {
+ Enabled *bool
+ }
}
}{}
- disableDarwin.Target.Darwin.Enabled = BoolPtr(false)
- ctx.AppendProperties(&disableDarwin)
+ disableDarwinAndLinuxBionic.Target.Darwin.Enabled = BoolPtr(false)
+ disableDarwinAndLinuxBionic.Target.Linux_bionic.Enabled = BoolPtr(false)
+ ctx.AppendProperties(&disableDarwinAndLinuxBionic)
})
return module
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 3e32958..51f5519 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -113,6 +113,7 @@
ProfileClassListing android.OptionalPath
ProfileIsTextListing bool
+ ProfileBootListing android.OptionalPath
EnforceUsesLibraries bool
PresentOptionalUsesLibraries []string
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index e02e60f..c378f09 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -108,11 +108,15 @@
rule = android.NewRuleBuilder()
generateProfile := module.ProfileClassListing.Valid() && !global.DisableGenerateProfile
+ generateBootProfile := module.ProfileBootListing.Valid() && !global.DisableGenerateProfile
var profile android.WritablePath
if generateProfile {
profile = profileCommand(ctx, global, module, rule)
}
+ if generateBootProfile {
+ bootProfileCommand(ctx, global, module, rule)
+ }
if !dexpreoptDisabled(global, module) {
// Don't preopt individual boot jars, they will be preopted together.
@@ -190,6 +194,38 @@
return profilePath
}
+func bootProfileCommand(ctx android.PathContext, global GlobalConfig, module ModuleConfig,
+ rule *android.RuleBuilder) android.WritablePath {
+
+ profilePath := module.BuildPath.InSameDir(ctx, "profile.bprof")
+ profileInstalledPath := module.DexLocation + ".bprof"
+
+ if !module.ProfileIsTextListing {
+ rule.Command().FlagWithOutput("touch ", profilePath)
+ }
+
+ cmd := rule.Command().
+ Text(`ANDROID_LOG_TAGS="*:e"`).
+ Tool(global.Tools.Profman)
+
+ // The profile is a test listing of methods.
+ // We need to generate the actual binary profile.
+ cmd.FlagWithInput("--create-profile-from=", module.ProfileBootListing.Path())
+
+ cmd.
+ Flag("--generate-boot-profile").
+ FlagWithInput("--apk=", module.DexPath).
+ Flag("--dex-location="+module.DexLocation).
+ FlagWithOutput("--reference-profile-file=", profilePath)
+
+ if !module.ProfileIsTextListing {
+ cmd.Text(fmt.Sprintf(`|| echo "Profile out of date for %s"`, module.DexPath))
+ }
+ rule.Install(profilePath, profileInstalledPath)
+
+ return profilePath
+}
+
func dexpreoptCommand(ctx android.PathContext, global GlobalConfig, module ModuleConfig, rule *android.RuleBuilder,
arch android.ArchType, profile, bootImage android.Path, bootImageDeps android.Paths, appImage, generateDM bool) {
diff --git a/java/androidmk.go b/java/androidmk.go
index ad0e171..90fdd0f 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -55,11 +55,6 @@
}
func (library *Library) AndroidMk() android.AndroidMkData {
- if !library.IsForPlatform() {
- return android.AndroidMkData{
- Disabled: true,
- }
- }
return android.AndroidMkData{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(library.outputFile),
@@ -146,11 +141,6 @@
}
func (prebuilt *Import) AndroidMk() android.AndroidMkData {
- if !prebuilt.IsForPlatform() {
- return android.AndroidMkData{
- Disabled: true,
- }
- }
return android.AndroidMkData{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
@@ -167,11 +157,6 @@
}
func (prebuilt *DexImport) AndroidMk() android.AndroidMkData {
- if !prebuilt.IsForPlatform() {
- return android.AndroidMkData{
- Disabled: true,
- }
- }
return android.AndroidMkData{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index ed12fe6..6214dac 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -143,6 +143,7 @@
strippedDexJarFile := android.PathForModuleOut(ctx, "dexpreopt", dexJarFile.Base())
var profileClassListing android.OptionalPath
+ var profileBootListing android.OptionalPath
profileIsTextListing := false
if BoolDefault(d.dexpreoptProperties.Dex_preopt.Profile_guided, true) {
// If dex_preopt.profile_guided is not set, default it based on the existence of the
@@ -150,6 +151,8 @@
if String(d.dexpreoptProperties.Dex_preopt.Profile) != "" {
profileClassListing = android.OptionalPathForPath(
android.PathForModuleSrc(ctx, String(d.dexpreoptProperties.Dex_preopt.Profile)))
+ profileBootListing = android.ExistentPathForSource(ctx,
+ ctx.ModuleDir(), String(d.dexpreoptProperties.Dex_preopt.Profile)+"-boot")
profileIsTextListing = true
} else {
profileClassListing = android.ExistentPathForSource(ctx,
@@ -169,6 +172,7 @@
ProfileClassListing: profileClassListing,
ProfileIsTextListing: profileIsTextListing,
+ ProfileBootListing: profileBootListing,
EnforceUsesLibraries: d.enforceUsesLibs,
PresentOptionalUsesLibraries: d.optionalUsesLibs,
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 4ef5bcf..19e92b7 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -216,6 +216,7 @@
}
profile := bootImageProfileRule(ctx, image, missingDeps)
+ bootFrameworkProfileRule(ctx, image, missingDeps)
var allFiles android.Paths
@@ -424,6 +425,52 @@
var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule")
+func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath {
+ global := dexpreoptGlobalConfig(ctx)
+
+ if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
+ return nil
+ }
+ return ctx.Config().Once(bootFrameworkProfileRuleKey, func() interface{} {
+ tools := global.Tools
+
+ rule := android.NewRuleBuilder()
+ rule.MissingDeps(missingDeps)
+
+ // Some branches like master-art-host don't have frameworks/base, so manually
+ // handle the case that the default is missing. Those branches won't attempt to build the profile rule,
+ // and if they do they'll get a missing deps error.
+ defaultProfile := "frameworks/base/config/boot-profile.txt"
+ path := android.ExistentPathForSource(ctx, defaultProfile)
+ var bootFrameworkProfile android.Path
+ if path.Valid() {
+ bootFrameworkProfile = path.Path()
+ } else {
+ missingDeps = append(missingDeps, defaultProfile)
+ bootFrameworkProfile = android.PathForOutput(ctx, "missing")
+ }
+
+ profile := image.dir.Join(ctx, "boot.bprof")
+
+ rule.Command().
+ Text(`ANDROID_LOG_TAGS="*:e"`).
+ Tool(tools.Profman).
+ Flag("--generate-boot-profile").
+ FlagWithInput("--create-profile-from=", bootFrameworkProfile).
+ FlagForEachInput("--apk=", image.dexPaths.Paths()).
+ FlagForEachArg("--dex-location=", image.dexLocations).
+ FlagWithOutput("--reference-profile-file=", profile)
+
+ rule.Install(profile, "/system/etc/boot-image.bprof")
+ rule.Build(pctx, ctx, "bootFrameworkProfile", "profile boot framework jars")
+ image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
+
+ return profile
+ }).(android.WritablePath)
+}
+
+var bootFrameworkProfileRuleKey = android.NewOnceKey("bootFrameworkProfileRule")
+
func dumpOatRules(ctx android.SingletonContext, image *bootImage) {
var archs []android.ArchType
for arch := range image.images {
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index 8379f53..c83dda1 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -152,14 +152,6 @@
// Collect dex jar paths for modules that had hiddenapi encode called on them.
if h, ok := module.(hiddenAPIIntf); ok {
if jar := h.bootDexJar(); jar != nil {
- // For a java lib included in an APEX, only take the one built for
- // the platform variant, and skip the variants for APEXes.
- // Otherwise, the hiddenapi tool will complain about duplicated classes
- if a, ok := module.(android.ApexModule); ok {
- if android.InAnyApex(module.Name()) && !a.IsForPlatform() {
- return
- }
- }
bootDexJars = append(bootDexJars, jar)
}
}
diff --git a/java/java.go b/java/java.go
index ca6e232..f3e10be 100644
--- a/java/java.go
+++ b/java/java.go
@@ -267,7 +267,6 @@
type Module struct {
android.ModuleBase
android.DefaultableModuleBase
- android.ApexModuleBase
properties CompilerProperties
protoProperties android.ProtoProperties
@@ -1582,7 +1581,6 @@
&module.Module.protoProperties)
InitJavaModule(module, android.HostAndDeviceSupported)
- android.InitApexModule(module)
return module
}
@@ -1605,7 +1603,6 @@
module.Module.properties.Installable = proptools.BoolPtr(true)
InitJavaModule(module, android.HostSupported)
- android.InitApexModule(module)
return module
}
@@ -1861,7 +1858,6 @@
type Import struct {
android.ModuleBase
android.DefaultableModuleBase
- android.ApexModuleBase
prebuilt android.Prebuilt
properties ImportProperties
@@ -2018,7 +2014,6 @@
android.InitPrebuiltModule(module, &module.properties.Jars)
InitJavaModule(module, android.HostAndDeviceSupported)
- android.InitApexModule(module)
return module
}
@@ -2034,7 +2029,6 @@
android.InitPrebuiltModule(module, &module.properties.Jars)
InitJavaModule(module, android.HostSupported)
- android.InitApexModule(module)
return module
}
@@ -2047,7 +2041,6 @@
type DexImport struct {
android.ModuleBase
android.DefaultableModuleBase
- android.ApexModuleBase
prebuilt android.Prebuilt
properties DexImportProperties
@@ -2139,7 +2132,6 @@
android.InitPrebuiltModule(module, &module.properties.Jars)
InitJavaModule(module, android.DeviceSupported)
- android.InitApexModule(module)
return module
}
@@ -2149,7 +2141,6 @@
type Defaults struct {
android.ModuleBase
android.DefaultsModuleBase
- android.ApexModuleBase
}
// java_defaults provides a set of properties that can be inherited by other java or android modules.
@@ -2208,7 +2199,7 @@
)
android.InitDefaultsModule(module)
- android.InitApexModule(module)
+
return module
}
diff --git a/xml/xml.go b/xml/xml.go
index 7c670fb..3a680ec 100644
--- a/xml/xml.go
+++ b/xml/xml.go
@@ -71,10 +71,6 @@
return android.PathForModuleOut(ctx, p.PrebuiltEtc.SourceFilePath(ctx).Base()+"-timestamp")
}
-func (p *prebuiltEtcXml) DepsMutator(ctx android.BottomUpMutatorContext) {
- p.PrebuiltEtc.DepsMutator(ctx)
-}
-
func (p *prebuiltEtcXml) GenerateAndroidBuildActions(ctx android.ModuleContext) {
p.PrebuiltEtc.GenerateAndroidBuildActions(ctx)
@@ -125,9 +121,8 @@
func PrebuiltEtcXmlFactory() android.Module {
module := &prebuiltEtcXml{}
module.AddProperties(&module.properties)
-
- android.InitPrebuiltEtcModule(&module.PrebuiltEtc)
+ android.InitPrebuiltEtcModule(&module.PrebuiltEtc, "etc")
// This module is device-only
- android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
return module
}
diff --git a/xml/xml_test.go b/xml/xml_test.go
index e8fa49c..ae3e9fe 100644
--- a/xml/xml_test.go
+++ b/xml/xml_test.go
@@ -34,6 +34,7 @@
"foo.dtd": nil,
"bar.xml": nil,
"bar.xsd": nil,
+ "baz.xml": nil,
}
ctx.MockFileSystem(mockFiles)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
@@ -59,6 +60,13 @@
os.RemoveAll(buildDir)
}
+func assertEqual(t *testing.T, name, expected, actual string) {
+ t.Helper()
+ if expected != actual {
+ t.Errorf(name+" expected %q != got %q", expected, actual)
+ }
+}
+
// Minimal test
func TestPrebuiltEtcXml(t *testing.T) {
ctx := testXml(t, `
@@ -72,15 +80,28 @@
src: "bar.xml",
schema: "bar.xsd",
}
+ prebuilt_etc_xml {
+ name: "baz.xml",
+ src: "baz.xml",
+ }
`)
- xmllint := ctx.ModuleForTests("foo.xml", "android_common").Rule("xmllint")
- input := xmllint.Input.String()
- if input != "foo.xml" {
- t.Errorf("input expected %q != got %q", "foo.xml", input)
+ for _, tc := range []struct {
+ rule, input, schemaType, schema string
+ }{
+ {rule: "xmllint-dtd", input: "foo.xml", schemaType: "dtd", schema: "foo.dtd"},
+ {rule: "xmllint-xsd", input: "bar.xml", schemaType: "xsd", schema: "bar.xsd"},
+ {rule: "xmllint-minimal", input: "baz.xml"},
+ } {
+ t.Run(tc.schemaType, func(t *testing.T) {
+ rule := ctx.ModuleForTests(tc.input, "android_arm64_armv8-a").Rule(tc.rule)
+ assertEqual(t, "input", tc.input, rule.Input.String())
+ if tc.schemaType != "" {
+ assertEqual(t, "schema", tc.schema, rule.Args[tc.schemaType])
+ }
+ })
}
- schema := xmllint.Args["dtd"]
- if schema != "foo.dtd" {
- t.Errorf("dtd expected %q != got %q", "foo.dtdl", schema)
- }
+
+ m := ctx.ModuleForTests("foo.xml", "android_arm64_armv8-a").Module().(*prebuiltEtcXml)
+ assertEqual(t, "installDir", "target/product/test_device/system/etc", m.InstallDirPath().RelPathString())
}