Export the license metadata files for dexpreopted bootjars to Make

Track the license metadata file of the module used to dexpreopt
bootjars and pass it to Make.

Bug: 224612665
Test: m alllicensemetadata reportmissinglicenses
Change-Id: I8466c3d8edf7dc44976c2a343bd38799c6617db2
This commit is contained in:
Colin Cross
2022-03-15 17:49:24 -07:00
parent 8a195897d1
commit e7fe0962f4
2 changed files with 23 additions and 0 deletions

View File

@@ -456,6 +456,10 @@ type ModuleContext interface {
// GetMissingDependencies returns the list of dependencies that were passed to AddDependencies or related methods, // GetMissingDependencies returns the list of dependencies that were passed to AddDependencies or related methods,
// but do not exist. // but do not exist.
GetMissingDependencies() []string GetMissingDependencies() []string
// LicenseMetadataFile returns the path where the license metadata for this module will be
// generated.
LicenseMetadataFile() Path
} }
type Module interface { type Module interface {
@@ -3279,6 +3283,10 @@ func (m *moduleContext) blueprintModuleContext() blueprint.ModuleContext {
return m.bp return m.bp
} }
func (m *moduleContext) LicenseMetadataFile() Path {
return m.module.base().licenseMetadataFile
}
// SrcIsModule decodes module references in the format ":unqualified-name" or "//namespace:name" // SrcIsModule decodes module references in the format ":unqualified-name" or "//namespace:name"
// into the module name, or empty string if the input was not a module reference. // into the module name, or empty string if the input was not a module reference.
func SrcIsModule(s string) (module string) { func SrcIsModule(s string) (module string) {

View File

@@ -276,6 +276,9 @@ type bootImageConfig struct {
// Rules which should be used in make to install the outputs. // Rules which should be used in make to install the outputs.
profileInstalls android.RuleBuilderInstalls profileInstalls android.RuleBuilderInstalls
// Path to the license metadata file for the module that built the profile.
profileLicenseMetadataFile android.OptionalPath
// Path to the image profile file on host (or empty, if profile is not generated). // Path to the image profile file on host (or empty, if profile is not generated).
profilePathOnHost android.Path profilePathOnHost android.Path
@@ -320,6 +323,9 @@ type bootImageVariant struct {
// Rules which should be used in make to install the outputs on device. // Rules which should be used in make to install the outputs on device.
deviceInstalls android.RuleBuilderInstalls deviceInstalls android.RuleBuilderInstalls
// Path to the license metadata file for the module that built the image.
licenseMetadataFile android.OptionalPath
} }
// Get target-specific boot image variant for the given boot image config and target. // Get target-specific boot image variant for the given boot image config and target.
@@ -759,6 +765,7 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p
image.vdexInstalls = vdexInstalls image.vdexInstalls = vdexInstalls
image.unstrippedInstalls = unstrippedInstalls image.unstrippedInstalls = unstrippedInstalls
image.deviceInstalls = deviceInstalls image.deviceInstalls = deviceInstalls
image.licenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile())
} }
const failureMessage = `ERROR: Dex2oat failed to compile a boot image. const failureMessage = `ERROR: Dex2oat failed to compile a boot image.
@@ -807,6 +814,7 @@ func bootImageProfileRule(ctx android.ModuleContext, image *bootImageConfig) and
if image == defaultBootImageConfig(ctx) { if image == defaultBootImageConfig(ctx) {
rule.Install(profile, "/system/etc/boot-image.prof") rule.Install(profile, "/system/etc/boot-image.prof")
image.profileInstalls = append(image.profileInstalls, rule.Installs()...) image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
image.profileLicenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile())
} }
rule.Build("bootJarsProfile", "profile boot jars") rule.Build("bootJarsProfile", "profile boot jars")
@@ -844,6 +852,7 @@ func bootFrameworkProfileRule(ctx android.ModuleContext, image *bootImageConfig)
rule.Install(profile, "/system/etc/boot-image.bprof") rule.Install(profile, "/system/etc/boot-image.bprof")
rule.Build("bootFrameworkProfile", "profile boot framework jars") rule.Build("bootFrameworkProfile", "profile boot framework jars")
image.profileInstalls = append(image.profileInstalls, rule.Installs()...) image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
image.profileLicenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile())
return profile return profile
} }
@@ -909,6 +918,9 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
image := d.defaultBootImage image := d.defaultBootImage
if image != nil { if image != nil {
ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String()) ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String())
if image.profileLicenseMetadataFile.Valid() {
ctx.Strict("DEXPREOPT_IMAGE_PROFILE_LICENSE_METADATA", image.profileLicenseMetadataFile.String())
}
global := dexpreopt.GetGlobalConfig(ctx) global := dexpreopt.GetGlobalConfig(ctx)
dexPaths, dexLocations := bcpForDexpreopt(ctx, global.PreoptWithUpdatableBcp) dexPaths, dexLocations := bcpForDexpreopt(ctx, global.PreoptWithUpdatableBcp)
@@ -934,6 +946,9 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
ctx.Strict("DEXPREOPT_IMAGE_DEPS_"+sfx, strings.Join(variant.imagesDeps.Strings(), " ")) ctx.Strict("DEXPREOPT_IMAGE_DEPS_"+sfx, strings.Join(variant.imagesDeps.Strings(), " "))
ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, variant.installs.String()) ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, variant.installs.String())
ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, variant.unstrippedInstalls.String()) ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, variant.unstrippedInstalls.String())
if variant.licenseMetadataFile.Valid() {
ctx.Strict("DEXPREOPT_IMAGE_LICENSE_METADATA_"+sfx, variant.licenseMetadataFile.String())
}
} }
imageLocationsOnHost, imageLocationsOnDevice := current.getAnyAndroidVariant().imageLocations() imageLocationsOnHost, imageLocationsOnDevice := current.getAnyAndroidVariant().imageLocations()
ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_ON_HOST"+current.name, strings.Join(imageLocationsOnHost, ":")) ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_ON_HOST"+current.name, strings.Join(imageLocationsOnHost, ":"))