Rust rlib vendor snapshot support.
Adds support for snapshotting Rust rlibs. This allows us vendor-specific code that uses rlib-only linkage until dylib snapshot support is added. Bug: 184042776 Test: m nothing # new Soong tests pass Test: Example test Rust vendor module builds Test: m dist vendor-snapshot # includes rlibs Change-Id: I4976d3e1efec0ee778cc97730d45be471dffb678
This commit is contained in:
@@ -120,6 +120,10 @@ func (vendorSnapshotImage) Init(ctx android.RegistrationContext) {
|
||||
ctx.RegisterSingletonType("vendor-fake-snapshot", VendorFakeSnapshotSingleton)
|
||||
}
|
||||
|
||||
func (vendorSnapshotImage) RegisterAdditionalModule(ctx android.RegistrationContext, name string, factory android.ModuleFactory) {
|
||||
ctx.RegisterModuleType(name, factory)
|
||||
}
|
||||
|
||||
func (vendorSnapshotImage) shouldGenerateSnapshot(ctx android.SingletonContext) bool {
|
||||
// BOARD_VNDK_VERSION must be set to 'current' in order to generate a snapshot.
|
||||
return ctx.DeviceConfig().VndkVersion() == "current"
|
||||
@@ -268,12 +272,14 @@ const (
|
||||
SnapshotStaticSuffix = "_static."
|
||||
snapshotBinarySuffix = "_binary."
|
||||
snapshotObjectSuffix = "_object."
|
||||
SnapshotRlibSuffix = "_rlib."
|
||||
)
|
||||
|
||||
type SnapshotProperties struct {
|
||||
Header_libs []string `android:"arch_variant"`
|
||||
Static_libs []string `android:"arch_variant"`
|
||||
Shared_libs []string `android:"arch_variant"`
|
||||
Rlibs []string `android:"arch_variant"`
|
||||
Vndk_libs []string `android:"arch_variant"`
|
||||
Binaries []string `android:"arch_variant"`
|
||||
Objects []string `android:"arch_variant"`
|
||||
@@ -353,6 +359,7 @@ func (s *snapshot) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
objects := collectSnapshotMap(s.properties.Objects, snapshotSuffix, snapshotObjectSuffix)
|
||||
staticLibs := collectSnapshotMap(s.properties.Static_libs, snapshotSuffix, SnapshotStaticSuffix)
|
||||
sharedLibs := collectSnapshotMap(s.properties.Shared_libs, snapshotSuffix, SnapshotSharedSuffix)
|
||||
rlibs := collectSnapshotMap(s.properties.Rlibs, snapshotSuffix, SnapshotRlibSuffix)
|
||||
vndkLibs := collectSnapshotMap(s.properties.Vndk_libs, "", vndkSuffix)
|
||||
for k, v := range vndkLibs {
|
||||
sharedLibs[k] = v
|
||||
@@ -364,11 +371,12 @@ func (s *snapshot) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
Objects: objects,
|
||||
StaticLibs: staticLibs,
|
||||
SharedLibs: sharedLibs,
|
||||
Rlibs: rlibs,
|
||||
})
|
||||
}
|
||||
|
||||
type SnapshotInfo struct {
|
||||
HeaderLibs, Binaries, Objects, StaticLibs, SharedLibs map[string]string
|
||||
HeaderLibs, Binaries, Objects, StaticLibs, SharedLibs, Rlibs map[string]string
|
||||
}
|
||||
|
||||
var SnapshotInfoProvider = blueprint.NewMutatorProvider(SnapshotInfo{}, "deps")
|
||||
|
@@ -205,7 +205,7 @@ func isSnapshotAware(cfg android.DeviceConfig, m LinkableInterface, inProprietar
|
||||
if sanitizable.Static() {
|
||||
return sanitizable.OutputFile().Valid() && !image.private(m)
|
||||
}
|
||||
if sanitizable.Shared() {
|
||||
if sanitizable.Shared() || sanitizable.Rlib() {
|
||||
if !sanitizable.OutputFile().Valid() {
|
||||
return false
|
||||
}
|
||||
@@ -393,6 +393,8 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
libType = "static"
|
||||
} else if m.Shared() {
|
||||
libType = "shared"
|
||||
} else if m.Rlib() {
|
||||
libType = "rlib"
|
||||
} else {
|
||||
libType = "header"
|
||||
}
|
||||
@@ -404,7 +406,7 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
libPath := m.OutputFile().Path()
|
||||
stem = libPath.Base()
|
||||
if sanitizable, ok := m.(PlatformSanitizeable); ok {
|
||||
if sanitizable.Static() && sanitizable.SanitizePropDefined() && sanitizable.IsSanitizerEnabled(cfi) {
|
||||
if (sanitizable.Static() || sanitizable.Rlib()) && sanitizable.SanitizePropDefined() && sanitizable.IsSanitizerEnabled(cfi) {
|
||||
// both cfi and non-cfi variant for static libraries can exist.
|
||||
// attach .cfi to distinguish between cfi and non-cfi.
|
||||
// e.g. libbase.a -> libbase.cfi.a
|
||||
|
Reference in New Issue
Block a user