rust: Add missing variation -D flags to bindgen.
rust_bindgen calls are missing a large set of -D cflags which control how headers are interpretted for certain variations (such as -D__ANDROID_VNDK__). This CL introduces the full set of these flags. Bug: 205609024 Test: rust_bindgen vendor variant builds correctly. Change-Id: Id781c1f88352e9c238c49619f0dce20f804cfc77
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
package rust
|
package rust
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"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.Cflags(), "${config.", "${cc_config."))
|
||||||
cflags = append(cflags, strings.ReplaceAll(ccToolchain.ToolchainCflags(), "${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
|
// Dependency clang flags and include paths
|
||||||
cflags = append(cflags, deps.depClangFlags...)
|
cflags = append(cflags, deps.depClangFlags...)
|
||||||
for _, include := range deps.depIncludePaths {
|
for _, include := range deps.depIncludePaths {
|
||||||
|
21
rust/rust.go
21
rust/rust.go
@@ -163,6 +163,9 @@ type Module struct {
|
|||||||
docTimestampFile android.OptionalPath
|
docTimestampFile android.OptionalPath
|
||||||
|
|
||||||
hideApexVariantFromMake bool
|
hideApexVariantFromMake bool
|
||||||
|
|
||||||
|
// For apex variants, this is set as apex.min_sdk_version
|
||||||
|
apexSdkVersion android.ApiLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *Module) Header() bool {
|
func (mod *Module) Header() bool {
|
||||||
@@ -678,6 +681,10 @@ func (mod *Module) installable(apexInfo android.ApexInfo) bool {
|
|||||||
return mod.OutputFile().Valid() && !mod.Properties.PreventInstall
|
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)
|
var _ cc.LinkableInterface = (*Module)(nil)
|
||||||
|
|
||||||
func (mod *Module) Init() android.Module {
|
func (mod *Module) Init() android.Module {
|
||||||
@@ -1023,6 +1030,20 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
directSrcProvidersDeps := []*Module{}
|
directSrcProvidersDeps := []*Module{}
|
||||||
directSrcDeps := [](android.SourceFileProducer){}
|
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) {
|
ctx.VisitDirectDeps(func(dep android.Module) {
|
||||||
depName := ctx.OtherModuleName(dep)
|
depName := ctx.OtherModuleName(dep)
|
||||||
depTag := ctx.OtherModuleDependencyTag(dep)
|
depTag := ctx.OtherModuleDependencyTag(dep)
|
||||||
|
Reference in New Issue
Block a user