Merge "rust: Add missing variation -D flags to bindgen."
This commit is contained in:
commit
fe700e19c8
2 changed files with 47 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
|||
package rust
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
|
@ -147,6 +148,31 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr
|
|||
cflags = append(cflags, strings.ReplaceAll(ccToolchain.Cflags(), "${config.", "${cc_config."))
|
||||
cflags = append(cflags, strings.ReplaceAll(ccToolchain.ToolchainCflags(), "${config.", "${cc_config."))
|
||||
|
||||
if ctx.RustModule().UseVndk() {
|
||||
cflags = append(cflags, "-D__ANDROID_VNDK__")
|
||||
if ctx.RustModule().InVendor() {
|
||||
cflags = append(cflags, "-D__ANDROID_VENDOR__")
|
||||
} else if ctx.RustModule().InProduct() {
|
||||
cflags = append(cflags, "-D__ANDROID_PRODUCT__")
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.RustModule().InRecovery() {
|
||||
cflags = append(cflags, "-D__ANDROID_RECOVERY__")
|
||||
}
|
||||
|
||||
if mctx, ok := ctx.(*moduleContext); ok && mctx.apexVariationName() != "" {
|
||||
cflags = append(cflags, "-D__ANDROID_APEX__")
|
||||
if ctx.Device() {
|
||||
cflags = append(cflags, fmt.Sprintf("-D__ANDROID_APEX_MIN_SDK_VERSION__=%d",
|
||||
ctx.RustModule().apexSdkVersion.FinalOrFutureInt()))
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
|
||||
cflags = append(cflags, "-D__ANDROID_NATIVE_BRIDGE__")
|
||||
}
|
||||
|
||||
// Dependency clang flags and include paths
|
||||
cflags = append(cflags, deps.depClangFlags...)
|
||||
for _, include := range deps.depIncludePaths {
|
||||
|
|
21
rust/rust.go
21
rust/rust.go
|
@ -163,6 +163,9 @@ type Module struct {
|
|||
docTimestampFile android.OptionalPath
|
||||
|
||||
hideApexVariantFromMake bool
|
||||
|
||||
// For apex variants, this is set as apex.min_sdk_version
|
||||
apexSdkVersion android.ApiLevel
|
||||
}
|
||||
|
||||
func (mod *Module) Header() bool {
|
||||
|
@ -678,6 +681,10 @@ func (mod *Module) installable(apexInfo android.ApexInfo) bool {
|
|||
return mod.OutputFile().Valid() && !mod.Properties.PreventInstall
|
||||
}
|
||||
|
||||
func (ctx moduleContext) apexVariationName() string {
|
||||
return ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).ApexVariationName
|
||||
}
|
||||
|
||||
var _ cc.LinkableInterface = (*Module)(nil)
|
||||
|
||||
func (mod *Module) Init() android.Module {
|
||||
|
@ -1023,6 +1030,20 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||
directSrcProvidersDeps := []*Module{}
|
||||
directSrcDeps := [](android.SourceFileProducer){}
|
||||
|
||||
// For the dependency from platform to apex, use the latest stubs
|
||||
mod.apexSdkVersion = android.FutureApiLevel
|
||||
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
||||
if !apexInfo.IsForPlatform() {
|
||||
mod.apexSdkVersion = apexInfo.MinSdkVersion
|
||||
}
|
||||
|
||||
if android.InList("hwaddress", ctx.Config().SanitizeDevice()) {
|
||||
// In hwasan build, we override apexSdkVersion to the FutureApiLevel(10000)
|
||||
// so that even Q(29/Android10) apexes could use the dynamic unwinder by linking the newer stubs(e.g libc(R+)).
|
||||
// (b/144430859)
|
||||
mod.apexSdkVersion = android.FutureApiLevel
|
||||
}
|
||||
|
||||
ctx.VisitDirectDeps(func(dep android.Module) {
|
||||
depName := ctx.OtherModuleName(dep)
|
||||
depTag := ctx.OtherModuleDependencyTag(dep)
|
||||
|
|
Loading…
Reference in a new issue