grammar: Restructure ANTLR generation to remove temp dir
Have ANTLR generate code directly in the pkg/grammar directory rather
than a temp dir and then moved into place. The moving was never really
necessary - there was concern that applying the patch might cause
conflicts, but not so.
@@ -38,7 +38,6 @@ coverage: ## Run tests and verify the test coverage remains high
./scripts/test-with-coverage.sh 85
test: ## Run tests without coverage
- rm -rf pkg/grammar/temp
$(TESTEXE)
BINARY := sysl
@@ -72,27 +71,22 @@ install: build ## Install the sysl binary into $(GOPATH)/bin
cp ./dist/sysl $(GOPATH)/bin
clean: ## Clean temp and build files
- rm -rf release dist pkg/grammar/temp
+ rm -rf release dist
# Autogen rules
ANTLR = java -jar pkg/antlr-4.7-complete.jar
-GRAMMARS = pkg/grammar/SyslParser.g4 \
- pkg/grammar/SyslLexer.g4
+ANTLR_GO = $(ANTLR) -Dlanguage=Go -lib $(@D) $^
-antlr: $(GRAMMARS)
- $(ANTLR) -Dlanguage=Go -lib pkg/grammar -o pkg/grammar/temp $^
+grammar: pkg/grammar/sysl_lexer.go pkg/grammar/sysl_parser.go ## Regenerate the grammars
-pkg/grammar/sysl_parser.go: antlr
- cp pkg/grammar/temp/pkg/grammar/sysl*parser*.go pkg/grammar
+pkg/grammar/sysl_parser.go: pkg/grammar/SyslParser.g4
+ $(ANTLR_GO)
git apply pkg/grammar/antlr4-datarace-fix-parser.go.diff
-pkg/grammar/sysl_lexer.go: antlr
- cp pkg/grammar/temp/pkg/grammar/sysl*lexer*.go pkg/grammar
+pkg/grammar/sysl_lexer.go: pkg/grammar/SyslLexer.g4
+ $(ANTLR_GO)
git apply pkg/grammar/antlr4-datarace-fix-lexer.go.diff
-
-grammar: pkg/grammar/sysl_lexer.go pkg/grammar/sysl_parser.go ## Regenerate the grammars
-
pkg/proto_old/sysl.pb.go: pkg/proto_old/sysl.proto
protoc -I pkg/proto_old -I $(GOPATH)/src --go_out=pkg/proto_old/ sysl.proto
