Rework vndk detection

Instead of having a module define `use_vndk: true`, assume that we're
building with the VNDK if we're installed on the vendor partition, and
BOARD_VNDK_VERSION==current. This now matches our behavior in Make.

Once BOARD_VNDK_VERSION!=current, we'll need to disable modules that
need to otherwise compile against the VNDK, since we can only compile
against the current VNDK.

Test: build.ninja for aosp_arm is the same before/after
Test: Ensure there are no boards that set BOARD_VNDK_VERSION
Change-Id: If937fa7bdb119648137af52daebadf486163484b
This commit is contained in:
Dan Willemsen
2017-03-19 18:30:37 -07:00
parent 9e3f627ea7
commit 11b261472a
5 changed files with 11 additions and 31 deletions

View File

@@ -462,11 +462,11 @@ func (c *deviceConfig) VendorPath() string {
return "vendor"
}
func (c *deviceConfig) VndkVersion() string {
func (c *deviceConfig) CompileVndk() bool {
if c.config.ProductVariables.DeviceVndkVersion == nil {
return ""
return false
}
return *c.config.ProductVariables.DeviceVndkVersion
return *c.config.ProductVariables.DeviceVndkVersion == "current"
}
func (c *deviceConfig) BtConfigIncludeDir() string {

View File

@@ -59,6 +59,7 @@ type androidBaseContext interface {
Darwin() bool
Debug() bool
PrimaryArch() bool
Proprietary() bool
AConfig() Config
DeviceConfig() DeviceConfig
}
@@ -87,7 +88,6 @@ type ModuleContext interface {
AddMissingDependencies(deps []string)
Proprietary() bool
InstallInData() bool
RequiredModuleNames() []string
@@ -455,6 +455,7 @@ func (a *ModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext)
return androidBaseContextImpl{
target: a.commonProperties.CompileTarget,
targetPrimary: a.commonProperties.CompilePrimary,
proprietary: a.commonProperties.Proprietary,
config: ctx.Config().(Config),
}
}
@@ -491,6 +492,7 @@ type androidBaseContextImpl struct {
target Target
targetPrimary bool
debug bool
proprietary bool
config Config
}
@@ -619,8 +621,8 @@ func (a *androidBaseContextImpl) DeviceConfig() DeviceConfig {
return DeviceConfig{a.config.deviceConfig}
}
func (a *androidModuleContext) Proprietary() bool {
return a.module.base().commonProperties.Proprietary
func (a *androidBaseContextImpl) Proprietary() bool {
return a.proprietary
}
func (a *androidModuleContext) InstallInData() bool {

View File

@@ -118,7 +118,6 @@ func init() {
"LOCAL_NO_STANDARD_LIBRARIES": "no_standard_libraries",
"LOCAL_PACK_MODULE_RELOCATIONS": "pack_relocations",
"LOCAL_TIDY": "tidy",
"LOCAL_USE_VNDK": "use_vndk",
"LOCAL_PROPRIETARY_MODULE": "proprietary",
"LOCAL_EXPORT_PACKAGE_RESOURCES": "export_package_resources",

View File

@@ -59,9 +59,6 @@ func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) {
if c.Target().Os == android.Android && c.Properties.Sdk_version != "" {
fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+c.Properties.Sdk_version)
fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
} else if c.Target().Os == android.Android && c.Properties.Use_vndk {
fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
} else {
// These are already included in LOCAL_SHARED_LIBRARIES
fmt.Fprintln(w, "LOCAL_CXX_STL := none")

View File

@@ -135,9 +135,6 @@ type BaseProperties struct {
// Minimum sdk version supported when compiling against the ndk
Sdk_version string
// Whether to compile against the VNDK
Use_vndk bool
// don't insert default compiler flags into asflags, cflags,
// cppflags, conlyflags, ldflags, or include_dirs
No_default_compiler_flags *bool
@@ -145,7 +142,6 @@ type BaseProperties struct {
AndroidMkSharedLibs []string `blueprint:"mutated"`
HideFromMake bool `blueprint:"mutated"`
PreventInstall bool `blueprint:"mutated"`
Vndk_version string `blueprint:"mutated"`
}
type UnusedProperties struct {
@@ -378,8 +374,8 @@ func (ctx *moduleContextImpl) sdk() bool {
func (ctx *moduleContextImpl) sdkVersion() string {
if ctx.ctx.Device() {
if ctx.mod.Properties.Use_vndk {
return ctx.mod.Properties.Vndk_version
if ctx.vndk() {
return "current"
} else {
return ctx.mod.Properties.Sdk_version
}
@@ -388,10 +384,7 @@ func (ctx *moduleContextImpl) sdkVersion() string {
}
func (ctx *moduleContextImpl) vndk() bool {
if ctx.ctx.Device() {
return ctx.mod.Properties.Use_vndk
}
return false
return ctx.ctx.Os() == android.Android && ctx.ctx.Proprietary() && ctx.ctx.DeviceConfig().CompileVndk()
}
func (ctx *moduleContextImpl) selectedStl() string {
@@ -544,22 +537,11 @@ func (c *Module) begin(ctx BaseModuleContext) {
feature.begin(ctx)
}
if ctx.sdk() {
if ctx.vndk() {
ctx.PropertyErrorf("use_vndk",
"sdk_version and use_vndk cannot be used at the same time")
}
version, err := normalizeNdkApiLevel(ctx.sdkVersion(), ctx.Arch())
if err != nil {
ctx.PropertyErrorf("sdk_version", err.Error())
}
c.Properties.Sdk_version = version
} else if ctx.vndk() {
version, err := normalizeNdkApiLevel(ctx.DeviceConfig().VndkVersion(), ctx.Arch())
if err != nil {
ctx.ModuleErrorf("Bad BOARD_VNDK_VERSION: %s", err.Error())
}
c.Properties.Vndk_version = version
}
}