Skip to content

Commit

Permalink
script: dump template json
Browse files Browse the repository at this point in the history
  • Loading branch information
micprog committed Apr 4, 2023
1 parent a1358aa commit 16a8fd5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cmd/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub fn new() -> Command {
PossibleValue::new("vivado"),
PossibleValue::new("vivado-sim"),
PossibleValue::new("precision"),
PossibleValue::new("template_json"),
]),
)
.arg(
Expand Down Expand Up @@ -214,6 +215,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
"vivado" => concat(vivado_targets, &["synthesis"]),
"vivado-sim" => concat(vivado_targets, &["simulation"]),
"precision" => vec!["precision", "fpga", "synthesis"],
"template_json" => vec![],
_ => unreachable!(),
}
} else {
Expand Down Expand Up @@ -291,6 +293,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
&& format != "vsim"
&& format != "vcs"
&& format != "riviera"
&& format != "template_json"
{
return Err(Error::new(
"vsim/vcs-only options can only be used for 'vcs', 'vsim' or 'riviera' format!",
Expand All @@ -301,6 +304,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
|| matches.get_flag("only-sources")
|| matches.get_flag("no-simset"))
&& !format.starts_with("vivado")
&& format != "template_json"
{
return Err(Error::new(
"Vivado-only options can only be used for 'vivado' format!",
Expand All @@ -327,6 +331,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
"vivado" => emit_template(sess, VIVADO_TCL_TPL, matches, targets, srcs),
"vivado-sim" => emit_template(sess, VIVADO_TCL_TPL, matches, targets, srcs),
"precision" => emit_precision_tcl(sess, matches, targets, srcs, abort_on_error),
"template_json" => emit_template(sess, JSON, matches, targets, srcs),
_ => unreachable!(),
}
}
Expand Down Expand Up @@ -447,6 +452,8 @@ fn add_defines_from_matches(defines: &mut Vec<(String, Option<String>)>, matches
}
}

static JSON: &str = "json";

fn emit_template(
sess: &Session,
template: &str,
Expand Down Expand Up @@ -586,6 +593,11 @@ fn emit_template(

tera_context.insert("vivado_filesets", &vivado_filesets);

if template == "json" {
println!("{:#}", tera_context.into_json());
return Ok(());
}

print!(
"{}",
tera_obj
Expand Down

0 comments on commit 16a8fd5

Please sign in to comment.