-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bat
52 lines (39 loc) · 1.52 KB
/
build.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@ECHO OFF
SET GRAMMARNAME=MetaGram
SET PARSERNAME=MetaGramParser
SET LEXERNAME=MetaGramLexer
SET PACKAGE=metagram.antlr
SET JAVA_TARGET_DIR=java
SET JAVA_TARGET_SRC_DIR=src/metagram/antlr
SET JAVA_TARGET_OUT_DIR=out
IF NOT DEFINED JAVA_HOME (
ECHO JAVA_HOME environment variable is not defined ! Create it and indicate JDK location as value.
EXIT /B 203
)
IF NOT DEFINED CLASSPATH (
ECHO CLASSPATH environment variable is not defined ! Create it with ".;antlr_jar_path" as value.
EXIT /B 203
)
IF EXIST "%JAVA_TARGET_DIR%/%JAVA_TARGET_SRC_DIR%" RMDIR /S /Q "%JAVA_TARGET_DIR%/%JAVA_TARGET_SRC_DIR%"
ECHO Compile grammar to Java...
"%JAVA_HOME%\bin\java.exe" -cp "%CLASSPATH%" org.antlr.v4.Tool "%LEXERNAME%.g4" -o "%JAVA_TARGET_DIR%/%JAVA_TARGET_SRC_DIR%/" -package "%PACKAGE%" -no-listener -visitor
IF errorlevel 1 (
ECHO Compilation failed!
EXIT /B %errorlevel%
)
"%JAVA_HOME%\bin\java.exe" -cp "%CLASSPATH%" org.antlr.v4.Tool "%PARSERNAME%.g4" -o "%JAVA_TARGET_DIR%/%JAVA_TARGET_SRC_DIR%/" -package "%PACKAGE%" -no-listener -visitor
IF errorlevel 1 (
ECHO Compilation failed!
EXIT /B %errorlevel%
)
ECHO Compilation completed.
ECHO Build Java...
IF EXIST "%JAVA_TARGET_DIR%/%JAVA_TARGET_OUT_DIR%" RMDIR /S /Q "%JAVA_TARGET_DIR%/%JAVA_TARGET_OUT_DIR%"
MKDIR "%JAVA_TARGET_DIR%/%JAVA_TARGET_OUT_DIR%"
"%JAVA_HOME%\bin\javac.exe" -cp "%CLASSPATH%" -d "%JAVA_TARGET_DIR%/%JAVA_TARGET_OUT_DIR%/" "%JAVA_TARGET_DIR%/%JAVA_TARGET_SRC_DIR%/%GRAMMARNAME%"*.java
IF errorlevel 1 (
ECHO Build failed!
EXIT /B %errorlevel%
)
ECHO Build completed.
EXIT /B 0