From 67eada34db07986abde08d652cd249c977d4a55c Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Thu, 23 Sep 2021 11:50:33 -0400 Subject: 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 --- rust/rust.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'rust/rust.go') diff --git a/rust/rust.go b/rust/rust.go index 0cd299dc1..0a7d68dee 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -436,6 +436,8 @@ type RustLibrary struct { type compiler interface { initialize(ctx ModuleContext) compilerFlags(ctx ModuleContext, flags Flags) Flags + cfgFlags(ctx ModuleContext, flags Flags) Flags + featureFlags(ctx ModuleContext, flags Flags) Flags compilerProps() []interface{} compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path compilerDeps(ctx DepsContext, deps Deps) Deps @@ -847,8 +849,11 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { Toolchain: toolchain, } + // Calculate rustc flags if mod.compiler != nil { flags = mod.compiler.compilerFlags(ctx, flags) + flags = mod.compiler.cfgFlags(ctx, flags) + flags = mod.compiler.featureFlags(ctx, flags) } if mod.coverage != nil { flags, deps = mod.coverage.flags(ctx, flags, deps) -- cgit v1.2.3-59-g8ed1b