Open BurtHarris opened 7 years ago
> antlr4ts -visitor benchmark/Java.g4 -DbaseImportPath=../../../src -o benchmark/gen/std
On Windows the output it looks like this:
Generating file 'C:\projects\antlr4ts\benchmark\gen\std\.\JavaLexer.ts' for grammar 'benchmark/Java.g4'
...
While on Linux:
Generating file '/home/travis/build/BurtHarris/antlr4ts/benchmark/gen/std/benchmark/JavaLexer.ts' for grammar 'benchmark/Java.g4'
...
Here's a link to show what the build output in this area should look like in context: https://ci.appveyor.com/project/sharwell/antlr4ts/build/1.0.473#L1187 vs https://travis-ci.org/BurtHarris/antlr4ts#L1184
This seems to be related outputDirectory
in Tool.java, perhaps code in TypeScriptTool.java near line 82.
The ANTLR tool treats input paths differently if they contain a path separator - but for this check it only uses the default path separator for the current platform. For cases where you have one fixed build command that runs on both Windows and non-Windows systems, you must avoid specifying directory names in the set of input files passed to antlr4ts. See commit 27b9316 for the resolution as applied to this repository.
I was confused by the title of #307. The fix in that PR is isn't very general, only fixes the problem in this one project. I'm now running into the same problem trying to build Mike's cool looking antlr4-c3. Sam, is it possible to fix the tool to be more platform-neutral? Perhaps Mike's antlr PR above can help.
@sharwell it sounds like this new -Xexact-output-dir
option is the key to addressing this issue.
I suspect taking advantage of it will be easy, but I've forgotten how to go about merging in and update from the antlr4/antlr4 repository. Any pointers to details?
Hi, I'm having a similar issue on MacOS when trying to build two .g4 files (one being the lexer and the other being the parser). The two files are located in a sub directory src/tom/grammar
. When I run the build script antlr4ts -visitor *.g4
, npm panics and displays the error:
error(160): TomParser.g4:4:17: cannot find tokens file './TomLexer.tokens'
It seems like antlr4 is looking at the current working directory (or root) instead of the location of the files. However, the workaround mentioned here resolves the issue.
When the Java part of the antlr4ts-cli tool gets invoked with a grammar file specification of
benchmark/Java.g4
, and-o benchmark/gen/std
, the output goes tobenchmark/gen/std/./Java.ts
on Windowsbenchmark/gen/std/benchmark/Java.ts
on LinuxThis discrepancy currently causes later failures on Linux builds as reported in #252 & #283 during the tsc step, because tsc doesn't find the file in the expected location.
Workaround The problem seems to be related to specifying relative path names on the
antlr4ts
command line. If your grammar files are in a subdirectory, it may work best to setup a script to run the tool in yourpackage.json
something like this:instead of