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

Commit 92487138 authored by Jihoon Kang's avatar Jihoon Kang
Browse files

Add fully qualified names of lincese modules as dependencies

This allows auto-generated modules to depend on the license modules that
are within a namespace. Note that the license dependency is
automatically done even if the module does not specify the licenses
property.

Test: m nothing --no-skip-soong-tests
Bug: 375053752
Change-Id: I331e4fae5c54b33723cd97266f646dbbd9d438fb
parent 0ba7034b
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -15,7 +15,10 @@
package android

import (
	"fmt"
	"path/filepath"
	"reflect"
	"strings"
	"sync"

	"github.com/google/blueprint"
@@ -155,7 +158,25 @@ func licensesPropertyGatherer(ctx BottomUpMutatorContext) {
	}

	licenses := getLicenses(ctx, m)
	ctx.AddVariationDependencies(nil, licensesTag, licenses...)

	var fullyQualifiedLicenseNames []string
	for _, license := range licenses {
		fullyQualifiedLicenseName := license
		if !strings.HasPrefix(license, "//") {
			licenseModuleDir := ctx.OtherModuleDir(m)
			for licenseModuleDir != "." && !ctx.OtherModuleExists(fmt.Sprintf("//%s:%s", licenseModuleDir, license)) {
				licenseModuleDir = filepath.Dir(licenseModuleDir)
			}
			if licenseModuleDir == "." {
				fullyQualifiedLicenseName = license
			} else {
				fullyQualifiedLicenseName = fmt.Sprintf("//%s:%s", licenseModuleDir, license)
			}
		}
		fullyQualifiedLicenseNames = append(fullyQualifiedLicenseNames, fullyQualifiedLicenseName)
	}

	ctx.AddVariationDependencies(nil, licensesTag, fullyQualifiedLicenseNames...)
}

// Verifies the license and license_kind dependencies are each the correct kind of module.