Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db901f84 authored by Yu Liu's avatar Yu Liu
Browse files

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
parent 3659226d
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -16,13 +16,14 @@ package android

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 @@ func (m *moduleContext) PackageFile(installPath InstallPath, name string, srcPat
	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 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e
		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 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src
		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 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str
		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(),
	})

+16 −20
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import (
	"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 @@ type PackagingSpec struct {
	// Whether relPathInPackage should be marked as executable or not
	executable bool

	effectiveLicenseFiles *Paths
	effectiveLicenseFiles uniquelist.UniqueList[Path]

	partition string

@@ -53,13 +54,13 @@ type PackagingSpec struct {
	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 @@ type packagingSpecGob struct {
	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 @@ func (p *PackagingSpec) ToGob() *packagingSpecGob {
		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 @@ func (p *PackagingSpec) FromGob(data *packagingSpecGob) {
	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) SetRelPathInPackage(relPathInPackage string) {
}

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 @@ func (p *PackagingSpec) SkipInstall() bool {

// 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 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter
			}
			all = append(all, ps)
			depNames = append(depNames, child.Name())
			if ps.overrides != nil {
				overridden = append(overridden, *ps.overrides...)
			}
			overridden = append(overridden, ps.overrides.ToSlice()...)
		}
	})