summaryrefslogtreecommitdiff
path: root/rust/library.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2021-09-23 11:50:33 -0400
committer Ivan Lozano <ivanlozano@google.com> 2021-09-23 12:21:04 -0400
commit67eada34db07986abde08d652cd249c977d4a55c (patch)
treee4b6e43db5c655ea496f9f0ff9ace05d702b2d80 /rust/library.go
parent1b15345ac932793054a5d8e65cf4862ae7c12e49 (diff)
rust: Refactor cfg and feature flag calculation
Move the cfg and feature flag calculation out of compilerFlags so that it's a separate step. The previous arrangement resulted in overridden compilerFlags which must to set any additional cfgs/features before calling the base. This is a bit confusing and undocumented behavior, so instead break it out into a separate call that can itself be overriden. Bug: N/A Test: Soong tests pass Change-Id: I28e4f707b3b3ca6eb621b7613c3737817f877bb8
Diffstat (limited to 'rust/library.go')
-rw-r--r--rust/library.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/rust/library.go b/rust/library.go
index 8c10e298b..38dae4d33 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -430,15 +430,25 @@ func (library *libraryDecorator) sharedLibFilename(ctx ModuleContext) string {
return library.getStem(ctx) + ctx.toolchain().SharedLibSuffix()
}
-func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
- flags.RustFlags = append(flags.RustFlags, "-C metadata="+ctx.ModuleName())
+func (library *libraryDecorator) cfgFlags(ctx ModuleContext, flags Flags) Flags {
+ flags = library.baseCompiler.cfgFlags(ctx, flags)
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.RustFlags = append(flags.RustFlags, library.baseCompiler.cfgsToFlags()...)
+ flags.RustdocFlags = append(flags.RustdocFlags, library.baseCompiler.cfgsToFlags()...)
+
+ return flags
+}
+
+func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
flags = library.baseCompiler.compilerFlags(ctx, flags)
+
+ flags.RustFlags = append(flags.RustFlags, "-C metadata="+ctx.ModuleName())
if library.shared() || library.static() {
library.includeDirs = append(library.includeDirs, android.PathsForModuleSrc(ctx, library.Properties.Include_dirs)...)
}