diff --git a/src/util.rs b/src/util.rs index 3019c40..49a9651 100644 --- a/src/util.rs +++ b/src/util.rs @@ -18,7 +18,13 @@ pub fn manifest_path() -> Result { Ok(StdPath::new(&manifest_dir).join("Cargo.toml")) } -#[cfg(not(feature = "nightly"))] +#[cfg(soong)] +pub fn mod_path() -> syn::Result { + Ok(std::env::var("CARGO_CRATE_NAME") + .expect("`CARGO_CRATE_NAME` should be set when building with Soong")) +} + +#[cfg(all(not(soong), not(feature = "nightly")))] pub fn mod_path() -> syn::Result { // Without the nightly feature and TokenStream::expand_expr, just return the crate name @@ -64,7 +70,7 @@ pub fn mod_path() -> syn::Result { .map_err(|e| syn::Error::new(Span::call_site(), e)) } -#[cfg(feature = "nightly")] +#[cfg(all(not(soong), feature = "nightly"))] pub fn mod_path() -> syn::Result { use proc_macro::TokenStream;