ToTamire / HDL_Linter

Verilog and SystemVerilog linting with Sublime Text 4
GNU General Public License v3.0
2 stars 0 forks source link

Linter doesn't support importing packages #1

Open albert-sun opened 1 year ago

albert-sun commented 1 year ago

When importing packages using the syntax import package_name::*, HDL_Linter outputs error vlog-13006, for instance: Error: ./projects/axi/axi4_lite_subordinate.sv(4): (vlog-13006) Could not find the package (axi4_pkg). Design read will continue [...]. This is caused by the work directory being cleaned after every compile - perhaps a setting to disable the cleaning could help mitigate this issue. The solution is still somewhat hacky since you have to lint the package file first and then your original file, but it somewhat solves the issue.

# Remove compilation library
path = os.path.join(self.work_path, 'work')
+ if not settings.skip_clean():
+     try:
+         shutil.rmtree(path)
+     except OSError:
+         print(f"HDL_Linter: Can\'t remove `{path}` directory.")
- try:
-     shutil.rmtree(path)
- except OSError:
-     print(f"HDL_Linter: Can\'t remove `{path}` directory.")
ToTamire commented 1 year ago

Cleaning work directory is required to avoid issues. This solution ensures that all files are up-to-date during compilation and also result of compilation is always the same.

Bypassing directory cleanup can cause the following issues:

Linter currently supports importing packages when you provide information where the package is. The simplest workaround is `include "package_name.svh" above import package_name::*;

I understand that this solution may be inconvenient, so probably HDL_Linter needs something better. Maybe new setting incfiles, similar to incdirs?

    // Specify files to be included in compilation
    // Possible values: list of "<path>"
    // Example value: ["C:/project1/packages_1/package_name1.svh", "C:/project1/packages_2/package_name2.svh"]
    // Default value: []
    "incfiles": [

    ]

What do you think about this?