changed tcl procs abs_sym_path and rel_sym_path, now the real symbol filename is obtained by prepending one of the XSCHEM_LIBRARY_PATH paths until the symbol is found. This allows more than one directory levels in symbol references.

This commit is contained in:
schippes 2020-08-13 02:19:08 +02:00
parent c5f412bdb7
commit ea4513f9c5
5 changed files with 33 additions and 53 deletions

View File

@ -113,11 +113,6 @@ the schematic file `counter.sch' will be loaded.
After exiting XSCHEM you can load directly this schematic with the following commands, they are
all equivalent.
<pre class="code">
# xschem defaults its search to the
# XSCHEM_LIBRARY_PATH root path
# .sch may be omitted, it is added by default ...
xschem test
# or ...
xschem /home/schippes/x/test.sch
# or ...
xschem ${HOME}/schippes/x/test

View File

@ -28,13 +28,13 @@ p{padding: 15px 30px 10px;}
</li>
<li>
second approach: define a <kbd>XSCHEM_LIBRARY_PATH</kbd> that is a list of paths
one level above the directories containing .sym/.sch files
one or more levels above the directories containing .sym/.sch files
</li>
</ul>
<p>
In the first approach a '<kbd>npn.sym</kbd>' symbol placed in a schematic will be
saved as '<kbd>npn.sym</kbd>' in the .sch file, when loading back the parent
schematic xschem will go through the <kbd>XSCHEM_LIBRARY_PATH</kbd> and look for
schematic xschem will go through the elements of <kbd>XSCHEM_LIBRARY_PATH</kbd> and look for
a directory containing <kbd>npn.sym</kbd>.
</p>
@ -50,10 +50,19 @@ p{padding: 15px 30px 10px;}
<p>
The first approach is preferred by pcb hobbysts, people working on
small designs.
the second approach is preferred for big designs where a one level
the second approach is preferred for big designs where a one or more directory level
indirection is desired for symbols, so any symbol in xschem is given
as '<kbd>libname/symname.sym</kbd>' instead of just '<kbd>symname.sym</kbd>'<br>
as '<kbd>libname/symname.sym</kbd>' (one level directory specification in symbol references)
or '<kbd>libgroup/libname/symname.sym</kbd>' (2 level directory specification in symbol references)
instead of just '<kbd>symname.sym</kbd>'<br>
</p>
<p>
In any case the real path of the symbol reference is obtained by prepending
the XSCHEM_LIBRARY_PATH paths to the symbol reference until the resulting file is found in
the machine filesystem.
</p>
<p>
For VLSI / big designs I <b>strongly</b> suggest using the second approach,
just as an example i have the following dirs:
</p>

View File

@ -977,7 +977,7 @@ proc myload_set_home {dir} {
proc setglob {dir} {
global globfilter myload_files2
set myload_files2 [lsort [glob -nocomplain -directory $dir -tails -type d \{.*,*\}]]
set myload_files2 ${myload_files2}\ [lsort [glob -nocomplain -directory $dir -tails -type {f l} \{.*,$globfilter\}]]
set myload_files2 ${myload_files2}\ [lsort [glob -nocomplain -directory $dir -tails -type {f} \{.*,$globfilter\}]]
}
proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}}} {
@ -2411,28 +2411,16 @@ proc viewdata {data {ro {}}} {
proc rel_sym_path {symbol} {
global pathlist current_dirname
set lib_cell [get_cell $symbol]
set cell [file tail $symbol]
set name {}
if {[regexp {^/} $symbol]} {set symbol [file normalize $symbol]}
foreach path_elem $pathlist {
if { ![string compare $path_elem .] && [info exist current_dirname]} {
set path_elem $current_dirname
}
# libname/symname[.ext] and libname in $path_elem
# --> libname/symname
if { [file exists [file dirname "${path_elem}/${lib_cell}"]] &&
(![string compare $symbol $lib_cell ]) } {
set name ${lib_cell} ;# was lib_cell
# /.../path/.../libname/cellname[.ext] and libname in $path_elem
# --> libname/cellname
} elseif { (![string compare $symbol "${path_elem}/${lib_cell}" ])
&& [file exists [file dirname "${path_elem}/${lib_cell}"]] } {
set name ${lib_cell} ;# was lib_cell
} elseif { (![string compare $symbol "${path_elem}/${cell}" ])
&& [file exists "${path_elem}/${cell}"] } {
set name ${cell}
}
if {$name ne {} } { break}
set pl [string length $path_elem]
if { [string equal -length $pl $path_elem $symbol] } {
set name [string range $symbol [expr $pl+1] end]
}
}
if { ![string compare $name {} ] } {
# no known lib, so return full path
@ -2445,6 +2433,8 @@ proc rel_sym_path {symbol} {
# given a library/symbol return its absolute path
proc abs_sym_path {fname {ext {} } } {
global pathlist current_dirname
if {$fname eq {} } return {}
if {$::OS == "Windows"} {
if { [regexp {^[A-Za-z]\:/$} $fname ] } {
return $fname;
@ -2458,46 +2448,32 @@ proc abs_sym_path {fname {ext {} } } {
if { $ext ne {} } {
set fname [file rootname $fname]$ext
}
# transform ./file_or_path to file_or_path
# transform ./file_or_path to file_or_path, resolve (normalize) ../file_or_path
if { [regexp {^\.\./} $fname ] } {
set fname [file normalize $fname]
} elseif {[regexp {^\./} $fname ] } {
regsub {^\./} $fname {} fname
}
set lib_cell [get_cell $fname]
if {$fname eq {} } return {}
set name {}
# fname is of type libname/cellname[.ext] but not ./cellname[.ext] or
# ../cellname[.ext] and has a slash, so no cellname[.ext]
# no ./cell.sym
if {![string compare $fname $lib_cell ]} {
if { ![regexp {^/} $fname] } {
foreach path_elem $pathlist {
if { ![string compare $path_elem .] && [info exist current_dirname]} {
set path_elem $current_dirname
}
# libname/cellname and libname is in pathlist
# --> $pathlist/libname/cellname
# cellname and $pathlist/cellname exists
# --> $pathlist/cellname
if { [regexp {/} $fname] && [file exists "${path_elem}/${fname}"] } {
set name "$path_elem/$lib_cell"
set fullpath "$path_elem/$fname"
if { [file exists $fullpath] } {
set name $fullpath
break
}
if { [file exists "${path_elem}/${fname}"] &&
![regexp {/} $fname]
} {
set name "$path_elem/$lib_cell"
break
}
}
# if no abs path, no existing items elsewhere,
# set name relative to $current_dirname
if { ![string compare $name {}] } {
set name "$current_dirname/$fname"
}
}
if { ![string compare $name {}] } {
set name $fname
if { [regexp {^/} $fname] } {
set name $fname
} else {
set name "$current_dirname/$fname"
}
}
regsub {/\.$} $name {} name
return $name

View File

@ -1,4 +1,4 @@
v {xschem version=2.9.5_RC5 file_version=1.1}
v {xschem version=2.9.7 file_version=1.2}
G {type=label
format="*.alias @lab"
template="name=l1 sig_type=std_logic lab=xxx"}

View File

@ -1,4 +1,4 @@
v {xschem version=2.9.5_RC6 file_version=1.1}
v {xschem version=2.9.7 file_version=1.2}
G {}
V {}
S {}