rust: set ANDROID_RUST_VERSION based on prebuilts

ANDROID_RUST_VERSION is always set to the default Rust version, rather
than than respecting the RUST_PREBUILTS_VERSION setting. This is not the
correct behavior, this CL resolves the issue.

Test: m nothing
Change-Id: I3f8a2fc3590b7313286278b77534bb669cc693d6
This commit is contained in:
Ivan Lozano 2022-04-12 10:29:43 -04:00
parent d72c85219a
commit 6d14ed157e
2 changed files with 13 additions and 7 deletions

View file

@ -274,7 +274,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
implicits = append(implicits, outputs.Paths()...)
}
envVars = append(envVars, "ANDROID_RUST_VERSION="+config.RustDefaultVersion)
envVars = append(envVars, "ANDROID_RUST_VERSION="+config.GetRustVersion(ctx))
if ctx.RustModule().compiler.CargoEnvCompat() {
if _, ok := ctx.RustModule().compiler.(*binaryDecorator); ok {

View file

@ -86,12 +86,7 @@ func init() {
return "${RustDefaultBase}"
})
pctx.VariableFunc("RustVersion", func(ctx android.PackageVarContext) string {
if override := ctx.Config().Getenv("RUST_PREBUILTS_VERSION"); override != "" {
return override
}
return RustDefaultVersion
})
pctx.VariableFunc("RustVersion", getRustVersionPctx)
pctx.StaticVariable("RustPath", "${RustBase}/${HostPrebuiltTag}/${RustVersion}")
pctx.StaticVariable("RustBin", "${RustPath}/bin")
@ -103,3 +98,14 @@ func init() {
pctx.StaticVariable("DeviceGlobalLinkFlags", strings.Join(deviceGlobalLinkFlags, " "))
}
func getRustVersionPctx(ctx android.PackageVarContext) string {
return GetRustVersion(ctx)
}
func GetRustVersion(ctx android.PathContext) string {
if override := ctx.Config().Getenv("RUST_PREBUILTS_VERSION"); override != "" {
return override
}
return RustDefaultVersion
}