Merge "rust: set ANDROID_RUST_VERSION based on prebuilts"
diff --git a/rust/builder.go b/rust/builder.go
index 00035b9..20ca5db 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -274,7 +274,7 @@
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 {
diff --git a/rust/config/global.go b/rust/config/global.go
index 1cf773e..2d5fa99 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -86,12 +86,7 @@
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 @@
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
+}