Change bool, and string properties to *bool, and *string for cc
there's no use case for prepending/appending to bool, and string properties within module struct. Declearing "*bool" and "*string" almost cover everything user need. I did see one case that user specify relative_install_path as path prefix in cc_defaults, and concatenate with the one in real module to get the final relative install path in Android.bp <bionic/tests/libs>. Test: m -j checkbuild Bug: b/68853585 Change-Id: If3a7a2689c3fc307aae136af6bc9c57f27a1e1a0
This commit is contained in:
33
cc/cc.go
33
cc/cc.go
@@ -148,7 +148,7 @@ type ObjectLinkerProperties struct {
|
||||
Objs []string `android:"arch_variant"`
|
||||
|
||||
// if set, add an extra objcopy --prefix-symbols= step
|
||||
Prefix_symbols string
|
||||
Prefix_symbols *string
|
||||
}
|
||||
|
||||
// Properties used to compile all C or C++ modules
|
||||
@@ -157,7 +157,7 @@ type BaseProperties struct {
|
||||
Clang *bool `android:"arch_variant"`
|
||||
|
||||
// Minimum sdk version supported when compiling against the ndk
|
||||
Sdk_version string
|
||||
Sdk_version *string
|
||||
|
||||
AndroidMkSharedLibs []string `blueprint:"mutated"`
|
||||
HideFromMake bool `blueprint:"mutated"`
|
||||
@@ -449,7 +449,7 @@ func (ctx *moduleContextImpl) staticBinary() bool {
|
||||
|
||||
func (ctx *moduleContextImpl) useSdk() bool {
|
||||
if ctx.ctx.Device() && !ctx.useVndk() {
|
||||
return ctx.mod.Properties.Sdk_version != ""
|
||||
return String(ctx.mod.Properties.Sdk_version) != ""
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -459,7 +459,7 @@ func (ctx *moduleContextImpl) sdkVersion() string {
|
||||
if ctx.useVndk() {
|
||||
return "current"
|
||||
} else {
|
||||
return ctx.mod.Properties.Sdk_version
|
||||
return String(ctx.mod.Properties.Sdk_version)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
@@ -711,7 +711,7 @@ func (c *Module) begin(ctx BaseModuleContext) {
|
||||
if err != nil {
|
||||
ctx.PropertyErrorf("sdk_version", err.Error())
|
||||
}
|
||||
c.Properties.Sdk_version = version
|
||||
c.Properties.Sdk_version = StringPtr(version)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -960,7 +960,7 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to *Module) {
|
||||
}
|
||||
return
|
||||
}
|
||||
if from.Properties.Sdk_version == "" {
|
||||
if String(from.Properties.Sdk_version) == "" {
|
||||
// Platform code can link to anything
|
||||
return
|
||||
}
|
||||
@@ -981,7 +981,7 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to *Module) {
|
||||
// the NDK.
|
||||
return
|
||||
}
|
||||
if to.Properties.Sdk_version == "" {
|
||||
if String(to.Properties.Sdk_version) == "" {
|
||||
// NDK code linking to platform code is never okay.
|
||||
ctx.ModuleErrorf("depends on non-NDK-built library %q",
|
||||
ctx.OtherModuleName(to))
|
||||
@@ -992,31 +992,31 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to *Module) {
|
||||
// API level, as it is only valid to link against older or equivalent
|
||||
// APIs.
|
||||
|
||||
if from.Properties.Sdk_version == "current" {
|
||||
if String(from.Properties.Sdk_version) == "current" {
|
||||
// Current can link against anything.
|
||||
return
|
||||
} else if to.Properties.Sdk_version == "current" {
|
||||
} else if String(to.Properties.Sdk_version) == "current" {
|
||||
// Current can't be linked against by anything else.
|
||||
ctx.ModuleErrorf("links %q built against newer API version %q",
|
||||
ctx.OtherModuleName(to), "current")
|
||||
}
|
||||
|
||||
fromApi, err := strconv.Atoi(from.Properties.Sdk_version)
|
||||
fromApi, err := strconv.Atoi(String(from.Properties.Sdk_version))
|
||||
if err != nil {
|
||||
ctx.PropertyErrorf("sdk_version",
|
||||
"Invalid sdk_version value (must be int): %q",
|
||||
from.Properties.Sdk_version)
|
||||
String(from.Properties.Sdk_version))
|
||||
}
|
||||
toApi, err := strconv.Atoi(to.Properties.Sdk_version)
|
||||
toApi, err := strconv.Atoi(String(to.Properties.Sdk_version))
|
||||
if err != nil {
|
||||
ctx.PropertyErrorf("sdk_version",
|
||||
"Invalid sdk_version value (must be int): %q",
|
||||
to.Properties.Sdk_version)
|
||||
String(to.Properties.Sdk_version))
|
||||
}
|
||||
|
||||
if toApi > fromApi {
|
||||
ctx.ModuleErrorf("links %q built against newer API version %q",
|
||||
ctx.OtherModuleName(to), to.Properties.Sdk_version)
|
||||
ctx.OtherModuleName(to), String(to.Properties.Sdk_version))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1410,7 +1410,7 @@ func vendorMutator(mctx android.BottomUpMutatorContext) {
|
||||
vendor := mod[1].(*Module)
|
||||
vendor.Properties.UseVndk = true
|
||||
squashVendorSrcs(vendor)
|
||||
} else if mctx.InstallOnVendorPartition() && m.Properties.Sdk_version == "" {
|
||||
} else if mctx.InstallOnVendorPartition() && String(m.Properties.Sdk_version) == "" {
|
||||
// This will be available in /vendor only
|
||||
mod := mctx.CreateVariations(vendorMode)
|
||||
vendor := mod[0].(*Module)
|
||||
@@ -1432,3 +1432,6 @@ func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
|
||||
}
|
||||
|
||||
var Bool = proptools.Bool
|
||||
var BoolPtr = proptools.BoolPtr
|
||||
var String = proptools.String
|
||||
var StringPtr = proptools.StringPtr
|
||||
|
Reference in New Issue
Block a user