fn emit_synopsys_tcl(
    sess: &Session,
    matches: &ArgMatches,
    targets: TargetSet,
    srcs: Vec<SourceGroup>,
    abort_on_error: bool,
) -> Result<()> {
    println!("{}", header_tcl(sess));
    println!("set search_path_initial $search_path");
    let relativize_path = |p: &std::path::Path| quote(&relativize_path(p, sess.root));
    for src in srcs {
        // Adjust the search path.
        println!("");
        println!("set search_path $search_path_initial");
        for i in src.clone().get_incdirs() {
            println!("lappend search_path {}", relativize_path(i));
        }

        // Emit analyze commands.
        separate_files_in_group(
            src,
            |f| match f {
                SourceFile::File(p) => match p.extension().and_then(std::ffi::OsStr::to_str) {
                    Some("sv") | Some("v") | Some("vp") => Some(SourceType::Verilog),
                    Some("vhd") | Some("vhdl") => Some(SourceType::Vhdl),
                    _ => None,
                },
                _ => None,
            },
            |src, ty, files| {
                let mut lines = vec![];
                lines.push(
                    tcl_catch_prefix(
                        &format!(
                            "analyze -format {}",
                            match ty {
                                SourceType::Verilog => {
                                    "sv"
                                }
                                SourceType::Vhdl => {
                                    "vhdl"
                                }
                            }
                        ),
                        abort_on_error,
                    )
                    .to_owned(),
                );

                // Add defines.
                let mut defines: Vec<(String, Option<String>)> = vec![];
                defines.extend(
                    src.defines
                        .iter()
                        .map(|(k, &v)| (k.to_string(), v.map(String::from))),
                );
                defines.extend(
                    targets
                        .iter()
                        .map(|t| (format!("TARGET_{}", t.to_uppercase()), None)),
                );
                add_defines_from_matches(&mut defines, matches);
                defines.sort();
                if !defines.is_empty() {
                    lines.push("-define {".to_owned());
                    for (k, v) in defines {
                        let mut s = format!("    {}", k);
                        if let Some(v) = v {
                            s.push('=');
                            s.push_str(&v);
                        }
                        lines.push(s);
                    }
                    lines.push("}".to_owned());
                }

                // Add files.
                lines.push("[list".to_owned());
                for file in files {
                    let p = match file {
                        SourceFile::File(p) => p,
                        _ => continue,
                    };
                    lines.push(format!("    {}", relativize_path(p)));
                }
                lines.push("]".to_owned());
                println!("");
                println!("{}", lines.join(" \\\n    "));
                if abort_on_error {
                    println!("{}", tcl_catch_postfix());
                }
            },
        );
    }
    println!("");
    println!("set search_path $search_path_initial");
    Ok(())
}
/// Emit a Synopsys Design Compiler compilation script.
Emit a Synopsys Design Compiler compilation script.
Emit a Synopsys Design Compiler compilation script .
fn emit_synopsys_tcl(
    sess: &Session,
    matches: &ArgMatches,
    targets: TargetSet,
    srcs: Vec<SourceGroup>,
    abort_on_error: bool,
) -> Result<()> {
    println!("{}", header_tcl(sess));
    println!("set search_path_initial $search_path");
    let relativize_path = |p: &std::path::Path| quote(&relativize_path(p, sess.root));
    for src in srcs {
        // Adjust the search path.
        println!("");
        println!("set search_path $search_path_initial");
        for i in src.clone().get_incdirs() {
            println!("lappend search_path {}", relativize_path(i));
        }
        // Emit analyze commands.
        separate_files_in_group(
            src,
            |f| match f {
                SourceFile::File(p) => match p.extension().and_then(std::ffi::OsStr::to_str) {
                    Some("sv") | Some("v") | Some("vp") => Some(SourceType::Verilog),
                    Some("vhd") | Some("vhdl") => Some(SourceType::Vhdl),
                    _ => None,
                },
                _ => None,
            },
            |src, ty, files| {
                let mut lines = vec![];
                lines.push(
                    tcl_catch_prefix(
                        &format!(
                            "analyze -format {}",
                            match ty {
                                SourceType::Verilog => {
                                    "sv"
                                }
                                SourceType::Vhdl => {
                                    "vhdl"
                                }
                            }
                        ),
                        abort_on_error,
                    )
                    .to_owned(),
                );
                // Add defines.
                let mut defines: Vec<(String, Option<String>)> = vec![];
                defines.extend(
                    src.defines
                        .iter()
                        .map(|(k, &v)| (k.to_string(), v.map(String::from))),
                );
                defines.extend(
                    targets
                        .iter()
                        .map(|t| (format!("TARGET_{}", t.to_uppercase()), None)),
                );
                add_defines_from_matches(&mut defines, matches);
                defines.sort();
                if !defines.is_empty() {
                    lines.push("-define {".to_owned());
                    for (k, v) in defines {
                        let mut s = format!("    {}", k);
                        if let Some(v) = v {
                            s.push('=');
                            s.push_str(&v);
                        }
                        lines.push(s);
                    }
                    lines.push("}".to_owned());
                }
                // Add files.
                lines.push("[list".to_owned());
                for file in files {
                    let p = match file {
                        SourceFile::File(p) => p,
                        _ => continue,
                    };
                    lines.push(format!("    {}", relativize_path(p)));
                }
                lines.push("]".to_owned());
                println!("");
                println!("{}", lines.join(" \\\n    "));
                if abort_on_error {
                    println!("{}", tcl_catch_postfix());
                }
            },
        );
    }
    println!("");
    println!("set search_path $search_path_initial");
    Ok(())
}
fn emit_synopsys_tcl ( sess : & Session , matches : & ArgMatches , targets : TargetSet , srcs : Vec < SourceGroup > , abort_on_error : bool , ) -> Result < ( ) > { println ! ( " " header_tcl ( sess ) ) ; println ! ( " " ) ; let relativize_path = | p : & std :: path :: Path | quote ( & relativize_path ( p , sess . root ) ) ; for src in srcs { // Adjust the search path. println ! ( " " ) ; println ! ( " " ) ; for i in src . clone ( ) . get_incdirs ( ) { println ! ( " " relativize_path ( i ) ) ; } // Emit analyze commands. separate_files_in_group ( src , | f | match f { SourceFile :: File ( p ) => match p . extension ( ) . and_then ( std :: ffi :: OsStr :: to_str ) { Some ( " " ) | Some ( " " ) | Some ( " " ) => Some ( SourceType :: Verilog ) , Some ( " " ) | Some ( " " ) => Some ( SourceType :: Vhdl ) , _ => None , } , _ => None , } , | src , ty , files | { let mut lines = vec ! [ ] ; lines . push ( tcl_catch_prefix ( & format ! ( " " match ty { SourceType Verilog { " " } SourceType Vhdl { " " } } ) , abort_on_error , ) . to_owned ( ) , ) ; // Add defines. let mut defines : Vec < ( String , Option < String > ) > = vec ! [ ] ; defines . extend ( src . defines . iter ( ) . map ( | ( k , & v ) | ( k . to_string ( ) , v . map ( String :: from ) ) ) , ) ; defines . extend ( targets . iter ( ) . map ( | t | ( format ! ( " " t to_uppercase ( ) ) , None ) ) , ) ; add_defines_from_matches ( & mut defines , matches ) ; defines . sort ( ) ; if ! defines . is_empty ( ) { lines . push ( " " . to_owned ( ) ) ; for ( k , v ) in defines { let mut s = format ! ( " " k ) ; if let Some ( v ) = v { s . push ( '=' ) ; s . push_str ( & v ) ; } lines . push ( s ) ; } lines . push ( " " . to_owned ( ) ) ; } // Add files. lines . push ( " " . to_owned ( ) ) ; for file in files { let p = match file { SourceFile :: File ( p ) => p , _ => continue , } ; lines . push ( format ! ( " " relativize_path ( p ) ) ) ; } lines . push ( " " . to_owned ( ) ) ; println ! ( " " ) ; println ! ( " " lines join ( " \\ \n " ) ) ; if abort_on_error { println ! ( " " tcl_catch_postfix ( ) ) ; } } , ) ; } println ! ( " " ) ; println ! ( " " ) ; Ok ( ( ) ) }
Emit a Synopsys Design Compiler compilation script.
Emit a Synopsys Design Compiler compilation script .
sess
&Session
matches
&ArgMatches
targets
TargetSet
srcs
Vec<SourceGroup>
abort_on_error
bool
sess
&Session
matches
&ArgMatches
targets
TargetSet
srcs
Vec<SourceGroup>
abort_on_error
bool