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

Commit a73c4021 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I439179a9,I8ad68f0d into main

* changes:
  Add pattern to match android-plus-updatable.jar
  Clean up apiLevelsGenerationFlags deps gathering
parents c9b4d4c5 5a195f40
Loading
Loading
Loading
Loading
+35 −6
Original line number Diff line number Diff line
@@ -604,6 +604,11 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a
	}
}

// AndroidPlusUpdatableJar is the name of some extra jars added into `module-lib` and
// `system-server` directories that contain all the APIs provided by the platform and updatable
// modules because the `android.jar` files do not. See b/337836752.
const AndroidPlusUpdatableJar = "android-plus-updatable.jar"

func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) {
	if len(d.properties.Api_levels_annotations_dirs) == 0 {
		ctx.PropertyErrorf("api_levels_annotations_dirs",
@@ -648,16 +653,24 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an
			// Grab the first extensions_dir and we find while scanning ExportedDroiddocDir.deps;
			// ideally this should be read from prebuiltApis.properties.Extensions_*
			for _, dep := range t.deps {
				// Check to see if it matches an extension first.
				depBase := dep.Base()
				if extRegex.MatchString(dep.String()) && d.properties.Extensions_info_file != nil {
					if extensions_dir == "" {
						extensions_dir = t.dir.String() + "/extensions"
					}
					cmd.Implicit(dep)
				}
				if dep.Base() == filename {
				} else if depBase == filename {
					// Check to see if it matches a dessert release for an SDK, e.g. Android, Car, Wear, etc..
					cmd.Implicit(dep)
				}
				if filename != "android.jar" && dep.Base() == "android.jar" {
				} else if depBase == AndroidPlusUpdatableJar && d.properties.Extensions_info_file != nil {
					// The output api-versions.xml has been requested to include information on SDK
					// extensions. That means it also needs to include
					// so
					// The module-lib and system-server directories should use `android-plus-updatable.jar`
					// instead of `android.jar`. See AndroidPlusUpdatableJar for more information.
					cmd.Implicit(dep)
				} else if filename != "android.jar" && depBase == "android.jar" {
					// Metalava implicitly searches these patterns:
					//  prebuilts/tools/common/api-versions/android-%/android.jar
					//  prebuilts/sdk/%/public/android.jar
@@ -675,9 +688,25 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an
		}
	})

	// Generate the list of --android-jar-pattern options. The order matters so the first one which
	// matches will be the one that is used for a specific api level..
	for _, sdkDir := range sdkDirs {
		for _, dir := range dirs {
			cmd.FlagWithArg("--android-jar-pattern ", fmt.Sprintf("%s/%%/%s/%s", dir, sdkDir, filename))
			addPattern := func(jarFilename string) {
				cmd.FlagWithArg("--android-jar-pattern ", fmt.Sprintf("%s/%%/%s/%s", dir, sdkDir, jarFilename))
			}

			if sdkDir == "module-lib" || sdkDir == "system-server" {
				// The module-lib and system-server android.jars do not include the updatable modules (as
				// doing so in the source would introduce dependency cycles and the prebuilts have to
				// match the sources). So, instead an additional `android-plus-updatable.jar` will be used
				// that does include the updatable modules and this pattern will match that. This pattern
				// is added in addition to the following pattern to decouple this change from the change
				// to add the `android-plus-updatable.jar`.
				addPattern(AndroidPlusUpdatableJar)
			}

			addPattern(filename)
		}
	}