Introduce min_sdk_version to deps info.
Bug: 149622332
Test: m
Change-Id: Ie6568cb8a82d5cca9a3dc91b5a068abf4b0632dc
Merged-In: Ie6568cb8a82d5cca9a3dc91b5a068abf4b0632dc
Exempt-From-Owner-Approval: cp from aosp
(cherry picked from commit 480e25b74f
)
This commit is contained in:
@@ -405,21 +405,29 @@ type ApexModuleDepInfo struct {
|
|||||||
From []string
|
From []string
|
||||||
// Whether the dependency belongs to the final compiled APEX.
|
// Whether the dependency belongs to the final compiled APEX.
|
||||||
IsExternal bool
|
IsExternal bool
|
||||||
|
// min_sdk_version of the ApexModule
|
||||||
|
MinSdkVersion string
|
||||||
}
|
}
|
||||||
|
|
||||||
// A map of a dependency name to its ApexModuleDepInfo
|
// A map of a dependency name to its ApexModuleDepInfo
|
||||||
type DepNameToDepInfoMap map[string]ApexModuleDepInfo
|
type DepNameToDepInfoMap map[string]ApexModuleDepInfo
|
||||||
|
|
||||||
type ApexBundleDepsInfo struct {
|
type ApexBundleDepsInfo struct {
|
||||||
flatListPath OutputPath
|
minSdkVersion string
|
||||||
fullListPath OutputPath
|
flatListPath OutputPath
|
||||||
|
fullListPath OutputPath
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApexDepsInfoIntf interface {
|
type ApexDepsInfoIntf interface {
|
||||||
|
MinSdkVersion() string
|
||||||
FlatListPath() Path
|
FlatListPath() Path
|
||||||
FullListPath() Path
|
FullListPath() Path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *ApexBundleDepsInfo) MinSdkVersion() string {
|
||||||
|
return d.minSdkVersion
|
||||||
|
}
|
||||||
|
|
||||||
func (d *ApexBundleDepsInfo) FlatListPath() Path {
|
func (d *ApexBundleDepsInfo) FlatListPath() Path {
|
||||||
return d.flatListPath
|
return d.flatListPath
|
||||||
}
|
}
|
||||||
@@ -433,14 +441,16 @@ var _ ApexDepsInfoIntf = (*ApexBundleDepsInfo)(nil)
|
|||||||
// Generate two module out files:
|
// Generate two module out files:
|
||||||
// 1. FullList with transitive deps and their parents in the dep graph
|
// 1. FullList with transitive deps and their parents in the dep graph
|
||||||
// 2. FlatList with a flat list of transitive deps
|
// 2. FlatList with a flat list of transitive deps
|
||||||
func (d *ApexBundleDepsInfo) BuildDepsInfoLists(ctx ModuleContext, depInfos DepNameToDepInfoMap) {
|
func (d *ApexBundleDepsInfo) BuildDepsInfoLists(ctx ModuleContext, minSdkVersion string, depInfos DepNameToDepInfoMap) {
|
||||||
|
d.minSdkVersion = minSdkVersion
|
||||||
|
|
||||||
var fullContent strings.Builder
|
var fullContent strings.Builder
|
||||||
var flatContent strings.Builder
|
var flatContent strings.Builder
|
||||||
|
|
||||||
fmt.Fprintf(&flatContent, "%s:\\n", ctx.ModuleName())
|
fmt.Fprintf(&flatContent, "%s(minSdkVersion:%s):\\n", ctx.ModuleName(), minSdkVersion)
|
||||||
for _, key := range FirstUniqueStrings(SortedStringKeys(depInfos)) {
|
for _, key := range FirstUniqueStrings(SortedStringKeys(depInfos)) {
|
||||||
info := depInfos[key]
|
info := depInfos[key]
|
||||||
toName := info.To
|
toName := fmt.Sprintf("%s(minSdkVersion:%s)", info.To, info.MinSdkVersion)
|
||||||
if info.IsExternal {
|
if info.IsExternal {
|
||||||
toName = toName + " (external)"
|
toName = toName + " (external)"
|
||||||
}
|
}
|
||||||
|
@@ -479,18 +479,18 @@ func TestBasicApex(t *testing.T) {
|
|||||||
ensureListContains(t, noticeInputs, "custom_notice_for_static_lib")
|
ensureListContains(t, noticeInputs, "custom_notice_for_static_lib")
|
||||||
|
|
||||||
fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
|
fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
|
||||||
ensureListContains(t, fullDepsInfo, "myjar <- myapex")
|
ensureListContains(t, fullDepsInfo, "myjar(minSdkVersion:(no version)) <- myapex")
|
||||||
ensureListContains(t, fullDepsInfo, "mylib <- myapex")
|
ensureListContains(t, fullDepsInfo, "mylib(minSdkVersion:(no version)) <- myapex")
|
||||||
ensureListContains(t, fullDepsInfo, "mylib2 <- mylib")
|
ensureListContains(t, fullDepsInfo, "mylib2(minSdkVersion:(no version)) <- mylib")
|
||||||
ensureListContains(t, fullDepsInfo, "myotherjar <- myjar")
|
ensureListContains(t, fullDepsInfo, "myotherjar(minSdkVersion:(no version)) <- myjar")
|
||||||
ensureListContains(t, fullDepsInfo, "mysharedjar (external) <- myjar")
|
ensureListContains(t, fullDepsInfo, "mysharedjar(minSdkVersion:(no version)) (external) <- myjar")
|
||||||
|
|
||||||
flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/flatlist.txt").Args["content"], "\\n")
|
flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/flatlist.txt").Args["content"], "\\n")
|
||||||
ensureListContains(t, flatDepsInfo, " myjar")
|
ensureListContains(t, flatDepsInfo, " myjar(minSdkVersion:(no version))")
|
||||||
ensureListContains(t, flatDepsInfo, " mylib")
|
ensureListContains(t, flatDepsInfo, " mylib(minSdkVersion:(no version))")
|
||||||
ensureListContains(t, flatDepsInfo, " mylib2")
|
ensureListContains(t, flatDepsInfo, " mylib2(minSdkVersion:(no version))")
|
||||||
ensureListContains(t, flatDepsInfo, " myotherjar")
|
ensureListContains(t, flatDepsInfo, " myotherjar(minSdkVersion:(no version))")
|
||||||
ensureListContains(t, flatDepsInfo, " mysharedjar (external)")
|
ensureListContains(t, flatDepsInfo, " mysharedjar(minSdkVersion:(no version)) (external)")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaults(t *testing.T) {
|
func TestDefaults(t *testing.T) {
|
||||||
@@ -792,14 +792,14 @@ func TestApexWithExplicitStubsDependency(t *testing.T) {
|
|||||||
ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
|
ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
|
||||||
|
|
||||||
fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
|
fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n")
|
||||||
ensureListContains(t, fullDepsInfo, "mylib <- myapex2")
|
ensureListContains(t, fullDepsInfo, "mylib(minSdkVersion:(no version)) <- myapex2")
|
||||||
ensureListContains(t, fullDepsInfo, "libbaz <- mylib")
|
ensureListContains(t, fullDepsInfo, "libbaz(minSdkVersion:(no version)) <- mylib")
|
||||||
ensureListContains(t, fullDepsInfo, "libfoo (external) <- mylib")
|
ensureListContains(t, fullDepsInfo, "libfoo(minSdkVersion:(no version)) (external) <- mylib")
|
||||||
|
|
||||||
flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("depsinfo/flatlist.txt").Args["content"], "\\n")
|
flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("depsinfo/flatlist.txt").Args["content"], "\\n")
|
||||||
ensureListContains(t, flatDepsInfo, " mylib")
|
ensureListContains(t, flatDepsInfo, " mylib(minSdkVersion:(no version))")
|
||||||
ensureListContains(t, flatDepsInfo, " libbaz")
|
ensureListContains(t, flatDepsInfo, " libbaz(minSdkVersion:(no version))")
|
||||||
ensureListContains(t, flatDepsInfo, " libfoo (external)")
|
ensureListContains(t, flatDepsInfo, " libfoo(minSdkVersion:(no version)) (external)")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApexWithRuntimeLibsDependency(t *testing.T) {
|
func TestApexWithRuntimeLibsDependency(t *testing.T) {
|
||||||
|
@@ -694,10 +694,18 @@ func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) {
|
|||||||
info.IsExternal = info.IsExternal && externalDep
|
info.IsExternal = info.IsExternal && externalDep
|
||||||
depInfos[to.Name()] = info
|
depInfos[to.Name()] = info
|
||||||
} else {
|
} else {
|
||||||
|
toMinSdkVersion := "(no version)"
|
||||||
|
if m, ok := to.(interface{ MinSdkVersion() string }); ok {
|
||||||
|
if v := m.MinSdkVersion(); v != "" {
|
||||||
|
toMinSdkVersion = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
depInfos[to.Name()] = android.ApexModuleDepInfo{
|
depInfos[to.Name()] = android.ApexModuleDepInfo{
|
||||||
To: to.Name(),
|
To: to.Name(),
|
||||||
From: []string{from.Name()},
|
From: []string{from.Name()},
|
||||||
IsExternal: externalDep,
|
IsExternal: externalDep,
|
||||||
|
MinSdkVersion: toMinSdkVersion,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -705,7 +713,7 @@ func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) {
|
|||||||
return !externalDep
|
return !externalDep
|
||||||
})
|
})
|
||||||
|
|
||||||
a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, depInfos)
|
a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, proptools.String(a.properties.Min_sdk_version), depInfos)
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: android.Phony,
|
Rule: android.Phony,
|
||||||
|
4
cc/cc.go
4
cc/cc.go
@@ -580,6 +580,10 @@ func (c *Module) SdkVersion() string {
|
|||||||
return String(c.Properties.Sdk_version)
|
return String(c.Properties.Sdk_version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Module) MinSdkVersion() string {
|
||||||
|
return String(c.Properties.Min_sdk_version)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Module) AlwaysSdk() bool {
|
func (c *Module) AlwaysSdk() bool {
|
||||||
return c.Properties.AlwaysSdk || Bool(c.Properties.Sdk_variant_only)
|
return c.Properties.AlwaysSdk || Bool(c.Properties.Sdk_variant_only)
|
||||||
}
|
}
|
||||||
|
@@ -604,6 +604,10 @@ func (j *Module) targetSdkVersion() sdkSpec {
|
|||||||
return j.sdkVersion()
|
return j.sdkVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *Module) MinSdkVersion() string {
|
||||||
|
return j.minSdkVersion().version.String()
|
||||||
|
}
|
||||||
|
|
||||||
func (j *Module) AvailableFor(what string) bool {
|
func (j *Module) AvailableFor(what string) bool {
|
||||||
if what == android.AvailableToPlatform && Bool(j.deviceProperties.Hostdex) {
|
if what == android.AvailableToPlatform && Bool(j.deviceProperties.Hostdex) {
|
||||||
// Exception: for hostdex: true libraries, the platform variant is created
|
// Exception: for hostdex: true libraries, the platform variant is created
|
||||||
@@ -2395,6 +2399,10 @@ func (j *Import) minSdkVersion() sdkSpec {
|
|||||||
return j.sdkVersion()
|
return j.sdkVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *Import) MinSdkVersion() string {
|
||||||
|
return j.minSdkVersion().version.String()
|
||||||
|
}
|
||||||
|
|
||||||
func (j *Import) Prebuilt() *android.Prebuilt {
|
func (j *Import) Prebuilt() *android.Prebuilt {
|
||||||
return &j.prebuilt
|
return &j.prebuilt
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user