Use Unique lists instead of pointers in PackagingSpec.
This is to support correctly serializing and deserializing DepSet.
Bug: 358427516
Test: Manually verified generated mk and ninja files.
Change-Id: Icca89034fe0e606ca2e257f26ae07f911e31f980
diff --git a/android/module_context.go b/android/module_context.go
index 9fa3a62..d71992d 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -16,13 +16,14 @@
import (
"fmt"
- "github.com/google/blueprint/depset"
"path"
"path/filepath"
"strings"
"github.com/google/blueprint"
+ "github.com/google/blueprint/depset"
"github.com/google/blueprint/proptools"
+ "github.com/google/blueprint/uniquelist"
)
// BuildParameters describes the set of potential parameters to build a Ninja rule.
@@ -554,8 +555,8 @@
return m.packageFile(fullInstallPath, srcPath, false)
}
-func (m *moduleContext) getAconfigPaths() *Paths {
- return &m.aconfigFilePaths
+func (m *moduleContext) getAconfigPaths() Paths {
+ return m.aconfigFilePaths
}
func (m *moduleContext) setAconfigPaths(paths Paths) {
@@ -570,12 +571,12 @@
srcPath: srcPath,
symlinkTarget: "",
executable: executable,
- effectiveLicenseFiles: &licenseFiles,
+ effectiveLicenseFiles: uniquelist.Make(licenseFiles),
partition: fullInstallPath.partition,
skipInstall: m.skipInstall(),
- aconfigPaths: m.getAconfigPaths(),
+ aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
archType: m.target.Arch.ArchType,
- overrides: &overrides,
+ overrides: uniquelist.Make(overrides),
owner: m.ModuleName(),
}
m.packagingSpecs = append(m.packagingSpecs, spec)
@@ -703,9 +704,9 @@
executable: false,
partition: fullInstallPath.partition,
skipInstall: m.skipInstall(),
- aconfigPaths: m.getAconfigPaths(),
+ aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
archType: m.target.Arch.ArchType,
- overrides: &overrides,
+ overrides: uniquelist.Make(overrides),
owner: m.ModuleName(),
})
@@ -750,9 +751,9 @@
executable: false,
partition: fullInstallPath.partition,
skipInstall: m.skipInstall(),
- aconfigPaths: m.getAconfigPaths(),
+ aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
archType: m.target.Arch.ArchType,
- overrides: &overrides,
+ overrides: uniquelist.Make(overrides),
owner: m.ModuleName(),
})
diff --git a/android/packaging.go b/android/packaging.go
index acafcd4..d455788 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -23,6 +23,7 @@
"github.com/google/blueprint"
"github.com/google/blueprint/gobtools"
"github.com/google/blueprint/proptools"
+ "github.com/google/blueprint/uniquelist"
)
// PackagingSpec abstracts a request to place a built artifact at a certain path in a package. A
@@ -43,7 +44,7 @@
// Whether relPathInPackage should be marked as executable or not
executable bool
- effectiveLicenseFiles *Paths
+ effectiveLicenseFiles uniquelist.UniqueList[Path]
partition string
@@ -53,13 +54,13 @@
skipInstall bool
// Paths of aconfig files for the built artifact
- aconfigPaths *Paths
+ aconfigPaths uniquelist.UniqueList[Path]
// ArchType of the module which produced this packaging spec
archType ArchType
// List of module names that this packaging spec overrides
- overrides *[]string
+ overrides uniquelist.UniqueList[string]
// Name of the module where this packaging spec is output of
owner string
@@ -70,12 +71,12 @@
SrcPath Path
SymlinkTarget string
Executable bool
- EffectiveLicenseFiles *Paths
+ EffectiveLicenseFiles Paths
Partition string
SkipInstall bool
- AconfigPaths *Paths
+ AconfigPaths Paths
ArchType ArchType
- Overrides *[]string
+ Overrides []string
Owner string
}
@@ -85,12 +86,12 @@
SrcPath: p.srcPath,
SymlinkTarget: p.symlinkTarget,
Executable: p.executable,
- EffectiveLicenseFiles: p.effectiveLicenseFiles,
+ EffectiveLicenseFiles: p.effectiveLicenseFiles.ToSlice(),
Partition: p.partition,
SkipInstall: p.skipInstall,
- AconfigPaths: p.aconfigPaths,
+ AconfigPaths: p.aconfigPaths.ToSlice(),
ArchType: p.archType,
- Overrides: p.overrides,
+ Overrides: p.overrides.ToSlice(),
Owner: p.owner,
}
}
@@ -100,12 +101,12 @@
p.srcPath = data.SrcPath
p.symlinkTarget = data.SymlinkTarget
p.executable = data.Executable
- p.effectiveLicenseFiles = data.EffectiveLicenseFiles
+ p.effectiveLicenseFiles = uniquelist.Make(data.EffectiveLicenseFiles)
p.partition = data.Partition
p.skipInstall = data.SkipInstall
- p.aconfigPaths = data.AconfigPaths
+ p.aconfigPaths = uniquelist.Make(data.AconfigPaths)
p.archType = data.ArchType
- p.overrides = data.Overrides
+ p.overrides = uniquelist.Make(data.Overrides)
p.owner = data.Owner
}
@@ -155,10 +156,7 @@
}
func (p *PackagingSpec) EffectiveLicenseFiles() Paths {
- if p.effectiveLicenseFiles == nil {
- return Paths{}
- }
- return *p.effectiveLicenseFiles
+ return p.effectiveLicenseFiles.ToSlice()
}
func (p *PackagingSpec) Partition() string {
@@ -171,7 +169,7 @@
// Paths of aconfig files for the built artifact
func (p *PackagingSpec) GetAconfigPaths() Paths {
- return *p.aconfigPaths
+ return p.aconfigPaths.ToSlice()
}
type PackageModule interface {
@@ -436,9 +434,7 @@
}
all = append(all, ps)
depNames = append(depNames, child.Name())
- if ps.overrides != nil {
- overridden = append(overridden, *ps.overrides...)
- }
+ overridden = append(overridden, ps.overrides.ToSlice()...)
}
})