Problem starting program (vcom) with multiple arguments in TCL

坚强是说给别人听的谎言 提交于 2020-01-24 21:09:05

问题


I'm trying to start a program (vcom) from a TCL script with extra options:

set compilationArgs "-quiet -93"
vcom $compilationArgs -work work polar2rect/sc_corproc.vhd

But when I run this, I get following error message:

# Model Technology ModelSim ALTERA vcom 6.5e Compiler 2010.02 Feb 27 2010
# ** Error: (vcom-1902) Option "-quiet -93" is either unknown, requires an argument, or was given with a bad argument.
# Use the -help option for complete vcom usage.
# /opt/altera/10.0/modelsim_ase/linuxaloem/vcom failed.

TCL seems to pass the two extra options (-quiet) and (-93) as one option to vcom. If I use only one of these two options it works. And if I run (vcom -93 -quiet -work work polar2rect/sc_corproc.vhd) it also works.

How can I fix this?

Thanks, Hendrik.


回答1:


The “problem” is that Tcl's being careful about managing spaces. This is very useful if you've got arguments with spaces in (such as many full filenames on Windows machines) but can sometimes be frustrating if you wanted the list to be broken up automatically. The fix is to indicate to Tcl that this is something that you want split into multiple words.

The best answer requires at least Tcl 8.5 (find out what version you've got with info tclversion, info patchlevel, or package require Tcl).

vcom {*}$compilationArgs -work work polar2rect/sc_corproc.vhd

If you're built against an older version of Tcl, you'll need this instead:

eval vcom $compilationArgs -work work polar2rect/sc_corproc.vhd

(Or this, to be officiously correct, but hardly anyone bothers for obvious reasons)

eval [list vcom] $compilationArgs [list -work work polar2rect/sc_corproc.vhd]

The version at the top with the expansion syntax ({*}) is best if supported. You can determine if it is easily enough; if it isn't, it's a syntax error.



来源:https://stackoverflow.com/questions/4497668/problem-starting-program-vcom-with-multiple-arguments-in-tcl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!