Merge "Add vendor snapshot usage test"
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index 665a649..c6b0bf0 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -119,6 +119,10 @@
ccModule := member.Variants()[0].(*Module)
+ if proptools.Bool(ccModule.VendorProperties.Vendor_available) {
+ pbm.AddProperty("vendor_available", true)
+ }
+
sdkVersion := ccModule.SdkVersion()
if sdkVersion != "" {
pbm.AddProperty("sdk_version", sdkVersion)
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index f22ee47..3ef8b8d 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -130,14 +130,20 @@
// Add a new library path to the map. Ensure that the build path to the library exists.
func (libPaths LibraryPaths) AddLibraryPath(ctx android.PathContext, lib string, hostPath, installPath android.Path) {
- if hostPath != nil {
- // Add a library only if the build path to it is known.
+ if hostPath != nil && installPath != nil {
+ // Add a library only if the build and install path to it is known.
libPaths.addLibraryPath(ctx, lib, hostPath, installPath)
- } else if !ctx.Config().AllowMissingDependencies() {
- // Error on libraries with unknown build paths, unless missing dependencies are allowed.
- android.ReportPathErrorf(ctx, "unknown build path to <uses-library> '%s'", lib)
+ } else if ctx.Config().AllowMissingDependencies() {
+ // If missing dependencies are allowed, the build shouldn't fail when a <uses-library> is
+ // not found. However, this is likely to result is disabling dexpreopt, as it won't be
+ // possible to construct class loader context without on-host and on-device library paths.
} else {
- // Not adding a library to the map will likely result in disabling dexpreopt.
+ // Error on libraries with unknown paths.
+ if hostPath == nil {
+ android.ReportPathErrorf(ctx, "unknown build path to <uses-library> '%s'", lib)
+ } else {
+ android.ReportPathErrorf(ctx, "unknown install path to <uses-library> '%s'", lib)
+ }
}
}
diff --git a/java/aar.go b/java/aar.go
index 0f5e30d..667dd9d 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -378,6 +378,10 @@
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 @@
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)
diff --git a/java/app.go b/java/app.go
index 34f96dd..406894d 100755
--- a/java/app.go
+++ b/java/app.go
@@ -284,8 +284,6 @@
aapt
android.OverridableModuleBase
- usesLibrary usesLibrary
-
certificate Certificate
appProperties appProperties
@@ -1018,8 +1016,7 @@
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 @@
&module.appProperties,
&module.appTestProperties,
&module.overridableAppProperties,
- &module.usesLibrary.usesLibraryProperties,
&module.testProperties)
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
@@ -1189,8 +1185,7 @@
&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 @@
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 @@
// 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
@@ -1918,11 +1915,11 @@
if hasFrameworkLibs {
// Dexpreopt needs paths to the dex jars of these libraries in order to construct
// class loader context for dex2oat. Add them as a dependency with a special tag.
- ctx.AddVariationDependencies(nil, usesLibTag,
+ ctx.AddVariationDependencies(nil, usesLibCompatTag,
"org.apache.http.legacy",
"android.hidl.base-V1.0-java",
"android.hidl.manager-V1.0-java")
- ctx.AddVariationDependencies(nil, usesLibTag, optionalUsesLibs...)
+ ctx.AddVariationDependencies(nil, usesLibCompatTag, optionalUsesLibs...)
}
}
}
@@ -1940,30 +1937,27 @@
usesLibPaths := make(dexpreopt.LibraryPaths)
if !ctx.Config().UnbundledBuild() {
- ctx.VisitDirectDepsWithTag(usesLibTag, func(m android.Module) {
- dep := ctx.OtherModuleName(m)
- if lib, ok := m.(Dependency); ok {
- buildPath := lib.DexJarBuildPath()
- if buildPath == nil {
- ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must"+
- " produce a dex jar, does it have installable: true?", dep)
- return
- }
+ ctx.VisitDirectDeps(func(m android.Module) {
+ tag := ctx.OtherModuleDependencyTag(m)
+ if tag == usesLibTag || tag == usesLibCompatTag {
+ dep := ctx.OtherModuleName(m)
- var devicePath string
- installPath := lib.DexJarInstallPath()
- if installPath == nil {
- devicePath = filepath.Join("/system/framework", dep+".jar")
+ if lib, ok := m.(Dependency); ok {
+ buildPath := lib.DexJarBuildPath()
+ installPath := lib.DexJarInstallPath()
+ if installPath == nil && tag == usesLibCompatTag {
+ // assume that compatibility libraries are in /system/framework
+ installPath = android.PathForModuleInstall(ctx, "framework", dep+".jar")
+ }
+ usesLibPaths.AddLibraryPath(ctx, dep, buildPath, installPath)
+
+ } else if ctx.Config().AllowMissingDependencies() {
+ ctx.AddMissingDependencies([]string{dep})
+
} else {
- devicePath = android.InstallPathToOnDevicePath(ctx, installPath.(android.InstallPath))
+ ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be "+
+ "a java library", dep)
}
-
- usesLibPaths[dep] = &dexpreopt.LibraryPath{buildPath, devicePath}
- } else if ctx.Config().AllowMissingDependencies() {
- ctx.AddMissingDependencies([]string{dep})
- } else {
- ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be "+
- "a java library", dep)
}
})
}
diff --git a/java/java.go b/java/java.go
index 3606f77..c568ec4 100644
--- a/java/java.go
+++ b/java/java.go
@@ -437,6 +437,7 @@
hiddenAPI
dexer
dexpreopter
+ usesLibrary
linter
// list of the xref extraction files
@@ -452,6 +453,7 @@
j.AddProperties(
&j.properties,
&j.protoProperties,
+ &j.usesLibraryProperties,
)
}
@@ -564,6 +566,7 @@
certificateTag = dependencyTag{name: "certificate"}
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
usesLibTag = dependencyTag{name: "uses-library"}
+ usesLibCompatTag = dependencyTag{name: "uses-library-compat"}
extraLintCheckTag = dependencyTag{name: "extra-lint-check"}
)
@@ -1976,6 +1979,11 @@
// 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)
}
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 84b905c..0811ef5 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -1672,6 +1672,7 @@
],
export_include_dirs: ["include"],
stl: "none",
+ vendor_available: true,
}
`)
@@ -1683,6 +1684,7 @@
name: "myexports_mynativelib@current",
sdk_member_name: "mynativelib",
installable: false,
+ vendor_available: true,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
@@ -1709,6 +1711,7 @@
cc_prebuilt_library {
name: "mynativelib",
prefer: false,
+ vendor_available: true,
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],