Merge "Move the caching/restoring code from soong to blueprint to fully skip build actions." into main
This commit is contained in:
@@ -219,11 +219,4 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module
|
|||||||
android.SetProvider(ctx, android.AconfigReleaseDeclarationsProviderKey, providerData)
|
android.SetProvider(ctx, android.AconfigReleaseDeclarationsProviderKey, providerData)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *DeclarationsModule) BuildActionProviderKeys() []blueprint.AnyProviderKey {
|
|
||||||
return []blueprint.AnyProviderKey{
|
|
||||||
android.AconfigDeclarationsProviderKey,
|
|
||||||
android.AconfigReleaseDeclarationsProviderKey,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ blueprint.Incremental = &DeclarationsModule{}
|
var _ blueprint.Incremental = &DeclarationsModule{}
|
||||||
|
@@ -15,8 +15,6 @@
|
|||||||
package aconfig
|
package aconfig
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/gob"
|
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
@@ -108,10 +106,6 @@ func init() {
|
|||||||
RegisterBuildComponents(android.InitRegistrationContext)
|
RegisterBuildComponents(android.InitRegistrationContext)
|
||||||
pctx.HostBinToolVariable("aconfig", "aconfig")
|
pctx.HostBinToolVariable("aconfig", "aconfig")
|
||||||
pctx.HostBinToolVariable("soong_zip", "soong_zip")
|
pctx.HostBinToolVariable("soong_zip", "soong_zip")
|
||||||
|
|
||||||
gob.Register(android.AconfigDeclarationsProviderData{})
|
|
||||||
gob.Register(android.AconfigReleaseDeclarationsProviderData{})
|
|
||||||
gob.Register(android.ModuleOutPath{})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterBuildComponents(ctx android.RegistrationContext) {
|
func RegisterBuildComponents(ctx android.RegistrationContext) {
|
||||||
|
@@ -59,6 +59,7 @@ bootstrap_go_package {
|
|||||||
"gen_notice.go",
|
"gen_notice.go",
|
||||||
"hooks.go",
|
"hooks.go",
|
||||||
"image.go",
|
"image.go",
|
||||||
|
"init.go",
|
||||||
"license.go",
|
"license.go",
|
||||||
"license_kind.go",
|
"license_kind.go",
|
||||||
"license_metadata.go",
|
"license_metadata.go",
|
||||||
|
@@ -17,6 +17,7 @@ package android
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -131,6 +132,28 @@ func NewComplianceMetadataInfo() *ComplianceMetadataInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ComplianceMetadataInfo) GobEncode() ([]byte, error) {
|
||||||
|
w := new(bytes.Buffer)
|
||||||
|
encoder := gob.NewEncoder(w)
|
||||||
|
err := encoder.Encode(c.properties)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return w.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ComplianceMetadataInfo) GobDecode(data []byte) error {
|
||||||
|
r := bytes.NewBuffer(data)
|
||||||
|
decoder := gob.NewDecoder(r)
|
||||||
|
err := decoder.Decode(&c.properties)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *ComplianceMetadataInfo) SetStringValue(propertyName string, value string) {
|
func (c *ComplianceMetadataInfo) SetStringValue(propertyName string, value string) {
|
||||||
if !slices.Contains(COMPLIANCE_METADATA_PROPS, propertyName) {
|
if !slices.Contains(COMPLIANCE_METADATA_PROPS, propertyName) {
|
||||||
panic(fmt.Errorf("Unknown metadata property: %s.", propertyName))
|
panic(fmt.Errorf("Unknown metadata property: %s.", propertyName))
|
||||||
|
@@ -15,6 +15,9 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/gob"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -65,6 +68,30 @@ type DepSet[T depSettableType] struct {
|
|||||||
transitive []*DepSet[T]
|
transitive []*DepSet[T]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DepSet[T]) GobEncode() ([]byte, error) {
|
||||||
|
w := new(bytes.Buffer)
|
||||||
|
encoder := gob.NewEncoder(w)
|
||||||
|
err := errors.Join(encoder.Encode(d.preorder), encoder.Encode(d.reverse),
|
||||||
|
encoder.Encode(d.order), encoder.Encode(d.direct), encoder.Encode(d.transitive))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return w.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DepSet[T]) GobDecode(data []byte) error {
|
||||||
|
r := bytes.NewBuffer(data)
|
||||||
|
decoder := gob.NewDecoder(r)
|
||||||
|
err := errors.Join(decoder.Decode(&d.preorder), decoder.Decode(&d.reverse),
|
||||||
|
decoder.Decode(&d.order), decoder.Decode(&d.direct), decoder.Decode(&d.transitive))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewDepSet returns an immutable DepSet with the given order, direct and transitive contents.
|
// NewDepSet returns an immutable DepSet with the given order, direct and transitive contents.
|
||||||
func NewDepSet[T depSettableType](order DepSetOrder, direct []T, transitive []*DepSet[T]) *DepSet[T] {
|
func NewDepSet[T depSettableType](order DepSetOrder, direct []T, transitive []*DepSet[T]) *DepSet[T] {
|
||||||
var directCopy []T
|
var directCopy []T
|
||||||
|
22
android/init.go
Normal file
22
android/init.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// Copyright 2024 Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package android
|
||||||
|
|
||||||
|
import "encoding/gob"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
gob.Register(ModuleOutPath{})
|
||||||
|
gob.Register(unstableInfo{})
|
||||||
|
}
|
@@ -15,6 +15,9 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/gob"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -1901,61 +1904,16 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
incrementalAnalysis := false
|
m.module.GenerateAndroidBuildActions(ctx)
|
||||||
incrementalEnabled := false
|
if ctx.Failed() {
|
||||||
var cacheKey *blueprint.BuildActionCacheKey = nil
|
return
|
||||||
var incrementalModule *blueprint.Incremental = nil
|
|
||||||
if ctx.bp.GetIncrementalEnabled() {
|
|
||||||
if im, ok := m.module.(blueprint.Incremental); ok {
|
|
||||||
incrementalModule = &im
|
|
||||||
incrementalEnabled = im.IncrementalSupported()
|
|
||||||
incrementalAnalysis = ctx.bp.GetIncrementalAnalysis() && incrementalEnabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if incrementalEnabled {
|
|
||||||
hash, err := proptools.CalculateHash(m.GetProperties())
|
|
||||||
if err != nil {
|
|
||||||
ctx.ModuleErrorf("failed to calculate properties hash: %s", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
cacheInput := new(blueprint.BuildActionCacheInput)
|
|
||||||
cacheInput.PropertiesHash = hash
|
|
||||||
ctx.VisitDirectDeps(func(module Module) {
|
|
||||||
cacheInput.ProvidersHash =
|
|
||||||
append(cacheInput.ProvidersHash, ctx.bp.OtherModuleProviderInitialValueHashes(module))
|
|
||||||
})
|
|
||||||
hash, err = proptools.CalculateHash(&cacheInput)
|
|
||||||
if err != nil {
|
|
||||||
ctx.ModuleErrorf("failed to calculate cache input hash: %s", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
cacheKey = &blueprint.BuildActionCacheKey{
|
|
||||||
Id: ctx.bp.ModuleCacheKey(),
|
|
||||||
InputHash: hash,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
restored := false
|
if x, ok := m.module.(IDEInfo); ok {
|
||||||
if incrementalAnalysis && cacheKey != nil {
|
var result IdeInfo
|
||||||
restored = ctx.bp.RestoreBuildActions(cacheKey)
|
x.IDEInfo(ctx, &result)
|
||||||
}
|
result.BaseModuleName = x.BaseModuleName()
|
||||||
|
SetProvider(ctx, IdeInfoProviderKey, result)
|
||||||
if !restored {
|
|
||||||
m.module.GenerateAndroidBuildActions(ctx)
|
|
||||||
if ctx.Failed() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if x, ok := m.module.(IDEInfo); ok {
|
|
||||||
var result IdeInfo
|
|
||||||
x.IDEInfo(ctx, &result)
|
|
||||||
result.BaseModuleName = x.BaseModuleName()
|
|
||||||
SetProvider(ctx, IdeInfoProviderKey, result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if incrementalEnabled && cacheKey != nil {
|
|
||||||
ctx.bp.CacheBuildActions(cacheKey, incrementalModule)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the set of tagged dist files after calling GenerateAndroidBuildActions
|
// Create the set of tagged dist files after calling GenerateAndroidBuildActions
|
||||||
@@ -2142,11 +2100,61 @@ type katiInstall struct {
|
|||||||
absFrom string
|
absFrom string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *katiInstall) GobEncode() ([]byte, error) {
|
||||||
|
w := new(bytes.Buffer)
|
||||||
|
encoder := gob.NewEncoder(w)
|
||||||
|
err := errors.Join(encoder.Encode(p.from), encoder.Encode(p.to),
|
||||||
|
encoder.Encode(p.implicitDeps), encoder.Encode(p.orderOnlyDeps),
|
||||||
|
encoder.Encode(p.executable), encoder.Encode(p.extraFiles),
|
||||||
|
encoder.Encode(p.absFrom))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return w.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *katiInstall) GobDecode(data []byte) error {
|
||||||
|
r := bytes.NewBuffer(data)
|
||||||
|
decoder := gob.NewDecoder(r)
|
||||||
|
err := errors.Join(decoder.Decode(&p.from), decoder.Decode(&p.to),
|
||||||
|
decoder.Decode(&p.implicitDeps), decoder.Decode(&p.orderOnlyDeps),
|
||||||
|
decoder.Decode(&p.executable), decoder.Decode(&p.extraFiles),
|
||||||
|
decoder.Decode(&p.absFrom))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type extraFilesZip struct {
|
type extraFilesZip struct {
|
||||||
zip Path
|
zip Path
|
||||||
dir InstallPath
|
dir InstallPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *extraFilesZip) GobEncode() ([]byte, error) {
|
||||||
|
w := new(bytes.Buffer)
|
||||||
|
encoder := gob.NewEncoder(w)
|
||||||
|
err := errors.Join(encoder.Encode(p.zip), encoder.Encode(p.dir))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return w.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *extraFilesZip) GobDecode(data []byte) error {
|
||||||
|
r := bytes.NewBuffer(data)
|
||||||
|
decoder := gob.NewDecoder(r)
|
||||||
|
err := errors.Join(decoder.Decode(&p.zip), decoder.Decode(&p.dir))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type katiInstalls []katiInstall
|
type katiInstalls []katiInstall
|
||||||
|
|
||||||
// BuiltInstalled returns the katiInstalls in the form used by $(call copy-many-files) in Make, a
|
// BuiltInstalled returns the katiInstalls in the form used by $(call copy-many-files) in Make, a
|
||||||
|
@@ -15,6 +15,9 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/gob"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -64,6 +67,36 @@ type PackagingSpec struct {
|
|||||||
owner string
|
owner string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PackagingSpec) GobEncode() ([]byte, error) {
|
||||||
|
w := new(bytes.Buffer)
|
||||||
|
encoder := gob.NewEncoder(w)
|
||||||
|
err := errors.Join(encoder.Encode(p.relPathInPackage), encoder.Encode(p.srcPath),
|
||||||
|
encoder.Encode(p.symlinkTarget), encoder.Encode(p.executable),
|
||||||
|
encoder.Encode(p.effectiveLicenseFiles), encoder.Encode(p.partition),
|
||||||
|
encoder.Encode(p.skipInstall), encoder.Encode(p.aconfigPaths),
|
||||||
|
encoder.Encode(p.archType))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return w.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PackagingSpec) GobDecode(data []byte) error {
|
||||||
|
r := bytes.NewBuffer(data)
|
||||||
|
decoder := gob.NewDecoder(r)
|
||||||
|
err := errors.Join(decoder.Decode(&p.relPathInPackage), decoder.Decode(&p.srcPath),
|
||||||
|
decoder.Decode(&p.symlinkTarget), decoder.Decode(&p.executable),
|
||||||
|
decoder.Decode(&p.effectiveLicenseFiles), decoder.Decode(&p.partition),
|
||||||
|
decoder.Decode(&p.skipInstall), decoder.Decode(&p.aconfigPaths),
|
||||||
|
decoder.Decode(&p.archType))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (p *PackagingSpec) Equals(other *PackagingSpec) bool {
|
func (p *PackagingSpec) Equals(other *PackagingSpec) bool {
|
||||||
if other == nil {
|
if other == nil {
|
||||||
return false
|
return false
|
||||||
|
@@ -1766,6 +1766,32 @@ type InstallPath struct {
|
|||||||
fullPath string
|
fullPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *InstallPath) GobEncode() ([]byte, error) {
|
||||||
|
w := new(bytes.Buffer)
|
||||||
|
encoder := gob.NewEncoder(w)
|
||||||
|
err := errors.Join(encoder.Encode(p.basePath), encoder.Encode(p.soongOutDir),
|
||||||
|
encoder.Encode(p.partitionDir), encoder.Encode(p.partition),
|
||||||
|
encoder.Encode(p.makePath), encoder.Encode(p.fullPath))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return w.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *InstallPath) GobDecode(data []byte) error {
|
||||||
|
r := bytes.NewBuffer(data)
|
||||||
|
decoder := gob.NewDecoder(r)
|
||||||
|
err := errors.Join(decoder.Decode(&p.basePath), decoder.Decode(&p.soongOutDir),
|
||||||
|
decoder.Decode(&p.partitionDir), decoder.Decode(&p.partition),
|
||||||
|
decoder.Decode(&p.makePath), decoder.Decode(&p.fullPath))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Will panic if called from outside a test environment.
|
// Will panic if called from outside a test environment.
|
||||||
func ensureTestOnly() {
|
func ensureTestOnly() {
|
||||||
if PrefixInList(os.Args, "-test.") {
|
if PrefixInList(os.Args, "-test.") {
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package java
|
package java
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -2519,6 +2520,8 @@ var overridableJarJarPrefix = "com.android.internal.hidden_from_bootclasspath"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.SetJarJarPrefixHandler(mergeJarJarPrefixes)
|
android.SetJarJarPrefixHandler(mergeJarJarPrefixes)
|
||||||
|
|
||||||
|
gob.Register(BaseJarJarProviderData{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// BaseJarJarProviderData contains information that will propagate across dependencies regardless of
|
// BaseJarJarProviderData contains information that will propagate across dependencies regardless of
|
||||||
|
Reference in New Issue
Block a user