Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Running ej from within a Cygwin shell #46

Merged
16 commits merged into from Jan 3, 2011
Commits
Jump to file or symbol
Failed to load files and symbols.
+636 −94
Split
View
@@ -23,34 +23,65 @@
</path>
<target name="all" depends="clean,weave,jar" />
- <target name="test" depends="all,testwoven" />
+ <target name="all_with_test" depends="all,weavetest" />
+ <target name="test" depends="all_with_test,testwoven" />
<target name="gen-interpreter">
- <echo message="generating interpreter code" />
+ <echo message="generating interpreter code ===================" />
<exec dir="src/main/java/erjang/beam/interpreter" executable="perl" input="src/main/java/erjang/beam/interpreter/ops.spec" failonerror="yes">
<arg value="-W"/>
<arg value="ErjIG_Main.pl"/>
</exec>
</target>
- <target name="compile" depends="gen-interpreter">
- <mkdir dir="target" />
+ <target name="create-dirs">
+ <mkdir dir="target" />
<mkdir dir="target/classes" />
<mkdir dir="target/test-classes" />
<mkdir dir="target/test-beam" />
<mkdir dir="target/compiled" />
+ </target>
+ <target name="gen-test-classes" description="generate test classes based on a generic one" depends="create-dirs">
+ <echo message="generating test classes ===================" />
+ <java classname="erjang.AllTests"
+ failonerror="true"
+ fork="true">
+ <jvmarg value="-Derjang.configfile=erjang_cfg.properties" />
+ <arg value="src/test/java/erjang/"/>
+ <classpath>
+ <pathelement location="target/test-classes" />
+ </classpath>
+ <classpath refid="erjang.classpath" />
+ </java>
+ </target>
+
+ <target name="compile" depends="gen-interpreter,create-dirs">
<echo message="Compiling src ===================" />
<javac debug="true" srcdir="src/main/java" destdir="target/classes" classpathref="erjang.classpath" deprecation="on" debuglevel="lines,vars,source"/>
</target>
<target name="testcompile" depends="compile">
<echo message="Compiling test ===================" />
- <javac debug="true" srcdir="src/test/java" destdir="target/test-classes" classpathref="erjang.classpath" debuglevel="lines,vars,source"/>
+ <javac debug="true" srcdir="src/test/java" destdir="target/test-classes" debuglevel="lines,vars,source">
+ <classpath>
+ <pathelement location="target/test-classes" />
+ </classpath>
+ <classpath refid="erjang.classpath" />
+ </javac>
</target>
+ <target name="gen-test-compile" depends="testcompile,gen-test-classes">
+ <echo message="Compiling generated test classes ===================" />
+ <javac debug="true" srcdir="src/test/java" destdir="target/test-classes" debuglevel="lines,vars,source">
+ <classpath>
+ <pathelement location="target/test-classes" />
+ </classpath>
+ <classpath refid="erjang.classpath" />
+ </javac>
+ </target>
- <target name="weave" depends="testcompile">
+ <target name="weave" depends="compile">
<echo message="Weaving files ===================" />
<java classname="kilim.tools.Weaver" fork="yes">
<classpath refid="erjang.classpath" />
@@ -61,6 +92,9 @@
<arg value="./target/classes" />
<arg line="./target/classes" />
</java>
+ </target>
+
+ <target name="weavetest" depends="gen-test-compile">
<echo message="Weaving test classes ==============" />
<java classname="kilim.tools.Weaver" fork="yes">
<classpath refid="erjang.testwovenclasspath" />
@@ -71,32 +105,45 @@
<arg value="./target/test-classes" />
<arg line="./target/test-classes" />
</java>
-
</target>
<target name="clean">
- <echo message="deleting files" />
+ <echo message="deleting files ===================" />
<delete>
<fileset defaultexcludes="no" dir="." includes="*~,#*,foo,bar,x,y" />
</delete>
<delete dir="./target" />
<delete dir="./.erj" />
+ <delete>
+ <fileset dir="src/test/java/erjang" includes="**/*_TEST.java" />
+ </delete>
</target>
-
<!-- This runs those tests depend on generated classes in testclasses-->
- <target name="testwoven">
+ <target name="testwoven" depends="weavetest">
<echo message="Testing Tasks ======================" />
<junit fork="yes" showoutput="yes">
- <formatter type="xml"/>
- <classpath refid="erjang.testwovenclasspath" />
+ <formatter type="brief" usefile="false"/>
+ <classpath>
+ <pathelement location="target/test-classes" />
+ <pathelement location="target/test-classes/generated/classes" />
+ </classpath>
+ <classpath refid="erjang.classpath" />
<assertions><enable /></assertions>
- <jvmarg value="-Derjang.configfile=erjang_cfg.properties" />
- <test name="erjang.AllTests" />
+ <jvmarg value="-Xmx1g"/>
+ <jvmarg value="-Xss50m"/>
+ <jvmarg value="-XX:PermSize=128m"/>
+ <jvmarg value="-XX:MaxPermSize=1024m"/>
+ <jvmarg value="-Derjang.configfile=erjang_cfg.properties" />
+ <batchtest>
+ <fileset dir="target/test-classes" includes="**/*_TEST.class" />
+ <!--<fileset dir="target/test-classes" includes="**/sizes_tests_erl_TEST.class" />-->
+ </batchtest>
</junit>
</target>
<target name="jar" description="generate the distribution" depends="clean,weave">
+ <echo message="Packaging ======================" />
<copy file="LICENSE" todir="classes/erjang" />
<copy file="NOTICE" todir="classes/erjang" />
<copy file="erjang_logo4.png" todir="classes/erjang" />
View
@@ -5,3 +5,5 @@ erjang.otp.version = R14B
# erjang.debug.port=true
# erjang.debug.inet=true
# erjang.dump_on_exit = true
+
+erjang.triq.root = c:/Users/pb/code/ex/triq
@@ -48,14 +48,8 @@
new erjang.driver.js.EJSDriver()
};
- public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
-
- Handler fh = new FileHandler("erjang.log");
- Logger.getLogger("").addHandler(fh);
- // Logger.getLogger("erjang").setLevel(Level.FINE);
- // Logger.getLogger("kilim.Task").setLevel(Level.FINEST);
-
- for (String m : MODULES) {
+ public static void load_modules_and_drivers() throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
+ for (String m : MODULES) {
ERT.load_module(EAtom.intern(m));
}
for (EDriver d : DRIVERS) {
@@ -64,20 +58,33 @@ public static void main(String[] args) throws ClassNotFoundException, Instantiat
for (EDriver d : extra_drivers) {
erjang.driver.Drivers.register(d);
}
+ }
- EAtom am_otp_ring0 = EAtom.intern("otp_ring0");
+ public static void start_otp_ring0(String[] args) {
+ EAtom am_otp_ring0 = EAtom.intern("otp_ring0");
EAtom am_start = EAtom.intern("start");
ESeq env = ERT.NIL;
ESeq argv = ERT.NIL;
-
+
for (int i = args.length-1; i >= 0; i--) {
argv = argv.cons(EBinary.fromString(args[i]));
}
-
+
EProc proc = new EProc(null, am_otp_ring0, am_start, ERT.NIL.cons(argv).cons(env));
ERT.run(proc);
proc.joinb();
+ }
+
+ public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
+
+ Handler fh = new FileHandler("erjang.log");
+ Logger.getLogger("").addHandler(fh);
+ // Logger.getLogger("erjang").setLevel(Level.FINE);
+ // Logger.getLogger("kilim.Task").setLevel(Level.FINEST);
+
+ load_modules_and_drivers();
+ start_otp_ring0(args);
System.out.println("done.");
}
@@ -116,16 +116,18 @@ public EExecDriverTask(EProc owner, ETuple2 name, EObject command, EObject portS
} else {
String cmd_path = env.get("PATH");
- for (String elm : cmd_path.split(File.pathSeparator)) {
- File dir = new File(elm);
- f = new File(dir, cmd[0]);
- if (f.exists()) {
- cmd[0] = f.getAbsolutePath();
- break;
- } else {
- f = null;
- }
- }
+ if (cmd_path != null) {
+ for (String elm : cmd_path.split(File.pathSeparator)) {
+ File dir = new File(elm);
+ f = new File(dir, cmd[0]);
+ if (f.exists()) {
+ cmd[0] = f.getAbsolutePath();
+ break;
+ } else {
+ f = null;
+ }
+ }
+ }
}
// System.err.println("lauching "+cmd[0]+" "+(f==null?"(not found)":""));
@@ -66,7 +66,14 @@
throw new RuntimeException(e);
}
}
-
+
+ private int getFDnumber(FileDescriptor fd) throws IllegalAccessException {
+ int res = FileDescriptor_FD.getInt(fd);
+ // Windows doesn't provide FD numbers - fallback to a usable dummy:
+ if (res == -1) res = 255;
+ return res;
+ }
+
/**
*
*/
@@ -1410,19 +1417,19 @@ public void run() {
case EFILE_MODE_READ: {
FileInputStream fo = new FileInputStream(file);
fd = fo.getChannel();
- res_fd = FileDescriptor_FD.getInt(fo.getFD());
+ res_fd = getFDnumber(fo.getFD());
break;
}
case EFILE_MODE_WRITE: {
FileOutputStream fo = new FileOutputStream(file);
fd = fo.getChannel();
- res_fd = FileDescriptor_FD.getInt(fo.getFD());
+ res_fd = getFDnumber(fo.getFD());
break;
}
case EFILE_MODE_READ_WRITE: {
RandomAccessFile rafff;
fd = (rafff=new RandomAccessFile(file,"rw")).getChannel();
- res_fd = FileDescriptor_FD.getInt(rafff.getFD());
+ res_fd = getFDnumber(rafff.getFD());
break;
}
default:
Oops, something went wrong.