1diff --git a/src/lib.rs b/src/lib.rs 2index 2614105..18d170d 100644 3--- a/src/lib.rs 4+++ b/src/lib.rs 5@@ -165,7 +165,16 @@ use crate::version::Version; 6 use proc_macro::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; 7 use std::iter::FromIterator; 8 9-const RUSTVERSION: Version = include!(concat!(env!("OUT_DIR"), "/version.rs")); 10+// ANDROID: Soong is providing the version of rustc via an env variable. 11+const ANDROID_RUSTVERSION: &str = env!("ANDROID_RUST_VERSION"); 12+fn rust_version() -> Version { 13+ let v: Vec<&str> = ANDROID_RUSTVERSION.split('.').collect(); 14+ Version { 15+ minor: v[1].parse().unwrap(), 16+ patch: v[2].parse().unwrap(), 17+ channel: version::Channel::Stable, 18+ } 19+} 20 21 #[proc_macro_attribute] 22 pub fn stable(args: TokenStream, input: TokenStream) -> TokenStream { 23@@ -226,7 +235,7 @@ fn try_cfg(introducer: &str, args: TokenStream, input: TokenStream) -> Result<To 24 let expr = expr::parse(full_args)?; 25 token::parse_end(full_args)?; 26 27- if expr.eval(RUSTVERSION) { 28+ if expr.eval(rust_version()) { 29 Ok(input) 30 } else { 31 Ok(TokenStream::new()) 32@@ -241,7 +250,7 @@ pub fn attr(args: TokenStream, input: TokenStream) -> TokenStream { 33 } 34 35 fn try_attr(args: attr::Args, input: TokenStream) -> Result<TokenStream> { 36- if !args.condition.eval(RUSTVERSION) { 37+ if !args.condition.eval(rust_version()) { 38 return Ok(input); 39 } 40 41