Segregate device specific generation to its own struct
@@ -439,12 +439,21 @@ mod generate;
mod util;
pub use util::Target;
-use util::build_rs;
pub struct Generation {
pub lib_rs: String,
+ pub device_specific: Option<DeviceSpecific>,
+
+ // Reserve the right to add more fields to this struct
+ _extensible: (),
+}
+
+pub struct DeviceSpecific {
pub device_x: String,
pub build_rs: String,
+
+ // Reserve the right to add more fields to this struct
+ _extensible: (),
}
type Result<T> = std::result::Result<T, SvdError>;
@@ -470,11 +479,23 @@ pub fn generate(xml: &str, target: &Target, nightly: bool) -> Result<Generation>
quote! {
#(#items)*
}
- ).or(Err(SvdError::Fmt))?;
+ )
+ .or(Err(SvdError::Fmt))?;
+
+ let device_specific = if device_x.is_empty() {
+ None
+ } else {
+ Some(DeviceSpecific {
+ device_x: device_x,
+ build_rs: util::build_rs().to_string(),
+ _extensible: (),
+ })
+ };
+
Ok(Generation {
lib_rs: lib_rs,
- device_x: device_x,
- build_rs: build_rs().to_string(),
+ device_specific: device_specific,
+ _extensible: (),
})
}
