Revert "Use hashed subdir for soong_config modules"
This reverts commit 81b00a8db7
.
Reason for revert:
* select() will supersede Soong config modules.
* A tiny change can make hundreds of gigabytes rebuilt.
* Hashed out/ directories are not cleaned.
* Even without this trace, AB build time is fast enough, thanks to
product-specific ninja files and so on.
Bug: 348548855
Test: m --no-skip-soong-tests
Change-Id: If9a97df1e161a9ef0fb1b801f9e129b71b11d1ac
This commit is contained in:
@@ -15,9 +15,6 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
@@ -249,31 +246,6 @@ func SortedUniqueNamedPaths(l NamedPaths) NamedPaths {
|
||||
return l[:k+1]
|
||||
}
|
||||
|
||||
// soongConfigTrace holds all references to VendorVars. Uses []string for blueprint:"mutated"
|
||||
type soongConfigTrace struct {
|
||||
Bools []string `json:",omitempty"`
|
||||
Strings []string `json:",omitempty"`
|
||||
IsSets []string `json:",omitempty"`
|
||||
}
|
||||
|
||||
func (c *soongConfigTrace) isEmpty() bool {
|
||||
return len(c.Bools) == 0 && len(c.Strings) == 0 && len(c.IsSets) == 0
|
||||
}
|
||||
|
||||
// Returns hash of serialized trace records (empty string if there's no trace recorded)
|
||||
func (c *soongConfigTrace) hash() string {
|
||||
// Use MD5 for speed. We don't care collision or preimage attack
|
||||
if c.isEmpty() {
|
||||
return ""
|
||||
}
|
||||
j, err := json.Marshal(c)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("json marshal of %#v failed: %#v", *c, err))
|
||||
}
|
||||
hash := md5.Sum(j)
|
||||
return hex.EncodeToString(hash[:])
|
||||
}
|
||||
|
||||
type nameProperties struct {
|
||||
// The name of the module. Must be unique across all modules.
|
||||
Name *string
|
||||
@@ -525,14 +497,6 @@ type commonProperties struct {
|
||||
// constants in image.go, but can also be set to a custom value by individual module types.
|
||||
ImageVariation string `blueprint:"mutated"`
|
||||
|
||||
// SoongConfigTrace records accesses to VendorVars (soong_config). The trace will be hashed
|
||||
// and used as a subdir of PathForModuleOut. Note that we mainly focus on incremental
|
||||
// builds among similar products (e.g. aosp_cf_x86_64_phone and aosp_cf_x86_64_foldable),
|
||||
// and there are variables other than soong_config, which isn't captured by soong config
|
||||
// trace, but influence modules among products.
|
||||
SoongConfigTrace soongConfigTrace `blueprint:"mutated"`
|
||||
SoongConfigTraceHash string `blueprint:"mutated"`
|
||||
|
||||
// The team (defined by the owner/vendor) who owns the property.
|
||||
Team *string `android:"path"`
|
||||
}
|
||||
@@ -2575,8 +2539,6 @@ type HostToolProvider interface {
|
||||
|
||||
func init() {
|
||||
RegisterParallelSingletonType("buildtarget", BuildTargetSingleton)
|
||||
RegisterParallelSingletonType("soongconfigtrace", soongConfigTraceSingletonFunc)
|
||||
FinalDepsMutators(registerSoongConfigTraceMutator)
|
||||
}
|
||||
|
||||
func BuildTargetSingleton() Singleton {
|
||||
@@ -2738,54 +2700,3 @@ func CheckBlueprintSyntax(ctx BaseModuleContext, filename string, contents strin
|
||||
bpctx := ctx.blueprintBaseModuleContext()
|
||||
return blueprint.CheckBlueprintSyntax(bpctx.ModuleFactories(), filename, contents)
|
||||
}
|
||||
|
||||
func registerSoongConfigTraceMutator(ctx RegisterMutatorsContext) {
|
||||
ctx.BottomUp("soongconfigtrace", soongConfigTraceMutator).Parallel()
|
||||
}
|
||||
|
||||
// soongConfigTraceMutator accumulates recorded soong_config trace from children. Also it normalizes
|
||||
// SoongConfigTrace to make it consistent.
|
||||
func soongConfigTraceMutator(ctx BottomUpMutatorContext) {
|
||||
trace := &ctx.Module().base().commonProperties.SoongConfigTrace
|
||||
ctx.VisitDirectDeps(func(m Module) {
|
||||
childTrace := &m.base().commonProperties.SoongConfigTrace
|
||||
trace.Bools = append(trace.Bools, childTrace.Bools...)
|
||||
trace.Strings = append(trace.Strings, childTrace.Strings...)
|
||||
trace.IsSets = append(trace.IsSets, childTrace.IsSets...)
|
||||
})
|
||||
trace.Bools = SortedUniqueStrings(trace.Bools)
|
||||
trace.Strings = SortedUniqueStrings(trace.Strings)
|
||||
trace.IsSets = SortedUniqueStrings(trace.IsSets)
|
||||
|
||||
ctx.Module().base().commonProperties.SoongConfigTraceHash = trace.hash()
|
||||
}
|
||||
|
||||
// soongConfigTraceSingleton writes a map from each module's config hash value to trace data.
|
||||
func soongConfigTraceSingletonFunc() Singleton {
|
||||
return &soongConfigTraceSingleton{}
|
||||
}
|
||||
|
||||
type soongConfigTraceSingleton struct {
|
||||
}
|
||||
|
||||
func (s *soongConfigTraceSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||
outFile := PathForOutput(ctx, "soong_config_trace.json")
|
||||
|
||||
traces := make(map[string]*soongConfigTrace)
|
||||
ctx.VisitAllModules(func(module Module) {
|
||||
trace := &module.base().commonProperties.SoongConfigTrace
|
||||
if !trace.isEmpty() {
|
||||
hash := module.base().commonProperties.SoongConfigTraceHash
|
||||
traces[hash] = trace
|
||||
}
|
||||
})
|
||||
|
||||
j, err := json.Marshal(traces)
|
||||
if err != nil {
|
||||
ctx.Errorf("json marshal to %q failed: %#v", outFile, err)
|
||||
return
|
||||
}
|
||||
|
||||
WriteFileRule(ctx, outFile, string(j))
|
||||
ctx.Phony("soong_config_trace", outFile)
|
||||
}
|
||||
|
Reference in New Issue
Block a user