summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-08 02:22:12 +0200
committerSven Gothel <[email protected]>2010-04-08 02:22:12 +0200
commit7cc4bb2a8bcc4c16b6a12826abbd874bf38f9dc1 (patch)
treeeb932553d0f9b36dbe6d703356502bf352cc6eca
parent82ac66ba1e7494b0a76a2063f0d56d3b785c6c31 (diff)
http://jogamp.org/bugzilla/show_bug.cgi?id=393
Fixed junit test: test1 - Create seperate native libraries to reflect a real world example: test1 - the library to bind to (no more declaring __stdcall @nn functions) BindingTest1p1 - the dynamic fixed linkage binding test1p1, references dynamic library test1 at linktime. BindingTest1p2 - the dynamic runtime linkage binding test1p2, loads dynamic library test1 at runtime. Generic: - gluegen-cpptasks-base.xml - target 'gluegen.cpptasks.detect.os' Set new property 'system.env.library.path' DYLD_LIBRARY_PATH (macosx) LD_LIBRARY_PATH (unix) PATH (windows) - target 'gluegen.cpptasks.striplibs' Strips the symbols out of the native libraries in case c.compiler.debug is false. Maybe configured with the properties: c.strip.tool, c.strip.args - Using system.env.library.path in junit call to find the test1 library in case of runtime linkage and lookup (test1p2). - Use gluegen.cpptasks.striplibs for all native libs .. - Added macosx32 in analogy to macosx64, both defaults to true now - com.jogamp.common.os.WindowsDynamicLinkerImpl:lookupSymbol() - Added lookup for __stdcall @nn (stepping alignment 4, max-args: 12) in case no undecorated __cdecl symbol is found. Fixed Windows platform: - Use proper path.seperator on Windows. - test1.dll needs proper soname inside for fixed linkage (test1p1) hence the output name must be test1.dll, not libtest1.so +++ http://jogamp.org/bugzilla/show_bug.cgi?id=394 Fix MacOsX platform: The commit of cpptasks.jar, git hash 129e783741d91e9ee5cd7da5d5c962c32ec96b0b, broke the universal binary build on MacOSX. The above change used cpptasks-1.05b with a few patches in regards to crosscompilation, but missed one, which accepts the '-arch' argument for GccLinker undecorated. The new cpptasks.jar is vanilla 1.05b + cpptasks-1.0b5-darwin-patch.diff, the latter a more refined one. This version accepts the '-arch' argument undecorated on the darwin platform. +++
-rw-r--r--make/build-junit.xml103
-rwxr-xr-xmake/build.xml22
-rwxr-xr-xmake/gluegen-cpptasks-base.xml100
-rwxr-xr-xmake/gluegen-cpptasks.xml3
-rwxr-xr-xmake/gluegen-properties.xml20
-rwxr-xr-xmake/gluegen.properties46
-rw-r--r--make/lib/CppTasksGCCNamespaceHack.jar-mbien-129e783741d91e9ee5cd7da5d5c962c32ec96b0b (renamed from make/lib/CppTasksGCCNamespaceHack.jar)bin7810 -> 7810 bytes
-rw-r--r--make/lib/cpptasks-1.0b5-darwin-patch.diff39
-rw-r--r--make/lib/cpptasks-1.0b5.zipbin0 -> 2221439 bytes
-rw-r--r--make/lib/cpptasks-patch-orig-c91f003551542c2aab62dd8ef89a7894c7e50689.tar.gz (renamed from make/lib/cpptasks-patch.tar.gz)bin7743 -> 7743 bytes
-rw-r--r--make/lib/cpptasks.jarbin363963 -> 364113 bytes
-rw-r--r--make/lib/cpptasks.jar-mbien-129e783741d91e9ee5cd7da5d5c962c32ec96b0bbin0 -> 363963 bytes
-rwxr-xr-xmake/lib/cpptasks.jar-orig-c91f003551542c2aab62dd8ef89a7894c7e50689bin0 -> 345356 bytes
-rw-r--r--make/make.gluegen.all.macosx.sh2
-rw-r--r--make/make.gluegen.all.win32.bat17
-rwxr-xr-xsrc/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java28
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java4
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java6
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.c44
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h20
-rw-r--r--test/junit/com/sun/gluegen/BasicTest.java5
21 files changed, 338 insertions, 121 deletions
diff --git a/make/build-junit.xml b/make/build-junit.xml
index f1f3b6f..2da5997 100644
--- a/make/build-junit.xml
+++ b/make/build-junit.xml
@@ -121,10 +121,8 @@
<property name="linker.cfg.id" value="${linker.cfg.id.base}" />
</target>
- <target name="rename.mingw.dll" if="isMingW">
- <move file="${src}" tofile="${dest}" />
- </target>
-
+ <!-- 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 -->
<target name="rename.dylib" if="isOSX">
<move file="${src}" tofile="${dest}" />
</target>
@@ -172,33 +170,30 @@
<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_t.lib}/lib@{output.lib.name}.dylib" />
- <param name="dest" value="${build_t.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_t.lib}/lib@{output.lib.name}.so" />
- <param name="dest" value="${build_t.lib}/@{output.lib.name}.dll" />
- </antcall>
</sequential>
</macrodef>
- <target name="junit.compile" depends="init, java.generate, java.build, c.build"/>
+ <target name="junit.compile" depends="init, java.generate, java.build, native.build"/>
+
+ <target name="junit.run" depends="init,gluegen.cpptasks.detect.os">
+ <!-- Use absolute path -->
+ <property name="gluegen.lib.abs" location="${gluegen.lib}" />
+ <property name="build_t.lib.abs" location="${build_t.lib}" />
+
- <target name="junit.run" depends="init">
<!-- Perform the junit tests-->
<mkdir dir="${results}"/>
<junit forkmode="once" showoutput="true" fork="true">
- <jvmarg value="-Djava.library.path=${gluegen.lib}:${build_t.lib}"/>
+ <env key="${system.env.library.path}" path="${gluegen.lib.abs}${path.separator}${build_t.lib.abs}"/>
+ <jvmarg value="-Djava.library.path=${gluegen.lib.abs}${path.separator}${build_t.lib.abs}"/>
<jvmarg value="-Drootrel.build=${rootrel.build}"/>
- <!--jvmarg value="-Dgluegen.debug.NativeLibrary=true"/-->
- <!--jvmarg value="-Dgluegen.debug.ProcAddressHelper=true"/-->
+ <!--
+ <jvmarg value="-Dgluegen.debug.NativeLibrary=true"/>
+ <jvmarg value="-Dgluegen.debug.ProcAddressHelper=true"/>
+ <jvmarg value="-verbose:jni"/>
+ <jvmarg value="-client"/>
+ <jvmarg value="-d32"/>
+ -->
<formatter usefile="false" type="plain"/>
<formatter usefile="true" type="xml"/>
<classpath refid="junit.run.classpath"/>
@@ -221,7 +216,12 @@
<target name="java.generate" depends="junit.test1.java.generate"/>
- <target name="c.build" depends="c.configure, junit.test1.c.build" unless="build.javaonly" />
+ <target name="native.build" depends="c.configure, junit.test1.c.build" unless="build.javaonly">
+ <antcall target="gluegen.cpptasks.striplibs" inheritRefs="true">
+ <param name="libdir" value="${build_t.lib}"/>
+ </antcall>
+ </target>
+
<!--
@@ -266,30 +266,71 @@
</gluegen>
</target>
- <target name="junit.test1.c.build" depends="junit.test1p1.c.build, junit.test1p2.c.build" unless="build.javaonly" />
+ <target name="junit.test1.c.build" depends="junit.test1i.c.build, junit.test1p1.c.build, junit.test1p2.c.build" unless="build.javaonly" />
+
+ <!-- this is the test1 implementation -->
+ <target name="junit.test1i.c.build">
+ <patternset id="junit.test1i.c.src.files">
+ <include name="${test.junit.rootrel}/generation/test1.c"/>
+ </patternset>
+
+ <!-- Windows hacks ro make a proper DLL -->
+ <linker id="linker.test1.dll.cfg.id" extends="${linker.cfg.id}">
+ <linkerarg value="-Wl,-soname=test1.dll" if="isMingW"/>
+ <linkerarg value="-Wl,--output=test1.dll" if="isMingW"/>
+ </linker>
+ <c.build c.compiler.src.files="junit.test1i.c.src.files"
+ output.lib.name="test1"
+ compiler.cfg.id="${compiler.cfg.id}"
+ linker.cfg.id="linker.test1.dll.cfg.id"/>
+ </target>
+
+ <!-- this is a fixed binding to the test1 implementation -->
<target name="junit.test1p1.c.build">
+ <linker id="linker.test1.fixed.cfg.id" extends="${linker.cfg.id}">
+ <linkerarg value="-Wl,-soname=BindingTest1p1.dll" if="isMingW"/>
+ <linkerarg value="-Wl,--output=BindingTest1p1.dll" if="isMingW"/>
+ <syslibset dir="${build_t.lib}" libs="test1"/>
+ </linker>
+
<patternset id="junit.test1p1.c.src.files">
- <include name="${test.junit.rootrel}/generation/test1.c"/>
<include name="${build_t.gen.rootrel}/native/BindingTest1p1Impl_JNI.c"/>
</patternset>
<c.build c.compiler.src.files="junit.test1p1.c.src.files"
- output.lib.name="test1p1"
+ output.lib.name="BindingTest1p1"
compiler.cfg.id="${compiler.cfg.id}"
- linker.cfg.id="${linker.cfg.id}"/>
+ linker.cfg.id="linker.test1.fixed.cfg.id"/>
+
+ <antcall target="rename.dylib" inheritRefs="true">
+ <param name="src" value="${build_t.lib}/libBindingTest1p1.dylib" />
+ <param name="dest" value="${build_t.lib}/libBindingTest1p1.jnilib" />
+ </antcall>
+
</target>
+ <!-- this is a dynamic lookup binding to the test1 implementation -->
<target name="junit.test1p2.c.build">
+ <linker id="linker.test1.runtime.cfg.id" extends="${linker.cfg.id}">
+ <linkerarg value="-Wl,-soname=BindingTest1p2.dll" if="isMingW"/>
+ <linkerarg value="-Wl,--output=BindingTest1p2.dll" if="isMingW"/>
+ </linker>
+
<patternset id="junit.test1p2.c.src.files">
- <include name="${test.junit.rootrel}/generation/test1.c"/>
<include name="${build_t.gen.rootrel}/native/BindingTest1p2Impl_JNI.c"/>
</patternset>
<c.build c.compiler.src.files="junit.test1p2.c.src.files"
- output.lib.name="test1p2"
+ output.lib.name="BindingTest1p2"
compiler.cfg.id="${compiler.cfg.id}"
- linker.cfg.id="${linker.cfg.id}"/>
+ linker.cfg.id="linker.test1.runtime.cfg.id"/>
+
+ <antcall target="rename.dylib" inheritRefs="true">
+ <param name="src" value="${build_t.lib}/libBindingTest1p2.dylib" />
+ <param name="dest" value="${build_t.lib}/libBindingTest1p2.jnilib" />
+ </antcall>
+
</target>
<!--
diff --git a/make/build.xml b/make/build.xml
index 6b51f7e..c41f21c 100755
--- a/make/build.xml
+++ b/make/build.xml
@@ -51,6 +51,9 @@
<property name="src.java" value="../src/java" />
<property name="build" value="../${rootrel.build}" />
+ <property name="gluegen.lib.dir" value="${build}/obj"/>
+
+
<!-- The generated source directories. -->
<property name="src.generated" value="${build}/gensrc" />
<property name="src.generated.java" value="${src.generated}/java" />
@@ -341,10 +344,7 @@
<condition property="c.compiler.use-debug"><istrue value="${c.compiler.debug}"/></condition>
- <!--namespace can be overwritten from outside-->
- <property name="namespace" value=""/>
-
- <mkdir dir="${build}/obj/${namespace}" />
+ <mkdir dir="${gluegen.lib.dir}"/>
<property name="c.compiler.src.files.common" value="src/native/common/*.c" />
@@ -352,8 +352,8 @@
<echo message="user.dir=${user.dir}" />
<cc outtype="shared"
- objdir="${build}/obj/${namespace}"
- outfile="${build}/obj/${namespace}/${output.lib.name}"
+ objdir="${gluegen.lib.dir}"
+ outfile="${gluegen.lib.dir}/${output.lib.name}"
optimize="${c.compiler.optimise}"
debug="${c.compiler.debug}"
multithreaded="true"
@@ -385,6 +385,11 @@
<antcall target="c.rename.lib.mingw" inheritRefs="true" />
<antcall target="c.rename.lib.macosx" inheritRefs="true" />
+
+ <antcall target="gluegen.cpptasks.striplibs" inheritRefs="true">
+ <param name="libdir" value="${gluegen.lib.dir}"/>
+ </antcall>
+
<antcall target="c.manifest" inheritRefs="true" />
<!-- Create Java Web Start jar file from built file -->
<jar destfile="${build}/gluegen-rt-natives-${os.and.arch}.jar">
@@ -572,7 +577,7 @@
</delete>
</target>
- <target name="test" depends="init, junit.run">
+ <target name="test" depends="init, gluegen.cpptasks.detect.os, junit.run">
<mkdir dir="${build}/test/build/classes"/>
<mkdir dir="${build}/test/results"/>
@@ -583,7 +588,8 @@
</javac>
<junit forkmode="once" showoutput="true" fork="true">
- <jvmarg value="-Djava.library.path=${build}/test/build/natives"/>
+ <env key="${system.env.library.path}" path="${gluegen.lib.dir}${path.separator}${build}/test/build/natives"/>
+ <jvmarg value="-Djava.library.path=${gluegen.lib.dir}${path.separator}${build}/test/build/natives"/>
<jvmarg value="-Drootrel.build=${rootrel.build}"/>
<jvmarg value="-Dos.arch=${os.arch}"/>
<jvmarg value="-Dgluegen.user.compiler.file=${gluegen.user.compiler.file}"/>
diff --git a/make/gluegen-cpptasks-base.xml b/make/gluegen-cpptasks-base.xml
index 9eedcd1..5375306 100755
--- a/make/gluegen-cpptasks-base.xml
+++ b/make/gluegen-cpptasks-base.xml
@@ -24,7 +24,6 @@
- isLinuxX86
- isOSX
- isOSXPPC
- - isOSXUniversal (if macosxfat=true)
- isSolaris
- isSolaris32Bit
- isSolarisAMD64
@@ -116,21 +115,37 @@
-->
<project name="GlueGen-cpptasks-base" basedir=".">
- <!-- Detect OS and compiler configuration -->
- <target name="gluegen.cpptasks.detect.os.1" depends="gluegen.properties.load.user" unless="gluegen.cpptasks.detected.os">
- <condition property="isOSX">
- <and>
- <os family="mac"/>
- <os family="unix"/>
- </and>
- </condition>
+ <target name="gluegen.cpptasks.initialize" depends="gluegen.properties.load.user">
+ <!-- NOTE: the value of the debug attribute will not be overridden if already set externally -->
+ <property name="c.compiler.debug" value="false" />
+
+ <condition property="c.strip.libraries"><isfalse value="${c.compiler.debug}"/></condition>
+
+ <!-- NOTE: the values of the macos<arch> attributes will not be overridden if already set externally -->
+ <property name="macosppc" value="false" />
+ <property name="macosx32" value="true" />
+ <property name="macosx64" value="true" />
+
<!-- Need a way to be able to disable the macosx64 property specification in a build.xml -->
<condition property="use.macosppc">
<istrue value="${macosppc}" />
</condition>
+ <condition property="use.macosx32">
+ <istrue value="${macosx32}" />
+ </condition>
<condition property="use.macosx64">
<istrue value="${macosx64}" />
</condition>
+ </target>
+
+ <!-- Detect OS and compiler configuration -->
+ <target name="gluegen.cpptasks.detect.os.1" depends="gluegen.cpptasks.initialize" unless="gluegen.cpptasks.detected.os">
+ <condition property="isOSX">
+ <and>
+ <os family="mac"/>
+ <os family="unix"/>
+ </and>
+ </condition>
<condition property="isUnix">
<and>
<os family="unix" />
@@ -265,6 +280,7 @@
<echo message="LinuxX86=${isLinuxX86}" />
<echo message="OS X=${isOSX}" />
<echo message="OS X PPC=${use.macosppc}" />
+ <echo message="OS X x32=${use.macosx32}" />
<echo message="OS X x64=${use.macosx64}" />
<echo message="Solaris=${isSolaris}" />
<echo message="Solaris32Bit=${isSolaris32Bit}" />
@@ -347,6 +363,26 @@
<target name="gluegen.cpptasks.detect.os" depends="gluegen.properties.load.user,gluegen.cpptasks.detect.os.1,gluegen.cpptasks.detect.os.2">
<property name="gluegen.cpptasks.detected.os" value="true" />
<property name="gluegen.cpptasks.detected.os.2" value="true" />
+
+ <!-- Set the OS search library environment variable -->
+ <condition property="system.env.library.path"
+ value="DYLD_LIBRARY_PATH">
+ <isset property="isOSX"/>
+ </condition>
+ <condition property="system.env.library.path"
+ value="LD_LIBRARY_PATH">
+ <isset property="isUnix"/>
+ </condition>
+ <condition property="system.env.library.path"
+ value="PATH">
+ <isset property="isWindows"/>
+ </condition>
+
+ <!-- NOTE: the value of the c.strip.tool and c.strip.args attribute will not be overridden if already set externally -->
+ <property name="c.strip.tool" value="strip" />
+ <condition property="c.strip.args" value="-S -x"><isset property="isOSX"/></condition>
+ <property name="c.strip.args" value="" />
+
</target>
<!-- Detect compiler setup, in particular on Windows; separated
@@ -424,9 +460,6 @@
<echo message="VC9=${isVC9}" />
<echo message="MingW=${isMingW}" />
- <!-- NOTE: the value of the debug and optimise attributes will not be overridden if already set externally -->
- <property name="c.compiler.debug" value="false" />
-
<condition property="isVC7Debug">
<and>
<istrue value="${isVC7}" />
@@ -473,12 +506,14 @@
<compilerarg value="-m64"/>
</compiler>
- <compiler id="compiler.cfg.linux64.mingw64" classname="net.sf.antcontrib.cpptasks.gcc.Gcc64CCompiler">
+ <!--compiler id="compiler.cfg.linux64.mingw64" classname="net.sf.antcontrib.cpptasks.gcc.Gcc64CCompiler"-->
+ <compiler id="compiler.cfg.linux64.mingw64" classname="net.sf.antcontrib.cpptasks.gcc.GccCCompiler">
<compilerarg value="-fPIC"/>
<compilerarg value="-m64"/>
</compiler>
- <compiler id="compiler.cfg.linux64.mingw32" classname="net.sf.antcontrib.cpptasks.gcc.Gcc32CCompiler">
+ <!--compiler id="compiler.cfg.linux64.mingw32" classname="net.sf.antcontrib.cpptasks.gcc.Gcc32CCompiler"-->
+ <compiler id="compiler.cfg.linux64.mingw32" classname="net.sf.antcontrib.cpptasks.gcc.GccCCompiler">
<compilerarg value="-m32"/>
</compiler>
@@ -561,8 +596,8 @@
<!-- Note: Apple doesn't seem to provide ppc binaries on Snow Leopard -->
<compilerarg value="-arch" if="use.macosppc"/>
<compilerarg value="ppc" if="use.macosppc"/>
- <compilerarg value="-arch" />
- <compilerarg value="i386" />
+ <compilerarg value="-arch" if="use.macosx32"/>
+ <compilerarg value="i386" if="use.macosx32"/>
<compilerarg value="-arch" if="use.macosx64"/>
<compilerarg value="x86_64" if="use.macosx64"/>
<!-- Note: Apple doesn't seem to provide ppc64 binaries on Leopard -->
@@ -611,13 +646,15 @@
<linkerarg value="-m64"/>
</linker>
- <linker id="linker.cfg.linux64.mingw64" classname="net.sf.antcontrib.cpptasks.gcc.Gcc64Linker">
+ <!--linker id="linker.cfg.linux64.mingw64" classname="net.sf.antcontrib.cpptasks.gcc.Gcc64Linker"-->
+ <linker id="linker.cfg.linux64.mingw64" classname="net.sf.antcontrib.cpptasks.gcc.GccLinker">
<linkerarg value="-m64"/>
</linker>
- <linker id="linker.cfg.linux64.mingw32" classname="net.sf.antcontrib.cpptasks.gcc.Gcc32Linker">
+ <!--linker id="linker.cfg.linux64.mingw32" classname="net.sf.antcontrib.cpptasks.gcc.Gcc32Linker"-->
+ <linker id="linker.cfg.linux64.mingw32" classname="net.sf.antcontrib.cpptasks.gcc.GccLinker">
<linkerarg value="-m32"/>
- <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names -->
+ <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names, ie no __stdcall @nn -->
</linker>
<!--
<linker id="linker.cfg.solaris" name="suncc">
@@ -633,7 +670,7 @@
-->
<linker id="linker.cfg.win32.mingw" name="gcc" incremental="false">
<linkerarg value="-m32"/>
- <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names -->
+ <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names, ie no __stdcall @nn -->
</linker>
<linker id="linker.cfg.win32.msvc" name="msvc" incremental="false">
@@ -647,10 +684,11 @@
</linker>
<linker id="linker.cfg.macosx" name="gcc">
+ <!-- Note: Apple doesn't seem to provide ppc binaries on Snow Leopard -->
<linkerarg value="-arch" if="use.macosppc"/>
<linkerarg value="ppc" if="use.macosppc"/>
- <linkerarg value="-arch" />
- <linkerarg value="i386" />
+ <linkerarg value="-arch" if="use.macosx32"/>
+ <linkerarg value="i386" if="use.macosx32"/>
<linkerarg value="-arch" if="use.macosx64"/>
<linkerarg value="x86_64" if="use.macosx64"/>
<!-- Note: Apple doesn't seem to provide ppc64 binaries on Leopard -->
@@ -783,6 +821,24 @@
<!-- ================================================================== -->
<!--
+ - Helper strip.libraries for stripping off debug information
+ -->
+ <target name="gluegen.cpptasks.striplibs" depends="gluegen.cpptasks.initialize" if="c.strip.libraries">
+ <echo message="Strip symbols from libs in ${libdir}" />
+ <apply dir="${libdir}" executable="${c.strip.tool}" parallel="false"
+ failonerror="true">
+ <arg line="${c.strip.args}"/>
+ <fileset dir="${libdir}">
+ <include name="**/*.so"/> <!-- unix -->
+ <include name="**/*.dll"/> <!-- windows -->
+ <include name="**/*.dylib"/> <!-- macosx -->
+ <include name="**/*.jnilib"/> <!-- macosx -->
+ </fileset>
+ </apply>
+ </target>
+
+ <!-- ================================================================== -->
+ <!--
- Helper macrodef for installing manifest in generated DLLs, needed for VC8 and later
-->
<macrodef name="msvc.manifest">
diff --git a/make/gluegen-cpptasks.xml b/make/gluegen-cpptasks.xml
index f569ea7..f4278d4 100755
--- a/make/gluegen-cpptasks.xml
+++ b/make/gluegen-cpptasks.xml
@@ -23,7 +23,8 @@
<import file="gluegen-properties.xml" />
<!-- import cpptasks -->
- <typedef resource="net/sf/antcontrib/cpptasks/antlib.xml" classpath="${gluegen.root}/make/lib/cpptasks.jar;${gluegen.root}/make/lib/CppTasksGCCNamespaceHack.jar"/>
+ <!--typedef resource="net/sf/antcontrib/cpptasks/antlib.xml" classpath="${gluegen.root}/make/lib/cpptasks.jar;${gluegen.root}/make/lib/CppTasksGCCNamespaceHack.jar"/-->
+ <typedef resource="net/sf/antcontrib/cpptasks/antlib.xml" classpath="${gluegen.root}/make/lib/cpptasks.jar"/>
<condition property="gluegen-cpptasks.file"
value="${gluegen.root}/make/gluegen-cpptasks-base.xml">
diff --git a/make/gluegen-properties.xml b/make/gluegen-properties.xml
index 19483bb..2afc533 100755
--- a/make/gluegen-properties.xml
+++ b/make/gluegen-properties.xml
@@ -11,14 +11,22 @@
- c.compiler.debug:
- set to "true" if debug version of the compiled
- C code is desired.
+ -
+ - MacOsX libraries can be universal / fat binaries.
+ - The following switches enables/disables a target platform.
+ - If non of them is enabled, the default
+ - compiler target platform is used for a thin binary.
+ -
- macosppc:
- - set to "true" if ppc universal / fat binaries are desired
- - on Mac OS X. Requires support for cross-compilation from the
- - underlying C compiler. Note: Unsupported on Snow Leopard!
+ - set to "true" for ppc support,
+ - default is 'false'
+ - Note: Unsupported on Snow Leopard!
+ - macosx32:
+ - set to "false" to disable x86 32-bit support,
+ - default is 'true'
- macosx64:
- - set to "true" if 64-bit universal / fat binaries are desired
- - on Mac OS X. Requires support for cross-compilation from the
- - underlying C compiler.
+ - set to "false" to disable x86 64-bit support,
+ - default is 'true'
-
-->
<project name="GlueGen-properties" basedir=".">
diff --git a/make/gluegen.properties b/make/gluegen.properties
index 8d667b4..2f319bc 100755
--- a/make/gluegen.properties
+++ b/make/gluegen.properties
@@ -13,13 +13,13 @@
# including the name of the jar
#
# Windows
-antlr.jar=C:/Users/kbr/ANTLR/antlr-2.7.2/antlr.jar
-# Linux
-# antlr.jar=/home/kbr/antlr-2.7.2/antlr.jar
+antlr.jar=C:/JOGL/lib/antlr-2.7.2.jar
+# Linux / Solaris / ..
+# antlr.jar=/home/sven/projects/JOGL/lib/antlr-2.7.7.jar
# Mac OS X
-# antlr.jar=/Users/kbr/antlr-2.7.2/antlr.jar
-# Solaris
-# antlr.jar=/export/kbr/ANTLR/antlr-2.7.2/antlr.jar
+# antlr.jar=/JOGL/lib/antlr-2.7.2.jar
+
+junit.jar=/home/sven/projects/JOGL/lib/junit-4.5.jar
# If you are building the native code for the GlueGen run-time library
# on Windows and have the Microsoft Visual C++ compilers installed,
@@ -28,19 +28,27 @@ antlr.jar=C:/Users/kbr/ANTLR/antlr-2.7.2/antlr.jar
# "mingw".
# win32.c.compiler=vc6
-# If you are building on a Mac OS X system supporting
-# cross-compilation and want to generate fat binaries containing
-# x86_64 code, uncomment the property below
-# macosx64=true
-
-# If you are building on a Mac OS X system supporting
-# cross-compilation and want to generate fat binaries containing
-# ppc code, uncomment the property below.
-# Note: Unsupported on Snow Leopard!
+# MacOsX libraries can be universal / fat binaries.
+# The following switches enables/disables a target platform.
+# If non of them is enabled, the default
+# compiler target platform is used for a thin binary.
+#
+# macosppc:
+# set to "true" for ppc support,
+# default is 'false'
+# Note: Unsupported on Snow Leopard!
# macosppc=true
+#
+# macosx32:
+# set to "false" to disable x86 32-bit support,
+# default is 'true'
+# macosx32=false
+#
+# macosx64:
+# set to "false" to disable x86 64-bit support,
+# default is 'true'
+# macosx64=false
+#
-# isX11 is selected for a platform where: !isWindows && !isOSX.
-# To avoid X11 related builds you need to set 'noX11' to true.
-# noX11=true
-#user.compiler.import="${user.home}/gluegen.compiler.xml"
+#gluegen-cpptasks.file="${user.home}/gluegen-cpptasks-linux-32bit.xml"
diff --git a/make/lib/CppTasksGCCNamespaceHack.jar b/make/lib/CppTasksGCCNamespaceHack.jar-mbien-129e783741d91e9ee5cd7da5d5c962c32ec96b0b
index c31779e..c31779e 100644
--- a/make/lib/CppTasksGCCNamespaceHack.jar
+++ b/make/lib/CppTasksGCCNamespaceHack.jar-mbien-129e783741d91e9ee5cd7da5d5c962c32ec96b0b
Binary files differ
diff --git a/make/lib/cpptasks-1.0b5-darwin-patch.diff b/make/lib/cpptasks-1.0b5-darwin-patch.diff
new file mode 100644
index 0000000..1544fcc
--- /dev/null
+++ b/make/lib/cpptasks-1.0b5-darwin-patch.diff
@@ -0,0 +1,39 @@
+diff -Nur cpptasks-1.0b5/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccLinker.java cpptasks-1.0b5-patched-01/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
+--- cpptasks-1.0b5/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccLinker.java 2008-04-02 19:26:44.000000000 +0200
++++ cpptasks-1.0b5-patched-01/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccLinker.java 2010-04-07 22:16:03.330794801 +0200
+@@ -17,6 +17,8 @@
+ package net.sf.antcontrib.cpptasks.gcc;
+ import java.io.File;
+ import java.util.Vector;
++import java.util.HashSet;
++import java.util.Arrays;
+
+ import net.sf.antcontrib.cpptasks.CUtil;
+ import net.sf.antcontrib.cpptasks.compiler.LinkType;
+@@ -36,6 +38,7 @@
+ "-dynamiclib", "-nostartfiles", "-nostdlib", "-prebind", "-s",
+ "-static", "-shared", "-symbolic", "-Xlinker",
+ "--export-all-symbols", "-static-libgcc",};
++ private static String[] darwinLinkerOptions = new String[]{"-arch", };
+ private static final GccLinker dllLinker = new GccLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", false, new GccLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", true, null));
+@@ -97,12 +100,13 @@
+ break;
+ default :
+ boolean known = false;
+- for (int i = 0; i < linkerOptions.length; i++) {
+- if (linkerOptions[i].equals(arg)) {
+- known = true;
+- break;
+- }
++ HashSet allLinkerOptions = new HashSet();
++ allLinkerOptions.addAll(Arrays.asList(linkerOptions));
++ if (isDarwin()) {
++ allLinkerOptions.addAll(Arrays.asList(darwinLinkerOptions));
+ }
++ known = allLinkerOptions.contains(arg);
++
+ if (!known) {
+ buf.setLength(0);
+ buf.append("-Wl,");
diff --git a/make/lib/cpptasks-1.0b5.zip b/make/lib/cpptasks-1.0b5.zip
new file mode 100644
index 0000000..21f8c07
--- /dev/null
+++ b/make/lib/cpptasks-1.0b5.zip
Binary files differ
diff --git a/make/lib/cpptasks-patch.tar.gz b/make/lib/cpptasks-patch-orig-c91f003551542c2aab62dd8ef89a7894c7e50689.tar.gz
index 22f1cde..22f1cde 100644
--- a/make/lib/cpptasks-patch.tar.gz
+++ b/make/lib/cpptasks-patch-orig-c91f003551542c2aab62dd8ef89a7894c7e50689.tar.gz
Binary files differ
diff --git a/make/lib/cpptasks.jar b/make/lib/cpptasks.jar
index dec6c13..f1bf393 100644
--- a/make/lib/cpptasks.jar
+++ b/make/lib/cpptasks.jar
Binary files differ
diff --git a/make/lib/cpptasks.jar-mbien-129e783741d91e9ee5cd7da5d5c962c32ec96b0b b/make/lib/cpptasks.jar-mbien-129e783741d91e9ee5cd7da5d5c962c32ec96b0b
new file mode 100644
index 0000000..dec6c13
--- /dev/null
+++ b/make/lib/cpptasks.jar-mbien-129e783741d91e9ee5cd7da5d5c962c32ec96b0b
Binary files differ
diff --git a/make/lib/cpptasks.jar-orig-c91f003551542c2aab62dd8ef89a7894c7e50689 b/make/lib/cpptasks.jar-orig-c91f003551542c2aab62dd8ef89a7894c7e50689
new file mode 100755
index 0000000..005691c
--- /dev/null
+++ b/make/lib/cpptasks.jar-orig-c91f003551542c2aab62dd8ef89a7894c7e50689
Binary files differ
diff --git a/make/make.gluegen.all.macosx.sh b/make/make.gluegen.all.macosx.sh
index 3086733..1078cec 100644
--- a/make/make.gluegen.all.macosx.sh
+++ b/make/make.gluegen.all.macosx.sh
@@ -8,4 +8,4 @@ fi
ant -v \
-Drootrel.build=build-macosx \
- $* 2>&1 | tee make.gluegen.all.macosx-x86.log
+ $* 2>&1 | tee make.gluegen.all.macosx.log
diff --git a/make/make.gluegen.all.win32.bat b/make/make.gluegen.all.win32.bat
new file mode 100644
index 0000000..2c97baf
--- /dev/null
+++ b/make/make.gluegen.all.win32.bat
@@ -0,0 +1,17 @@
+set THISDIR="C:\JOGL"
+
+set J2RE_HOME=c:\jre1.6.0_19
+set JAVA_HOME=c:\jdk1.6.0_19
+set ANT_PATH=C:\apache-ant-1.7.1
+
+set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
+
+set LIB_GEN=%THISDIR%\lib
+set CLASSPATH=.;%THISDIR%\build-win32\classes
+REM -Dc.compiler.debug=true
+REM -DuseOpenMAX=true
+REM -DuseKD=true
+REM -Djogl.cg=1 -D-Dwindows.cg.lib=C:\Cg-2.2
+
+ant -Drootrel.build=build-win32 %1 %2 %3 %4 %5 %6 %7 %8 %9 > make.gluegen.all.win32.log 2>&1
+
diff --git a/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java b/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java
index f5a3312..2858f74 100755
--- a/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java
+++ b/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java
@@ -2,9 +2,20 @@
package com.jogamp.common.os;
+import java.security.*;
public class WindowsDynamicLinkerImpl implements DynamicLinker {
+ private static boolean DEBUG;
+
+ static {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ DEBUG = (System.getProperty("gluegen.debug.NativeLibrary") != null);
+ return null;
+ }
+ });
+ }
/** Interface to C language function: <br> <code> BOOL FreeLibrary(HANDLE hLibModule); </code> */
private static native int FreeLibrary(long hLibModule);
@@ -36,7 +47,22 @@ public class WindowsDynamicLinkerImpl implements DynamicLinker {
}
public long lookupSymbol(long libraryHandle, String symbolName) {
- return GetProcAddressA(libraryHandle, symbolName);
+ String _symbolName = symbolName;
+ long addr = GetProcAddressA(libraryHandle, _symbolName);
+ if(0==addr) {
+ // __stdcall hack: try some @nn decorations,
+ // the leading '_' must not be added (same with cdecl)
+ final int argAlignment=4; // 4 byte alignment of each argument
+ final int maxArguments=12; // experience ..
+ for(int arg=0; 0==addr && arg<=maxArguments; arg++) {
+ _symbolName = symbolName+"@"+(arg*argAlignment);
+ addr = GetProcAddressA(libraryHandle, _symbolName);
+ }
+ }
+ if(DEBUG) {
+ System.err.println("WindowsDynamicLinkerImpl.lookupSymbol(0x"+Long.toHexString(libraryHandle)+", "+symbolName+") -> "+_symbolName+", 0x"+Long.toHexString(addr));
+ }
+ return addr;
}
public void closeLibrary(long libraryHandle) {
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
index 6320f92..7e8ef49 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
@@ -65,8 +65,8 @@ public class Test1p1JavaEmitter extends BaseTest1 {
*/
@Test
public void chapter01TestLoadLibrary() throws Exception {
- String nativesPath = testOutput + "/build/natives";
- System.load(nativesPath + "/libtest1p1.so");
+ //System.loadLibrary("test1");
+ System.loadLibrary("BindingTest1p1");
}
/**
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
index 83f20d1..2d2cca3 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
@@ -69,9 +69,9 @@ public class Test1p2ProcAddressEmitter extends BaseTest1 {
*/
@Test
public void chapter01TestLoadLibrary() throws Exception {
- System.loadLibrary("test1p2");
- dynamicLookupHelper = NativeLibrary.open("test1p2", getClass().getClassLoader(), true);
- Assert.assertNotNull("NativeLibrary.open(test1p2) failed", dynamicLookupHelper);
+ System.loadLibrary("BindingTest1p2");
+ dynamicLookupHelper = NativeLibrary.open("test1", getClass().getClassLoader(), true);
+ Assert.assertNotNull("NativeLibrary.open(test1) failed", dynamicLookupHelper);
BindingTest1p2Impl.resetProcAddressTable(dynamicLookupHelper);
}
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
index f654467..d74cfc6 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
@@ -1,14 +1,16 @@
+#define __MYAPI_EXPORT_ 1
#include "test1.h"
+
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-foo nopTest() {
+MYAPI foo MYAPIENTRY nopTest() {
return 42;
}
-int32_t arrayTestInt32(int64_t context, int32_t * array) {
+MYAPI int32_t MYAPIENTRY arrayTestInt32(int64_t context, int32_t * array) {
int32_t r=0;
int i;
assert(NULL!=array);
@@ -20,7 +22,7 @@ int32_t arrayTestInt32(int64_t context, int32_t * array) {
return r+context;
}
-int64_t arrayTestInt64(int64_t context, int64_t * array) {
+MYAPI int64_t MYAPIENTRY arrayTestInt64(int64_t context, int64_t * array) {
int64_t r=0;
int i;
assert(NULL!=array);
@@ -32,7 +34,7 @@ int64_t arrayTestInt64(int64_t context, int64_t * array) {
return r+context;
}
-foo * arrayTestFoo2( foo * array ) {
+MYAPI foo * MYAPIENTRY arrayTestFoo2( foo * array ) {
int i;
foo * result = calloc(ARRAY_SIZE, sizeof(foo));
assert(NULL!=array);
@@ -43,7 +45,7 @@ foo * arrayTestFoo2( foo * array ) {
return result;
}
-foo * * arrayTestFoo3ArrayToPtrPtr(foo * array) {
+MYAPI foo * * MYAPIENTRY arrayTestFoo3ArrayToPtrPtr(foo * array) {
int j;
foo * * result = calloc(ARRAY_SIZE, sizeof(foo *));
for(j=0; j<ARRAY_SIZE; j++) {
@@ -52,7 +54,7 @@ foo * * arrayTestFoo3ArrayToPtrPtr(foo * array) {
return result;
}
-foo * * arrayTestFoo3PtrPtr(foo * * array ) {
+MYAPI foo * * MYAPIENTRY arrayTestFoo3PtrPtr(foo * * array ) {
int i,j;
assert(NULL!=array);
for(j=0; j<ARRAY_SIZE; j++) {
@@ -63,7 +65,7 @@ foo * * arrayTestFoo3PtrPtr(foo * * array ) {
return array;
}
-foo arrayTestFoo1(int64_t context, foo * array) {
+MYAPI foo MYAPIENTRY arrayTestFoo1(int64_t context, foo * array) {
foo r=0;
int i;
assert(NULL!=array);
@@ -75,18 +77,18 @@ foo arrayTestFoo1(int64_t context, foo * array) {
return r+context;
}
-foo bufferTest(void * object) {
+MYAPI foo MYAPIENTRY bufferTest(void * object) {
assert(NULL!=object);
return *((foo *)object);
}
-foo mixedTest(int64_t context, void * object, foo * array){
+MYAPI foo MYAPIENTRY mixedTest(int64_t context, void * object, foo * array){
assert(NULL!=object);
assert(NULL!=array);
return arrayTestFoo1(context, array) + bufferTest(object);
}
-foo doubleTest(int64_t context, void * object1, foo * array1, void * object2, foo * array2) {
+MYAPI foo MYAPIENTRY doubleTest(int64_t context, void * object1, foo * array1, void * object2, foo * array2) {
assert(NULL!=object1);
assert(NULL!=array1);
assert(NULL!=object2);
@@ -97,33 +99,33 @@ foo doubleTest(int64_t context, void * object1, foo * array1, void * object2, fo
bufferTest(object2);
}
-foo arrayTestFooNioOnly(int64_t context, foo * array ) {
+MYAPI foo MYAPIENTRY arrayTestFooNioOnly(int64_t context, foo * array ) {
return arrayTestFoo1(context, array);
}
-foo bufferTestNioOnly(void * object) {
+MYAPI foo MYAPIENTRY bufferTestNioOnly(void * object) {
return bufferTest(object);
}
-foo mixedTestNioOnly(int64_t context, void * object, foo * array ) {
+MYAPI foo MYAPIENTRY mixedTestNioOnly(int64_t context, void * object, foo * array ) {
return mixedTest(context, object, array);
}
-foo doubleTestNioOnly(int64_t context, void * object1, foo * array1, void * object2, foo * array2 ) {
+MYAPI foo MYAPIENTRY doubleTestNioOnly(int64_t context, void * object1, foo * array1, void * object2, foo * array2 ) {
return doubleTest(context, object1, array1, object2, array2);
}
-int strToInt(const char * str) {
+MYAPI int MYAPIENTRY strToInt(const char * str) {
return atoi(str);
}
-const char * intToStr(int i) {
+MYAPI const char * MYAPIENTRY intToStr(int i) {
static char singleton[200];
snprintf(singleton, sizeof(singleton)-1, "%d", i);
return singleton;
}
-int stringArrayRead(const char * * strings, int num) {
+MYAPI int MYAPIENTRY stringArrayRead(const char * * strings, int num) {
int i=0, l=0;
if(NULL!=strings) {
for(i=0; i<num; i++) {
@@ -135,7 +137,7 @@ int stringArrayRead(const char * * strings, int num) {
return l;
}
-int intArrayRead(const int * ints, int num) {
+MYAPI int MYAPIENTRY intArrayRead(const int * ints, int num) {
int i=0, s=0;
if(NULL!=ints) {
for(i=0; i<num; i++) {
@@ -146,7 +148,7 @@ int intArrayRead(const int * ints, int num) {
}
/**
-int intArrayWrite(int * * ints, int num) {
+MYAPI int intArrayWrite(int * * ints, int num) {
int i=0, s=0;
if(NULL!=ints) {
for(i=0; i<num; i++) {
@@ -157,11 +159,11 @@ int intArrayWrite(int * * ints, int num) {
return s;
} */
-MYAPIConfig typeTestAnonSingle(const MYAPIConfig a) {
+MYAPI MYAPIConfig MYAPIENTRY typeTestAnonSingle(const MYAPIConfig a) {
return (MYAPIConfig) ( ((void *)a) + 1 );
}
-MYAPIConfig * MYAPIENTRY typeTestAnonPointer(const MYAPIConfig * a) {
+MYAPI MYAPIConfig * MYAPIENTRY typeTestAnonPointer(const MYAPIConfig * a) {
int j;
MYAPIConfig * result = calloc(ARRAY_SIZE, sizeof(MYAPIConfig));
for(j=0; j<ARRAY_SIZE; j++) {
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
index d0e50e5..eb7bb00 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -1,13 +1,25 @@
-#ifndef MYAPIENTRY
-#define MYAPIENTRY
+#if defined(__WIN32__)
+# if defined (__MYAPI_EXPORT_)
+# define MYAPI __declspec(dllexport)
+# else
+# define MYAPI __declspec(dllimport)
+# endif
+# define MYAPIENTRY_NOPE __stdcall /* we don't use __stdcall convention, ie @nn */
+# define MYAPIENTRY
+#else
+# if defined (__MYAPI_EXPORT_)
+# define MYAPI extern
+# else
+# define MYAPI
+# endif
+# define MYAPIENTRY
#endif
+
#ifndef MYAPIENTRYP
#define MYAPIENTRYP MYAPIENTRY *
#endif
-#define MYAPI
-
#define CONSTANT_ONE 1
#define ARRAY_SIZE 8
diff --git a/test/junit/com/sun/gluegen/BasicTest.java b/test/junit/com/sun/gluegen/BasicTest.java
index b186c53..77868c5 100644
--- a/test/junit/com/sun/gluegen/BasicTest.java
+++ b/test/junit/com/sun/gluegen/BasicTest.java
@@ -44,8 +44,9 @@ public class BasicTest {
@Test
public void bindingTest() throws Exception {
- String nativesPath = testOutput + "/build/natives";
- System.load(nativesPath + "/librofl.so");
+ // String nativesPath = testOutput + "/build/natives";
+ // System.load(nativesPath + "/librofl.so");
+ System.loadLibrary("rofl");
Class<?> clazz = Class.forName("test.BindingTest");