]> git.proxmox.com Git - perlmod.git/commitdiff
macro: only write package files if requested
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 24 Feb 2022 10:43:05 +0000 (11:43 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 24 Feb 2022 10:44:03 +0000 (11:44 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
perlmod-macro/src/module.rs
perlmod-macro/src/package.rs

index bd699fe3f9a011112c6400d766c1491c51f14926..6df79288c7ffc0b9b11044f0c13a54de648e63f8 100644 (file)
@@ -68,7 +68,12 @@ pub fn handle_module(attr: AttributeArgs, mut module: syn::ItemMod) -> Result<To
         items.push(syn::Item::Verbatim(package.bootstrap_function()));
     }
 
-    package.write()?;
+    if package.attrs.file_name.is_some()
+        || package.attrs.lib_name.is_some()
+        || std::env::var("PERLMOD_WRITE_PACKAGES").ok().as_deref() == Some("1")
+    {
+        package.write()?;
+    }
 
     Ok(quote! { #module })
 }
index 4430c50183879be655d92a7c6a10477cef8b8b47..0f7547ec28ace1f97ebfe94433664c3a3c23b8b8 100644 (file)
@@ -50,7 +50,7 @@ struct Export {
 }
 
 pub struct Package {
-    attrs: ModuleAttrs,
+    pub attrs: ModuleAttrs,
     exported: Vec<Export>,
 }