Merge "Fix defaults of BaseCompilerProperties"

This commit is contained in:
Chih-hung Hsieh
2019-10-07 04:46:30 +00:00
committed by Gerrit Code Review
2 changed files with 15 additions and 11 deletions

View File

@@ -20,16 +20,22 @@ import (
"android/soong/android" "android/soong/android"
"android/soong/rust/config" "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 { func NewBaseCompiler(dir, dir64 string) *baseCompiler {
return &baseCompiler{ return &baseCompiler{
Properties: BaseCompilerProperties{ Properties: BaseCompilerProperties{},
Edition: &config.DefaultEdition, dir: dir,
Deny_warnings: config.DefaultDenyWarnings, dir64: dir64,
},
dir: dir,
dir64: dir64,
} }
} }
@@ -113,12 +119,12 @@ func (compiler *baseCompiler) featuresToFlags(features []string) []string {
func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flags { 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, "-D warnings")
} }
flags.RustFlags = append(flags.RustFlags, compiler.Properties.Flags...) flags.RustFlags = append(flags.RustFlags, compiler.Properties.Flags...)
flags.RustFlags = append(flags.RustFlags, compiler.featuresToFlags(compiler.Properties.Features)...) 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.LinkFlags = append(flags.LinkFlags, compiler.Properties.Ld_flags...)
flags.GlobalRustFlags = append(flags.GlobalRustFlags, config.GlobalRustFlags...) flags.GlobalRustFlags = append(flags.GlobalRustFlags, config.GlobalRustFlags...)
flags.GlobalRustFlags = append(flags.GlobalRustFlags, ctx.toolchain().ToolchainRustFlags()) flags.GlobalRustFlags = append(flags.GlobalRustFlags, ctx.toolchain().ToolchainRustFlags())

View File

@@ -17,8 +17,6 @@ package config
import ( import (
"strings" "strings"
"github.com/google/blueprint/proptools"
"android/soong/android" "android/soong/android"
_ "android/soong/cc/config" _ "android/soong/cc/config"
) )
@@ -35,7 +33,7 @@ var (
"libtest", "libtest",
} }
DefaultDenyWarnings = proptools.BoolPtr(true) DefaultDenyWarnings = true
GlobalRustFlags = []string{ GlobalRustFlags = []string{
"--remap-path-prefix $$(pwd)=", "--remap-path-prefix $$(pwd)=",