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

Commit bb3467d2 authored by Ulyana Trafimovich's avatar Ulyana Trafimovich Committed by Gerrit Code Review
Browse files

Merge "Allow non-SDK Java libraries to masquerade as <uses-library>."

parents 66a0ae60 21a73752
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -378,6 +378,10 @@ func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStati
			exportPackage = aarDep.ExportPackage()
		}

		if dep, ok := module.(Dependency); ok {
			sdkLibraries.AddLibraryPaths(dep.ExportedSdkLibs())
		}

		switch ctx.OtherModuleDependencyTag(module) {
		case instrumentationForTag:
			// Nothing, instrumentationForTag is treated as libTag for javac but not for aapt2.
@@ -399,9 +403,6 @@ func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStati
				sharedLibs = append(sharedLibs, exportPackage)
			}
		case staticLibTag:
			if dep, ok := module.(Dependency); ok {
				sdkLibraries.AddLibraryPaths(dep.ExportedSdkLibs())
			}
			if exportPackage != nil {
				transitiveStaticLibs = append(transitiveStaticLibs, aarDep.ExportedStaticPackages()...)
				transitiveStaticLibs = append(transitiveStaticLibs, exportPackage)
+5 −8
Original line number Diff line number Diff line
@@ -284,8 +284,6 @@ type AndroidApp struct {
	aapt
	android.OverridableModuleBase

	usesLibrary usesLibrary

	certificate Certificate

	appProperties appProperties
@@ -1018,8 +1016,7 @@ func AndroidAppFactory() android.Module {
	module.AddProperties(
		&module.aaptProperties,
		&module.appProperties,
		&module.overridableAppProperties,
		&module.usesLibrary.usesLibraryProperties)
		&module.overridableAppProperties)

	android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
	android.InitDefaultableModule(module)
@@ -1140,7 +1137,6 @@ func AndroidTestFactory() android.Module {
		&module.appProperties,
		&module.appTestProperties,
		&module.overridableAppProperties,
		&module.usesLibrary.usesLibraryProperties,
		&module.testProperties)

	android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
@@ -1189,8 +1185,7 @@ func AndroidTestHelperAppFactory() android.Module {
		&module.aaptProperties,
		&module.appProperties,
		&module.appTestHelperAppProperties,
		&module.overridableAppProperties,
		&module.usesLibrary.usesLibraryProperties)
		&module.overridableAppProperties)

	android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
	android.InitDefaultableModule(module)
@@ -1704,7 +1699,6 @@ func AndroidTestImportFactory() android.Module {
	module := &AndroidTestImport{}
	module.AddProperties(&module.properties)
	module.AddProperties(&module.dexpreoptProperties)
	module.AddProperties(&module.usesLibrary.usesLibraryProperties)
	module.AddProperties(&module.testProperties)
	module.AddProperties(&module.testImportProperties)
	module.populateAllVariantStructs()
@@ -1888,6 +1882,9 @@ type UsesLibraryProperties struct {
	// If true, the list of uses_libs and optional_uses_libs modules must match the AndroidManifest.xml file.  Defaults
	// to true if either uses_libs or optional_uses_libs is set.  Will unconditionally default to true in the future.
	Enforce_uses_libs *bool

	// If the library itself is a uses-library (this is needed for non-SDK libraries).
	Is_uses_lib *bool
}

// usesLibrary provides properties and helper functions for AndroidApp and AndroidAppImport to verify that the
+7 −0
Original line number Diff line number Diff line
@@ -437,6 +437,7 @@ type Module struct {
	hiddenAPI
	dexer
	dexpreopter
	usesLibrary
	linter

	// list of the xref extraction files
@@ -452,6 +453,7 @@ func (j *Module) addHostProperties() {
	j.AddProperties(
		&j.properties,
		&j.protoProperties,
		&j.usesLibraryProperties,
	)
}

@@ -1976,6 +1978,11 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	// added to the Android manifest.
	j.exportedSdkLibs.MaybeAddLibraryPath(ctx, j.OptionalImplicitSdkLibrary(), j.DexJarBuildPath(), j.DexJarInstallPath())

	// If this is a non-SDK uses-library, export itself.
	if proptools.Bool(j.usesLibraryProperties.Is_uses_lib) {
		j.exportedSdkLibs.AddLibraryPath(ctx, ctx.ModuleName(), j.DexJarBuildPath(), j.DexJarInstallPath())
	}

	j.distFiles = j.GenerateTaggedDistFiles(ctx)
}