diff options
author | Chih-Hung Hsieh <chh@google.com> | 2019-10-03 09:47:06 -0700 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2019-10-03 09:47:06 -0700 |
commit | 961a30c714d6910c57c5f2c6c4f43d1e0564a263 (patch) | |
tree | d4888afea5ee831bc5dcb10946bf913e9897d5bb /rust/compiler.go | |
parent | 65ab468452d8e839140f279b80ccf0eb3bb3ff88 (diff) | |
download | build_soong-961a30c714d6910c57c5f2c6c4f43d1e0564a263.tar.gz build_soong-961a30c714d6910c57c5f2c6c4f43d1e0564a263.tar.bz2 build_soong-961a30c714d6910c57c5f2c6c4f43d1e0564a263.zip |
Fix defaults of BaseCompilerProperties
* Edition and Deny_warnings should not be set when
constructing a BaseCompilerProperties, or the
initialized values will reject values inherited from rust_defaults.
* Use getEdition and getDenyWarnings to retrieve those properties
with defaults from config.
Bug: 141699953
Test: mm in rust projects
Change-Id: Id1ae357caeaf656cd33732bf4e54920e206f4ead
Diffstat (limited to 'rust/compiler.go')
-rw-r--r-- | rust/compiler.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/rust/compiler.go b/rust/compiler.go index 3bfef769..5a35a05a 100644 --- a/rust/compiler.go +++ b/rust/compiler.go @@ -20,16 +20,22 @@ import ( "android/soong/android" "android/soong/rust/config" + "github.com/google/blueprint/proptools" ) +func getEdition(compiler *baseCompiler) string { + return proptools.StringDefault(compiler.Properties.Edition, config.DefaultEdition) +} + +func getDenyWarnings(compiler *baseCompiler) bool { + return BoolDefault(compiler.Properties.Deny_warnings, config.DefaultDenyWarnings) +} + func NewBaseCompiler(dir, dir64 string) *baseCompiler { return &baseCompiler{ - Properties: BaseCompilerProperties{ - Edition: &config.DefaultEdition, - Deny_warnings: config.DefaultDenyWarnings, - }, - dir: dir, - dir64: dir64, + Properties: BaseCompilerProperties{}, + dir: dir, + dir64: dir64, } } @@ -113,12 +119,12 @@ func (compiler *baseCompiler) featuresToFlags(features []string) []string { func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flags { - if Bool(compiler.Properties.Deny_warnings) { + if getDenyWarnings(compiler) { flags.RustFlags = append(flags.RustFlags, "-D warnings") } flags.RustFlags = append(flags.RustFlags, compiler.Properties.Flags...) flags.RustFlags = append(flags.RustFlags, compiler.featuresToFlags(compiler.Properties.Features)...) - flags.RustFlags = append(flags.RustFlags, "--edition="+*compiler.Properties.Edition) + flags.RustFlags = append(flags.RustFlags, "--edition="+getEdition(compiler)) flags.LinkFlags = append(flags.LinkFlags, compiler.Properties.Ld_flags...) flags.GlobalRustFlags = append(flags.GlobalRustFlags, config.GlobalRustFlags...) flags.GlobalRustFlags = append(flags.GlobalRustFlags, ctx.toolchain().ToolchainRustFlags()) |