Merge changes from topic "vendor_snapshot_remove_suffix"

* changes:
  Fix arch in snapshot DepsMutator.
  Automatically set Androidmk suffix of snapshot
This commit is contained in:
Jose "Pepe" Galmes
2021-04-07 22:29:50 +00:00
committed by Gerrit Code Review
3 changed files with 269 additions and 46 deletions

View File

@@ -337,7 +337,8 @@ func (s *snapshot) DepsMutator(ctx android.BottomUpMutatorContext) {
for _, name := range names { for _, name := range names {
snapshotMap[name] = name + snapshotMap[name] = name +
getSnapshotNameSuffix(snapshotSuffix+moduleSuffix, getSnapshotNameSuffix(snapshotSuffix+moduleSuffix,
s.baseSnapshot.version(), ctx.Arch().ArchType.Name) s.baseSnapshot.version(),
ctx.DeviceConfig().Arches()[0].ArchType.String())
} }
return snapshotMap return snapshotMap
} }
@@ -396,7 +397,7 @@ type baseSnapshotDecoratorProperties struct {
Target_arch string Target_arch string
// Suffix to be added to the module name when exporting to Android.mk, e.g. ".vendor". // Suffix to be added to the module name when exporting to Android.mk, e.g. ".vendor".
Androidmk_suffix string Androidmk_suffix string `blueprint:"mutated"`
// Suffix to be added to the module name, e.g., vendor_shared, // Suffix to be added to the module name, e.g., vendor_shared,
// recovery_shared, etc. // recovery_shared, etc.
@@ -417,6 +418,7 @@ type baseSnapshotDecoratorProperties struct {
// will be seen as "libbase.vendor_static.30.arm64" by Soong. // will be seen as "libbase.vendor_static.30.arm64" by Soong.
type baseSnapshotDecorator struct { type baseSnapshotDecorator struct {
baseProperties baseSnapshotDecoratorProperties baseProperties baseSnapshotDecoratorProperties
image snapshotImage
} }
func (p *baseSnapshotDecorator) Name(name string) string { func (p *baseSnapshotDecorator) Name(name string) string {
@@ -447,10 +449,21 @@ func (p *baseSnapshotDecorator) snapshotAndroidMkSuffix() string {
return p.baseProperties.Androidmk_suffix return p.baseProperties.Androidmk_suffix
} }
func (p *baseSnapshotDecorator) setSnapshotAndroidMkSuffix(ctx android.ModuleContext) {
if ctx.OtherModuleDependencyVariantExists([]blueprint.Variation{
{Mutator: "image", Variation: android.CoreVariation},
}, ctx.Module().(*Module).BaseModuleName()) {
p.baseProperties.Androidmk_suffix = p.image.moduleNameSuffix()
} else {
p.baseProperties.Androidmk_suffix = ""
}
}
// Call this with a module suffix after creating a snapshot module, such as // Call this with a module suffix after creating a snapshot module, such as
// vendorSnapshotSharedSuffix, recoverySnapshotBinarySuffix, etc. // vendorSnapshotSharedSuffix, recoverySnapshotBinarySuffix, etc.
func (p *baseSnapshotDecorator) init(m *Module, snapshotSuffix, moduleSuffix string) { func (p *baseSnapshotDecorator) init(m *Module, image snapshotImage, moduleSuffix string) {
p.baseProperties.ModuleSuffix = snapshotSuffix + moduleSuffix p.image = image
p.baseProperties.ModuleSuffix = image.moduleNameSuffix() + moduleSuffix
m.AddProperties(&p.baseProperties) m.AddProperties(&p.baseProperties)
android.AddLoadHook(m, func(ctx android.LoadHookContext) { android.AddLoadHook(m, func(ctx android.LoadHookContext) {
vendorSnapshotLoadHook(ctx, p) vendorSnapshotLoadHook(ctx, p)
@@ -532,6 +545,8 @@ func (p *snapshotLibraryDecorator) matchesWithDevice(config android.DeviceConfig
// As snapshots are prebuilts, this just returns the prebuilt binary after doing things which are // As snapshots are prebuilts, this just returns the prebuilt binary after doing things which are
// done by normal library decorator, e.g. exporting flags. // done by normal library decorator, e.g. exporting flags.
func (p *snapshotLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { func (p *snapshotLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
p.setSnapshotAndroidMkSuffix(ctx)
if p.header() { if p.header() {
return p.libraryDecorator.link(ctx, flags, deps, objs) return p.libraryDecorator.link(ctx, flags, deps, objs)
} }
@@ -614,7 +629,7 @@ func (p *snapshotLibraryDecorator) setSanitizerVariation(t SanitizerType, enable
} }
} }
func snapshotLibraryFactory(snapshotSuffix, moduleSuffix string) (*Module, *snapshotLibraryDecorator) { func snapshotLibraryFactory(image snapshotImage, moduleSuffix string) (*Module, *snapshotLibraryDecorator) {
module, library := NewLibrary(android.DeviceSupported) module, library := NewLibrary(android.DeviceSupported)
module.stl = nil module.stl = nil
@@ -637,7 +652,7 @@ func snapshotLibraryFactory(snapshotSuffix, moduleSuffix string) (*Module, *snap
module.linker = prebuilt module.linker = prebuilt
module.installer = prebuilt module.installer = prebuilt
prebuilt.init(module, snapshotSuffix, moduleSuffix) prebuilt.init(module, image, moduleSuffix)
module.AddProperties( module.AddProperties(
&prebuilt.properties, &prebuilt.properties,
&prebuilt.sanitizerProperties, &prebuilt.sanitizerProperties,
@@ -651,7 +666,7 @@ func snapshotLibraryFactory(snapshotSuffix, moduleSuffix string) (*Module, *snap
// overrides the vendor variant of the cc shared library with the same name, if BOARD_VNDK_VERSION // overrides the vendor variant of the cc shared library with the same name, if BOARD_VNDK_VERSION
// is set. // is set.
func VendorSnapshotSharedFactory() android.Module { func VendorSnapshotSharedFactory() android.Module {
module, prebuilt := snapshotLibraryFactory(vendorSnapshotImageSingleton.moduleNameSuffix(), snapshotSharedSuffix) module, prebuilt := snapshotLibraryFactory(vendorSnapshotImageSingleton, snapshotSharedSuffix)
prebuilt.libraryDecorator.BuildOnlyShared() prebuilt.libraryDecorator.BuildOnlyShared()
return module.Init() return module.Init()
} }
@@ -661,7 +676,7 @@ func VendorSnapshotSharedFactory() android.Module {
// overrides the recovery variant of the cc shared library with the same name, if BOARD_VNDK_VERSION // overrides the recovery variant of the cc shared library with the same name, if BOARD_VNDK_VERSION
// is set. // is set.
func RecoverySnapshotSharedFactory() android.Module { func RecoverySnapshotSharedFactory() android.Module {
module, prebuilt := snapshotLibraryFactory(recoverySnapshotImageSingleton.moduleNameSuffix(), snapshotSharedSuffix) module, prebuilt := snapshotLibraryFactory(recoverySnapshotImageSingleton, snapshotSharedSuffix)
prebuilt.libraryDecorator.BuildOnlyShared() prebuilt.libraryDecorator.BuildOnlyShared()
return module.Init() return module.Init()
} }
@@ -671,7 +686,7 @@ func RecoverySnapshotSharedFactory() android.Module {
// overrides the vendor variant of the cc static library with the same name, if BOARD_VNDK_VERSION // overrides the vendor variant of the cc static library with the same name, if BOARD_VNDK_VERSION
// is set. // is set.
func VendorSnapshotStaticFactory() android.Module { func VendorSnapshotStaticFactory() android.Module {
module, prebuilt := snapshotLibraryFactory(vendorSnapshotImageSingleton.moduleNameSuffix(), snapshotStaticSuffix) module, prebuilt := snapshotLibraryFactory(vendorSnapshotImageSingleton, snapshotStaticSuffix)
prebuilt.libraryDecorator.BuildOnlyStatic() prebuilt.libraryDecorator.BuildOnlyStatic()
return module.Init() return module.Init()
} }
@@ -681,7 +696,7 @@ func VendorSnapshotStaticFactory() android.Module {
// overrides the recovery variant of the cc static library with the same name, if BOARD_VNDK_VERSION // overrides the recovery variant of the cc static library with the same name, if BOARD_VNDK_VERSION
// is set. // is set.
func RecoverySnapshotStaticFactory() android.Module { func RecoverySnapshotStaticFactory() android.Module {
module, prebuilt := snapshotLibraryFactory(recoverySnapshotImageSingleton.moduleNameSuffix(), snapshotStaticSuffix) module, prebuilt := snapshotLibraryFactory(recoverySnapshotImageSingleton, snapshotStaticSuffix)
prebuilt.libraryDecorator.BuildOnlyStatic() prebuilt.libraryDecorator.BuildOnlyStatic()
return module.Init() return module.Init()
} }
@@ -691,7 +706,7 @@ func RecoverySnapshotStaticFactory() android.Module {
// overrides the vendor variant of the cc header library with the same name, if BOARD_VNDK_VERSION // overrides the vendor variant of the cc header library with the same name, if BOARD_VNDK_VERSION
// is set. // is set.
func VendorSnapshotHeaderFactory() android.Module { func VendorSnapshotHeaderFactory() android.Module {
module, prebuilt := snapshotLibraryFactory(vendorSnapshotImageSingleton.moduleNameSuffix(), snapshotHeaderSuffix) module, prebuilt := snapshotLibraryFactory(vendorSnapshotImageSingleton, snapshotHeaderSuffix)
prebuilt.libraryDecorator.HeaderOnly() prebuilt.libraryDecorator.HeaderOnly()
return module.Init() return module.Init()
} }
@@ -701,7 +716,7 @@ func VendorSnapshotHeaderFactory() android.Module {
// overrides the recovery variant of the cc header library with the same name, if BOARD_VNDK_VERSION // overrides the recovery variant of the cc header library with the same name, if BOARD_VNDK_VERSION
// is set. // is set.
func RecoverySnapshotHeaderFactory() android.Module { func RecoverySnapshotHeaderFactory() android.Module {
module, prebuilt := snapshotLibraryFactory(recoverySnapshotImageSingleton.moduleNameSuffix(), snapshotHeaderSuffix) module, prebuilt := snapshotLibraryFactory(recoverySnapshotImageSingleton, snapshotHeaderSuffix)
prebuilt.libraryDecorator.HeaderOnly() prebuilt.libraryDecorator.HeaderOnly()
return module.Init() return module.Init()
} }
@@ -739,6 +754,8 @@ func (p *snapshotBinaryDecorator) matchesWithDevice(config android.DeviceConfig)
// cc modules' link functions are to link compiled objects into final binaries. // cc modules' link functions are to link compiled objects into final binaries.
// As snapshots are prebuilts, this just returns the prebuilt binary // As snapshots are prebuilts, this just returns the prebuilt binary
func (p *snapshotBinaryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { func (p *snapshotBinaryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
p.setSnapshotAndroidMkSuffix(ctx)
if !p.matchesWithDevice(ctx.DeviceConfig()) { if !p.matchesWithDevice(ctx.DeviceConfig()) {
return nil return nil
} }
@@ -767,17 +784,17 @@ func (p *snapshotBinaryDecorator) nativeCoverage() bool {
// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_binary // development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_binary
// overrides the vendor variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set. // overrides the vendor variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set.
func VendorSnapshotBinaryFactory() android.Module { func VendorSnapshotBinaryFactory() android.Module {
return snapshotBinaryFactory(vendorSnapshotImageSingleton.moduleNameSuffix(), snapshotBinarySuffix) return snapshotBinaryFactory(vendorSnapshotImageSingleton, snapshotBinarySuffix)
} }
// recovery_snapshot_binary is a special prebuilt executable binary which is auto-generated by // recovery_snapshot_binary is a special prebuilt executable binary which is auto-generated by
// development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_binary // development/vendor_snapshot/update.py. As a part of recovery snapshot, recovery_snapshot_binary
// overrides the recovery variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set. // overrides the recovery variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set.
func RecoverySnapshotBinaryFactory() android.Module { func RecoverySnapshotBinaryFactory() android.Module {
return snapshotBinaryFactory(recoverySnapshotImageSingleton.moduleNameSuffix(), snapshotBinarySuffix) return snapshotBinaryFactory(recoverySnapshotImageSingleton, snapshotBinarySuffix)
} }
func snapshotBinaryFactory(snapshotSuffix, moduleSuffix string) android.Module { func snapshotBinaryFactory(image snapshotImage, moduleSuffix string) android.Module {
module, binary := NewBinary(android.DeviceSupported) module, binary := NewBinary(android.DeviceSupported)
binary.baseLinker.Properties.No_libcrt = BoolPtr(true) binary.baseLinker.Properties.No_libcrt = BoolPtr(true)
binary.baseLinker.Properties.Nocrt = BoolPtr(true) binary.baseLinker.Properties.Nocrt = BoolPtr(true)
@@ -796,7 +813,7 @@ func snapshotBinaryFactory(snapshotSuffix, moduleSuffix string) android.Module {
module.stl = nil module.stl = nil
module.linker = prebuilt module.linker = prebuilt
prebuilt.init(module, snapshotSuffix, moduleSuffix) prebuilt.init(module, image, moduleSuffix)
module.AddProperties(&prebuilt.properties) module.AddProperties(&prebuilt.properties)
return module.Init() return module.Init()
} }
@@ -832,6 +849,8 @@ func (p *snapshotObjectLinker) matchesWithDevice(config android.DeviceConfig) bo
// cc modules' link functions are to link compiled objects into final binaries. // cc modules' link functions are to link compiled objects into final binaries.
// As snapshots are prebuilts, this just returns the prebuilt binary // As snapshots are prebuilts, this just returns the prebuilt binary
func (p *snapshotObjectLinker) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { func (p *snapshotObjectLinker) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
p.setSnapshotAndroidMkSuffix(ctx)
if !p.matchesWithDevice(ctx.DeviceConfig()) { if !p.matchesWithDevice(ctx.DeviceConfig()) {
return nil return nil
} }
@@ -856,7 +875,7 @@ func VendorSnapshotObjectFactory() android.Module {
} }
module.linker = prebuilt module.linker = prebuilt
prebuilt.init(module, vendorSnapshotImageSingleton.moduleNameSuffix(), snapshotObjectSuffix) prebuilt.init(module, vendorSnapshotImageSingleton, snapshotObjectSuffix)
module.AddProperties(&prebuilt.properties) module.AddProperties(&prebuilt.properties)
return module.Init() return module.Init()
} }
@@ -874,7 +893,7 @@ func RecoverySnapshotObjectFactory() android.Module {
} }
module.linker = prebuilt module.linker = prebuilt
prebuilt.init(module, recoverySnapshotImageSingleton.moduleNameSuffix(), snapshotObjectSuffix) prebuilt.init(module, recoverySnapshotImageSingleton, snapshotObjectSuffix)
module.AddProperties(&prebuilt.properties) module.AddProperties(&prebuilt.properties)
return module.Init() return module.Init()
} }

View File

@@ -238,7 +238,6 @@ func isSnapshotAware(cfg android.DeviceConfig, m *Module, inProprietaryPath bool
type snapshotJsonFlags struct { type snapshotJsonFlags struct {
ModuleName string `json:",omitempty"` ModuleName string `json:",omitempty"`
RelativeInstallPath string `json:",omitempty"` RelativeInstallPath string `json:",omitempty"`
AndroidMkSuffix string `json:",omitempty"`
// library flags // library flags
ExportedDirs []string `json:",omitempty"` ExportedDirs []string `json:",omitempty"`
@@ -352,7 +351,6 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
} else { } else {
prop.RelativeInstallPath = m.RelativeInstallPath() prop.RelativeInstallPath = m.RelativeInstallPath()
} }
prop.AndroidMkSuffix = m.Properties.SubName
prop.RuntimeLibs = m.Properties.SnapshotRuntimeLibs prop.RuntimeLibs = m.Properties.SnapshotRuntimeLibs
prop.Required = m.RequiredModuleNames() prop.Required = m.RequiredModuleNames()
for _, path := range m.InitRc() { for _, path := range m.InitRc() {

View File

@@ -271,7 +271,6 @@ func TestVendorSnapshotUse(t *testing.T) {
enabled: true, enabled: true,
}, },
nocrt: true, nocrt: true,
compile_multilib: "64",
} }
cc_library { cc_library {
@@ -281,7 +280,6 @@ func TestVendorSnapshotUse(t *testing.T) {
no_libcrt: true, no_libcrt: true,
stl: "none", stl: "none",
system_shared_libs: [], system_shared_libs: [],
compile_multilib: "64",
} }
cc_library { cc_library {
@@ -291,6 +289,25 @@ func TestVendorSnapshotUse(t *testing.T) {
no_libcrt: true, no_libcrt: true,
stl: "none", stl: "none",
system_shared_libs: [], system_shared_libs: [],
}
cc_library {
name: "lib32",
vendor: true,
nocrt: true,
no_libcrt: true,
stl: "none",
system_shared_libs: [],
compile_multilib: "32",
}
cc_library {
name: "lib64",
vendor: true,
nocrt: true,
no_libcrt: true,
stl: "none",
system_shared_libs: [],
compile_multilib: "64", compile_multilib: "64",
} }
@@ -301,7 +318,16 @@ func TestVendorSnapshotUse(t *testing.T) {
no_libcrt: true, no_libcrt: true,
stl: "none", stl: "none",
system_shared_libs: [], system_shared_libs: [],
compile_multilib: "64", }
cc_binary {
name: "bin32",
vendor: true,
nocrt: true,
no_libcrt: true,
stl: "none",
system_shared_libs: [],
compile_multilib: "32",
} }
` `
@@ -320,6 +346,10 @@ func TestVendorSnapshotUse(t *testing.T) {
srcs: ["libvndk.so"], srcs: ["libvndk.so"],
export_include_dirs: ["include/libvndk"], export_include_dirs: ["include/libvndk"],
}, },
arm: {
srcs: ["libvndk.so"],
export_include_dirs: ["include/libvndk"],
},
}, },
} }
@@ -338,6 +368,28 @@ func TestVendorSnapshotUse(t *testing.T) {
srcs: ["libvndk.so"], srcs: ["libvndk.so"],
export_include_dirs: ["include/libvndk"], export_include_dirs: ["include/libvndk"],
}, },
arm: {
srcs: ["libvndk.so"],
export_include_dirs: ["include/libvndk"],
},
},
}
// different arch snapshot which has to be ignored
vndk_prebuilt_shared {
name: "libvndk",
version: "28",
target_arch: "arm",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
},
arch: {
arm: {
srcs: ["libvndk.so"],
export_include_dirs: ["include/libvndk"],
},
}, },
} }
` `
@@ -350,7 +402,6 @@ func TestVendorSnapshotUse(t *testing.T) {
no_libcrt: true, no_libcrt: true,
stl: "none", stl: "none",
system_shared_libs: [], system_shared_libs: [],
compile_multilib: "64",
} }
cc_library_shared { cc_library_shared {
@@ -362,7 +413,14 @@ func TestVendorSnapshotUse(t *testing.T) {
system_shared_libs: [], system_shared_libs: [],
shared_libs: ["libvndk", "libvendor_available"], shared_libs: ["libvndk", "libvendor_available"],
static_libs: ["libvendor", "libvendor_without_snapshot"], static_libs: ["libvendor", "libvendor_without_snapshot"],
compile_multilib: "64", arch: {
arm64: {
shared_libs: ["lib64"],
},
arm: {
shared_libs: ["lib32"],
},
},
srcs: ["client.cpp"], srcs: ["client.cpp"],
} }
@@ -374,41 +432,69 @@ func TestVendorSnapshotUse(t *testing.T) {
stl: "none", stl: "none",
system_shared_libs: [], system_shared_libs: [],
static_libs: ["libvndk"], static_libs: ["libvndk"],
compile_multilib: "64",
srcs: ["bin.cpp"], srcs: ["bin.cpp"],
} }
vendor_snapshot { vendor_snapshot {
name: "vendor_snapshot", name: "vendor_snapshot",
compile_multilib: "first",
version: "28", version: "28",
vndk_libs: [ arch: {
"libvndk", arm64: {
], vndk_libs: [
static_libs: [ "libvndk",
"libvendor", ],
"libvendor_available", static_libs: [
"libvndk", "libvendor",
], "libvendor_available",
shared_libs: [ "libvndk",
"libvendor", "lib64",
"libvendor_available", ],
], shared_libs: [
binaries: [ "libvendor",
"bin", "libvendor_available",
], "lib64",
],
binaries: [
"bin",
],
},
arm: {
vndk_libs: [
"libvndk",
],
static_libs: [
"libvendor",
"libvendor_available",
"libvndk",
"lib32",
],
shared_libs: [
"libvendor",
"libvendor_available",
"lib32",
],
binaries: [
"bin32",
],
},
}
} }
vendor_snapshot_static { vendor_snapshot_static {
name: "libvndk", name: "libvndk",
version: "28", version: "28",
target_arch: "arm64", target_arch: "arm64",
compile_multilib: "both",
vendor: true, vendor: true,
arch: { arch: {
arm64: { arm64: {
src: "libvndk.a", src: "libvndk.a",
export_include_dirs: ["include/libvndk"], export_include_dirs: ["include/libvndk"],
}, },
arm: {
src: "libvndk.a",
export_include_dirs: ["include/libvndk"],
},
}, },
} }
@@ -416,7 +502,7 @@ func TestVendorSnapshotUse(t *testing.T) {
name: "libvendor", name: "libvendor",
version: "28", version: "28",
target_arch: "arm64", target_arch: "arm64",
compile_multilib: "64", compile_multilib: "both",
vendor: true, vendor: true,
shared_libs: [ shared_libs: [
"libvendor_without_snapshot", "libvendor_without_snapshot",
@@ -428,6 +514,62 @@ func TestVendorSnapshotUse(t *testing.T) {
src: "libvendor.so", src: "libvendor.so",
export_include_dirs: ["include/libvendor"], export_include_dirs: ["include/libvendor"],
}, },
arm: {
src: "libvendor.so",
export_include_dirs: ["include/libvendor"],
},
},
}
vendor_snapshot_static {
name: "lib32",
version: "28",
target_arch: "arm64",
compile_multilib: "32",
vendor: true,
arch: {
arm: {
src: "lib32.a",
},
},
}
vendor_snapshot_shared {
name: "lib32",
version: "28",
target_arch: "arm64",
compile_multilib: "32",
vendor: true,
arch: {
arm: {
src: "lib32.so",
},
},
}
vendor_snapshot_static {
name: "lib64",
version: "28",
target_arch: "arm64",
compile_multilib: "64",
vendor: true,
arch: {
arm64: {
src: "lib64.a",
},
},
}
vendor_snapshot_shared {
name: "lib64",
version: "28",
target_arch: "arm64",
compile_multilib: "64",
vendor: true,
arch: {
arm64: {
src: "lib64.so",
},
}, },
} }
@@ -435,40 +577,53 @@ func TestVendorSnapshotUse(t *testing.T) {
name: "libvendor", name: "libvendor",
version: "28", version: "28",
target_arch: "arm64", target_arch: "arm64",
compile_multilib: "both",
vendor: true, vendor: true,
arch: { arch: {
arm64: { arm64: {
src: "libvendor.a", src: "libvendor.a",
export_include_dirs: ["include/libvendor"], export_include_dirs: ["include/libvendor"],
}, },
arm: {
src: "libvendor.a",
export_include_dirs: ["include/libvendor"],
},
}, },
} }
vendor_snapshot_shared { vendor_snapshot_shared {
name: "libvendor_available", name: "libvendor_available",
androidmk_suffix: ".vendor",
version: "28", version: "28",
target_arch: "arm64", target_arch: "arm64",
compile_multilib: "both",
vendor: true, vendor: true,
arch: { arch: {
arm64: { arm64: {
src: "libvendor_available.so", src: "libvendor_available.so",
export_include_dirs: ["include/libvendor"], export_include_dirs: ["include/libvendor"],
}, },
arm: {
src: "libvendor_available.so",
export_include_dirs: ["include/libvendor"],
},
}, },
} }
vendor_snapshot_static { vendor_snapshot_static {
name: "libvendor_available", name: "libvendor_available",
androidmk_suffix: ".vendor",
version: "28", version: "28",
target_arch: "arm64", target_arch: "arm64",
compile_multilib: "both",
vendor: true, vendor: true,
arch: { arch: {
arm64: { arm64: {
src: "libvendor_available.a", src: "libvendor_available.a",
export_include_dirs: ["include/libvendor"], export_include_dirs: ["include/libvendor"],
}, },
arm: {
src: "libvendor_available.so",
export_include_dirs: ["include/libvendor"],
},
}, },
} }
@@ -476,6 +631,7 @@ func TestVendorSnapshotUse(t *testing.T) {
name: "bin", name: "bin",
version: "28", version: "28",
target_arch: "arm64", target_arch: "arm64",
compile_multilib: "64",
vendor: true, vendor: true,
arch: { arch: {
arm64: { arm64: {
@@ -484,11 +640,39 @@ func TestVendorSnapshotUse(t *testing.T) {
}, },
} }
vendor_snapshot_binary {
name: "bin32",
version: "28",
target_arch: "arm64",
compile_multilib: "32",
vendor: true,
arch: {
arm: {
src: "bin32",
},
},
}
// old snapshot module which has to be ignored // old snapshot module which has to be ignored
vendor_snapshot_binary { vendor_snapshot_binary {
name: "bin", name: "bin",
version: "26", version: "26",
target_arch: "arm64", target_arch: "arm64",
compile_multilib: "first",
vendor: true,
arch: {
arm64: {
src: "bin",
},
},
}
// different arch snapshot which has to be ignored
vendor_snapshot_binary {
name: "bin",
version: "28",
target_arch: "arm",
compile_multilib: "first",
vendor: true, vendor: true,
arch: { arch: {
arm64: { arm64: {
@@ -504,6 +688,7 @@ func TestVendorSnapshotUse(t *testing.T) {
"framework/Android.bp": []byte(frameworkBp), "framework/Android.bp": []byte(frameworkBp),
"vendor/Android.bp": []byte(vendorProprietaryBp), "vendor/Android.bp": []byte(vendorProprietaryBp),
"vendor/bin": nil, "vendor/bin": nil,
"vendor/bin32": nil,
"vendor/bin.cpp": nil, "vendor/bin.cpp": nil,
"vendor/client.cpp": nil, "vendor/client.cpp": nil,
"vendor/include/libvndk/a.h": nil, "vendor/include/libvndk/a.h": nil,
@@ -511,6 +696,10 @@ func TestVendorSnapshotUse(t *testing.T) {
"vendor/libvndk.a": nil, "vendor/libvndk.a": nil,
"vendor/libvendor.a": nil, "vendor/libvendor.a": nil,
"vendor/libvendor.so": nil, "vendor/libvendor.so": nil,
"vendor/lib32.a": nil,
"vendor/lib32.so": nil,
"vendor/lib64.a": nil,
"vendor/lib64.so": nil,
"vndk/Android.bp": []byte(vndkBp), "vndk/Android.bp": []byte(vndkBp),
"vndk/include/libvndk/a.h": nil, "vndk/include/libvndk/a.h": nil,
"vndk/libvndk.so": nil, "vndk/libvndk.so": nil,
@@ -531,6 +720,9 @@ func TestVendorSnapshotUse(t *testing.T) {
staticVariant := "android_vendor.28_arm64_armv8-a_static" staticVariant := "android_vendor.28_arm64_armv8-a_static"
binaryVariant := "android_vendor.28_arm64_armv8-a" binaryVariant := "android_vendor.28_arm64_armv8-a"
shared32Variant := "android_vendor.28_arm_armv7-a-neon_shared"
binary32Variant := "android_vendor.28_arm_armv7-a-neon"
// libclient uses libvndk.vndk.28.arm64, libvendor.vendor_static.28.arm64, libvendor_without_snapshot // libclient uses libvndk.vndk.28.arm64, libvendor.vendor_static.28.arm64, libvendor_without_snapshot
libclientCcFlags := ctx.ModuleForTests("libclient", sharedVariant).Rule("cc").Args["cFlags"] libclientCcFlags := ctx.ModuleForTests("libclient", sharedVariant).Rule("cc").Args["cFlags"]
for _, includeFlags := range []string{ for _, includeFlags := range []string{
@@ -556,7 +748,7 @@ func TestVendorSnapshotUse(t *testing.T) {
} }
libclientAndroidMkSharedLibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkSharedLibs libclientAndroidMkSharedLibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkSharedLibs
if g, w := libclientAndroidMkSharedLibs, []string{"libvndk.vendor", "libvendor_available.vendor"}; !reflect.DeepEqual(g, w) { if g, w := libclientAndroidMkSharedLibs, []string{"libvndk.vendor", "libvendor_available.vendor", "lib64"}; !reflect.DeepEqual(g, w) {
t.Errorf("wanted libclient AndroidMkSharedLibs %q, got %q", w, g) t.Errorf("wanted libclient AndroidMkSharedLibs %q, got %q", w, g)
} }
@@ -565,6 +757,11 @@ func TestVendorSnapshotUse(t *testing.T) {
t.Errorf("wanted libclient AndroidMkStaticLibs %q, got %q", w, g) t.Errorf("wanted libclient AndroidMkStaticLibs %q, got %q", w, g)
} }
libclient32AndroidMkSharedLibs := ctx.ModuleForTests("libclient", shared32Variant).Module().(*Module).Properties.AndroidMkSharedLibs
if g, w := libclient32AndroidMkSharedLibs, []string{"libvndk.vendor", "libvendor_available.vendor", "lib32"}; !reflect.DeepEqual(g, w) {
t.Errorf("wanted libclient32 AndroidMkSharedLibs %q, got %q", w, g)
}
// bin_without_snapshot uses libvndk.vendor_static.28.arm64 // bin_without_snapshot uses libvndk.vendor_static.28.arm64
binWithoutSnapshotCcFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("cc").Args["cFlags"] binWithoutSnapshotCcFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("cc").Args["cFlags"]
if !strings.Contains(binWithoutSnapshotCcFlags, "-Ivendor/include/libvndk") { if !strings.Contains(binWithoutSnapshotCcFlags, "-Ivendor/include/libvndk") {
@@ -582,6 +779,12 @@ func TestVendorSnapshotUse(t *testing.T) {
// libvendor.so is installed by libvendor.vendor_shared.28.arm64 // libvendor.so is installed by libvendor.vendor_shared.28.arm64
ctx.ModuleForTests("libvendor.vendor_shared.28.arm64", sharedVariant).Output("libvendor.so") ctx.ModuleForTests("libvendor.vendor_shared.28.arm64", sharedVariant).Output("libvendor.so")
// lib64.so is installed by lib64.vendor_shared.28.arm64
ctx.ModuleForTests("lib64.vendor_shared.28.arm64", sharedVariant).Output("lib64.so")
// lib32.so is installed by lib32.vendor_shared.28.arm64
ctx.ModuleForTests("lib32.vendor_shared.28.arm64", shared32Variant).Output("lib32.so")
// libvendor_available.so is installed by libvendor_available.vendor_shared.28.arm64 // libvendor_available.so is installed by libvendor_available.vendor_shared.28.arm64
ctx.ModuleForTests("libvendor_available.vendor_shared.28.arm64", sharedVariant).Output("libvendor_available.so") ctx.ModuleForTests("libvendor_available.vendor_shared.28.arm64", sharedVariant).Output("libvendor_available.so")
@@ -591,6 +794,9 @@ func TestVendorSnapshotUse(t *testing.T) {
// bin is installed by bin.vendor_binary.28.arm64 // bin is installed by bin.vendor_binary.28.arm64
ctx.ModuleForTests("bin.vendor_binary.28.arm64", binaryVariant).Output("bin") ctx.ModuleForTests("bin.vendor_binary.28.arm64", binaryVariant).Output("bin")
// bin32 is installed by bin32.vendor_binary.28.arm64
ctx.ModuleForTests("bin32.vendor_binary.28.arm64", binary32Variant).Output("bin32")
// bin_without_snapshot is installed by bin_without_snapshot // bin_without_snapshot is installed by bin_without_snapshot
ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Output("bin_without_snapshot") ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Output("bin_without_snapshot")