eirikpre / VSCode-SystemVerilog

SystemVerilog support in VS Code
MIT License
128 stars 50 forks source link

Compile fails on MacOS due to antlr4ts issue #132

Closed sw23 closed 3 years ago

sw23 commented 3 years ago

I downloaded the extension and ran into an issue compiling on MacOS.

Command:

npm run compile

Output:

...
src/compiling/ANTLRBackend.ts:4:36 - error TS2307: Cannot find module './ANTLR/grammar/build/SystemVerilogLexer' or its corresponding type declarations.

4 import { SystemVerilogLexer } from './ANTLR/grammar/build/SystemVerilogLexer';
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/compiling/ANTLRBackend.ts:5:37 - error TS2307: Cannot find module './ANTLR/grammar/build/SystemVerilogParser' or its corresponding type declarations.

5 import { SystemVerilogParser } from './ANTLR/grammar/build/SystemVerilogParser';

I noticed the ANTLR files were being created in the wrong path:

Correct: ./src/compiling/ANTLR/grammar/build/SystemVerilogLexer.ts
Actual:  ./src/compiling/ANTLR/grammar/build/src/compiling/ANTLR/grammar/SystemVerilogLexer.ts

I researched this issue and it turns out to be a problem with using relative paths with the antlr4ts package: https://github.com/tunnelvisionlabs/antlr4ts/issues/303

A new argument was added to address this: -Xexact-output-dir

I confirmed this fixes the issue on MacOS and doesn't cause issues building on Windows. I'll submit a PR with this fix.