rust_hdl
rust_hdl copied to clipboard
'is_third_party' does not disable errors in third party libraries
Hello
I am using vhdl-ls linter via TerosHDL integration in VS Code. I have a vhld_ls.toml file like this in the root of my repository:
[libraries]
vunit_lib.files = ['.venv/Lib/site-packages/vunit/**/*.vhd']
vunit_lib.is_third_party = true
mylib.files = ['sources/**/*.vhd']
mylib.is_third_party = false
Adding vunit_lib like this was the only way I found to have vhdl-ls recognize vunit_lib usage within my testbenches successfully.
My expectation is that the vunit_lib.is_third_party = true statement will supress all errors within vunit_lib.
The reality is hundreds of errors, all in vunit_lib:
Is this a bug, working as intened, or is there perhaps a different way to ignore/supress/exclude errors in a particular folder?
I find this behavior very annoying. If I don't include vunit_lib files, I get errors in my testbench, if I do, I get errors in vunit_lib itself.
Thank you.
Kind regards Jakub
The is_third_party switch only turns off warnings for some libraries (e.g., unused declaration). So this is intended behaviour. I think the solution is to not include vunit by a glob expression, but instead spell out each file explicitly (also see the example project). I believe that vunit and others have several files for various VHDL standards. Adding both files will cause the duplicate declarations error.
@JakubFranek, you can't use glob expressions to include all of the VHDL files from within the VUnit distribution, because some of them (or many of them) conflict (note the error messages "A primary unit has already been declared...").
One alternative is to export your VUnit file list and use the from_vunit_export.py script from the example project that @Schottkyc137 referenced to parse that into a vhdl_ls.toml file, then manually edit it to remove the sources that are inside of the vunit_out/preprocessed directory.
It would be great if VHDL-LS gave us an exclude_files option for each library so you could specify a glob for files and then override it for specific files that need to be left out.
This was discussed in #40, but only include was added. It would be great to have an exclude list too, especially for Vunit!
Thank you all for your responses. I explicitly listed the files in the vhdl_ls.toml and the errors are now gone, so that's great.
That being said I think an exclude option would be a good thing to implement. In my limited experience, every linter I encountered in other languages supported exclusion of files and even specific rules or checks.
@JakubFranek, you can also use VHDL-by-HGB to automatically generate a vhdl_ls.toml from your vunit-project
you can also use VHDL-by-HGB to automatically generate a vhdl_ls.toml from your vunit-project
When TerosHDL generates its .vhdl_ls.toml file from a VUnit run.py file, the sources all point into the vunit_out/preprocessed directory, which is not ideal when you want to work directly on the original source files, since VHDL-LS will try to process the original files as non-project files. Does the VHDL-by-HGB extension make any attempt to resolve the paths of the original source files, or does it just use the paths exported by run.py --export-json?
...Actually, I just noticed that the preprocessed path is caused by the settings vu.enable_location_preprocessing() or vu.enable_check_preprocessing() (and maybe others?) so maybe this is not a universal issue and could be solved in VUnit... Related issue: https://github.com/VUnit/vunit/issues/678