aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp
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 /src/junit/com/jogamp
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. +++
Diffstat (limited to 'src/junit/com/jogamp')
-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
4 files changed, 44 insertions, 30 deletions
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