-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve include directives relative to each file #109
base: develop
Are you sure you want to change the base?
Conversation
This commit changes how ADMS resolves include directives. ADMS currently does this relative to the current working directory, each user-provided search path and the ADMS include directory, in that order. This is not typical of Verilog-A compilers or compilers in general. Following are just a few examples of why the current ADMS behaviour is undesirable. Example 1: A.va `include "sub/B.va" sub/B.va `include "C.va" sub/C.va // desired file C.va // stray file "C.va" will always find the stray file in the current working directory. Example 2: dir/A.va `include "sub/B.va" dir/sub/B.va `include "C.va" dir/sub/C.va // desired file dir/C.va // stray file "sub/B.va" will only find the desired file if "dir" is manually added to the search path. "C.va" would then always find the stray file, unless "dir/sub" had been previously added to the search path. Either of these actions could have unintended consequences. This commit addresses these limitations. ADMS will now first look for files relative to the directory of the file containing the include directives and will behave the same way regardless of the current working directory or how many nested include directives are used, without the need to specify additional user-defined search paths.
I'm not 100% sure on whether this will work on Windows yet. Also, the |
Is it possible to check this builds correctly on Windows? |
The adms_dirname function needs to be used in preprocessorLex.l, but it is currently a static function declared in admsXml.c. Making it accessible from libadmsElement allows both files to use it. The dependencies, adms_split_new and adms_free_strlist, have also been relocated, as well as the related functions adms_basename and adms_filename, for consistency.
I have copied the static function dirname from admsXml.c along with its two dependencies. Ideally, both instances of this function should be cleaned up. At this stage, I just want to get include directives to evaluate relative paths correctly.
Commit 71c6d35 contains all changes to in the pull request to |
This commit changes how ADMS resolves include directives. ADMS currently
does this relative to the current working directory, each user-provided
search path and the ADMS include directory, in that order. This is not
typical of Verilog-A compilers or compilers in general.
Following are just a few examples of why the current ADMS behaviour is
undesirable.
Example 1:
Example 2:
This commit addresses these limitations.
ADMS will now first look for files relative to the directory of the
file containing the include directives and will behave the same way
regardless of the current working directory or how many nested include
directives are used, without the need to specify additional user-defined
search paths.