Skip to content
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

Fix build issues on Mac and Linux #252

Closed
wants to merge 1 commit into from

Conversation

carlansley
Copy link

This PR gets npm install working on Mac and Linux due to various path & case-sensitive filename issues. A fresh install also doesn't currently compile with the latest typescript 2.1, so fixed TS version at 2.0.8.

Haven't tested this under Windows.

@carlansley
Copy link
Author

Ok, clearly the tool behaves differently under Windows vs Unix wrt output paths...

@@ -14,7 +14,7 @@ import { ParseInfo } from "./atn/ParseInfo";
import { ProxyErrorListener } from "./ProxyErrorListener";
import { RecognitionException } from "./RecognitionException";
import { RuleContext } from "./RuleContext";
import { SuppressWarnings, NotNull } from "./decorators";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line prevents the module working on Linux

@sharwell
Copy link
Member

sharwell commented Dec 18, 2016

@carlansley ❗️ We won't be able to review this pull request until you submit a pull request to antlr/antlr4 to add your name to the contributors.txt agreement.

In lieu of signing the agreement, you could file issues here describing the specific problems you encountered and we could independently implement solutions to them. 😄

@carlansley carlansley closed this Dec 19, 2016
@BurtHarris
Copy link
Collaborator

@carlansley, are things working for you now?

@carlansley
Copy link
Author

Been a while since I've looked at this. It was working for me, not sure if I'd done something to make it work, but I think at least some of my issues at the time were fixed in master (e.g. case sensitive filename issues).

However on a fresh clone of master on my Mac, I now get thousands of tsc errors. Haven't tried on Linux. Looks like files got generated into the wrong places.


> antlr4ts-root@0.4.0-dev tsc /Users/carl/Development/antlr4ts
> tsc

benchmark/TestPerformance.ts(61,40): error TS2307: Cannot find module './gen/std/JavaLexer'.
benchmark/TestPerformance.ts(62,43): error TS2307: Cannot find module './gen/std-atn/JavaLexer'.
benchmark/TestPerformance.ts(63,44): error TS2307: Cannot find module './gen/lr/JavaLRLexer'.
benchmark/TestPerformance.ts(64,47): error TS2307: Cannot find module './gen/lr-atn/JavaLRLexer'.
benchmark/TestPerformance.ts(66,42): error TS2307: Cannot find module './gen/std/JavaParser'.
benchmark/TestPerformance.ts(67,45): error TS2307: Cannot find module './gen/std-atn/JavaParser'.
benchmark/TestPerformance.ts(68,46): error TS2307: Cannot find module './gen/lr/JavaLRParser'.
benchmark/TestPerformance.ts(69,49): error TS2307: Cannot find module './gen/lr-atn/JavaLRParser'.
benchmark/TestPerformance.ts(1276,24): error TS2532: Object is possibly 'undefined'.
benchmark/TestPerformance.ts(1282,9): error TS2532: Object is possibly 'undefined'.
benchmark/TestPerformance.ts(1282,66): error TS2345: Argument of type 'Lexer | undefined' is not assignable to parameter of type 'Lexer'.
  Type 'undefined' is not assignable to type 'Lexer'.
benchmark/TestPerformance.ts(1284,9): error TS2532: Object is possibly 'undefined'.
benchmark/TestPerformance.ts(1284,66): error TS2345: Argument of type 'Lexer | undefined' is not assignable to parameter of type 'Lexer'.
  Type 'undefined' is not assignable to type 'Lexer'.
benchmark/TestPerformance.ts(1288,7): error TS2532: Object is possibly 'undefined'.

...

@carlansley carlansley reopened this Mar 7, 2017
@carlansley carlansley closed this Mar 7, 2017
@BurtHarris
Copy link
Collaborator

BurtHarris commented Mar 7, 2017

Those missing files under ./gen are almost certainly an indication you need to run the whole build process by invoking npm install. They are generated by the Java-based tool which is built by maven, the tsc command has to come after that.

@carlansley
Copy link
Author

These errors occur during the npm install.

@BurtHarris
Copy link
Collaborator

Please make sure you have the build prerequisites (Java & Maven) installed. Executing mvn -v should give you a summary.

If the errors are due to that, we should probably add a more explicit check to the NPM build script in package.json.

@carlansley
Copy link
Author

Both are installed:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T11:41:47-05:00)
Maven home: /opt/local/share/java/maven3
Java version: 1.8.0_111, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.3", arch: "x86_64", family: "mac"

This has worked in this environment. I believe there is an issue with the generated ts files being put in the wrong directory location in Mac (and maybe Linux) environments.

@carlansley
Copy link
Author

Notice the first error from tsc:

benchmark/TestPerformance.ts(61,40): error TS2307: Cannot find module './gen/std/JavaLexer'.

JavaLexer has been successfully generated, but in the wrong place:

mbp:antlr4ts carl$ find . -name "JavaLexer.ts"
./benchmark/gen/std/benchmark/JavaLexer.ts
./benchmark/gen/std-atn/benchmark/JavaLexer.ts

It's putting it in ./gen/std/benchmark and not ./gen/std that TestPerformance.ts is expecting.

@BurtHarris
Copy link
Collaborator

During build, this is what I see on Windows generating those files. I notice it includes a "\.\" that seems like it might be related:

> antlr4ts-root@0.4.0-dev antlr4ts-benchmark-std C:\code\antlr4ts
> antlr4ts -visitor benchmark/Java.g4 -DbaseImportPath=../../../src -o benchmark/gen/std

Generating file 'C:\code\antlr4ts\benchmark\gen\std\.\JavaLexer.ts' for grammar 'benchmark/Java.g4'
Generating file 'C:\code\antlr4ts\benchmark\gen\std\.\JavaLexer.tokens' for grammar 'benchmark/Java.g4'
Generating file 'C:\code\antlr4ts\benchmark\gen\std\.\JavaParser.ts' for grammar 'benchmark/Java.g4'
Generating file 'C:\code\antlr4ts\benchmark\gen\std\.\JavaListener.ts' for grammar 'benchmark/Java.g4'
Generating file 'C:\code\antlr4ts\benchmark\gen\std\.\JavaVisitor.ts' for grammar 'benchmark/Java.g4'
Generating file 'C:\code\antlr4ts\benchmark\gen\std\.\Java.tokens' for grammar 'benchmark/Java.g4'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants