From: hssig on
Hi,

I have the following directory structure:

directory "F:/tests" containing directories "compA", "compB",
"root_for_script"


contents of "root_for_script": file_list.lst
"file_list.lst" has the following entries:
.../compA/file_list.lst


contents of compA : compA.vhd, file_list.lst
"file_list.lst" has the following entries:
compA.vhd
.../compB/compB.vhd

contents of compB:
compB.vhd


In directory "root_for_script" I have the following tcl script (so
far):


cd F:/tests/root_for_script
set fd [open "../compA/file_list.lst" r]
set file_list [split [read $fd] "\n"]

foreach file $file_list {
puts "$file "

if [regexp {.vhdl?$} $file] {
vcom $file
} else {
puts "Found list file"
}
}


I want the script to start looking at ths base list "f:/tests/
root_for_script/file_list.lst"
for VHDL files and other file lists. VHDL files are compiled (vcom),
file lists are opened
and so on ... So the steps would be:

1. Open "f:/tests/root_for_script/file_list.lst"
2. Open "../compA/file_list.lst"
3. Compile "compA.vhd" and "../compB/compB.vhd"
Point 3 would lead to the following paths in the compile commands
vcom ../compA/compA.vhd
vcom ../compA/../compB/compB.vhd)


How can I do that task ? I am not sure how to structure the tcl
script, thank you for your proposals.


Cheers,
hssig
From: hssig on
Hi,

I have tried to use procedures in the following manner:

#
##################################################################################################
# procedures

proc p_compile {file} {

# vcom $file
puts "Compiling $file"
}


proc p_open {file} {
set fd [open $file r]
puts "Opening $file"
set file_list [split [read $fd] "\n"]
foreach file $file_list {
puts "@T3: $file "

if [regexp {.vhdl?$} $file] {
puts "Found VHDL file"
p_compile $file
} else {
puts "Found list file"
p_open $file}
}
}


#
###################################################################################################
# main program

cd F:/tests/root_for_script
set fd [open "file_list.lst" r]
set file_list [split [read $fd] "\n"]

foreach file $file_list {
puts "$file "

if [regexp {.vhdl?$} $file] {
puts "Found VHDL file"
p_compile $file [file join [file tail $file]]
} else {
puts "Found list file"
puts "@T1 $file"
p_open $file
}
}



When executing the tcl script I get the following log messages: (tkcon
v2.5, Tcl v8.5.7)

Found list file
@T1 ../compA/file_list.lst
Opening ../compA/file_list.lst
@T3: compA.vhd
Found VHDL file
Compiling compA.vhd
@T3: ../compB/compB.vhd
Found VHDL file
Compiling ../compB/compB.vhd


But the compiling paths should be:
vcom ../compA/compA.vhd
vcom ../compA/../compB/compB.vhd

How can I pass the correct path when calling the procedures
recursively ? Starting point is the location of the script.

Cheers,
hssig