Add basic VNDK support in Soong
Export a list of libraries in the VNDK, which is currently empty. Take in Make's global BOARD_VNDK_VERSION, and use that as the SDK version for modules that specify use_vndk: true. Modules that use the vndk have some configuration as if they were building against the NDK (the absence of globally defined headers), but in other cases look like platform modules (using the platform libc++, for now). This change does not attempt to enforce any linking constraints, that will come in a later patch. Test: out/soong/build.ninja doesn't change Change-Id: I3be206b67015ac5177b7eef4a451c579e3dc903f
This commit is contained in:
@@ -424,3 +424,10 @@ func (c *deviceConfig) Arches() []Arch {
|
|||||||
}
|
}
|
||||||
return arches
|
return arches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *deviceConfig) VndkVersion() string {
|
||||||
|
if c.config.ProductVariables.DeviceVndkVersion == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return *c.config.ProductVariables.DeviceVndkVersion
|
||||||
|
}
|
||||||
|
@@ -87,6 +87,7 @@ type productVariables struct {
|
|||||||
DeviceCpuVariant *string `json:",omitempty"`
|
DeviceCpuVariant *string `json:",omitempty"`
|
||||||
DeviceAbi *[]string `json:",omitempty"`
|
DeviceAbi *[]string `json:",omitempty"`
|
||||||
DeviceUsesClang *bool `json:",omitempty"`
|
DeviceUsesClang *bool `json:",omitempty"`
|
||||||
|
DeviceVndkVersion *string `json:",omitempty"`
|
||||||
|
|
||||||
DeviceSecondaryArch *string `json:",omitempty"`
|
DeviceSecondaryArch *string `json:",omitempty"`
|
||||||
DeviceSecondaryArchVariant *string `json:",omitempty"`
|
DeviceSecondaryArchVariant *string `json:",omitempty"`
|
||||||
|
@@ -77,6 +77,7 @@ var standardProperties = map[string]struct {
|
|||||||
"LOCAL_NO_STANDARD_LIBRARIES": {"no_standard_libraries", bpparser.BoolType},
|
"LOCAL_NO_STANDARD_LIBRARIES": {"no_standard_libraries", bpparser.BoolType},
|
||||||
"LOCAL_PACK_MODULE_RELOCATIONS": {"pack_relocations", bpparser.BoolType},
|
"LOCAL_PACK_MODULE_RELOCATIONS": {"pack_relocations", bpparser.BoolType},
|
||||||
"LOCAL_TIDY": {"tidy", bpparser.BoolType},
|
"LOCAL_TIDY": {"tidy", bpparser.BoolType},
|
||||||
|
"LOCAL_USE_VNDK": {"use_vndk", bpparser.BoolType},
|
||||||
|
|
||||||
"LOCAL_EXPORT_PACKAGE_RESOURCES": {"export_package_resources", bpparser.BoolType},
|
"LOCAL_EXPORT_PACKAGE_RESOURCES": {"export_package_resources", bpparser.BoolType},
|
||||||
}
|
}
|
||||||
|
@@ -59,6 +59,9 @@ func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) {
|
|||||||
if c.Target().Os == android.Android && c.Properties.Sdk_version != "" {
|
if c.Target().Os == android.Android && c.Properties.Sdk_version != "" {
|
||||||
fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+c.Properties.Sdk_version)
|
fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+c.Properties.Sdk_version)
|
||||||
fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
|
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 {
|
} else {
|
||||||
// These are already included in LOCAL_SHARED_LIBRARIES
|
// These are already included in LOCAL_SHARED_LIBRARIES
|
||||||
fmt.Fprintln(w, "LOCAL_CXX_STL := none")
|
fmt.Fprintln(w, "LOCAL_CXX_STL := none")
|
||||||
|
@@ -93,7 +93,7 @@ func (binary *binaryDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps
|
|||||||
deps = binary.baseLinker.linkerDeps(ctx, deps)
|
deps = binary.baseLinker.linkerDeps(ctx, deps)
|
||||||
if ctx.toolchain().Bionic() {
|
if ctx.toolchain().Bionic() {
|
||||||
if !Bool(binary.baseLinker.Properties.Nocrt) {
|
if !Bool(binary.baseLinker.Properties.Nocrt) {
|
||||||
if !ctx.sdk() {
|
if !ctx.sdk() && !ctx.vndk() {
|
||||||
if binary.static() {
|
if binary.static() {
|
||||||
deps.CrtBegin = "crtbegin_static"
|
deps.CrtBegin = "crtbegin_static"
|
||||||
} else {
|
} else {
|
||||||
|
29
cc/cc.go
29
cc/cc.go
@@ -125,6 +125,9 @@ type BaseProperties struct {
|
|||||||
// Minimum sdk version supported when compiling against the ndk
|
// Minimum sdk version supported when compiling against the ndk
|
||||||
Sdk_version string
|
Sdk_version string
|
||||||
|
|
||||||
|
// Whether to compile against the VNDK
|
||||||
|
Use_vndk bool
|
||||||
|
|
||||||
// don't insert default compiler flags into asflags, cflags,
|
// don't insert default compiler flags into asflags, cflags,
|
||||||
// cppflags, conlyflags, ldflags, or include_dirs
|
// cppflags, conlyflags, ldflags, or include_dirs
|
||||||
No_default_compiler_flags *bool
|
No_default_compiler_flags *bool
|
||||||
@@ -132,6 +135,7 @@ type BaseProperties struct {
|
|||||||
AndroidMkSharedLibs []string `blueprint:"mutated"`
|
AndroidMkSharedLibs []string `blueprint:"mutated"`
|
||||||
HideFromMake bool `blueprint:"mutated"`
|
HideFromMake bool `blueprint:"mutated"`
|
||||||
PreventInstall bool `blueprint:"mutated"`
|
PreventInstall bool `blueprint:"mutated"`
|
||||||
|
Vndk_version string `blueprint:"mutated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UnusedProperties struct {
|
type UnusedProperties struct {
|
||||||
@@ -147,6 +151,7 @@ type ModuleContextIntf interface {
|
|||||||
noDefaultCompilerFlags() bool
|
noDefaultCompilerFlags() bool
|
||||||
sdk() bool
|
sdk() bool
|
||||||
sdkVersion() string
|
sdkVersion() string
|
||||||
|
vndk() bool
|
||||||
selectedStl() string
|
selectedStl() string
|
||||||
baseModuleName() string
|
baseModuleName() string
|
||||||
}
|
}
|
||||||
@@ -345,11 +350,22 @@ func (ctx *moduleContextImpl) sdk() bool {
|
|||||||
|
|
||||||
func (ctx *moduleContextImpl) sdkVersion() string {
|
func (ctx *moduleContextImpl) sdkVersion() string {
|
||||||
if ctx.ctx.Device() {
|
if ctx.ctx.Device() {
|
||||||
|
if ctx.mod.Properties.Use_vndk {
|
||||||
|
return ctx.mod.Properties.Vndk_version
|
||||||
|
} else {
|
||||||
return ctx.mod.Properties.Sdk_version
|
return ctx.mod.Properties.Sdk_version
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx *moduleContextImpl) vndk() bool {
|
||||||
|
if ctx.ctx.Device() {
|
||||||
|
return ctx.mod.Properties.Use_vndk
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) selectedStl() string {
|
func (ctx *moduleContextImpl) selectedStl() string {
|
||||||
if stl := ctx.mod.stl; stl != nil {
|
if stl := ctx.mod.stl; stl != nil {
|
||||||
return stl.Properties.SelectedStl
|
return stl.Properties.SelectedStl
|
||||||
@@ -493,11 +509,22 @@ func (c *Module) begin(ctx BaseModuleContext) {
|
|||||||
feature.begin(ctx)
|
feature.begin(ctx)
|
||||||
}
|
}
|
||||||
if ctx.sdk() {
|
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())
|
version, err := normalizeNdkApiLevel(ctx.sdkVersion(), ctx.Arch())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.PropertyErrorf("sdk_version", err.Error())
|
ctx.PropertyErrorf("sdk_version", err.Error())
|
||||||
}
|
}
|
||||||
c.Properties.Sdk_version = version
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,7 +606,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
|
|
||||||
variantNdkLibs := []string{}
|
variantNdkLibs := []string{}
|
||||||
variantLateNdkLibs := []string{}
|
variantLateNdkLibs := []string{}
|
||||||
if ctx.sdk() {
|
if ctx.sdk() || ctx.vndk() {
|
||||||
version := ctx.sdkVersion()
|
version := ctx.sdkVersion()
|
||||||
|
|
||||||
// Rewrites the names of shared libraries into the names of the NDK
|
// Rewrites the names of shared libraries into the names of the NDK
|
||||||
|
@@ -160,7 +160,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !ctx.noDefaultCompilerFlags() {
|
if !ctx.noDefaultCompilerFlags() {
|
||||||
if !ctx.sdk() || ctx.Host() {
|
if !(ctx.sdk() || ctx.vndk()) || ctx.Host() {
|
||||||
flags.GlobalFlags = append(flags.GlobalFlags,
|
flags.GlobalFlags = append(flags.GlobalFlags,
|
||||||
"${config.CommonGlobalIncludes}",
|
"${config.CommonGlobalIncludes}",
|
||||||
"${config.CommonGlobalSystemIncludes}",
|
"${config.CommonGlobalSystemIncludes}",
|
||||||
@@ -171,7 +171,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
|
|||||||
flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String())
|
flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.sdk() {
|
if ctx.sdk() || ctx.vndk() {
|
||||||
// The NDK headers are installed to a common sysroot. While a more
|
// The NDK headers are installed to a common sysroot. While a more
|
||||||
// typical Soong approach would be to only make the headers for the
|
// typical Soong approach would be to only make the headers for the
|
||||||
// library you're using available, we're trying to emulate the NDK
|
// library you're using available, we're trying to emulate the NDK
|
||||||
@@ -354,7 +354,7 @@ func (compiler *baseCompiler) hasSrcExt(ext string) bool {
|
|||||||
var gnuToCReplacer = strings.NewReplacer("gnu", "c")
|
var gnuToCReplacer = strings.NewReplacer("gnu", "c")
|
||||||
|
|
||||||
func ndkPathDeps(ctx ModuleContext) android.Paths {
|
func ndkPathDeps(ctx ModuleContext) android.Paths {
|
||||||
if ctx.sdk() {
|
if ctx.sdk() || ctx.vndk() {
|
||||||
// The NDK sysroot timestamp file depends on all the NDK sysroot files
|
// The NDK sysroot timestamp file depends on all the NDK sysroot files
|
||||||
// (headers and libraries).
|
// (headers and libraries).
|
||||||
return android.Paths{getNdkSysrootTimestampFile(ctx)}
|
return android.Paths{getNdkSysrootTimestampFile(ctx)}
|
||||||
|
@@ -163,3 +163,7 @@ func bionicHeaders(bionicArch, kernelArch string) string {
|
|||||||
"-isystem bionic/libc/kernel/android/uapi",
|
"-isystem bionic/libc/kernel/android/uapi",
|
||||||
}, " ")
|
}, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func VndkLibraries() []string {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
@@ -331,7 +331,7 @@ func (library *libraryDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) De
|
|||||||
deps.SharedLibs = append(deps.SharedLibs, library.Properties.Static.Shared_libs...)
|
deps.SharedLibs = append(deps.SharedLibs, library.Properties.Static.Shared_libs...)
|
||||||
} else {
|
} else {
|
||||||
if ctx.toolchain().Bionic() && !Bool(library.baseLinker.Properties.Nocrt) {
|
if ctx.toolchain().Bionic() && !Bool(library.baseLinker.Properties.Nocrt) {
|
||||||
if !ctx.sdk() {
|
if !ctx.sdk() && !ctx.vndk() {
|
||||||
deps.CrtBegin = "crtbegin_so"
|
deps.CrtBegin = "crtbegin_so"
|
||||||
deps.CrtEnd = "crtend_so"
|
deps.CrtEnd = "crtend_so"
|
||||||
} else {
|
} else {
|
||||||
|
@@ -45,6 +45,13 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
|||||||
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
|
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
|
||||||
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkPrebuiltSharedLibs, " "))
|
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkPrebuiltSharedLibs, " "))
|
||||||
|
|
||||||
|
if ctx.Config().ProductVariables.DeviceVndkVersion != nil {
|
||||||
|
ctx.Strict("BOARD_VNDK_VERSION", *ctx.Config().ProductVariables.DeviceVndkVersion)
|
||||||
|
} else {
|
||||||
|
ctx.Strict("BOARD_VNDK_VERSION", "")
|
||||||
|
}
|
||||||
|
ctx.Strict("VNDK_LIBRARIES", strings.Join(config.VndkLibraries(), " "))
|
||||||
|
|
||||||
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", asanCflags)
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", asanCflags)
|
||||||
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", asanLdflags)
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", asanLdflags)
|
||||||
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES", asanLibs)
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES", asanLibs)
|
||||||
|
Reference in New Issue
Block a user