[rust] Add android_dylib cfg flag
Adds an android_dylib cfg when building a Rust crate as a dylib. This cfg lets us make the hack to add a dependency on std for the panic_handler and eh_personality conditional on actually building a dylib. Test: m nothing Bug: 193087363 Change-Id: Idad5b98245264f916afa327812a435b368f99321
This commit is contained in:
@@ -431,6 +431,12 @@ func (library *libraryDecorator) sharedLibFilename(ctx ModuleContext) string {
|
||||
|
||||
func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||
flags.RustFlags = append(flags.RustFlags, "-C metadata="+ctx.ModuleName())
|
||||
if library.dylib() {
|
||||
// We need to add a dependency on std in order to link crates as dylibs.
|
||||
// The hack to add this dependency is guarded by the following cfg so
|
||||
// that we don't force a dependency when it isn't needed.
|
||||
library.baseCompiler.Properties.Cfgs = append(library.baseCompiler.Properties.Cfgs, "android_dylib")
|
||||
}
|
||||
flags = library.baseCompiler.compilerFlags(ctx, flags)
|
||||
if library.shared() || library.static() {
|
||||
library.includeDirs = append(library.includeDirs, android.PathsForModuleSrc(ctx, library.Properties.Include_dirs)...)
|
||||
|
Reference in New Issue
Block a user