OSVVM / OSVVM-Scripts

OSVVM project simulation scripts. Scripts are tedious. These scripts simplify the steps to compile your project for simulation
Other
8 stars 13 forks source link

LinkLibraryDirectory and relative paths #30

Closed fhuemer closed 1 year ago

fhuemer commented 1 year ago

When a relative path is passed to LinkLibraryDirectory, the path is interpreted relative to the CurrentSimulationDirectory. I guess that is the intended behavior. However, would it be possible to add a variant of this command that uses the CurrentWorkingDirectory instead.

In any case, it may be a good idea, to specify this more explicitly in the documentation in README.rst.

JimLewis commented 1 year ago

First, thanks for the feedback on the documentation. As the author of both the code and the document, it is easy to overlook details like this. So your comments will help the document quality.

Right now, to work with local paths you can do:

LinkLibraryDirectory [file join ::osvvm::CurrentWorkingDirectory YourLocalPath]

But that is ugly. We could shorten it to the following, which gives it a similar capability to command switches - without the complexity being pushed into LinkLibraryDirectory.

LinkLibraryDirectory [OsvvmScriptPath YourLocalPath]

Does that sound good? The name I suggested there is flexible, so if you like something else, let me know.

fhuemer commented 1 year ago

Yes, I like this idea! The naming scheme is fine as well. You could also change CurrentWorkingDirectory to CurrentScriptDirectory in the documentation (the term only appears in one place anyway). This would IMO avoid the ambiguity with the term "working directory" (i.e., is it the directory the simulator runs in or the one the current script is located in).

Edit: I just saw that CurrentWorkingDirectory is, of course, also an internal variable. So the proposed change might not be such a good idea after all. However, to improve the documentation you could introduce the concept of the CurrentWorkingDirectory a little sooner, e.g., in the paragraph:

"Note that there are no paths to the files. For OSVVM commands that use paths, the path is always relative to the directory the script is located in unless an absolute path is specified."

You could add something like "which is referred to as the CurrentWorkingDirectory" in parenthesis.

To keep things consistent OsvvmScriptPath could also be named OsvvmWorkingPath or OsvvmCurrentWorkingPath or something along those lines.

JimLewis commented 1 year ago

Since the variable name is CurrentWorkingDirectory, I named the function, JoinWorkingDirectory. It is now in the dev release. Its usage is as we discussed:

LinkLibraryDirectory [JoinWorkingDirectory YourLocalPath]

I also implemented ChangeWorkingDirectory in the Dev release. This allows a script to be in one directory and the sources to be in a different directory - one ChangeWorkingDirectory call and all the sources can be referenced without adding a path.

Sorry this took so long. I was hyper focused on getting a beta of an Ethernet (Phy and MAC) xMii VC that implementes GMII/RGMII/MII/RMII done.

JimLewis commented 1 year ago

This is already done on the dev branch. Will be released to main shortly.