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

Commit a14fb6a7 authored by Colin Cross's avatar Colin Cross
Browse files

Update DepSet references

Update all references to depset to use blueprint/depset, and to use
DepSet instead of *DepSet.

Bug: 375276086
Test: all soong tests pass
Flag: EXEMPT refactor
Change-Id: I59a7836d0975366ddc336225fb770ac7e6e0c8ea
parent 11d0c38a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ bootstrap_go_package {
    name: "soong-aidl-library",
    pkgPath: "android/soong/aidl_library",
    deps: [
        "blueprint-depset",
        "soong-android",
    ],
    srcs: [
+9 −8
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package aidl_library
import (
	"android/soong/android"
	"github.com/google/blueprint"
	"github.com/google/blueprint/depset"
	"github.com/google/blueprint/proptools"
)

@@ -58,17 +59,17 @@ type AidlLibraryInfo struct {
	// The direct aidl files of the module
	Srcs android.Paths
	// The include dirs to the direct aidl files and those provided from transitive aidl_library deps
	IncludeDirs android.DepSet[android.Path]
	IncludeDirs depset.DepSet[android.Path]
	// The direct hdrs and hdrs from transitive deps
	Hdrs android.DepSet[android.Path]
	Hdrs depset.DepSet[android.Path]
}

// AidlLibraryProvider provides the srcs and the transitive include dirs
var AidlLibraryProvider = blueprint.NewProvider[AidlLibraryInfo]()

func (lib *AidlLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	includeDirsDepSetBuilder := android.NewDepSetBuilder[android.Path](android.PREORDER)
	hdrsDepSetBuilder := android.NewDepSetBuilder[android.Path](android.PREORDER)
	includeDirsDepSetBuilder := depset.NewBuilder[android.Path](depset.PREORDER)
	hdrsDepSetBuilder := depset.NewBuilder[android.Path](depset.PREORDER)

	if len(lib.properties.Srcs) == 0 && len(lib.properties.Hdrs) == 0 {
		ctx.ModuleErrorf("at least srcs or hdrs prop must be non-empty")
@@ -100,15 +101,15 @@ func (lib *AidlLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {

	for _, dep := range ctx.GetDirectDepsWithTag(aidlLibraryTag) {
		if info, ok := android.OtherModuleProvider(ctx, dep, AidlLibraryProvider); ok {
			includeDirsDepSetBuilder.Transitive(&info.IncludeDirs)
			hdrsDepSetBuilder.Transitive(&info.Hdrs)
			includeDirsDepSetBuilder.Transitive(info.IncludeDirs)
			hdrsDepSetBuilder.Transitive(info.Hdrs)
		}
	}

	android.SetProvider(ctx, AidlLibraryProvider, AidlLibraryInfo{
		Srcs:        srcs,
		IncludeDirs: *includeDirsDepSetBuilder.Build(),
		Hdrs:        *hdrsDepSetBuilder.Build(),
		IncludeDirs: includeDirsDepSetBuilder.Build(),
		Hdrs:        hdrsDepSetBuilder.Build(),
	})
}

+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ bootstrap_go_package {
    deps: [
        "blueprint",
        "blueprint-bootstrap",
        "blueprint-depset",
        "blueprint-metrics",
        "sbox_proto",
        "soong",
+5 −4
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
package android

import (
	"github.com/google/blueprint/depset"
	"sort"
	"strings"

@@ -61,7 +62,7 @@ func buildLicenseMetadata(ctx *moduleContext, licenseMetadataFile WritablePath)
	var allDepMetadataFiles Paths
	var allDepMetadataArgs []string
	var allDepOutputFiles Paths
	var allDepMetadataDepSets []*DepSet[Path]
	var allDepMetadataDepSets []depset.DepSet[Path]

	ctx.VisitDirectDeps(func(dep Module) {
		if !dep.Enabled(ctx) {
@@ -133,7 +134,7 @@ func buildLicenseMetadata(ctx *moduleContext, licenseMetadataFile WritablePath)
		JoinWithPrefix(proptools.NinjaAndShellEscapeListIncludingSpaces(base.commonProperties.Effective_license_text.Strings()), "-n "))

	if isContainer {
		transitiveDeps := Paths(NewDepSet[Path](TOPOLOGICAL, nil, allDepMetadataDepSets).ToList())
		transitiveDeps := Paths(depset.New[Path](depset.TOPOLOGICAL, nil, allDepMetadataDepSets).ToList())
		args = append(args,
			JoinWithPrefix(proptools.NinjaAndShellEscapeListIncludingSpaces(transitiveDeps.Strings()), "-d "))
		orderOnlyDeps = append(orderOnlyDeps, transitiveDeps...)
@@ -176,7 +177,7 @@ func buildLicenseMetadata(ctx *moduleContext, licenseMetadataFile WritablePath)

	SetProvider(ctx, LicenseMetadataProvider, &LicenseMetadataInfo{
		LicenseMetadataPath:   licenseMetadataFile,
		LicenseMetadataDepSet: NewDepSet(TOPOLOGICAL, Paths{licenseMetadataFile}, allDepMetadataDepSets),
		LicenseMetadataDepSet: depset.New(depset.TOPOLOGICAL, Paths{licenseMetadataFile}, allDepMetadataDepSets),
	})
}

@@ -204,7 +205,7 @@ var LicenseMetadataProvider = blueprint.NewProvider[*LicenseMetadataInfo]()
// LicenseMetadataInfo stores the license metadata path for a module.
type LicenseMetadataInfo struct {
	LicenseMetadataPath   Path
	LicenseMetadataDepSet *DepSet[Path]
	LicenseMetadataDepSet depset.DepSet[Path]
}

// licenseAnnotationsFromTag returns the LicenseAnnotations for a tag (if any) converted into
+9 −8
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package android

import (
	"fmt"
	"github.com/google/blueprint/depset"
	"net/url"
	"path/filepath"
	"reflect"
@@ -1437,9 +1438,9 @@ func (m *ModuleBase) EffectiveLicenseFiles() Paths {

// computeInstallDeps finds the installed paths of all dependencies that have a dependency
// tag that is annotated as needing installation via the isInstallDepNeeded method.
func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]*DepSet[InstallPath], []*DepSet[PackagingSpec]) {
	var installDeps []*DepSet[InstallPath]
	var packagingSpecs []*DepSet[PackagingSpec]
func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]depset.DepSet[InstallPath], []depset.DepSet[PackagingSpec]) {
	var installDeps []depset.DepSet[InstallPath]
	var packagingSpecs []depset.DepSet[PackagingSpec]
	ctx.VisitDirectDeps(func(dep Module) {
		if isInstallDepNeeded(dep, ctx.OtherModuleDependencyTag(dep)) {
			// Installation is still handled by Make, so anything hidden from Make is not
@@ -1772,12 +1773,12 @@ type InstallFilesInfo struct {
	KatiInstalls             katiInstalls
	KatiSymlinks             katiInstalls
	TestData                 []DataPath
	TransitivePackagingSpecs *DepSet[PackagingSpec]
	TransitivePackagingSpecs depset.DepSet[PackagingSpec]
	LicenseMetadataFile      WritablePath

	// The following fields are private before, make it private again once we have
	// better solution.
	TransitiveInstallFiles *DepSet[InstallPath]
	TransitiveInstallFiles depset.DepSet[InstallPath]
	// katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are
	// allowed to have duplicates across modules and variants.
	KatiInitRcInstalls           katiInstalls
@@ -1843,7 +1844,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
	// set the TransitiveInstallFiles to only the transitive dependencies to be used as the dependencies
	// of installed files of this module.  It will be replaced by a depset including the installed
	// files of this module at the end for use by modules that depend on this one.
	ctx.TransitiveInstallFiles = NewDepSet[InstallPath](TOPOLOGICAL, nil, dependencyInstallFiles)
	ctx.TransitiveInstallFiles = depset.New[InstallPath](depset.TOPOLOGICAL, nil, dependencyInstallFiles)

	// Temporarily continue to call blueprintCtx.GetMissingDependencies() to maintain the previous behavior of never
	// reporting missing dependency errors in Blueprint when AllowMissingDependencies == true.
@@ -2002,9 +2003,9 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
		}
	}

	ctx.TransitiveInstallFiles = NewDepSet[InstallPath](TOPOLOGICAL, ctx.installFiles, dependencyInstallFiles)
	ctx.TransitiveInstallFiles = depset.New[InstallPath](depset.TOPOLOGICAL, ctx.installFiles, dependencyInstallFiles)
	installFiles.TransitiveInstallFiles = ctx.TransitiveInstallFiles
	installFiles.TransitivePackagingSpecs = NewDepSet[PackagingSpec](TOPOLOGICAL, ctx.packagingSpecs, dependencyPackagingSpecs)
	installFiles.TransitivePackagingSpecs = depset.New[PackagingSpec](depset.TOPOLOGICAL, ctx.packagingSpecs, dependencyPackagingSpecs)

	SetProvider(ctx, InstallFilesProvider, installFiles)
	buildLicenseMetadata(ctx, ctx.licenseMetadataFile)
Loading