diff options
author | 2021-06-01 15:09:53 -0400 | |
---|---|---|
committer | 2021-06-03 08:36:09 -0400 | |
commit | 3149e6ed1882786fc9e1defd0b5540c0147a0209 (patch) | |
tree | edee79e9487fdbc90116eb3d71f9f867746ac28a /rust/image.go | |
parent | d1dec54988630cabaf15b2353e55460f79c05b0c (diff) |
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
Diffstat (limited to 'rust/image.go')
-rw-r--r-- | rust/image.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/rust/image.go b/rust/image.go index 6cfb42c7d..3b54f12c7 100644 --- a/rust/image.go +++ b/rust/image.go @@ -82,7 +82,12 @@ func (mod *Module) SetCoreVariantNeeded(b bool) { } func (mod *Module) SnapshotVersion(mctx android.BaseModuleContext) string { - panic("Rust modules do not support snapshotting: " + mod.BaseModuleName()) + if snapshot, ok := mod.compiler.(cc.SnapshotInterface); ok { + return snapshot.Version() + } else { + mctx.ModuleErrorf("version is unknown for snapshot prebuilt") + return "" + } } func (mod *Module) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { @@ -110,7 +115,9 @@ func (mod *Module) ExtraImageVariations(android.BaseModuleContext) []string { } func (mod *Module) IsSnapshotPrebuilt() bool { - // Rust does not support prebuilts in its snapshots + if p, ok := mod.compiler.(cc.SnapshotInterface); ok { + return p.IsSnapshotPrebuilt() + } return false } @@ -220,7 +227,9 @@ func (mod *Module) ImageMutatorBegin(mctx android.BaseModuleContext) { } } if vendorSpecific { - mctx.PropertyErrorf("vendor", "Vendor-only non-rust_ffi Rust modules are not supported.") + if lib, ok := mod.compiler.(libraryInterface); ok && lib.buildDylib() { + mctx.PropertyErrorf("vendor", "Vendor-only dylibs are not yet supported, use rust_library_rlib.") + } } cc.MutateImage(mctx, mod) |