Merge "Fix build failure when building unbundled apps (second try)"
This commit is contained in:
@@ -121,13 +121,6 @@ type hiddenAPIIntf interface {
|
|||||||
|
|
||||||
var _ hiddenAPIIntf = (*hiddenAPI)(nil)
|
var _ hiddenAPIIntf = (*hiddenAPI)(nil)
|
||||||
|
|
||||||
// hiddenAPISupportingModule is the interface that is implemented by any module that supports
|
|
||||||
// contributing to the hidden API processing.
|
|
||||||
type hiddenAPISupportingModule interface {
|
|
||||||
android.Module
|
|
||||||
hiddenAPIIntf
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the hiddenapi structure
|
// Initialize the hiddenapi structure
|
||||||
func (h *hiddenAPI) initHiddenAPI(ctx android.BaseModuleContext, configurationName string) {
|
func (h *hiddenAPI) initHiddenAPI(ctx android.BaseModuleContext, configurationName string) {
|
||||||
// If hiddenapi processing is disabled treat this as inactive.
|
// If hiddenapi processing is disabled treat this as inactive.
|
||||||
|
@@ -239,6 +239,17 @@ func (b *platformBootclasspathModule) getImageConfig(ctx android.EarlyModuleCont
|
|||||||
return defaultBootImageConfig(ctx)
|
return defaultBootImageConfig(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hiddenAPISupportingModule encapsulates the information provided by any module that contributes to
|
||||||
|
// the hidden API processing.
|
||||||
|
type hiddenAPISupportingModule struct {
|
||||||
|
module android.Module
|
||||||
|
|
||||||
|
bootDexJar android.Path
|
||||||
|
flagsCSV android.Path
|
||||||
|
indexCSV android.Path
|
||||||
|
metadataCSV android.Path
|
||||||
|
}
|
||||||
|
|
||||||
// generateHiddenAPIBuildActions generates all the hidden API related build rules.
|
// generateHiddenAPIBuildActions generates all the hidden API related build rules.
|
||||||
func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, modules []android.Module, fragments []android.Module) {
|
func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, modules []android.Module, fragments []android.Module) {
|
||||||
|
|
||||||
@@ -261,27 +272,55 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
hiddenAPISupportingModules := []hiddenAPISupportingModule{}
|
// nilPathHandler will check the supplied path and if it is nil then it will either immediately
|
||||||
for _, module := range modules {
|
// report an error, or it will defer the error reporting until it is actually used, depending
|
||||||
if h, ok := module.(hiddenAPISupportingModule); ok {
|
// whether missing dependencies are allowed.
|
||||||
if h.bootDexJar() == nil {
|
var nilPathHandler func(path android.Path, name string, module android.Module) android.Path
|
||||||
ctx.ModuleErrorf("module %s does not provide a bootDexJar file", module)
|
if ctx.Config().AllowMissingDependencies() {
|
||||||
|
nilPathHandler = func(path android.Path, name string, module android.Module) android.Path {
|
||||||
|
if path == nil {
|
||||||
|
outputPath := android.PathForModuleOut(ctx, "missing", module.Name(), name)
|
||||||
|
path = outputPath
|
||||||
|
|
||||||
|
// Create an error rule that pretends to create the output file but will actually fail if it
|
||||||
|
// is run.
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: android.ErrorRule,
|
||||||
|
Output: outputPath,
|
||||||
|
Args: map[string]string{
|
||||||
|
"error": fmt.Sprintf("missing hidden API file: %s for %s", name, module),
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if h.flagsCSV() == nil {
|
return path
|
||||||
ctx.ModuleErrorf("module %s does not provide a flagsCSV file", module)
|
|
||||||
}
|
}
|
||||||
if h.indexCSV() == nil {
|
} else {
|
||||||
ctx.ModuleErrorf("module %s does not provide an indexCSV file", module)
|
nilPathHandler = func(path android.Path, name string, module android.Module) android.Path {
|
||||||
|
if path == nil {
|
||||||
|
ctx.ModuleErrorf("module %s does not provide a %s file", module, name)
|
||||||
|
}
|
||||||
|
return path
|
||||||
}
|
}
|
||||||
if h.metadataCSV() == nil {
|
|
||||||
ctx.ModuleErrorf("module %s does not provide a metadataCSV file", module)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hiddenAPISupportingModules := []hiddenAPISupportingModule{}
|
||||||
|
for _, module := range modules {
|
||||||
|
if h, ok := module.(hiddenAPIIntf); ok {
|
||||||
|
hiddenAPISupportingModule := hiddenAPISupportingModule{
|
||||||
|
module: module,
|
||||||
|
bootDexJar: nilPathHandler(h.bootDexJar(), "bootDexJar", module),
|
||||||
|
flagsCSV: nilPathHandler(h.flagsCSV(), "flagsCSV", module),
|
||||||
|
indexCSV: nilPathHandler(h.indexCSV(), "indexCSV", module),
|
||||||
|
metadataCSV: nilPathHandler(h.metadataCSV(), "metadataCSV", module),
|
||||||
|
}
|
||||||
|
|
||||||
|
// If any errors were reported when trying to populate the hiddenAPISupportingModule struct
|
||||||
|
// then don't add it to the list.
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
hiddenAPISupportingModules = append(hiddenAPISupportingModules, h)
|
hiddenAPISupportingModules = append(hiddenAPISupportingModules, hiddenAPISupportingModule)
|
||||||
} else {
|
} else {
|
||||||
ctx.ModuleErrorf("module %s of type %s does not support hidden API processing", module, ctx.OtherModuleType(module))
|
ctx.ModuleErrorf("module %s of type %s does not support hidden API processing", module, ctx.OtherModuleType(module))
|
||||||
}
|
}
|
||||||
@@ -289,7 +328,7 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
|
|||||||
|
|
||||||
moduleSpecificFlagsPaths := android.Paths{}
|
moduleSpecificFlagsPaths := android.Paths{}
|
||||||
for _, module := range hiddenAPISupportingModules {
|
for _, module := range hiddenAPISupportingModules {
|
||||||
moduleSpecificFlagsPaths = append(moduleSpecificFlagsPaths, module.flagsCSV())
|
moduleSpecificFlagsPaths = append(moduleSpecificFlagsPaths, module.flagsCSV)
|
||||||
}
|
}
|
||||||
|
|
||||||
flagFileInfo := b.properties.Hidden_api.hiddenAPIFlagFileInfo(ctx)
|
flagFileInfo := b.properties.Hidden_api.hiddenAPIFlagFileInfo(ctx)
|
||||||
@@ -315,7 +354,7 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
|
|||||||
func (b *platformBootclasspathModule) generateHiddenAPIStubFlagsRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) {
|
func (b *platformBootclasspathModule) generateHiddenAPIStubFlagsRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) {
|
||||||
bootDexJars := android.Paths{}
|
bootDexJars := android.Paths{}
|
||||||
for _, module := range modules {
|
for _, module := range modules {
|
||||||
bootDexJars = append(bootDexJars, module.bootDexJar())
|
bootDexJars = append(bootDexJars, module.bootDexJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
sdkKindToStubPaths := hiddenAPIGatherStubLibDexJarPaths(ctx)
|
sdkKindToStubPaths := hiddenAPIGatherStubLibDexJarPaths(ctx)
|
||||||
@@ -328,7 +367,7 @@ func (b *platformBootclasspathModule) generateHiddenAPIStubFlagsRules(ctx androi
|
|||||||
func (b *platformBootclasspathModule) generateHiddenAPIIndexRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) {
|
func (b *platformBootclasspathModule) generateHiddenAPIIndexRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) {
|
||||||
indexes := android.Paths{}
|
indexes := android.Paths{}
|
||||||
for _, module := range modules {
|
for _, module := range modules {
|
||||||
indexes = append(indexes, module.indexCSV())
|
indexes = append(indexes, module.indexCSV)
|
||||||
}
|
}
|
||||||
|
|
||||||
rule := android.NewRuleBuilder(pctx, ctx)
|
rule := android.NewRuleBuilder(pctx, ctx)
|
||||||
@@ -344,7 +383,7 @@ func (b *platformBootclasspathModule) generateHiddenAPIIndexRules(ctx android.Mo
|
|||||||
func (b *platformBootclasspathModule) generatedHiddenAPIMetadataRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) {
|
func (b *platformBootclasspathModule) generatedHiddenAPIMetadataRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) {
|
||||||
metadataCSVFiles := android.Paths{}
|
metadataCSVFiles := android.Paths{}
|
||||||
for _, module := range modules {
|
for _, module := range modules {
|
||||||
metadataCSVFiles = append(metadataCSVFiles, module.metadataCSV())
|
metadataCSVFiles = append(metadataCSVFiles, module.metadataCSV)
|
||||||
}
|
}
|
||||||
|
|
||||||
rule := android.NewRuleBuilder(pctx, ctx)
|
rule := android.NewRuleBuilder(pctx, ctx)
|
||||||
|
Reference in New Issue
Block a user