summaryrefslogtreecommitdiffstats
path: root/make/build-junit.xml
diff options
context:
space:
mode:
Diffstat (limited to 'make/build-junit.xml')
-rw-r--r--make/build-junit.xml256
1 files changed, 256 insertions, 0 deletions
diff --git a/make/build-junit.xml b/make/build-junit.xml
new file mode 100644
index 0000000..34f0a66
--- /dev/null
+++ b/make/build-junit.xml
@@ -0,0 +1,256 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="GlueGenTest" basedir=".">
+
+ <description>JUNIT Tests GlueGen</description>
+
+ <!-- On jpackage.org-compatible systems, antlr.jar can be found in /usr/share/java -->
+ <available property="antlr.jar" file="/usr/share/java/antlr.jar"
+ value="/usr/share/java/antlr.jar"/>
+
+ <property name="gluegen.root" value=".." />
+
+ <import file="gluegen-cpptasks.xml" />
+
+ <condition property="rootrel.build" value="build">
+ <not>
+ <isset property="rootrel.build"/>
+ </not>
+ </condition>
+
+ <target name="init" depends="gluegen.properties.load.user">
+
+ <!-- Call the external config validator script to make sure the config is ok and consistent -->
+ <ant antfile="validate-properties.xml" inheritall="true"/>
+
+ <property name="project.root" value=".." />
+
+ <property name="test.base.dir" value="${project.root}/src/junit" />
+ <property name="test.junit.rel" value="com/jogamp/gluegen/test/junit" />
+ <property name="test.junit.dir" value="${test.base.dir}/${test.junit.rel}" />
+
+ <property name="test.dir" value="${project.root}/${rootrel.build}/test"/>
+ <property name="results" value="${test.dir}/results" />
+ <property name="build" value="${test.dir}/build" />
+ <property name="build.gen" value="${build}/gensrc"/>
+ <property name="build.java" value="${build}/classes"/>
+ <property name="build.obj" value="${build}/obj"/>
+ <property name="build.lib" value="${build}/natives"/>
+
+ <property name="test.junit.rootrel" value="src/junit/${test.junit.rel}" />
+ <property name="build.gen.rootrel" value="${rootrel.build}/test/build/gensrc"/>
+
+ <mkdir dir="${test.dir}"/>
+ <mkdir dir="${results}"/>
+ <mkdir dir="${build}"/>
+ <mkdir dir="${build.gen}"/>
+ <mkdir dir="${build.java}"/>
+ <mkdir dir="${build.obj}"/>
+ <mkdir dir="${build.lib}"/>
+
+ <property name="gluegen.jar" value="${gluegen.root}/${rootrel.build}/gluegen.jar" />
+ <property name="gluegen-rt.jar" value="${gluegen.root}/${rootrel.build}/gluegen-rt.jar" />
+ <property name="junit.jar" value="${gluegen.root}/make/lib/junit-4.5.jar" />
+
+ <property name="gluegen-test.jar" value="${build}/gluegen-test.jar" />
+
+ <path id="gluegen.classpath">
+ <pathelement location="${gluegen.jar}" />
+ <pathelement location="${antlr.jar}" />
+ </path>
+
+ <path id="gluegen_rt.classpath">
+ <pathelement location="${gluegen-rt.jar}" />
+ </path>
+
+ <path id="junit.compile.classpath">
+ <pathelement location="${junit.jar}" />
+ <pathelement location="${gluegen-rt.jar}" />
+ </path>
+
+ <path id="junit.run.classpath">
+ <pathelement location="${junit.jar}" />
+ <pathelement location="${gluegen-rt.jar}" />
+ <pathelement location="${gluegen-test.jar}" />
+ </path>
+
+ <echo message="test.base.dir: ${test.base.dir} "/>
+ <echo message="test.junit.dir: ${test.junit.dir} "/>
+ <echo message="test.dir: ${test.dir} "/>
+ <echo message="results: ${results} "/>
+ <echo message="build: ${build} "/>
+ <echo message="build.gen: ${build.gen} "/>
+ <echo message="build.java: ${build.java} "/>
+ <echo message="build.obj: ${build.obj} "/>
+ <echo message="build.lib: ${build.lib} "/>
+
+ <!-- Add the GlueGen and BuildStaticGLInfo tasks to ANT -->
+ <taskdef name="gluegen" classname="com.sun.gluegen.ant.GlueGenTask"
+ classpathref="gluegen.classpath" />
+ <taskdef name="staticglgen" classname="com.sun.gluegen.ant.StaticGLGenTask"
+ classpathref="gluegen.classpath" />
+ </target>
+
+ <target name="java.build" depends="java.generate">
+ <echo message=" - - - compiling all java files - - - "/>
+
+ <javac destdir="${build.java}"
+ source="1.5" debug="true"
+ fork="yes"
+ verbose="true"
+ debuglevel="lines,vars,source">
+ <classpath refid="junit.compile.classpath"/>
+ <src path="${test.base.dir}"/>
+ <src path="${build.gen}" />
+ </javac>
+
+ <jar destfile="${gluegen-test.jar}">
+ <fileset dir="${build.java}">
+ <include name="${test.junit.rel}/*.class"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="c.configure" depends="gluegen.cpptasks.detect.os,gluegen.cpptasks.setup.compiler">
+ <property name="compiler.cfg.id" value="${compiler.cfg.id.base}" />
+ <property name="linker.cfg.id" value="${linker.cfg.id.base}" />
+ </target>
+
+ <target name="rename.mingw.dll" if="isMingW">
+ <move file="${src}" tofile="${dest}" />
+ </target>
+
+ <target name="rename.dylib" if="isOSX">
+ <move file="${src}" tofile="${dest}" />
+ </target>
+
+ <macrodef name="c.build">
+ <attribute name="c.compiler.src.files" />
+ <attribute name="compiler.cfg.id" />
+ <attribute name="linker.cfg.id" />
+ <attribute name="output.lib.name" />
+ <sequential>
+ <echo message="Compiling @{output.lib.name}" />
+ <echo message=" c.compiler.src.files @{c.compiler.src.files}" />
+ <echo message=" compiler.cfg.id @{compiler.cfg.id}" />
+ <echo message=" linker.cfg.id @{linker.cfg.id}" />
+ <echo message=" output.lib.name @{output.lib.name}" />
+
+ <!-- NOTE: the value of the debug and optimise attributes will not be overridden if already set externally -->
+ <property name="c.compiler.debug" value="false" />
+ <!-- Optimise flags one of { none, size, speed, minimal, full, aggressive, extreme, unsafe } -->
+ <property name="c.compiler.optimise" value="none" />
+
+ <condition property="c.compiler.use-debug"><istrue value="${c.compiler.debug}"/></condition>
+
+ <cc outtype="shared"
+ objdir="${build.obj}"
+ outfile="${build.lib}/@{output.lib.name}"
+ optimize="${c.compiler.optimise}"
+ debug="${c.compiler.debug}"
+ multithreaded="true"
+ exceptions="false"
+ rtti="false">
+
+ <fileset dir="${project.root}"><patternset refid="@{c.compiler.src.files}"/></fileset>
+
+ <compiler extends="@{compiler.cfg.id}" >
+ <includepath path="${test.junit.dir}"/>
+ <includepath path="${build.gen}/native"/>
+ </compiler>
+
+ <linker extends="@{linker.cfg.id}">
+ <syslibset dir="${java.lib.dir.platform}" libs="jawt" if="@{output.lib.name}.useLibJAWT"/>
+ <syslibset dir="${java.lib.dir.platform}/server" libs="jvm" if="@{output.lib.name}.useLibJVM"/>
+ </linker>
+ </cc>
+
+ <!-- FIXME: this is a hack; the cpptask should have an option to change the
+ suffix or at least understand the override from dylib to jnilib -->
+ <antcall target="rename.dylib" inheritRefs="true">
+ <param name="src" value="${build.lib}/lib@{output.lib.name}.dylib" />
+ <param name="dest" value="${build.lib}/lib@{output.lib.name}.jnilib" />
+ </antcall>
+
+ <!-- FIXME: this is a hack; the cpptask should have an option to change the
+ suffix or at least understand the override from dylib to jnilib -->
+ <antcall target="rename.mingw.dll" inheritRefs="true">
+ <param name="src" value="${build.lib}/lib@{output.lib.name}.so" />
+ <param name="dest" value="${build.lib}/@{output.lib.name}.dll" />
+ </antcall>
+ </sequential>
+ </macrodef>
+
+ <target name="junit.compile" depends="init, java.generate, java.build, c.build"/>
+
+ <target name="junit.run" depends="init">
+ <!-- Perform the junit tests-->
+ <mkdir dir="${results}"/>
+ <junit forkmode="once" showoutput="true" fork="true" haltonerror="true">
+ <jvmarg value="-Djava.library.path=${build.lib}"/>
+ <jvmarg value="-Drootrel.build=${rootrel.build}"/>
+ <formatter usefile="false" type="plain"/>
+ <formatter usefile="true" type="xml"/>
+ <classpath refid="junit.run.classpath"/>
+
+ <batchtest todir="${results}">
+ <fileset dir="${build.java}">
+ <include name="${test.junit.rel}/Test*"/>
+ </fileset>
+ <formatter usefile="false" type="brief"/>
+ <formatter usefile="true" type="xml"/>
+ </batchtest>
+ </junit>
+ </target>
+
+ <!--
+
+ Hook all junit.test* ..
+
+ -->
+
+ <target name="java.generate" depends="junit.test1.java.generate"/>
+
+ <target name="c.build" depends="c.configure, junit.test1.c.build" unless="build.javaonly" />
+
+ <!--
+
+ junit.test1
+
+ -->
+
+ <target name="junit.test1.java.generate">
+ <echo message=" - - - junit.test1.java.generate" />
+
+ <dirset id="stub.includes.fileset.test" dir="." includes="${test.junit.dir}/*" />
+
+ <gluegen src="${test.junit.dir}/test1-gluegen.c"
+ outputRootDir="${build.gen}"
+ config="${test.junit.dir}/test1-gluegen.cfg"
+ literalInclude="${test.junit.dir}"
+ includeRefid="stub.includes.fileset.test"
+ emitter="com.sun.gluegen.JavaEmitter">
+ <!-- emitter="com.sun.gluegen.procaddress.ProcAddressEmitter" -->
+ <classpath refid="gluegen.classpath" />
+ </gluegen>
+ </target>
+
+ <target name="junit.test1.c.build" unless="build.javaonly" >
+ <patternset id="junit.test1.c.src.files">
+ <include name="${test.junit.rootrel}/test1.c"/>
+ <include name="${build.gen.rootrel}/native/BindingTest1_JNI.c"/>
+ </patternset>
+
+ <c.build c.compiler.src.files="junit.test1.c.src.files"
+ output.lib.name="test1"
+ compiler.cfg.id="${compiler.cfg.id}"
+ linker.cfg.id="${linker.cfg.id}"/>
+ </target>
+
+ <!--
+
+ junit.test2
+
+ -->
+
+</project>