Eingabedatei ist ein tcl-Skript und es sieht aus wie:Tcl: Wie variable Zeichenfolge ersetzen?
set PATH /user/abc/path
set PATH2 /user/abc/path2
...
read_verilog ${PATH}/src/vlog/code_1.v
read_verilog $PATH/src/vlog/code_2.v
read_vhdl ${PATH2}/src/vhd/code_3.vh
read_vhdl $PATH2/src/vhd/code_4.vh
[other commands ...]
überprüfen müssen, ob die Quelldatei vorhanden sind und auszudrucken ist Dateien keine existieren. Falls keine der Datei vorhanden ist, die Ausgabe wie folgt aussieht:
read_verilog ${PATH}/src/vlog/code_1.v
read_verilog $PATH/src/vlog/code_2.v
read_vhdl ${PATH2}/src/vhd/code_3.vh
read_vhdl $PATH2/src/vhd/code_4.vh
Und unten ist mein Skript:
#!/usr/bin/tclsh
set input_file "input.tcl"
set input_fpt [open $input_file r]
set input_lines_all [read $input_fpt]
set input_lines [split $input_lines_all "\n"]
set PATH /user/abc/PATH
set PATH /user/dgc/PATH2
foreach line $input_lines {
if { [string match "read_verilog *" $line] || [string match "read_vhdl*" $line] } {
regexp {[read_verilog read_vhdl] (.*)} $line matched file
if { [string match {*[{P]AT[H}]*} $file] } {
set abs_file [string map {${PATH} /user/abc/PATH} $file]
} elseif { [string match "*PATH2*" $file] } {
set abs_file [string map {${PATH2} /user/abc/PATH2} $file]
} else {
set abs_file $file
}
if { ![file exists $abs_file] } {
puts $line
}
}
}
Mein Skript $ PATH nicht überprüfen und sicher nicht, ob es ein mehr effiziente Art und Weise, um den Job zu erledigen.
check puts befehl –