1diff --git a/src/util.rs b/src/util.rs 2index 3019c40..49a9651 100644 3--- a/src/util.rs 4+++ b/src/util.rs 5@@ -18,7 +18,13 @@ pub fn manifest_path() -> Result<PathBuf, String> { 6 Ok(StdPath::new(&manifest_dir).join("Cargo.toml")) 7 } 8 9-#[cfg(not(feature = "nightly"))] 10+#[cfg(soong)] 11+pub fn mod_path() -> syn::Result<String> { 12+ Ok(std::env::var("CARGO_CRATE_NAME") 13+ .expect("`CARGO_CRATE_NAME` should be set when building with Soong")) 14+} 15+ 16+#[cfg(all(not(soong), not(feature = "nightly")))] 17 pub fn mod_path() -> syn::Result<String> { 18 // Without the nightly feature and TokenStream::expand_expr, just return the crate name 19 20@@ -64,7 +70,7 @@ pub fn mod_path() -> syn::Result<String> { 21 .map_err(|e| syn::Error::new(Span::call_site(), e)) 22 } 23 24-#[cfg(feature = "nightly")] 25+#[cfg(all(not(soong), feature = "nightly"))] 26 pub fn mod_path() -> syn::Result<String> { 27 use proc_macro::TokenStream; 28 29