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:
Nan Zhang 2017-11-07 10:57:05 -08:00
parent 4647be4afe
commit 0007d810e2
21 changed files with 116 additions and 115 deletions

View file

@ -25,7 +25,6 @@ import (
"strings"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
func init() {
@ -77,7 +76,7 @@ func (c *androidMkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext
sort.Sort(AndroidModulesByName{androidMkModulesList, ctx})
transMk := PathForOutput(ctx, "Android"+proptools.String(config.ProductVariables.Make_suffix)+".mk")
transMk := PathForOutput(ctx, "Android"+String(config.ProductVariables.Make_suffix)+".mk")
if ctx.Failed() {
return
}

View file

@ -152,7 +152,7 @@ type Module interface {
type nameProperties struct {
// The name of the module. Must be unique across all modules.
Name string
Name *string
}
type commonProperties struct {
@ -351,12 +351,12 @@ func (a *ModuleBase) BuildParamsForTests() []BuildParams {
// Name returns the name of the module. It may be overridden by individual module types, for
// example prebuilts will prepend prebuilt_ to the name.
func (a *ModuleBase) Name() string {
return a.nameProperties.Name
return String(a.nameProperties.Name)
}
// BaseModuleName returns the name of the module as specified in the blueprints file.
func (a *ModuleBase) BaseModuleName() string {
return a.nameProperties.Name
return String(a.nameProperties.Name)
}
func (a *ModuleBase) base() *ModuleBase {

View file

@ -32,7 +32,7 @@ var prebuiltDepTag prebuiltDependencyTag
type PrebuiltProperties struct {
// When prefer is set to true the prebuilt will be used instead of any source module with
// a matching name.
Prefer bool `android:"arch_variant"`
Prefer *bool `android:"arch_variant"`
SourceExists bool `blueprint:"mutated"`
UsePrebuilt bool `blueprint:"mutated"`
@ -146,7 +146,7 @@ func (p *Prebuilt) usePrebuilt(ctx TopDownMutatorContext, source Module) bool {
}
// TODO: use p.Properties.Name and ctx.ModuleDir to override preference
if p.properties.Prefer {
if Bool(p.properties.Prefer) {
return true
}

View file

@ -64,8 +64,9 @@ func (c *Module) AndroidMk() android.AndroidMkData {
if len(c.Properties.AndroidMkSharedLibs) > 0 {
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
}
if c.Target().Os == android.Android && c.Properties.Sdk_version != "" && !c.useVndk() {
fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+c.Properties.Sdk_version)
if c.Target().Os == android.Android &&
String(c.Properties.Sdk_version) != "" && !c.useVndk() {
fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+String(c.Properties.Sdk_version))
fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
} else {
// These are already included in LOCAL_SHARED_LIBRARIES
@ -244,7 +245,7 @@ func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa
ctx.subAndroidMk(ret, test.binaryDecorator)
ret.Class = "NATIVE_TESTS"
if Bool(test.Properties.Test_per_src) {
ret.SubName = "_" + test.binaryDecorator.Properties.Stem
ret.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
}
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
@ -276,9 +277,10 @@ func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMk
}
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
if stripper.StripProperties.Strip.None {
if Bool(stripper.StripProperties.Strip.None) {
fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
} else if stripper.StripProperties.Strip.Keep_symbols {
} else if Bool(stripper.StripProperties.Strip.Keep_symbols) {
fmt.Fprintln(w, "LOCAL_STRIP_MODULE := keep_symbols")
} else {
fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info")

View file

@ -15,8 +15,6 @@
package cc
import (
"github.com/google/blueprint/proptools"
"android/soong/android"
)
@ -25,19 +23,19 @@ type BinaryLinkerProperties struct {
Static_executable *bool `android:"arch_variant"`
// set the name of the output
Stem string `android:"arch_variant"`
Stem *string `android:"arch_variant"`
// append to the name of the output
Suffix string `android:"arch_variant"`
Suffix *string `android:"arch_variant"`
// if set, add an extra objcopy --prefix-symbols= step
Prefix_symbols string
Prefix_symbols *string
// local file name to pass to the linker as --version_script
Version_script *string `android:"arch_variant"`
// if set, install a symlink to the preferred architecture
Symlink_preferred_arch bool
Symlink_preferred_arch *bool
// install symlinks to the binary. Symlink names will have the suffix and the binary
// extension (if any) appended
@ -97,11 +95,11 @@ func (binary *binaryDecorator) linkerProps() []interface{} {
func (binary *binaryDecorator) getStem(ctx BaseModuleContext) string {
stem := ctx.baseModuleName()
if binary.Properties.Stem != "" {
stem = binary.Properties.Stem
if String(binary.Properties.Stem) != "" {
stem = String(binary.Properties.Stem)
}
return stem + binary.Properties.Suffix
return stem + String(binary.Properties.Suffix)
}
func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
@ -185,7 +183,7 @@ func (binary *binaryDecorator) linkerInit(ctx BaseModuleContext) {
if !ctx.toolchain().Bionic() {
if ctx.Os() == android.Linux {
if binary.Properties.Static_executable == nil && Bool(ctx.AConfig().ProductVariables.HostStaticBinaries) {
binary.Properties.Static_executable = proptools.BoolPtr(true)
binary.Properties.Static_executable = BoolPtr(true)
}
} else {
// Static executables are not supported on Darwin or Windows
@ -315,10 +313,10 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
binary.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
}
if binary.Properties.Prefix_symbols != "" {
if String(binary.Properties.Prefix_symbols) != "" {
afterPrefixSymbols := outputFile
outputFile = android.PathForModuleOut(ctx, "unprefixed", fileName)
TransformBinaryPrefixSymbols(ctx, binary.Properties.Prefix_symbols, outputFile,
TransformBinaryPrefixSymbols(ctx, String(binary.Properties.Prefix_symbols), outputFile,
flagsToBuilderFlags(flags), afterPrefixSymbols)
}
@ -342,11 +340,11 @@ func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) {
binary.baseInstaller.install(ctx, file)
for _, symlink := range binary.Properties.Symlinks {
binary.symlinks = append(binary.symlinks,
symlink+binary.Properties.Suffix+ctx.toolchain().ExecutableSuffix())
symlink+String(binary.Properties.Suffix)+ctx.toolchain().ExecutableSuffix())
}
if binary.Properties.Symlink_preferred_arch {
if binary.Properties.Stem == "" && binary.Properties.Suffix == "" {
if Bool(binary.Properties.Symlink_preferred_arch) {
if String(binary.Properties.Stem) == "" && String(binary.Properties.Suffix) == "" {
ctx.PropertyErrorf("symlink_preferred_arch", "must also specify stem or suffix")
}
if ctx.TargetPrimary() {

View file

@ -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

View file

@ -9,8 +9,6 @@ import (
"sort"
"strings"
"testing"
"github.com/google/blueprint/proptools"
)
var buildDir string
@ -40,7 +38,7 @@ func TestMain(m *testing.M) {
func testCc(t *testing.T, bp string) *android.TestContext {
config := android.TestArchConfig(buildDir, nil)
config.ProductVariables.DeviceVndkVersion = proptools.StringPtr("current")
config.ProductVariables.DeviceVndkVersion = StringPtr("current")
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(LibraryFactory))

View file

@ -89,12 +89,12 @@ type BaseCompilerProperties struct {
// C standard version to use. Can be a specific version (such as "gnu11"),
// "experimental" (which will use draft versions like C1x when available),
// or the empty string (which will use the default).
C_std string
C_std *string
// C++ standard version to use. Can be a specific version (such as
// "gnu++11"), "experimental" (which will use draft versions like C++1z when
// available), or the empty string (which will use the default).
Cpp_std string
Cpp_std *string
// if set to false, use -std=c++* instead of -std=gnu++*
Gnu_extensions *bool
@ -143,7 +143,7 @@ type BaseCompilerProperties struct {
Proto struct {
// Link statically against the protobuf runtime
Static bool `android:"arch_variant"`
Static *bool `android:"arch_variant"`
} `android:"arch_variant"`
// Stores the original list of source files before being cleared by library reuse
@ -193,7 +193,7 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
android.ExtractSourcesDeps(ctx, compiler.Properties.Srcs)
if compiler.hasSrcExt(".proto") {
deps = protoDeps(ctx, deps, &compiler.Proto, compiler.Properties.Proto.Static)
deps = protoDeps(ctx, deps, &compiler.Proto, Bool(compiler.Properties.Proto.Static))
}
return deps
@ -275,7 +275,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
"-D__ANDROID_API__=__ANDROID_API_FUTURE__", "-D__ANDROID_VNDK__")
}
instructionSet := proptools.String(compiler.Properties.Instruction_set)
instructionSet := String(compiler.Properties.Instruction_set)
if flags.RequiredInstructionSet != "" {
instructionSet = flags.RequiredInstructionSet
}
@ -364,21 +364,21 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
if !ctx.useSdk() {
cStd := config.CStdVersion
if compiler.Properties.C_std == "experimental" {
if String(compiler.Properties.C_std) == "experimental" {
cStd = config.ExperimentalCStdVersion
} else if compiler.Properties.C_std != "" {
cStd = compiler.Properties.C_std
} else if String(compiler.Properties.C_std) != "" {
cStd = String(compiler.Properties.C_std)
}
cppStd := compiler.Properties.Cpp_std
switch compiler.Properties.Cpp_std {
cppStd := String(compiler.Properties.Cpp_std)
switch String(compiler.Properties.Cpp_std) {
case "":
cppStd = config.CppStdVersion
case "experimental":
cppStd = config.ExperimentalCppStdVersion
case "c++17", "gnu++17":
// Map c++17 and gnu++17 to their 1z equivalents, until 17 is finalized.
cppStd = strings.Replace(compiler.Properties.Cpp_std, "17", "1z", 1)
cppStd = strings.Replace(String(compiler.Properties.Cpp_std), "17", "1z", 1)
}
if !flags.Clang {

View file

@ -24,7 +24,7 @@ import (
type InstallerProperties struct {
// install to a subdirectory of the default install path for the module
Relative_install_path string `android:"arch_variant"`
Relative_install_path *string `android:"arch_variant"`
}
type installLocation int
@ -72,7 +72,8 @@ func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath
if installer.location == InstallInData && ctx.useVndk() {
dir = filepath.Join(dir, "vendor")
}
return android.PathForModuleInstall(ctx, dir, installer.subDir, installer.Properties.Relative_install_path, installer.relative)
return android.PathForModuleInstall(ctx, dir, installer.subDir,
String(installer.Properties.Relative_install_path), installer.relative)
}
func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) {

View file

@ -57,12 +57,12 @@ type LibraryProperties struct {
Aidl struct {
// export headers generated from .aidl sources
Export_aidl_headers bool
Export_aidl_headers *bool
}
Proto struct {
// export headers generated from .proto sources
Export_proto_headers bool
Export_proto_headers *bool
}
Target struct {
Vendor struct {
@ -71,7 +71,7 @@ type LibraryProperties struct {
}
}
Static_ndk_lib bool
Static_ndk_lib *bool
}
type LibraryMutatedProperties struct {
@ -663,7 +663,7 @@ func (library *libraryDecorator) link(ctx ModuleContext,
library.reexportFlags(deps.ReexportedFlags)
library.reexportDeps(deps.ReexportedFlagsDeps)
if library.Properties.Aidl.Export_aidl_headers {
if Bool(library.Properties.Aidl.Export_aidl_headers) {
if library.baseCompiler.hasSrcExt(".aidl") {
flags := []string{
"-I" + android.PathForModuleGen(ctx, "aidl").String(),
@ -675,7 +675,7 @@ func (library *libraryDecorator) link(ctx ModuleContext,
}
}
if library.Properties.Proto.Export_proto_headers {
if Bool(library.Properties.Proto.Export_proto_headers) {
if library.baseCompiler.hasSrcExt(".proto") {
flags := []string{
"-I" + android.ProtoSubDir(ctx).String(),
@ -731,7 +731,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
library.baseInstaller.install(ctx, file)
}
if library.Properties.Static_ndk_lib && library.static() {
if Bool(library.Properties.Static_ndk_lib) && library.static() {
installPath := getNdkSysrootBase(ctx).Join(
ctx, "usr/lib", ctx.toolchain().ClangTriple(), file.Base())

View file

@ -39,23 +39,23 @@ var (
type llndkLibraryProperties struct {
// Relative path to the symbol map.
// An example file can be seen here: TODO(danalbert): Make an example.
Symbol_file string
Symbol_file *string
// Whether to export any headers as -isystem instead of -I. Mainly for use by
// bionic/libc.
Export_headers_as_system bool
Export_headers_as_system *bool
// Which headers to process with versioner. This really only handles
// bionic/libc/include right now.
Export_preprocessed_headers []string
// Whether the system library uses symbol versions.
Unversioned bool
Unversioned *bool
// whether this module can be directly depended upon by libs that are installed to /vendor.
// When set to false, this module can only be depended on by VNDK libraries, not vendor
// libraries. This effectively hides this module from vendors. Default value is true.
Vendor_available bool
Vendor_available *bool
// list of llndk headers to re-export include directories from.
Export_llndk_headers []string `android:"arch_variant"`
@ -76,7 +76,7 @@ func (stub *llndkStubDecorator) compilerFlags(ctx ModuleContext, flags Flags) Fl
}
func (stub *llndkStubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
objs, versionScript := compileStubLibrary(ctx, flags, stub.Properties.Symbol_file, "current", "--vndk")
objs, versionScript := compileStubLibrary(ctx, flags, String(stub.Properties.Symbol_file), "current", "--vndk")
stub.versionScriptPath = versionScript
return objs
}
@ -121,7 +121,7 @@ func (stub *llndkStubDecorator) processHeaders(ctx ModuleContext, srcHeaderDir s
func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps,
objs Objects) android.Path {
if !stub.Properties.Unversioned {
if !Bool(stub.Properties.Unversioned) {
linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
flags.LdFlags = append(flags.LdFlags, linkerScriptFlag)
}
@ -135,7 +135,7 @@ func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDe
}
includePrefix := "-I "
if stub.Properties.Export_headers_as_system {
if Bool(stub.Properties.Export_headers_as_system) {
includePrefix = "-isystem "
}
@ -143,7 +143,7 @@ func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDe
stub.reexportDeps(timestampFiles)
}
if stub.Properties.Export_headers_as_system {
if Bool(stub.Properties.Export_headers_as_system) {
stub.exportIncludes(ctx, "-isystem")
stub.libraryDecorator.flagExporter.Properties.Export_include_dirs = []string{}
}
@ -156,12 +156,12 @@ func newLLndkStubLibrary() *Module {
library.BuildOnlyShared()
module.stl = nil
module.sanitize = nil
library.StripProperties.Strip.None = true
library.StripProperties.Strip.None = BoolPtr(true)
stub := &llndkStubDecorator{
libraryDecorator: library,
}
stub.Properties.Vendor_available = true
stub.Properties.Vendor_available = BoolPtr(true)
module.compiler = stub
module.linker = stub
module.installer = nil

View file

@ -56,16 +56,16 @@ type headerProperies struct {
//
// Will install $SYSROOT/usr/include/foo/bar/baz.h. If `from` were instead
// "include/foo", it would have installed $SYSROOT/usr/include/bar/baz.h.
From string
From *string
// Install path within the sysroot. This is relative to usr/include.
To string
To *string
// List of headers to install. Glob compatible. Common case is "include/**/*.h".
Srcs []string
// Path to the NOTICE file associated with the headers.
License string
License *string
}
type headerModule struct {
@ -113,15 +113,16 @@ func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from st
}
func (m *headerModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if m.properties.License == "" {
if String(m.properties.License) == "" {
ctx.PropertyErrorf("license", "field is required")
}
m.licensePath = android.PathForModuleSrc(ctx, m.properties.License)
m.licensePath = android.PathForModuleSrc(ctx, String(m.properties.License))
srcFiles := ctx.ExpandSources(m.properties.Srcs, nil)
for _, header := range srcFiles {
installDir := getHeaderInstallDir(ctx, header, m.properties.From, m.properties.To)
installDir := getHeaderInstallDir(ctx, header, String(m.properties.From),
String(m.properties.To))
installedPath := ctx.InstallFile(installDir, header.Base(), header)
installPath := installDir.Join(ctx, header.Base())
if installPath != installedPath {

View file

@ -76,17 +76,17 @@ var (
type libraryProperties struct {
// Relative path to the symbol map.
// An example file can be seen here: TODO(danalbert): Make an example.
Symbol_file string
Symbol_file *string
// The first API level a library was available. A library will be generated
// for every API level beginning with this one.
First_version string
First_version *string
// The first API level that library should have the version script applied.
// This defaults to the value of first_version, and should almost never be
// used. This is only needed to work around platform bugs like
// https://github.com/android-ndk/ndk/issues/265.
Unversioned_until string
Unversioned_until *string
// Private property for use by the mutator that splits per-API level.
ApiLevel string `blueprint:"mutated"`
@ -158,11 +158,11 @@ func getFirstGeneratedVersion(firstSupportedVersion string, platformVersion int)
func shouldUseVersionScript(stub *stubDecorator) (bool, error) {
// unversioned_until is normally empty, in which case we should use the version script.
if stub.properties.Unversioned_until == "" {
if String(stub.properties.Unversioned_until) == "" {
return true, nil
}
if stub.properties.Unversioned_until == "current" {
if String(stub.properties.Unversioned_until) == "current" {
if stub.properties.ApiLevel == "current" {
return true, nil
} else {
@ -174,7 +174,7 @@ func shouldUseVersionScript(stub *stubDecorator) (bool, error) {
return true, nil
}
unversionedUntil, err := strconv.Atoi(stub.properties.Unversioned_until)
unversionedUntil, err := strconv.Atoi(String(stub.properties.Unversioned_until))
if err != nil {
return true, err
}
@ -190,7 +190,7 @@ func shouldUseVersionScript(stub *stubDecorator) (bool, error) {
func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorator) {
platformVersion := mctx.AConfig().PlatformSdkVersionInt()
firstSupportedVersion, err := normalizeNdkApiLevel(mctx, c.properties.First_version,
firstSupportedVersion, err := normalizeNdkApiLevel(mctx, String(c.properties.First_version),
mctx.Arch())
if err != nil {
mctx.PropertyErrorf("first_version", err.Error())
@ -290,11 +290,12 @@ func compileStubLibrary(ctx ModuleContext, flags Flags, symbolFile, apiLevel, vn
}
func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
if !strings.HasSuffix(c.properties.Symbol_file, ".map.txt") {
if !strings.HasSuffix(String(c.properties.Symbol_file), ".map.txt") {
ctx.PropertyErrorf("symbol_file", "must end with .map.txt")
}
objs, versionScript := compileStubLibrary(ctx, flags, c.properties.Symbol_file, c.properties.ApiLevel, "")
objs, versionScript := compileStubLibrary(ctx, flags, String(c.properties.Symbol_file),
c.properties.ApiLevel, "")
c.versionScriptPath = versionScript
return objs
}
@ -349,7 +350,7 @@ func newStubLibrary() *Module {
library.BuildOnlyShared()
module.stl = nil
module.sanitize = nil
library.StripProperties.Strip.None = true
library.StripProperties.Strip.None = BoolPtr(true)
stub := &stubDecorator{
libraryDecorator: library,

View file

@ -83,9 +83,9 @@ func (object *objectLinker) link(ctx ModuleContext,
if len(objs.objFiles) == 1 {
outputFile = objs.objFiles[0]
if object.Properties.Prefix_symbols != "" {
if String(object.Properties.Prefix_symbols) != "" {
output := android.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension)
TransformBinaryPrefixSymbols(ctx, object.Properties.Prefix_symbols, outputFile,
TransformBinaryPrefixSymbols(ctx, String(object.Properties.Prefix_symbols), outputFile,
builderFlags, output)
outputFile = output
}
@ -93,9 +93,9 @@ func (object *objectLinker) link(ctx ModuleContext,
output := android.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension)
outputFile = output
if object.Properties.Prefix_symbols != "" {
if String(object.Properties.Prefix_symbols) != "" {
input := android.PathForModuleOut(ctx, "unprefixed", ctx.ModuleName()+objectExtension)
TransformBinaryPrefixSymbols(ctx, object.Properties.Prefix_symbols, input,
TransformBinaryPrefixSymbols(ctx, String(object.Properties.Prefix_symbols), input,
builderFlags, output)
output = input
}

View file

@ -16,7 +16,6 @@ package cc
import (
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
)
@ -58,7 +57,7 @@ func genProto(ctx android.ModuleContext, protoFile android.Path,
func protoDeps(ctx BaseModuleContext, deps Deps, p *android.ProtoProperties, static bool) Deps {
var lib string
switch proptools.String(p.Proto.Type) {
switch String(p.Proto.Type) {
case "full":
if ctx.useSdk() {
lib = "libprotobuf-cpp-full-ndk"
@ -75,7 +74,7 @@ func protoDeps(ctx BaseModuleContext, deps Deps, p *android.ProtoProperties, sta
}
default:
ctx.PropertyErrorf("proto.type", "unknown proto type %q",
proptools.String(p.Proto.Type))
String(p.Proto.Type))
}
if static {

View file

@ -19,7 +19,6 @@ import (
"strings"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
func init() {
@ -81,7 +80,7 @@ func rsGenerateCpp(ctx android.ModuleContext, rsFiles android.Paths, rsFlags str
}
func rsFlags(ctx ModuleContext, flags Flags, properties *BaseCompilerProperties) Flags {
targetApi := proptools.String(properties.Renderscript.Target_api)
targetApi := String(properties.Renderscript.Target_api)
if targetApi == "" && ctx.useSdk() {
switch ctx.sdkVersion() {
case "current", "system_current", "test_current":

View file

@ -78,7 +78,7 @@ func (t sanitizerType) String() string {
type SanitizeProperties struct {
// enable AddressSanitizer, ThreadSanitizer, or UndefinedBehaviorSanitizer
Sanitize struct {
Never bool `android:"arch_variant"`
Never *bool `android:"arch_variant"`
// main sanitizers
Address *bool `android:"arch_variant"`
@ -131,11 +131,11 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
// Don't apply sanitizers to NDK code.
if ctx.useSdk() {
s.Never = true
s.Never = BoolPtr(true)
}
// Never always wins.
if s.Never {
if Bool(s.Never) {
return
}
@ -540,7 +540,7 @@ func sanitizerDepsMutator(t sanitizerType) func(android.TopDownMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize.isSanitizerEnabled(t) {
mctx.VisitDepsDepthFirst(func(module android.Module) {
if d, ok := module.(*Module); ok && d.sanitize != nil &&
!d.sanitize.Properties.Sanitize.Never &&
!Bool(d.sanitize.Properties.Sanitize.Never) &&
!d.sanitize.isSanitizerExplicitlyDisabled(t) {
if (t == cfi && d.static()) || t != cfi {
d.sanitize.Properties.SanitizeDep = true

View file

@ -14,12 +14,14 @@
package cc
import "android/soong/android"
import (
"android/soong/android"
)
type StripProperties struct {
Strip struct {
None bool
Keep_symbols bool
None *bool
Keep_symbols *bool
}
}
@ -28,7 +30,7 @@ type stripper struct {
}
func (stripper *stripper) needsStrip(ctx ModuleContext) bool {
return !ctx.AConfig().EmbeddedInMake() && !stripper.StripProperties.Strip.None
return !ctx.AConfig().EmbeddedInMake() && !Bool(stripper.StripProperties.Strip.None)
}
func (stripper *stripper) strip(ctx ModuleContext, in, out android.ModuleOutPath,
@ -36,7 +38,7 @@ func (stripper *stripper) strip(ctx ModuleContext, in, out android.ModuleOutPath
if ctx.Darwin() {
TransformDarwinStrip(ctx, in, out)
} else {
flags.stripKeepSymbols = stripper.StripProperties.Strip.Keep_symbols
flags.stripKeepSymbols = Bool(stripper.StripProperties.Strip.Keep_symbols)
// TODO(ccross): don't add gnu debuglink for user builds
flags.stripAddGnuDebuglink = true
TransformStrip(ctx, in, out, flags)

View file

@ -100,7 +100,7 @@ func (test *testBinary) srcs() []string {
func (test *testBinary) setSrc(name, src string) {
test.baseCompiler.Properties.Srcs = []string{src}
test.binaryDecorator.Properties.Stem = name
test.binaryDecorator.Properties.Stem = StringPtr(name)
}
var _ testPerSrc = (*testBinary)(nil)
@ -236,7 +236,7 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) {
if !Bool(test.Properties.No_named_install_directory) {
test.binaryDecorator.baseInstaller.relative = ctx.ModuleName()
} else if test.binaryDecorator.baseInstaller.Properties.Relative_install_path == "" {
} else if String(test.binaryDecorator.baseInstaller.Properties.Relative_install_path) == "" {
ctx.PropertyErrorf("no_named_install_directory", "Module install directory may only be disabled if relative_install_path is set")
}

View file

@ -15,8 +15,6 @@
package cc
import (
"github.com/google/blueprint/proptools"
"android/soong/android"
)
@ -45,7 +43,7 @@ func toolchainLibraryFactory() android.Module {
}
module.compiler = toolchainLibrary
module.linker = toolchainLibrary
module.Properties.Clang = proptools.BoolPtr(false)
module.Properties.Clang = BoolPtr(false)
module.stl = nil
module.sanitize = nil
module.installer = nil

View file

@ -85,7 +85,7 @@ func (vndk *vndkdep) vndkCheckLinkType(ctx android.ModuleContext, to *Module) {
// Non-VNDK modules (those installed to /vendor) can't depend on modules marked with
// vendor_available: false.
violation := false
if lib, ok := to.linker.(*llndkStubDecorator); ok && !lib.Properties.Vendor_available {
if lib, ok := to.linker.(*llndkStubDecorator); ok && !Bool(lib.Properties.Vendor_available) {
violation = true
} else {
if _, ok := to.linker.(libraryInterface); ok && to.VendorProperties.Vendor_available != nil && !Bool(to.VendorProperties.Vendor_available) {
@ -138,7 +138,7 @@ func vndkMutator(mctx android.BottomUpMutatorContext) {
llndkLibraries = append(llndkLibraries, name)
sort.Strings(llndkLibraries)
}
if !lib.Properties.Vendor_available {
if !Bool(lib.Properties.Vendor_available) {
if !inList(name, vndkPrivateLibraries) {
vndkPrivateLibraries = append(vndkPrivateLibraries, name)
sort.Strings(vndkPrivateLibraries)