add python sdist build. separate out the deploy stuff with scaffolding to fill in.

This commit is contained in:
Terence Parr 2015-01-16 11:52:14 -08:00
parent c97df3d883
commit e6f3911fa5
3 changed files with 129 additions and 28 deletions

View File

@ -12,7 +12,7 @@
[Release notes](https://github.com/antlr/antlr4/releases)
*For installation and other getting started information, see [Getting started with v4](https://theantlrguy.atlassian.net/wiki/display/ANTLR4/Getting+Started+with+ANTLR+v4).*
*For installation and other getting started information, see [Getting started with v4](https://theantlrguy.atlassian.net/wiki/display/ANTLR4/Getting+Started+with+ANTLR+v4). You can also read about [building ANTLR itself](https://github.com/antlr/antlr4/wiki/How-to-build-ANTLR-itself).*
## The Definitive ANTLR 4 Reference
You can buy a book [The Definitive ANTLR 4 Reference](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference)

66
bild.py
View File

@ -8,7 +8,7 @@ This script uses my experimental build tool http://www.bildtool.org
In order to build the complete ANTLR4 product with Java, CSharp, Python 2/3, and JavaScript
targets, do the following from a UNIX command line. Windows build using this script
is not yet supported. Please use the mvn build or ant build.
is not yet supported.
You will also need python 2.7, python 3.4, node.js and mono (on Mac/Linux)
@ -23,6 +23,8 @@ git clone git@github.com:antlr/antlr4-csharp.git
git clone git@github.com:antlr/antlr4-javascript.git
cd antlr4
./bild.py tests
This script must be run from the main antlr4 directory.
"""
# bootstrap by downloading bilder.py if not found
@ -165,6 +167,30 @@ def mkjar():
mkjar_runtime() # now build the runtime jar
def javascript(): # TODO @eric
# No build to do. Just zip up the sources
pass
def csharp(): # TODO @eric
# For C#, there are 2 equivalent projects: a VisualStudio one and a Xamarin one.
# You can build on windows using msbuild and on mono using xbuild and pointing to the corresponding runtime project.
pass
def python_sdist(): # TODO @eric
# No build it to do. Just zip up the sources
cmd = ["python", "setup.py", "sdist"]
savedir= os.getcwd()
try:
os.chdir(uniformpath(PYTHON2_TARGET))
exec_and_log(cmd)
os.chdir(uniformpath(PYTHON3_TARGET))
exec_and_log(cmd)
finally:
os.chdir(savedir)
def tests():
require(mkjar)
junit_jar, hamcrest_jar = load_junitjars()
@ -233,31 +259,6 @@ def install():
VERSION)
def deploy():
require(mkjar)
require(mksrc)
require(mkdoc)
binjar = uniformpath("dist/antlr4-%s-complete.jar" % VERSION)
docjar = uniformpath("dist/antlr4-%s-complete-javadoc.jar" % VERSION)
srcjar = uniformpath("dist/antlr4-%s-complete-sources.jar" % VERSION)
mvn_deploy(binjar, docjar, srcjar, repositoryid="ossrh", groupid="org.antlr",
artifactid="antlr4", pomfile="tool/pom.xml", version=VERSION)
binjar = uniformpath("dist/antlr4-%s.jar" % VERSION)
docjar = uniformpath("dist/antlr4-%s-javadoc.jar" % VERSION)
srcjar = uniformpath("dist/antlr4-%s-sources.jar" % VERSION)
mvn_deploy(binjar, docjar, srcjar, repositoryid="ossrh", groupid="org.antlr",
artifactid="antlr4-runtime", pomfile="runtime/Java/pom.xml", version=VERSION)
def clean(dist=False):
if dist:
rmdir("dist")
rmdir("out")
rmdir("gen3")
rmdir("gen4")
rmdir("doc")
def mksrc():
srcpath = "runtime/Java/src/org"
srcfiles = allfiles(srcpath, "*.java");
@ -328,9 +329,20 @@ def mkdoc():
zip(tooldoc, "doc/JavaTool")
def all():
def clean(dist=False):
if dist:
rmdir("dist")
rmdir("out")
rmdir("gen3")
rmdir("gen4")
rmdir("doc")
def all(): # Note: deployment is in a separate file deploy.py
clean(True)
mkjar()
javascript()
python_sdist()
tests()
mkdoc()
mksrc()

89
deploy.py Normal file
View File

@ -0,0 +1,89 @@
#!/usr/bin/env python
import os
"""
This script uses my experimental build tool http://www.bildtool.org
This script deploys artifacts created by bild.py.
Windows build using this script is not yet supported.
cd /usr/local/antlr/antlr4
./deploy.py maven_snapshot
or
./deploy.py maven
or
./deploy.py pypi
or
./deploy.py # does "all"
This script must be run from the main antlr4 directory.
"""
# bootstrap by downloading bilder.py if not found
import urllib
import os
if not os.path.exists("bilder.py"):
print "bootstrapping; downloading bilder.py"
urllib.urlretrieve(
"https://raw.githubusercontent.com/parrt/bild/master/src/python/bilder.py",
"bilder.py")
# assumes bilder.py is in current directory
from bilder import *
VERSION = "4.5"
def maven_snapshot():
require(mkjar)
require(mksrc)
require(mkdoc)
binjar = uniformpath("dist/antlr4-%s-complete.jar" % VERSION)
docjar = uniformpath("dist/antlr4-%s-complete-javadoc.jar" % VERSION)
srcjar = uniformpath("dist/antlr4-%s-complete-sources.jar" % VERSION)
mvn_deploy(binjar, docjar, srcjar, repositoryid="ossrh", groupid="org.antlr",
artifactid="antlr4", pomfile="tool/pom.xml", version=VERSION)
binjar = uniformpath("dist/antlr4-%s.jar" % VERSION)
docjar = uniformpath("dist/antlr4-%s-javadoc.jar" % VERSION)
srcjar = uniformpath("dist/antlr4-%s-sources.jar" % VERSION)
mvn_deploy(binjar, docjar, srcjar, repositoryid="ossrh", groupid="org.antlr",
artifactid="antlr4-runtime", pomfile="runtime/Java/pom.xml", version=VERSION)
def maven(): # TODO
pass
def pypi(): # TODO
pass
def nuget(): # TODO
pass
def website():
"""
Push all jars, source, target artifacts etc.
"""
# There is no JavaScript project i.e; nothing to "build" it's just a bunch of files that I zip.
pass
def all(): # Note: building artifacts is in a separate file bild.py
maven()
pypi()
nuget()
website()
processargs(globals()) # E.g., "python bild.py all"