mirror of
https://gitlab.cern.ch/wotsubo/endcap-sl-software-ri-generator.git
synced 2025-06-29 16:19:26 +09:00
Prepare for release (Refine cli, writing docs)
This commit is contained in:
parent
c4407639a0
commit
a652b40228
9 changed files with 245 additions and 5 deletions
|
@ -13,7 +13,7 @@ pub fn write_to_files(
|
|||
if fs::read_dir(out_path)?.next().is_some() {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::AlreadyExists,
|
||||
"out path is not empty",
|
||||
format!("out path `{}` is not empty", out_path.display()),
|
||||
));
|
||||
}
|
||||
for (file_path, code) in files {
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
#![doc = include_str!("../README.md")]
|
||||
//!
|
||||
//! ----
|
||||
//!
|
||||
//! _documents in the library_
|
||||
//!
|
||||
//! Generate register interface software from register map in XML.
|
||||
//!
|
||||
//! # Example
|
||||
|
@ -25,7 +31,7 @@
|
|||
//!
|
||||
//! # Overview
|
||||
//!
|
||||
//! 1. Convert [`roxmltree::Document`] to register map respresented with types defined in
|
||||
//! 1. Convert [`roxmltree::Document`] to register map represented with types defined in
|
||||
//! [`types`], filling missing parameters. See [`converter`].
|
||||
//! 2. Generate [`proc_macro2::TokenStream`] from register map produced in the previous step. See
|
||||
//! [`generator`].
|
||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -1,14 +1,27 @@
|
|||
use std::fs;
|
||||
use std::{fs, path};
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use endcap_sl_software_ri_generator::types;
|
||||
use itertools::Itertools;
|
||||
|
||||
/// Generate register interface from register map xml.
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about)]
|
||||
struct Args {
|
||||
/// Input XML register map.
|
||||
xml: path::PathBuf,
|
||||
/// Output directory.
|
||||
out: path::PathBuf,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
env_logger::init();
|
||||
log::debug!("logger enabled");
|
||||
let args = Args::parse();
|
||||
log::debug!("args: {:?}", args);
|
||||
|
||||
let xmlfile = fs::read_to_string("./csr.xml")?;
|
||||
let xmlfile = fs::read_to_string(args.xml)?;
|
||||
let doc = roxmltree::Document::parse_with_options(
|
||||
&xmlfile,
|
||||
roxmltree::ParsingOptions {
|
||||
|
@ -36,7 +49,7 @@ fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
endcap_sl_software_ri_generator::write_to_files(files, &std::path::PathBuf::from("out"))?;
|
||||
endcap_sl_software_ri_generator::write_to_files(files, &args.out)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
//! Get build metadata at compile time.
|
||||
//!
|
||||
//! See build.rs for more detail.
|
||||
|
||||
pub(crate) const GENERATOR_BUILD_TIMESTAMP: &str =
|
||||
env!("VERGEN_BUILD_TIMESTAMP", "Failed to get build timestamp");
|
||||
pub(crate) const GENERATOR_GIT_DESCRIBE: &str =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue