Merge "Copy removed.txt file to the snapshot correctly" into rvc-dev
diff --git a/apex/androidmk.go b/apex/androidmk.go
index 624c47d..d1c2a64 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -170,7 +170,7 @@
// soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
// we will have foo.jar.jar
- fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.builtFile.Base(), ".jar"))
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".jar"))
fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String())
fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String())
fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", fi.builtFile.String())
@@ -181,13 +181,13 @@
// soong_app_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .apk Therefore
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
// we will have foo.apk.apk
- fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.builtFile.Base(), ".apk"))
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".apk"))
if app, ok := fi.module.(*java.AndroidApp); ok && len(app.JniCoverageOutputs()) > 0 {
fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", strings.Join(app.JniCoverageOutputs().Strings(), " "))
}
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_app_prebuilt.mk")
} else if fi.class == nativeSharedLib || fi.class == nativeExecutable || fi.class == nativeTest {
- fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base())
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.Stem())
if cc, ok := fi.module.(*cc.Module); ok {
if cc.UnstrippedOutputFile() != nil {
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", cc.UnstrippedOutputFile().String())
@@ -199,7 +199,7 @@
}
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk")
} else {
- fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base())
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.Stem())
if fi.builtFile == a.manifestPbOut && apexType == flattenedApex {
if a.primaryApexType {
// Make apex_manifest.pb module for this APEX to override all other
diff --git a/apex/apex.go b/apex/apex.go
index 4c5dbd0..b974bcd 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1227,11 +1227,14 @@
// Path() returns path of this apex file relative to the APEX root
func (af *apexFile) Path() string {
- stem := af.builtFile.Base()
+ return af.apexRelativePath(af.Stem())
+}
+
+func (af *apexFile) Stem() string {
if af.stem != "" {
- stem = af.stem
+ return af.stem
}
- return af.apexRelativePath(stem)
+ return af.builtFile.Base()
}
// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
@@ -1672,7 +1675,8 @@
}
type javaDependency interface {
- java.Dependency
+ DexJar() android.Path
+ JacocoReportClassesFile() android.Path
Stem() string
}
@@ -1933,11 +1937,12 @@
switch depTag {
case sharedLibTag:
if c, ok := child.(*cc.Module); ok {
+ fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs)
+ filesInfo = append(filesInfo, fi)
// bootstrap bionic libs are treated as provided by system
if c.HasStubsVariants() && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
- provideNativeLibs = append(provideNativeLibs, c.OutputFile().Path().Base())
+ provideNativeLibs = append(provideNativeLibs, fi.Stem())
}
- filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, c, handleSpecialLibs))
return true // track transitive dependencies
} else {
ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
@@ -1956,23 +1961,16 @@
ctx.PropertyErrorf("binaries", "%q is neither cc_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName)
}
case javaLibTag:
- if javaLib, ok := child.(*java.Library); ok {
- af := apexFileForJavaLibrary(ctx, javaLib, javaLib)
- if !af.Ok() {
- ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
- } else {
- filesInfo = append(filesInfo, af)
- return true // track transitive dependencies
- }
- } else if sdkLib, ok := child.(*java.SdkLibrary); ok {
- af := apexFileForJavaLibrary(ctx, sdkLib, sdkLib)
+ switch child.(type) {
+ case *java.Library, *java.SdkLibrary, *java.DexImport:
+ af := apexFileForJavaLibrary(ctx, child.(javaDependency), child.(android.Module))
if !af.Ok() {
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
return false
}
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
- } else {
+ default:
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
}
case androidAppTag:
@@ -2047,6 +2045,8 @@
// don't include it in this APEX
return false
}
+ af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
+ af.transitiveDep = true
if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
// If the dependency is a stubs lib, don't include it in this APEX,
// but make sure that the lib is installed on the device.
@@ -2058,12 +2058,10 @@
if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.requiredDeps) {
a.requiredDeps = append(a.requiredDeps, cc.Name())
}
- requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
+ requireNativeLibs = append(requireNativeLibs, af.Stem())
// Don't track further
return false
}
- af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
- af.transitiveDep = true
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 3ff47ce..a98f6c6 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -291,7 +291,10 @@
binaries: ["foo",],
}
},
- java_libs: ["myjar"],
+ java_libs: [
+ "myjar",
+ "myjar_dex",
+ ],
}
apex {
@@ -400,6 +403,15 @@
],
}
+ dex_import {
+ name: "myjar_dex",
+ jars: ["prebuilt.jar"],
+ apex_available: [
+ "//apex_available:platform",
+ "myapex",
+ ],
+ }
+
java_library {
name: "myotherjar",
srcs: ["foo/bar/MyClass.java"],
@@ -435,6 +447,7 @@
// Ensure that apex variant is created for the direct dep
ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared_myapex")
ensureListContains(t, ctx.ModuleVariantsForTests("myjar"), "android_common_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("myjar_dex"), "android_common_myapex")
// Ensure that apex variant is created for the indirect dep
ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared_myapex")
@@ -444,6 +457,7 @@
ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
ensureContains(t, copyCmds, "image.apex/lib64/mylib2.so")
ensureContains(t, copyCmds, "image.apex/javalib/myjar_stem.jar")
+ ensureContains(t, copyCmds, "image.apex/javalib/myjar_dex.jar")
// .. but not for java libs
ensureNotContains(t, copyCmds, "image.apex/javalib/myotherjar.jar")
ensureNotContains(t, copyCmds, "image.apex/javalib/msharedjar.jar")
diff --git a/apex/builder.go b/apex/builder.go
index 2eb7672..fce2503 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -395,7 +395,7 @@
var readOnlyPaths = []string{"apex_manifest.json", "apex_manifest.pb"}
var executablePaths []string // this also includes dirs
for _, f := range a.filesInfo {
- pathInApex := filepath.Join(f.installDir, f.builtFile.Base())
+ pathInApex := f.Path()
if f.installDir == "bin" || strings.HasPrefix(f.installDir, "bin/") {
executablePaths = append(executablePaths, pathInApex)
for _, s := range f.symlinks {
@@ -642,7 +642,7 @@
apexBundleName := a.Name()
for _, fi := range a.filesInfo {
dir := filepath.Join("apex", apexBundleName, fi.installDir)
- target := ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.builtFile.Base(), fi.builtFile)
+ target := ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.Stem(), fi.builtFile)
for _, sym := range fi.symlinks {
ctx.InstallSymlink(android.PathForModuleInstall(ctx, dir), sym, target)
}
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 5438b14..fede601 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -540,6 +540,25 @@
})
}
+func (c *vendorSnapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
+ entries.Class = "STATIC_LIBRARIES"
+
+ if c.androidMkVendorSuffix {
+ entries.SubName = vendorSuffix
+ } else {
+ entries.SubName = ""
+ }
+
+ entries.ExtraFooters = append(entries.ExtraFooters,
+ func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
+ out := entries.OutputFile.Path()
+ varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName)
+
+ fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
+ fmt.Fprintln(w, ".KATI_READONLY: "+varname)
+ })
+}
+
func (c *ndkPrebuiltStlLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
entries.Class = "SHARED_LIBRARIES"
}
diff --git a/cc/binary.go b/cc/binary.go
index 661264e..251b7f0 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -231,6 +231,10 @@
return binary.static()
}
+func (binary *binaryDecorator) binary() bool {
+ return true
+}
+
func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
flags = binary.baseLinker.linkerFlags(ctx, flags)
diff --git a/cc/cc.go b/cc/cc.go
index 01bf5f1..3d3a841 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -309,6 +309,8 @@
static() bool
staticBinary() bool
header() bool
+ binary() bool
+ object() bool
toolchain() config.Toolchain
canUseSdk() bool
useSdk() bool
@@ -1002,14 +1004,8 @@
}
func (c *Module) isSnapshotPrebuilt() bool {
- if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
- return true
- }
- if _, ok := c.linker.(*vendorSnapshotLibraryDecorator); ok {
- return true
- }
- if _, ok := c.linker.(*vendorSnapshotBinaryDecorator); ok {
- return true
+ if p, ok := c.linker.(interface{ isSnapshotPrebuilt() bool }); ok {
+ return p.isSnapshotPrebuilt()
}
return false
}
@@ -1114,6 +1110,14 @@
return ctx.mod.header()
}
+func (ctx *moduleContextImpl) binary() bool {
+ return ctx.mod.binary()
+}
+
+func (ctx *moduleContextImpl) object() bool {
+ return ctx.mod.object()
+}
+
func (ctx *moduleContextImpl) canUseSdk() bool {
return ctx.mod.canUseSdk()
}
@@ -1896,7 +1900,7 @@
if deps.StaticUnwinderIfLegacy {
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
- }, staticUnwinderDepTag, staticUnwinder(actx))
+ }, staticUnwinderDepTag, rewriteSnapshotLibs(staticUnwinder(actx), vendorSnapshotStaticLibs))
}
for _, lib := range deps.LateStaticLibs {
@@ -1977,11 +1981,13 @@
actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...)
+ vendorSnapshotObjects := vendorSnapshotObjects(actx.Config())
+
if deps.CrtBegin != "" {
- actx.AddVariationDependencies(nil, CrtBeginDepTag, deps.CrtBegin)
+ actx.AddVariationDependencies(nil, CrtBeginDepTag, rewriteSnapshotLibs(deps.CrtBegin, vendorSnapshotObjects))
}
if deps.CrtEnd != "" {
- actx.AddVariationDependencies(nil, CrtEndDepTag, deps.CrtEnd)
+ actx.AddVariationDependencies(nil, CrtEndDepTag, rewriteSnapshotLibs(deps.CrtEnd, vendorSnapshotObjects))
}
if deps.LinkerFlagsFile != "" {
actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile)
@@ -2713,6 +2719,24 @@
return false
}
+func (c *Module) binary() bool {
+ if b, ok := c.linker.(interface {
+ binary() bool
+ }); ok {
+ return b.binary()
+ }
+ return false
+}
+
+func (c *Module) object() bool {
+ if o, ok := c.linker.(interface {
+ object() bool
+ }); ok {
+ return o.object()
+ }
+ return false
+}
+
func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
if c.UseVndk() {
if lib, ok := c.linker.(*llndkStubDecorator); ok {
@@ -3022,20 +3046,32 @@
// This will be available in /system, /vendor and /product
// or a /system directory that is available to vendor and product.
coreVariantNeeded = true
- vendorVariants = append(vendorVariants, platformVndkVersion)
- productVariants = append(productVariants, platformVndkVersion)
- // VNDK modules must not create BOARD_VNDK_VERSION variant because its
- // code is PLATFORM_VNDK_VERSION.
- // On the other hand, vendor_available modules which are not VNDK should
- // also build BOARD_VNDK_VERSION because it's installed in /vendor.
- // vendor_available modules are also available to /product.
- if !m.IsVndk() {
+
+ // We assume that modules under proprietary paths are compatible for
+ // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, or
+ // PLATFORM_VNDK_VERSION.
+ if isVendorProprietaryPath(mctx.ModuleDir()) {
vendorVariants = append(vendorVariants, boardVndkVersion)
+ } else {
+ vendorVariants = append(vendorVariants, platformVndkVersion)
+ }
+
+ // vendor_available modules are also available to /product.
+ productVariants = append(productVariants, platformVndkVersion)
+ // VNDK is always PLATFORM_VNDK_VERSION
+ if !m.IsVndk() {
productVariants = append(productVariants, productVndkVersion)
}
} else if vendorSpecific && String(m.Properties.Sdk_version) == "" {
// This will be available in /vendor (or /odm) only
- vendorVariants = append(vendorVariants, boardVndkVersion)
+ // We assume that modules under proprietary paths are compatible for
+ // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, or
+ // PLATFORM_VNDK_VERSION.
+ if isVendorProprietaryPath(mctx.ModuleDir()) {
+ vendorVariants = append(vendorVariants, boardVndkVersion)
+ } else {
+ vendorVariants = append(vendorVariants, platformVndkVersion)
+ }
} else {
// This is either in /system (or similar: /data), or is a
// modules built with the NDK. Modules built with the NDK
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 67eb248..76b4e38 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -258,9 +258,7 @@
}
}
-func checkSnapshot(t *testing.T, ctx *android.TestContext, singletonName, moduleName, snapshotFilename, subDir, variant string) {
- snapshotSingleton := ctx.SingletonForTests(singletonName)
-
+func checkSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
mod, ok := ctx.ModuleForTests(moduleName, variant).Module().(android.OutputFileProducer)
if !ok {
t.Errorf("%q must have output\n", moduleName)
@@ -273,7 +271,7 @@
}
snapshotPath := filepath.Join(subDir, snapshotFilename)
- out := snapshotSingleton.Output(snapshotPath)
+ out := singleton.Output(snapshotPath)
if out.Input.String() != outputFiles[0].String() {
t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFiles[0])
}
@@ -398,16 +396,18 @@
variant := "android_vendor.VER_arm64_armv8-a_shared"
variant2nd := "android_vendor.VER_arm_armv7-a-neon_shared"
- checkSnapshot(t, ctx, "vndk-snapshot", "libvndk", "libvndk.so", vndkCoreLibPath, variant)
- checkSnapshot(t, ctx, "vndk-snapshot", "libvndk", "libvndk.so", vndkCoreLib2ndPath, variant2nd)
- checkSnapshot(t, ctx, "vndk-snapshot", "libvndk_sp", "libvndk_sp-x.so", vndkSpLibPath, variant)
- checkSnapshot(t, ctx, "vndk-snapshot", "libvndk_sp", "libvndk_sp-x.so", vndkSpLib2ndPath, variant2nd)
+ snapshotSingleton := ctx.SingletonForTests("vndk-snapshot")
+
+ checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLibPath, variant)
+ checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLib2ndPath, variant2nd)
+ checkSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLibPath, variant)
+ checkSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLib2ndPath, variant2nd)
snapshotConfigsPath := filepath.Join(snapshotVariantPath, "configs")
- checkSnapshot(t, ctx, "vndk-snapshot", "llndk.libraries.txt", "llndk.libraries.txt", snapshotConfigsPath, "")
- checkSnapshot(t, ctx, "vndk-snapshot", "vndkcore.libraries.txt", "vndkcore.libraries.txt", snapshotConfigsPath, "")
- checkSnapshot(t, ctx, "vndk-snapshot", "vndksp.libraries.txt", "vndksp.libraries.txt", snapshotConfigsPath, "")
- checkSnapshot(t, ctx, "vndk-snapshot", "vndkprivate.libraries.txt", "vndkprivate.libraries.txt", snapshotConfigsPath, "")
+ checkSnapshot(t, ctx, snapshotSingleton, "llndk.libraries.txt", "llndk.libraries.txt", snapshotConfigsPath, "")
+ checkSnapshot(t, ctx, snapshotSingleton, "vndkcore.libraries.txt", "vndkcore.libraries.txt", snapshotConfigsPath, "")
+ checkSnapshot(t, ctx, snapshotSingleton, "vndksp.libraries.txt", "vndksp.libraries.txt", snapshotConfigsPath, "")
+ checkSnapshot(t, ctx, snapshotSingleton, "vndkprivate.libraries.txt", "vndkprivate.libraries.txt", snapshotConfigsPath, "")
checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{
"LLNDK: libc.so",
@@ -839,6 +839,17 @@
vendor_available: true,
nocrt: true,
}
+
+ toolchain_library {
+ name: "libb",
+ vendor_available: true,
+ src: "libb.a",
+ }
+
+ cc_object {
+ name: "obj",
+ vendor_available: true,
+ }
`
config := TestConfig(buildDir, android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
@@ -849,6 +860,9 @@
snapshotDir := "vendor-snapshot"
snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64")
+ snapshotSingleton := ctx.SingletonForTests("vendor-snapshot")
+
+ var jsonFiles []string
for _, arch := range [][]string{
[]string{"arm64", "armv8-a"},
@@ -861,22 +875,51 @@
// For shared libraries, only non-VNDK vendor_available modules are captured
sharedVariant := fmt.Sprintf("android_vendor.VER_%s_%s_shared", archType, archVariant)
sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared")
- checkSnapshot(t, ctx, "vendor-snapshot", "libvendor", "libvendor.so", sharedDir, sharedVariant)
- checkSnapshot(t, ctx, "vendor-snapshot", "libvendor_available", "libvendor_available.so", sharedDir, sharedVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.so", sharedDir, sharedVariant)
+ jsonFiles = append(jsonFiles,
+ filepath.Join(sharedDir, "libvendor.so.json"),
+ filepath.Join(sharedDir, "libvendor_available.so.json"))
// For static libraries, all vendor:true and vendor_available modules (including VNDK) are captured.
staticVariant := fmt.Sprintf("android_vendor.VER_%s_%s_static", archType, archVariant)
staticDir := filepath.Join(snapshotVariantPath, archDir, "static")
- checkSnapshot(t, ctx, "vendor-snapshot", "libvndk", "libvndk.a", staticDir, staticVariant)
- checkSnapshot(t, ctx, "vendor-snapshot", "libvendor", "libvendor.a", staticDir, staticVariant)
- checkSnapshot(t, ctx, "vendor-snapshot", "libvendor_available", "libvendor_available.a", staticDir, staticVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "libb", "libb.a", staticDir, staticVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.a", staticDir, staticVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.a", staticDir, staticVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.a", staticDir, staticVariant)
+ jsonFiles = append(jsonFiles,
+ filepath.Join(staticDir, "libb.a.json"),
+ filepath.Join(staticDir, "libvndk.a.json"),
+ filepath.Join(staticDir, "libvendor.a.json"),
+ filepath.Join(staticDir, "libvendor_available.a.json"))
- // For binary libraries, all vendor:true and vendor_available modules are captured.
+ // For binary executables, all vendor:true and vendor_available modules are captured.
if archType == "arm64" {
binaryVariant := fmt.Sprintf("android_vendor.VER_%s_%s", archType, archVariant)
binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary")
- checkSnapshot(t, ctx, "vendor-snapshot", "vendor_bin", "vendor_bin", binaryDir, binaryVariant)
- checkSnapshot(t, ctx, "vendor-snapshot", "vendor_available_bin", "vendor_available_bin", binaryDir, binaryVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "vendor_bin", "vendor_bin", binaryDir, binaryVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "vendor_available_bin", "vendor_available_bin", binaryDir, binaryVariant)
+ jsonFiles = append(jsonFiles,
+ filepath.Join(binaryDir, "vendor_bin.json"),
+ filepath.Join(binaryDir, "vendor_available_bin.json"))
+ }
+
+ // For header libraries, all vendor:true and vendor_available modules are captured.
+ headerDir := filepath.Join(snapshotVariantPath, archDir, "header")
+ jsonFiles = append(jsonFiles, filepath.Join(headerDir, "libvendor_headers.json"))
+
+ // For object modules, all vendor:true and vendor_available modules are captured.
+ objectVariant := fmt.Sprintf("android_vendor.VER_%s_%s", archType, archVariant)
+ objectDir := filepath.Join(snapshotVariantPath, archDir, "object")
+ checkSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant)
+ jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json"))
+ }
+
+ for _, jsonFile := range jsonFiles {
+ // verify all json files exist
+ if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil {
+ t.Errorf("%q expected but not found", jsonFile)
}
}
}
diff --git a/cc/genrule.go b/cc/genrule.go
index 9331448..66d1784 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -79,8 +79,14 @@
var variants []string
if Bool(g.Vendor_available) || ctx.SocSpecific() || ctx.DeviceSpecific() {
- variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
- if vndkVersion := ctx.DeviceConfig().VndkVersion(); vndkVersion != "current" {
+ vndkVersion := ctx.DeviceConfig().VndkVersion()
+ // If vndkVersion is current, we can always use PlatformVndkVersion.
+ // If not, we assume modules under proprietary paths are compatible for
+ // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, that is
+ // PLATFORM_VNDK_VERSION.
+ if vndkVersion == "current" || !isVendorProprietaryPath(ctx.ModuleDir()) {
+ variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
+ } else {
variants = append(variants, VendorVariationPrefix+vndkVersion)
}
}
diff --git a/cc/object.go b/cc/object.go
index 19decec..15a529e 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -158,3 +158,7 @@
func (object *objectLinker) coverageOutputFilePath() android.OptionalPath {
return android.OptionalPath{}
}
+
+func (object *objectLinker) object() bool {
+ return true
+}
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 2ef3195..b7c0bf2 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -248,6 +248,10 @@
return nil
}
+func (p *prebuiltObjectLinker) object() bool {
+ return true
+}
+
func newPrebuiltObject() *Module {
module := newObject()
prebuilt := &prebuiltObjectLinker{
@@ -306,6 +310,10 @@
return nil
}
+func (p *prebuiltBinaryLinker) binary() bool {
+ return true
+}
+
// cc_prebuilt_binary installs a precompiled executable in srcs property in the
// device's directory.
func prebuiltBinaryFactory() android.Module {
diff --git a/cc/testing.go b/cc/testing.go
index 6119920..d92309f 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -457,6 +457,7 @@
"my_include": nil,
"foo.map.txt": nil,
"liba.so": nil,
+ "libb.a": nil,
}
GatherRequiredFilesForTest(mockFS)
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index c79a653..2e2a779 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -30,6 +30,7 @@
vendorSnapshotSharedSuffix = ".vendor_shared."
vendorSnapshotStaticSuffix = ".vendor_static."
vendorSnapshotBinarySuffix = ".vendor_binary."
+ vendorSnapshotObjectSuffix = ".vendor_object."
)
var (
@@ -39,6 +40,7 @@
vendorSnapshotStaticLibsKey = android.NewOnceKey("vendorSnapshotStaticLibs")
vendorSnapshotSharedLibsKey = android.NewOnceKey("vendorSnapshotSharedLibs")
vendorSnapshotBinariesKey = android.NewOnceKey("vendorSnapshotBinaries")
+ vendorSnapshotObjectsKey = android.NewOnceKey("vendorSnapshotObjects")
)
// vendor snapshot maps hold names of vendor snapshot modules per arch
@@ -72,6 +74,12 @@
}).(*snapshotMap)
}
+func vendorSnapshotObjects(config android.Config) *snapshotMap {
+ return config.Once(vendorSnapshotObjectsKey, func() interface{} {
+ return newSnapshotMap()
+ }).(*snapshotMap)
+}
+
type vendorSnapshotLibraryProperties struct {
// snapshot version.
Version string
@@ -185,6 +193,10 @@
return false
}
+func (p *vendorSnapshotLibraryDecorator) isSnapshotPrebuilt() bool {
+ return true
+}
+
func (p *vendorSnapshotLibraryDecorator) install(ctx ModuleContext, file android.Path) {
if p.matchesWithDevice(ctx.DeviceConfig()) && (p.shared() || p.static()) {
p.baseInstaller.install(ctx, file)
@@ -337,6 +349,10 @@
return outputFile
}
+func (p *vendorSnapshotBinaryDecorator) isSnapshotPrebuilt() bool {
+ return true
+}
+
func VendorSnapshotBinaryFactory() android.Module {
module, binary := NewBinary(android.DeviceSupported)
binary.baseLinker.Properties.No_libcrt = BoolPtr(true)
@@ -364,12 +380,98 @@
return module.Init()
}
+type vendorSnapshotObjectProperties struct {
+ // snapshot version.
+ Version string
+
+ // Target arch name of the snapshot (e.g. 'arm64' for variant 'aosp_arm64_ab')
+ Target_arch string
+
+ // Prebuilt file for each arch.
+ Src *string `android:"arch_variant"`
+}
+
+type vendorSnapshotObjectLinker struct {
+ objectLinker
+ properties vendorSnapshotObjectProperties
+ androidMkVendorSuffix bool
+}
+
+func (p *vendorSnapshotObjectLinker) Name(name string) string {
+ return name + p.NameSuffix()
+}
+
+func (p *vendorSnapshotObjectLinker) NameSuffix() string {
+ versionSuffix := p.version()
+ if p.arch() != "" {
+ versionSuffix += "." + p.arch()
+ }
+ return vendorSnapshotObjectSuffix + versionSuffix
+}
+
+func (p *vendorSnapshotObjectLinker) version() string {
+ return p.properties.Version
+}
+
+func (p *vendorSnapshotObjectLinker) arch() string {
+ return p.properties.Target_arch
+}
+
+func (p *vendorSnapshotObjectLinker) matchesWithDevice(config android.DeviceConfig) bool {
+ if config.DeviceArch() != p.arch() {
+ return false
+ }
+ if p.properties.Src == nil {
+ return false
+ }
+ return true
+}
+
+func (p *vendorSnapshotObjectLinker) link(ctx ModuleContext,
+ flags Flags, deps PathDeps, objs Objects) android.Path {
+ if !p.matchesWithDevice(ctx.DeviceConfig()) {
+ return nil
+ }
+
+ m := ctx.Module().(*Module)
+ p.androidMkVendorSuffix = vendorSuffixModules(ctx.Config())[m.BaseModuleName()]
+
+ return android.PathForModuleSrc(ctx, *p.properties.Src)
+}
+
+func (p *vendorSnapshotObjectLinker) nativeCoverage() bool {
+ return false
+}
+
+func (p *vendorSnapshotObjectLinker) isSnapshotPrebuilt() bool {
+ return true
+}
+
+func VendorSnapshotObjectFactory() android.Module {
+ module := newObject()
+
+ prebuilt := &vendorSnapshotObjectLinker{
+ objectLinker: objectLinker{
+ baseLinker: NewBaseLinker(nil),
+ },
+ }
+ module.linker = prebuilt
+
+ android.AddLoadHook(module, func(ctx android.LoadHookContext) {
+ vendorSnapshotLoadHook(ctx, prebuilt)
+ })
+
+ module.AddProperties(&prebuilt.properties)
+ return module.Init()
+}
+
func init() {
android.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
android.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
android.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
android.RegisterModuleType("vendor_snapshot_header", VendorSnapshotHeaderFactory)
android.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
+ android.RegisterModuleType("vendor_snapshot_object", VendorSnapshotObjectFactory)
}
func VendorSnapshotSingleton() android.Singleton {
@@ -429,7 +531,7 @@
// depend on newer VNDK) So they are captured as vendor snapshot To build older vendor
// image and newer system image altogether.
func isVendorSnapshotModule(m *Module, moduleDir string) bool {
- if !m.Enabled() {
+ if !m.Enabled() || m.Properties.HideFromMake {
return false
}
// skip proprietary modules, but include all VNDK (static)
@@ -443,37 +545,37 @@
return false
}
// the module must be installed in /vendor
- if !m.installable() || m.isSnapshotPrebuilt() || !m.inVendor() {
- return false
- }
- // exclude test modules
- if _, ok := m.linker.(interface{ gtest() bool }); ok {
- return false
- }
- // TODO(b/65377115): add full support for sanitizer
- if m.sanitize != nil && !m.sanitize.isUnsanitizedVariant() {
+ if !m.IsForPlatform() || m.isSnapshotPrebuilt() || !m.inVendor() {
return false
}
// Libraries
if l, ok := m.linker.(snapshotLibraryInterface); ok {
+ // TODO(b/65377115): add full support for sanitizer
+ if m.sanitize != nil {
+ // cfi, scs and hwasan export both sanitized and unsanitized variants for static and header
+ // Always use unsanitized variants of them.
+ for _, t := range []sanitizerType{cfi, scs, hwasan} {
+ if !l.shared() && m.sanitize.isSanitizerEnabled(t) {
+ return false
+ }
+ }
+ }
if l.static() {
- return proptools.BoolDefault(m.VendorProperties.Vendor_available, true)
+ return m.outputFile.Valid() && proptools.BoolDefault(m.VendorProperties.Vendor_available, true)
}
if l.shared() {
- return !m.IsVndk()
+ return m.outputFile.Valid() && !m.IsVndk()
}
return true
}
- // Binaries
- _, ok := m.linker.(*binaryDecorator)
- if !ok {
- if _, ok := m.linker.(*prebuiltBinaryLinker); !ok {
- return false
- }
+ // Binaries and Objects
+ if m.binary() || m.object() {
+ return m.outputFile.Valid() && proptools.BoolDefault(m.VendorProperties.Vendor_available, true)
}
- return proptools.BoolDefault(m.VendorProperties.Vendor_available, true)
+
+ return false
}
func (c *vendorSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
@@ -496,6 +598,8 @@
(header only libraries)
binary/
(executable binaries)
+ object/
+ (.o object files)
arch-{TARGET_2ND_ARCH}-{TARGET_2ND_ARCH_VARIANT}/
shared/
(.so shared libraries)
@@ -505,6 +609,8 @@
(header only libraries)
binary/
(executable binaries)
+ object/
+ (.o object files)
NOTICE_FILES/
(notice files, e.g. libbase.txt)
configs/
@@ -620,7 +726,7 @@
}
propOut = filepath.Join(snapshotArchDir, targetArch, libType, stem+".json")
- } else {
+ } else if m.binary() {
// binary flags
prop.Symlinks = m.Symlinks()
prop.SharedLibs = m.Properties.SnapshotSharedLibs
@@ -630,6 +736,17 @@
snapshotBinOut := filepath.Join(snapshotArchDir, targetArch, "binary", binPath.Base())
ret = append(ret, copyFile(ctx, binPath, snapshotBinOut))
propOut = snapshotBinOut + ".json"
+ } else if m.object() {
+ // object files aren't installed to the device, so their names can conflict.
+ // Use module name as stem.
+ objPath := m.outputFile.Path()
+ snapshotObjOut := filepath.Join(snapshotArchDir, targetArch, "object",
+ ctx.ModuleName(m)+filepath.Ext(objPath.Base()))
+ ret = append(ret, copyFile(ctx, objPath, snapshotObjOut))
+ propOut = snapshotObjOut + ".json"
+ } else {
+ ctx.Errorf("unknown module %q in vendor snapshot", m.String())
+ return nil
}
j, err := json.Marshal(prop)
@@ -716,6 +833,7 @@
var _ snapshotInterface = (*vndkPrebuiltLibraryDecorator)(nil)
var _ snapshotInterface = (*vendorSnapshotLibraryDecorator)(nil)
var _ snapshotInterface = (*vendorSnapshotBinaryDecorator)(nil)
+var _ snapshotInterface = (*vendorSnapshotObjectLinker)(nil)
// gathers all snapshot modules for vendor, and disable unnecessary snapshots
// TODO(b/145966707): remove mutator and utilize android.Prebuilt to override source modules
@@ -731,12 +849,12 @@
return
}
- snapshot, ok := module.linker.(snapshotInterface)
- if !ok {
+ if !module.isSnapshotPrebuilt() {
return
}
- if !snapshot.matchesWithDevice(ctx.DeviceConfig()) {
+ // isSnapshotPrebuilt ensures snapshotInterface
+ if !module.linker.(snapshotInterface).matchesWithDevice(ctx.DeviceConfig()) {
// Disable unnecessary snapshot module, but do not disable
// vndk_prebuilt_shared because they might be packed into vndk APEX
if !module.IsVndk() {
@@ -758,6 +876,8 @@
}
} else if _, ok := module.linker.(*vendorSnapshotBinaryDecorator); ok {
snapshotMap = vendorSnapshotBinaries(ctx.Config())
+ } else if _, ok := module.linker.(*vendorSnapshotObjectLinker); ok {
+ snapshotMap = vendorSnapshotObjects(ctx.Config())
} else {
return
}
@@ -804,6 +924,11 @@
return
}
+ // .. and also filter out llndk library
+ if module.isLlndk(ctx.Config()) {
+ return
+ }
+
var snapshotMap *snapshotMap
if lib, ok := module.linker.(libraryInterface); ok {
@@ -815,10 +940,10 @@
// header
snapshotMap = vendorSnapshotHeaderLibs(ctx.Config())
}
- } else if _, ok := module.linker.(*binaryDecorator); ok {
+ } else if module.binary() {
snapshotMap = vendorSnapshotBinaries(ctx.Config())
- } else if _, ok := module.linker.(*prebuiltBinaryLinker); ok {
- snapshotMap = vendorSnapshotBinaries(ctx.Config())
+ } else if module.object() {
+ snapshotMap = vendorSnapshotObjects(ctx.Config())
} else {
return
}
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index 53b5181..5a44c46 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -186,6 +186,10 @@
return false
}
+func (p *vndkPrebuiltLibraryDecorator) isSnapshotPrebuilt() bool {
+ return true
+}
+
func (p *vndkPrebuiltLibraryDecorator) install(ctx ModuleContext, file android.Path) {
arches := ctx.DeviceConfig().Arches()
if len(arches) == 0 || arches[0].ArchType.String() != p.arch() {
diff --git a/java/java.go b/java/java.go
index 2623d2c..b086504 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2684,6 +2684,10 @@
return proptools.StringDefault(j.properties.Stem, j.ModuleBase.Name())
}
+func (a *DexImport) JacocoReportClassesFile() android.Path {
+ return nil
+}
+
func (j *DexImport) IsInstallable() bool {
return true
}
@@ -2737,8 +2741,10 @@
j.maybeStrippedDexJarFile = dexOutputFile
- ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
- j.Stem()+".jar", dexOutputFile)
+ if j.IsForPlatform() {
+ ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
+ j.Stem()+".jar", dexOutputFile)
+ }
}
func (j *DexImport) DexJar() android.Path {