Propagate min and max sdk versions to classpaths.proto configs.
These attributed define a range for dessert releases where the jars should be active, and included in corresponding CLASSPATH varibles by derive_classpath. Bug: 190818041 Test: presubmit Change-Id: Ieb9aef29657ad0694d48a63019f93faca2678252
This commit is contained in:
parent
0a420e771a
commit
cca4ab762e
3 changed files with 53 additions and 7 deletions
|
@ -765,6 +765,16 @@ func (c *config) PreviewApiLevels() []ApiLevel {
|
||||||
return levels
|
return levels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *config) LatestPreviewApiLevel() ApiLevel {
|
||||||
|
level := NoneApiLevel
|
||||||
|
for _, l := range c.PreviewApiLevels() {
|
||||||
|
if l.GreaterThan(level) {
|
||||||
|
level = l
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return level
|
||||||
|
}
|
||||||
|
|
||||||
func (c *config) AllSupportedApiLevels() []ApiLevel {
|
func (c *config) AllSupportedApiLevels() []ApiLevel {
|
||||||
var levels []ApiLevel
|
var levels []ApiLevel
|
||||||
levels = append(levels, c.FinalApiLevels()...)
|
levels = append(levels, c.FinalApiLevels()...)
|
||||||
|
|
|
@ -86,9 +86,8 @@ func initClasspathFragment(c classpathFragment, classpathType classpathType) {
|
||||||
type classpathJar struct {
|
type classpathJar struct {
|
||||||
path string
|
path string
|
||||||
classpath classpathType
|
classpath classpathType
|
||||||
// TODO(satayev): propagate min/max sdk versions for the jars
|
minSdkVersion string
|
||||||
minSdkVersion int32
|
maxSdkVersion string
|
||||||
maxSdkVersion int32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gatherPossibleApexModuleNamesAndStems returns a set of module and stem names from the
|
// gatherPossibleApexModuleNamesAndStems returns a set of module and stem names from the
|
||||||
|
@ -120,10 +119,32 @@ func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars
|
||||||
jars := make([]classpathJar, 0, len(paths)*len(classpaths))
|
jars := make([]classpathJar, 0, len(paths)*len(classpaths))
|
||||||
for i := 0; i < len(paths); i++ {
|
for i := 0; i < len(paths); i++ {
|
||||||
for _, classpathType := range classpaths {
|
for _, classpathType := range classpaths {
|
||||||
jars = append(jars, classpathJar{
|
jar := classpathJar{
|
||||||
classpath: classpathType,
|
classpath: classpathType,
|
||||||
path: paths[i],
|
path: paths[i],
|
||||||
|
}
|
||||||
|
ctx.VisitDirectDepsIf(func(m android.Module) bool {
|
||||||
|
return m.Name() == configuredJars.Jar(i)
|
||||||
|
}, func(m android.Module) {
|
||||||
|
if s, ok := m.(*SdkLibrary); ok {
|
||||||
|
// TODO(208456999): instead of mapping "current" to latest, min_sdk_version should never be set to "current"
|
||||||
|
if s.minSdkVersion.Specified() {
|
||||||
|
if s.minSdkVersion.ApiLevel.IsCurrent() {
|
||||||
|
jar.minSdkVersion = ctx.Config().LatestPreviewApiLevel().String()
|
||||||
|
} else {
|
||||||
|
jar.minSdkVersion = s.minSdkVersion.ApiLevel.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if s.maxSdkVersion.Specified() {
|
||||||
|
if s.maxSdkVersion.ApiLevel.IsCurrent() {
|
||||||
|
jar.maxSdkVersion = ctx.Config().LatestPreviewApiLevel().String()
|
||||||
|
} else {
|
||||||
|
jar.maxSdkVersion = s.maxSdkVersion.ApiLevel.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
jars = append(jars, jar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return jars
|
return jars
|
||||||
|
@ -161,6 +182,7 @@ func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.M
|
||||||
|
|
||||||
func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) {
|
func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) {
|
||||||
var content strings.Builder
|
var content strings.Builder
|
||||||
|
|
||||||
fmt.Fprintf(&content, "{\n")
|
fmt.Fprintf(&content, "{\n")
|
||||||
fmt.Fprintf(&content, "\"jars\": [\n")
|
fmt.Fprintf(&content, "\"jars\": [\n")
|
||||||
for idx, jar := range jars {
|
for idx, jar := range jars {
|
||||||
|
@ -169,6 +191,20 @@ func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath,
|
||||||
fmt.Fprintf(&content, "\"path\": \"%s\",\n", jar.path)
|
fmt.Fprintf(&content, "\"path\": \"%s\",\n", jar.path)
|
||||||
fmt.Fprintf(&content, "\"classpath\": \"%s\"\n", jar.classpath)
|
fmt.Fprintf(&content, "\"classpath\": \"%s\"\n", jar.classpath)
|
||||||
|
|
||||||
|
if jar.minSdkVersion != "" {
|
||||||
|
fmt.Fprintf(&content, ",\n")
|
||||||
|
fmt.Fprintf(&content, "\"minSdkVersion\": \"%s\"\n", jar.minSdkVersion)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(&content, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
if jar.maxSdkVersion != "" {
|
||||||
|
fmt.Fprintf(&content, ",\n")
|
||||||
|
fmt.Fprintf(&content, "\"maxSdkVersion\": \"%s\"\n", jar.maxSdkVersion)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(&content, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
if idx < len(jars)-1 {
|
if idx < len(jars)-1 {
|
||||||
fmt.Fprintf(&content, "},\n")
|
fmt.Fprintf(&content, "},\n")
|
||||||
} else {
|
} else {
|
||||||
|
@ -177,6 +213,7 @@ func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath,
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&content, "]\n")
|
fmt.Fprintf(&content, "]\n")
|
||||||
fmt.Fprintf(&content, "}\n")
|
fmt.Fprintf(&content, "}\n")
|
||||||
|
|
||||||
android.WriteFileRule(ctx, output, content.String())
|
android.WriteFileRule(ctx, output, content.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,6 @@ type platformBootclasspathProperties struct {
|
||||||
func platformBootclasspathFactory() android.SingletonModule {
|
func platformBootclasspathFactory() android.SingletonModule {
|
||||||
m := &platformBootclasspathModule{}
|
m := &platformBootclasspathModule{}
|
||||||
m.AddProperties(&m.properties)
|
m.AddProperties(&m.properties)
|
||||||
// TODO(satayev): split apex jars into separate configs.
|
|
||||||
initClasspathFragment(m, BOOTCLASSPATH)
|
initClasspathFragment(m, BOOTCLASSPATH)
|
||||||
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
|
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
|
||||||
return m
|
return m
|
||||||
|
|
Loading…
Reference in a new issue