bild.py works to build c# now.

This commit is contained in:
Terence Parr 2015-06-02 20:06:35 -07:00
parent 29db15736d
commit 6333674588
6 changed files with 61 additions and 77 deletions

View File

@ -7,7 +7,7 @@
<component name="ProjectKey">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="false" assert-keyword="true" jdk-15="true">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

80
bild.py
View File

@ -84,11 +84,16 @@ def parsers():
version=BOOTSTRAP_VERSION, package="org.antlr.v4.runtime.tree.xpath")
def compile():
"""
Compile tool, runtime, tool tests, runtime tests into ./out dir
Depends on treelayout jar, antlr v3, junit/hamcrest
"""
require(parsers)
require(regen_tests)
cp = uniformpath("out") + os.pathsep + \
os.path.join(JARCACHE, "antlr-3.5.2-complete.jar") + os.pathsep + \
"runtime/Java/lib/org.abego.treelayout.core.jar" + os.pathsep
srcpath = ["gen3", "gen4", "runtime/Java/src", "runtime-testsuite/src", "tool/src"]
srcpath = ["gen3", "gen4", "runtime/Java/src", "tool/src"]
args = ["-Xlint", "-Xlint:-serial", "-g", "-sourcepath", string.join(srcpath, os.pathsep)]
for sp in srcpath:
javac(sp, "out", version="1.6", cp=cp, args=args)
@ -96,16 +101,18 @@ def compile():
cp += os.pathsep + uniformpath("out") \
+ os.pathsep + junit_jar \
+ os.pathsep + hamcrest_jar
# pull in targets' code gen and test rigs
# pull in targets' code gen
for t in TARGETS:
javac(TARGETS[t] + "/tool/src", "out", version="1.6", cp=cp, args=args)
javac(TARGETS[t] + "/tool/test", "out", version="1.6", cp=cp, args=args, skip=['org/antlr/v4/test/rt'])
javac(TARGETS[t] + "/tool/src", "out", version="1.6", cp=cp, args=args)
# pull in generated runtime tests and runtime test support code
for t in RUNTIME_TEST_TEMPLATES:
javac(TARGETS[t] + "/tool/test", "out", version="1.6", cp=cp, args=args)
javac('gen/test/'+t, "out", version="1.6", cp=cp, args=args)
def mkjar_complete():
require(compile)
copytree(src="tool/resources", trg="out") # messages, Java code gen, etc...
copytree(src="runtime-testsuite/resources", trg="out") # templates for generating unit tests
manifest = \
"Main-Class: org.antlr.v4.Tool\n" +\
"Implementation-Title: ANTLR 4 Tool\n" +\
@ -254,6 +261,11 @@ def python_sdist():
def regen_tests():
"""
Generate all runtime Test*.java files for all targets into ./gen/TargetName
They will all get compiled in compile() so we have all together but
can drop from final jar in mkjar().
"""
# first compile runtime-testsuite; only needs ST and junit
junit_jar, hamcrest_jar = load_junitjars()
download("http://www.stringtemplate.org/download/ST-4.0.8.jar", JARCACHE)
@ -270,7 +282,6 @@ def regen_tests():
for targetName in RUNTIME_TEST_TEMPLATES:
java(classname="org.antlr.v4.testgen.TestGenerator", cp="out/testsuite:"+cp,
progargs=['-o', 'gen/test/'+targetName, '-templates', RUNTIME_TEST_TEMPLATES[targetName]])
#javac("gen/test", "out/test", version="1.6", cp=cp, args=args) # compile generated runtime tests
print_and_log("test generation complete")
@ -301,48 +312,52 @@ def test_javascript():
def test_target(t):
require(regen_tests) # gens and compiles
require(_mkjar)
juprops = ["-D%s=%s" % (p, test_properties[p]) for p in test_properties]
args = ["-nowarn", "-Xlint", "-Xlint:-serial", "-g"]
print_and_log("Testing %s ..." % t)
try:
test(t, juprops, args)
print t + " tests complete"
except:
print t + " tests failed"
except Exception as e:
print t + " tests failed: ", e
def test(t, juprops, args):
def test(target, juprops, args):
junit_jar, hamcrest_jar = load_junitjars()
srcdir = uniformpath('gen/test/'+t)
dstdir = uniformpath("out/test/"+t)
srcdir = uniformpath('gen/test/'+target)
dstdir = uniformpath("out/test/"+target)
# Prefix CLASSPATH with individual target tests
cp = dstdir + os.pathsep + uniformpath("dist/antlr4-" + VERSION + "-complete.jar")
thisjarwithjunit = cp + os.pathsep + hamcrest_jar + os.pathsep + junit_jar
skip = []
if t=='Java':
if target=='Java':
# don't test generator
skip = [ "/org/antlr/v4/test/rt/gen/", "TestPerformance.java", "TestGenerator.java" ]
elif t=='Python2':
elif target=='Python2':
# need BaseTest located in Py3 target
base = uniformpath(TARGETS['Python3'] + "/tool/test")
skip = [ "/org/antlr/v4/test/rt/py3/" ]
javac(base, "out/test/"+t, version="1.6", cp=thisjarwithjunit, args=args, skip=skip)
javac(base, "out/test/"+target, version="1.6", cp=thisjarwithjunit, args=args, skip=skip)
skip = []
elif t=='JavaScript':
elif target=='JavaScript':
# don't test browsers automatically, this is overkill and unreliable
browsers = ["safari","chrome","firefox","explorer"]
skip = [ uniformpath(srcdir + "/org/antlr/v4/test/rt/js/" + b) for b in browsers ]
javac(srcdir, trgdir="out/test/"+t, version="1.6", cp=thisjarwithjunit, args=args, skip=skip)
# copy resource files required for testing
files = allfiles(srcdir)
for src in files:
if not ".java" in src and not ".stg" in src and not ".DS_Store" in src:
dst = src.replace(srcdir, uniformpath("out/test/"+t))
# only copy files from test dirs
if os.path.exists(os.path.split(dst)[0]):
shutil.copyfile(src, dst)
junit("out/test/"+t, cp=uniformpath("dist/antlr4-" + VERSION + "-complete.jar"), verbose=False, args=juprops)
javac(srcdir, trgdir="out/test/"+target, version="1.6", cp=thisjarwithjunit, args=args, skip=skip)
print "DONE"
# copy any resource files required for testing
for t in TARGETS:
root = TARGETS[t] + "/tool/test"
files = allfiles(root)
for src in files:
if not ".java" in src and not ".stg" in src and not os.path.basename(src).startswith("."):
dst = uniformpath(src.replace(root, "out"))
# print src, dst
if os.path.exists(os.path.split(dst)[0]):
shutil.copyfile(src, dst)
junit("out/test/"+target, cp='/Users/parrt/antlr/code/antlr4/out:'+uniformpath("dist/antlr4-" + VERSION + "-complete.jar"),
verbose=False, args=juprops)
def install(): # mvn installed locally in ~/.m2, java jar to /usr/local/lib if present
@ -444,7 +459,7 @@ def target_artifacts():
csharp()
def clean(dist=False):
def clean(dist=True):
if dist:
rmdir("dist")
rmdir("out")
@ -464,5 +479,16 @@ def all():
install()
clean()
# def duh():
# for t in TARGETS:
# root = TARGETS[t] + "/tool/test"
# files = allfiles(root)
# print t
# for src in files:
# if not ".java" in src and not ".stg" in src and not os.path.basename(src).startswith("."):
# dst = uniformpath(src.replace(root, "out"));
# print src, dst
# if os.path.exists(os.path.split(dst)[0]):
# shutil.copyfile(src, dst)
processargs(globals()) # E.g., "python bild.py all"

View File

@ -9,7 +9,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>

View File

@ -1,5 +1,5 @@
TestFile(file) ::= <<
package org.antlr.v4.runtime.test.java;
package org.antlr.v4.test.runtime.java;
import org.antlr.v4.test.tool.BaseTest;
import org.junit.Test;

View File

@ -106,7 +106,6 @@ import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@ -469,48 +468,7 @@ public abstract class BaseTest {
ioe.printStackTrace(System.err);
}
// List<String> errors = new ArrayList<String>();
// for (Diagnostic diagnostic : diagnostics.getDiagnostics()) {
// errors.add(
// String.valueOf(diagnostic.getLineNumber())+
// ": " + diagnostic.getMessage(null));
// }
// if ( errors.size()>0 ) {
// System.err.println("compile stderr from: "+cmdLine);
// System.err.println(errors);
// return false;
// }
return ok;
/*
File outputDir = new File(tmpdir);
try {
Process process =
Runtime.getRuntime().exec(args, null, outputDir);
StreamVacuum stdout = new StreamVacuum(process.getInputStream());
StreamVacuum stderr = new StreamVacuum(process.getErrorStream());
stdout.start();
stderr.start();
process.waitFor();
stdout.join();
stderr.join();
if ( stdout.toString().length()>0 ) {
System.err.println("compile stdout from: "+cmdLine);
System.err.println(stdout);
}
if ( stderr.toString().length()>0 ) {
System.err.println("compile stderr from: "+cmdLine);
System.err.println(stderr);
}
int ret = process.exitValue();
return ret==0;
}
catch (Exception e) {
System.err.println("can't exec compilation");
e.printStackTrace(System.err);
return false;
}
*/
}
protected ErrorQueue antlr(String grammarFileName, boolean defaultListener, String... extraOptions) {
@ -842,8 +800,8 @@ public abstract class BaseTest {
"java", "-classpath", tmpdir+pathSep+CLASSPATH,
className, new File(tmpdir, "input").getAbsolutePath()
};
//String cmdLine = "java -classpath "+CLASSPATH+pathSep+tmpdir+" Test " + new File(tmpdir, "input").getAbsolutePath();
//System.out.println("execParser: "+cmdLine);
// String cmdLine = Utils.join(args, " ");
// System.err.println("execParser: "+cmdLine);
Process process =
Runtime.getRuntime().exec(args, null, new File(tmpdir));
StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());

View File

@ -2,7 +2,7 @@
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Python" name="Python">
<configuration sdkName="" />
<configuration sdkName="Python 2.7.8 (/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/bin/python2.7)" />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
@ -21,7 +21,6 @@
<sourceFolder url="file://$MODULE_DIR$/../gen/test/Java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/../.idea" />
<excludeFolder url="file://$MODULE_DIR$/../antlr4-maven-plugin" />
<excludeFolder url="file://$MODULE_DIR$/../build" />
<excludeFolder url="file://$MODULE_DIR$/../runtime" />
</content>
<content url="file://$MODULE_DIR$/../../antlr4-csharp/tool/resources">
@ -33,7 +32,7 @@
<content url="file://$MODULE_DIR$/../../antlr4-csharp/tool/test">
<sourceFolder url="file://$MODULE_DIR$/../../antlr4-csharp/tool/test" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="runtime" />
<orderEntry type="library" scope="TEST" name="ST-4.0.8" level="application" />
@ -44,6 +43,7 @@
<orderEntry type="library" name="maven-plugin-annotations-3.4" level="application" />
<orderEntry type="library" name="plexus-compiler-api-1.5.3" level="application" />
<orderEntry type="library" name="plexus-build-api-0.0.7" level="application" />
<orderEntry type="library" name="Python 2.7.8 (/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/bin/python2.7) interpreter library" level="application" />
</component>
<component name="PluginUploader.PluginUploadConfigurable">
<option name="ARCHIVE_PATH" />