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

Commit cca4ab76 authored by satayev's avatar satayev
Browse files

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
parent 0a420e77
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -765,6 +765,16 @@ func (c *config) PreviewApiLevels() []ApiLevel {
	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 {
	var levels []ApiLevel
	levels = append(levels, c.FinalApiLevels()...)
+43 −6
Original line number Diff line number Diff line
@@ -86,9 +86,8 @@ func initClasspathFragment(c classpathFragment, classpathType classpathType) {
type classpathJar struct {
	path          string
	classpath     classpathType
	// TODO(satayev): propagate min/max sdk versions for the jars
	minSdkVersion int32
	maxSdkVersion int32
	minSdkVersion string
	maxSdkVersion string
}

// 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))
	for i := 0; i < len(paths); i++ {
		for _, classpathType := range classpaths {
			jars = append(jars, classpathJar{
			jar := classpathJar{
				classpath: classpathType,
				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
@@ -161,6 +182,7 @@ func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.M

func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) {
	var content strings.Builder

	fmt.Fprintf(&content, "{\n")
	fmt.Fprintf(&content, "\"jars\": [\n")
	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, "\"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 {
			fmt.Fprintf(&content, "},\n")
		} else {
@@ -177,6 +213,7 @@ func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath,
	}
	fmt.Fprintf(&content, "]\n")
	fmt.Fprintf(&content, "}\n")

	android.WriteFileRule(ctx, output, content.String())
}

+0 −1
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ type platformBootclasspathProperties struct {
func platformBootclasspathFactory() android.SingletonModule {
	m := &platformBootclasspathModule{}
	m.AddProperties(&m.properties)
	// TODO(satayev): split apex jars into separate configs.
	initClasspathFragment(m, BOOTCLASSPATH)
	android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
	return m