Merge changes Ieb9aef29,I6985ebb6
* changes: Propagate min and max sdk versions to classpaths.proto configs. Introduce max_sdk_version device property.
This commit is contained in:
@@ -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()...)
|
||||||
|
12
java/base.go
12
java/base.go
@@ -197,6 +197,10 @@ type DeviceProperties struct {
|
|||||||
// Defaults to sdk_version if not set. See sdk_version for possible values.
|
// Defaults to sdk_version if not set. See sdk_version for possible values.
|
||||||
Min_sdk_version *string
|
Min_sdk_version *string
|
||||||
|
|
||||||
|
// if not blank, set the maximum version of the sdk that the compiled artifacts will run against.
|
||||||
|
// Defaults to empty string "". See sdk_version for possible values.
|
||||||
|
Max_sdk_version *string
|
||||||
|
|
||||||
// if not blank, set the targetSdkVersion in the AndroidManifest.xml.
|
// if not blank, set the targetSdkVersion in the AndroidManifest.xml.
|
||||||
// Defaults to sdk_version if not set. See sdk_version for possible values.
|
// Defaults to sdk_version if not set. See sdk_version for possible values.
|
||||||
Target_sdk_version *string
|
Target_sdk_version *string
|
||||||
@@ -460,6 +464,7 @@ type Module struct {
|
|||||||
|
|
||||||
sdkVersion android.SdkSpec
|
sdkVersion android.SdkSpec
|
||||||
minSdkVersion android.SdkSpec
|
minSdkVersion android.SdkSpec
|
||||||
|
maxSdkVersion android.SdkSpec
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
|
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
|
||||||
@@ -617,6 +622,13 @@ func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
|||||||
return j.SdkVersion(ctx)
|
return j.SdkVersion(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *Module) MaxSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||||
|
maxSdkVersion := proptools.StringDefault(j.deviceProperties.Max_sdk_version, "")
|
||||||
|
// SdkSpecFrom returns SdkSpecPrivate for this, which may be confusing.
|
||||||
|
// TODO(b/208456999): ideally MaxSdkVersion should be an ApiLevel and not SdkSpec.
|
||||||
|
return android.SdkSpecFrom(ctx, maxSdkVersion)
|
||||||
|
}
|
||||||
|
|
||||||
func (j *Module) MinSdkVersionString() string {
|
func (j *Module) MinSdkVersionString() string {
|
||||||
return j.minSdkVersion.Raw
|
return j.minSdkVersion.Raw
|
||||||
}
|
}
|
||||||
|
@@ -85,11 +85,10 @@ func initClasspathFragment(c classpathFragment, classpathType classpathType) {
|
|||||||
|
|
||||||
// Matches definition of Jar in packages/modules/SdkExtensions/proto/classpaths.proto
|
// Matches definition of Jar in packages/modules/SdkExtensions/proto/classpaths.proto
|
||||||
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
|
||||||
@@ -121,10 +120,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
|
||||||
@@ -162,6 +183,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 {
|
||||||
@@ -170,6 +192,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 {
|
||||||
@@ -178,6 +214,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())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -550,6 +550,7 @@ func setUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter, dexer
|
|||||||
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
j.sdkVersion = j.SdkVersion(ctx)
|
j.sdkVersion = j.SdkVersion(ctx)
|
||||||
j.minSdkVersion = j.MinSdkVersion(ctx)
|
j.minSdkVersion = j.MinSdkVersion(ctx)
|
||||||
|
j.maxSdkVersion = j.MaxSdkVersion(ctx)
|
||||||
|
|
||||||
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
||||||
if !apexInfo.IsForPlatform() {
|
if !apexInfo.IsForPlatform() {
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user