2014-07-02 09:18:17 +08:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
sys.path.append(os.path.abspath("/Users/parrt/github/bild"))
|
|
|
|
|
|
|
|
from bilder import *
|
|
|
|
|
2014-07-02 12:33:26 +08:00
|
|
|
VERSION = "4.4"
|
2014-07-04 02:46:28 +08:00
|
|
|
PYTHON2_TARGET = "../antlr4-python2"
|
|
|
|
PYTHON3_TARGET = "../antlr4-python3"
|
|
|
|
CSHARP_TARGET = "../antlr4cs"
|
|
|
|
|
|
|
|
TARGETS = {"Python2":PYTHON2_TARGET, "Python3":PYTHON3_TARGET, "CSharp":CSHARP_TARGET}
|
2014-07-02 09:18:17 +08:00
|
|
|
|
|
|
|
def parsers():
|
2014-07-04 02:46:28 +08:00
|
|
|
antlr3("tool/src/org/antlr/v4/parse", "gen", package="org.antlr.v4.parse")
|
|
|
|
antlr3("tool/src/org/antlr/v4/codegen", "gen", package="org.antlr.v4.codegen", args=["-lib","tool/src/org/antlr/v4/parse"])
|
|
|
|
antlr4("runtime/Java/src/org/antlr/v4/runtime/tree/xpath", "gen", package="org.antlr.v4.runtime.tree.xpath")
|
2014-07-02 09:18:17 +08:00
|
|
|
|
|
|
|
def compile():
|
2014-07-04 02:46:28 +08:00
|
|
|
require(parsers)
|
|
|
|
cp = uniformpath("out")+os.pathsep+ \
|
|
|
|
os.path.join(JARCACHE,"antlr-3.5.1-complete.jar")+os.pathsep+ \
|
|
|
|
"runtime/Java/lib/org.abego.treelayout.core.jar"
|
|
|
|
args = ["-Xlint", "-Xlint:-serial", "-g"]
|
|
|
|
javac("runtime/JavaAnnotations/src/", "out", version="1.6", cp=cp, args=args)
|
|
|
|
javac("runtime/Java/src", "out", version="1.6", cp=cp, args=args)
|
|
|
|
javac("tool/src", "out", version="1.6", cp=cp, args=args)
|
|
|
|
javac("gen", "out", version="1.6", cp=cp, args=args)
|
|
|
|
# pull in targets
|
|
|
|
for t in TARGETS:
|
|
|
|
javac(TARGETS[t]+"/tool/src/org/antlr/v4/codegen/"+t+"Target.java",
|
|
|
|
"out/org/antlr/v4/tool/templates/codegen",
|
|
|
|
version="1.6", cp=cp, args=args)
|
2014-07-02 09:18:17 +08:00
|
|
|
|
|
|
|
def mkjar():
|
2014-07-04 02:46:28 +08:00
|
|
|
require(compile)
|
|
|
|
copytree(src="tool/resources", dst="out")
|
|
|
|
manifest = \
|
|
|
|
"""Version: %s
|
2014-07-02 12:33:26 +08:00
|
|
|
Main-Class: org.antlr.v4.Tool
|
2014-07-02 09:18:17 +08:00
|
|
|
""" % VERSION
|
2014-07-04 02:46:28 +08:00
|
|
|
# unjar required libraries
|
|
|
|
unjar("runtime/Java/lib/org.abego.treelayout.core.jar", trgdir="out")
|
|
|
|
unjar(os.path.join(JARCACHE,"antlr-3.5.1-complete.jar"), trgdir="out")
|
|
|
|
# pull in target templates
|
|
|
|
for t in TARGETS:
|
|
|
|
copyfile(TARGETS[t]+"/tool/resources/org/antlr/v4/tool/templates/codegen/"+t+"/"+t+".stg",
|
|
|
|
"out/org/antlr/v4/tool/templates/codegen/"+t)
|
|
|
|
jar("dist/antlr-"+VERSION+"-complete.jar", srcdir="out", manifest=manifest)
|
2014-07-02 09:18:17 +08:00
|
|
|
|
|
|
|
def all():
|
2014-07-04 02:46:28 +08:00
|
|
|
mkjar()
|
2014-07-02 09:18:17 +08:00
|
|
|
|
|
|
|
def clean():
|
2014-07-04 02:46:28 +08:00
|
|
|
rmdir("out")
|
|
|
|
rmdir("gen")
|
|
|
|
rmdir("doc")
|
2014-07-03 09:31:38 +08:00
|
|
|
|
|
|
|
def mkdoc():
|
2014-07-04 02:46:28 +08:00
|
|
|
mkdir("doc/Java")
|
|
|
|
mkdir("doc/JavaTool")
|
|
|
|
javadoc(srcdir="runtime/Java/src", trgdir="doc/Java", packages="org.antlr.v4.runtime")
|
|
|
|
javadoc(srcdir="tool/src", trgdir="doc/JavaTool", packages="org.antlr.v4")
|
|
|
|
# build stack merge PredictionContext and ATNState images from DOT
|
|
|
|
# DOT Images are in runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/
|
|
|
|
# Gen into E.g., doc/Java/org/antlr/v4/runtime/atn/images/SingletonMerge_DiffRootSamePar.svg
|
|
|
|
mkdir("doc/Java/org/antlr/v4/runtime/atn/images")
|
|
|
|
for f in glob.glob("runtime/Java/src/main/dot/org/antlr/v4/runtime/atn/images/*.dot"):
|
|
|
|
dot(f, "doc/Java/org/antlr/v4/runtime/atn/images", format="svg")
|
|
|
|
zip("doc/antlr4-runtime.zip", "doc/Java")
|
|
|
|
zip("doc/antlr4-tool.zip", "doc/JavaTool")
|
2014-07-03 10:10:36 +08:00
|
|
|
|
|
|
|
processargs(globals()) # E.g., "python bild.py all"
|