Merge changes Ifcb338e6,Ie509ed80,I270fed60,Id825cb75,I92a963bd am: cc2d11961c am: 9053375b93

am: 31cabeea1c

Change-Id: I3abcc60539de84d3365df989de341b4bb3e1db09
This commit is contained in:
Colin Cross
2019-02-05 21:26:50 -08:00
committed by android-build-merger
23 changed files with 928 additions and 283 deletions

View File

@@ -46,7 +46,7 @@ type overlayGlobResult struct {
paths android.DirectorySortedPaths
}
const overlayDataKey = "overlayDataKey"
var overlayDataKey = android.NewOnceKey("overlayDataKey")
type globbedResourceDir struct {
dir android.Path

View File

@@ -15,12 +15,6 @@
package java
import (
"path/filepath"
"strings"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
"android/soong/dexpreopt"
)
@@ -87,12 +81,14 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.ModuleContext) bool {
return false
}
var dexpreoptGlobalConfigKey = android.NewOnceKey("DexpreoptGlobalConfig")
func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.ModuleOutPath) android.ModuleOutPath {
if d.dexpreoptDisabled(ctx) {
return dexJarFile
}
globalConfig := ctx.Config().Once("DexpreoptGlobalConfig", func() interface{} {
globalConfig := ctx.Config().Once(dexpreoptGlobalConfigKey, func() interface{} {
if f := ctx.Config().DexpreoptGlobalConfig(); f != "" {
ctx.AddNinjaFileDeps(f)
globalConfig, err := dexpreopt.LoadGlobalConfig(f)
@@ -185,69 +181,19 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
return dexJarFile
}
var inputs android.Paths
for _, input := range dexpreoptRule.Inputs() {
if input == "" {
// Tests sometimes have empty configuration values that lead to empty inputs
continue
}
rel, isRel := android.MaybeRel(ctx, android.PathForModuleOut(ctx).String(), input)
if isRel {
inputs = append(inputs, android.PathForModuleOut(ctx, rel))
} else {
// TODO: use PathForOutput once boot image is moved to where PathForOutput can find it.
inputs = append(inputs, &bootImagePath{input})
}
}
var outputs android.WritablePaths
for _, output := range dexpreoptRule.Outputs() {
rel := android.Rel(ctx, android.PathForModuleOut(ctx).String(), output)
outputs = append(outputs, android.PathForModuleOut(ctx, rel))
}
dexpreoptRule.Build(pctx, ctx, "dexpreopt", "dexpreopt")
for _, install := range dexpreoptRule.Installs() {
d.builtInstalled = append(d.builtInstalled, install.From+":"+install.To)
}
if len(dexpreoptRule.Commands()) > 0 {
ctx.Build(pctx, android.BuildParams{
Rule: ctx.Rule(pctx, "dexpreopt", blueprint.RuleParams{
Command: strings.Join(proptools.NinjaEscape(dexpreoptRule.Commands()), " && "),
CommandDeps: dexpreoptRule.Tools(),
}),
Implicits: inputs,
Outputs: outputs,
Description: "dexpreopt",
})
}
stripRule, err := dexpreopt.GenerateStripRule(globalConfig, dexpreoptConfig)
if err != nil {
ctx.ModuleErrorf("error generating dexpreopt strip rule: %s", err.Error())
return dexJarFile
}
ctx.Build(pctx, android.BuildParams{
Rule: ctx.Rule(pctx, "dexpreopt_strip", blueprint.RuleParams{
Command: strings.Join(proptools.NinjaEscape(stripRule.Commands()), " && "),
CommandDeps: stripRule.Tools(),
}),
Input: dexJarFile,
Output: strippedDexJarFile,
Description: "dexpreopt strip",
})
stripRule.Build(pctx, ctx, "dexpreopt_strip", "dexpreopt strip")
return strippedDexJarFile
}
type bootImagePath struct {
path string
}
var _ android.Path = (*bootImagePath)(nil)
func (p *bootImagePath) String() string { return p.path }
func (p *bootImagePath) Ext() string { return filepath.Ext(p.path) }
func (p *bootImagePath) Base() string { return filepath.Base(p.path) }
func (p *bootImagePath) Rel() string { return p.path }

View File

@@ -15,6 +15,7 @@
package java
import (
"path/filepath"
"sort"
"strings"
"sync"
@@ -32,7 +33,7 @@ var hiddenAPIGenerateCSVRule = pctx.AndroidStaticRule("hiddenAPIGenerateCSV", bl
func hiddenAPIGenerateCSV(ctx android.ModuleContext, classesJar android.Path) {
flagsCSV := android.PathForModuleOut(ctx, "hiddenapi", "flags.csv")
metadataCSV := android.PathForModuleOut(ctx, "hiddenapi", "metadata.csv")
stubFlagsCSV := &bootImagePath{ctx.Config().HiddenAPIStubFlags()}
stubFlagsCSV := &hiddenAPIPath{ctx.Config().HiddenAPIStubFlags()}
ctx.Build(pctx, android.BuildParams{
Rule: hiddenAPIGenerateCSVRule,
@@ -80,7 +81,7 @@ var hiddenAPIEncodeDexRule = pctx.AndroidStaticRule("hiddenAPIEncodeDex", bluepr
func hiddenAPIEncodeDex(ctx android.ModuleContext, output android.WritablePath, dexInput android.WritablePath,
uncompressDex bool) {
flagsCsv := &bootImagePath{ctx.Config().HiddenAPIFlags()}
flagsCsv := &hiddenAPIPath{ctx.Config().HiddenAPIFlags()}
// The encode dex rule requires unzipping and rezipping the classes.dex files, ensure that if it was uncompressed
// in the input it stays uncompressed in the output.
@@ -120,7 +121,7 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, output android.WritablePath,
hiddenAPISaveDexInputs(ctx, dexInput)
}
const hiddenAPIOutputsKey = "hiddenAPIOutputsKey"
var hiddenAPIOutputsKey = android.NewOnceKey("hiddenAPIOutputsKey")
var hiddenAPIOutputsLock sync.Mutex
@@ -168,3 +169,14 @@ func hiddenAPIMakeVars(ctx android.MakeVarsContext) {
export("SOONG_HIDDENAPI_GREYLIST_METADATA", metadataCSVList)
export("SOONG_HIDDENAPI_DEX_INPUTS", dexInputList)
}
type hiddenAPIPath struct {
path string
}
var _ android.Path = (*hiddenAPIPath)(nil)
func (p *hiddenAPIPath) String() string { return p.path }
func (p *hiddenAPIPath) Ext() string { return filepath.Ext(p.path) }
func (p *hiddenAPIPath) Base() string { return filepath.Base(p.path) }
func (p *hiddenAPIPath) Rel() string { return p.path }

View File

@@ -28,7 +28,7 @@ func init() {
android.RegisterPreSingletonType("sdk", sdkSingletonFactory)
}
const sdkSingletonKey = "sdkSingletonKey"
var sdkSingletonKey = android.NewOnceKey("sdkSingletonKey")
type sdkContext interface {
// sdkVersion eturns the sdk_version property of the current module, or an empty string if it is not set.

View File

@@ -627,8 +627,10 @@ func (module *sdkLibrary) ImplementationJars(ctx android.BaseContext, sdkVersion
}
}
var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries")
func javaSdkLibraries(config android.Config) *[]string {
return config.Once("javaSdkLibraries", func() interface{} {
return config.Once(javaSdkLibrariesKey, func() interface{} {
return &[]string{}
}).(*[]string)
}