summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yu Liu <yudiliu@google.com> 2025-03-12 12:11:48 -0700
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2025-03-12 12:11:48 -0700
commit7c18e7f15b997e0e3199111446e0511ffd96b811 (patch)
treebc12f661228775bb1b5469b38aeb68605ee48f2a
parent18548fd4d847dea2090e8763d00f4d0ee22f21d0 (diff)
parent619b6ef5c5a06fe3eaaa3fd0bdbd44e6795b29e4 (diff)
Merge "Add Gob support of ApiLevel and applicableLicensesPropertyImpl." into main
-rw-r--r--android/api_levels.go30
-rw-r--r--android/init.go1
-rw-r--r--android/licenses.go26
-rw-r--r--android/packaging.go6
4 files changed, 63 insertions, 0 deletions
diff --git a/android/api_levels.go b/android/api_levels.go
index c042eebee..c83fae878 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -19,6 +19,8 @@ import (
"fmt"
"strconv"
"strings"
+
+ "github.com/google/blueprint/gobtools"
)
func init() {
@@ -52,6 +54,34 @@ type ApiLevel struct {
isPreview bool
}
+type apiLevelGob struct {
+ Value string
+ Number int
+ IsPreview bool
+}
+
+func (a *ApiLevel) ToGob() *apiLevelGob {
+ return &apiLevelGob{
+ Value: a.value,
+ Number: a.number,
+ IsPreview: a.isPreview,
+ }
+}
+
+func (a *ApiLevel) FromGob(data *apiLevelGob) {
+ a.value = data.Value
+ a.number = data.Number
+ a.isPreview = data.IsPreview
+}
+
+func (a ApiLevel) GobEncode() ([]byte, error) {
+ return gobtools.CustomGobEncode[apiLevelGob](&a)
+}
+
+func (a *ApiLevel) GobDecode(data []byte) error {
+ return gobtools.CustomGobDecode[apiLevelGob](data, a)
+}
+
func (this ApiLevel) FinalInt() int {
if this.IsInvalid() {
panic(fmt.Errorf("%v is not a recognized api_level\n", this))
diff --git a/android/init.go b/android/init.go
index d3a13d0ed..af50323d3 100644
--- a/android/init.go
+++ b/android/init.go
@@ -17,6 +17,7 @@ package android
import "encoding/gob"
func init() {
+ gob.Register(applicableLicensesPropertyImpl{})
gob.Register(extraFilesZip{})
gob.Register(InstallPath{})
gob.Register(ModuleGenPath{})
diff --git a/android/licenses.go b/android/licenses.go
index 55f46ae23..387792144 100644
--- a/android/licenses.go
+++ b/android/licenses.go
@@ -22,6 +22,7 @@ import (
"sync"
"github.com/google/blueprint"
+ "github.com/google/blueprint/gobtools"
)
// Adds cross-cutting licenses dependency to propagate license metadata through the build system.
@@ -67,6 +68,31 @@ type applicableLicensesPropertyImpl struct {
licensesProperty *[]string
}
+type applicableLicensesPropertyImplGob struct {
+ Name string
+ LicensesProperty []string
+}
+
+func (a *applicableLicensesPropertyImpl) ToGob() *applicableLicensesPropertyImplGob {
+ return &applicableLicensesPropertyImplGob{
+ Name: a.name,
+ LicensesProperty: *a.licensesProperty,
+ }
+}
+
+func (a *applicableLicensesPropertyImpl) FromGob(data *applicableLicensesPropertyImplGob) {
+ a.name = data.Name
+ a.licensesProperty = &data.LicensesProperty
+}
+
+func (a applicableLicensesPropertyImpl) GobEncode() ([]byte, error) {
+ return gobtools.CustomGobEncode[applicableLicensesPropertyImplGob](&a)
+}
+
+func (a *applicableLicensesPropertyImpl) GobDecode(data []byte) error {
+ return gobtools.CustomGobDecode[applicableLicensesPropertyImplGob](data, a)
+}
+
func newApplicableLicensesProperty(name string, licensesProperty *[]string) applicableLicensesProperty {
return applicableLicensesPropertyImpl{
name: name,
diff --git a/android/packaging.go b/android/packaging.go
index 6146f02c9..bb1fe4e45 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -89,6 +89,8 @@ type packagingSpecGob struct {
ArchType ArchType
Overrides []string
Owner string
+ RequiresFullInstall bool
+ FullInstallPath InstallPath
Variation string
}
@@ -113,6 +115,8 @@ func (p *PackagingSpec) ToGob() *packagingSpecGob {
ArchType: p.archType,
Overrides: p.overrides.ToSlice(),
Owner: p.owner,
+ RequiresFullInstall: p.requiresFullInstall,
+ FullInstallPath: p.fullInstallPath,
Variation: p.variation,
}
}
@@ -129,6 +133,8 @@ func (p *PackagingSpec) FromGob(data *packagingSpecGob) {
p.archType = data.ArchType
p.overrides = uniquelist.Make(data.Overrides)
p.owner = data.Owner
+ p.requiresFullInstall = data.RequiresFullInstall
+ p.fullInstallPath = data.FullInstallPath
p.variation = data.Variation
}