diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2008-02-07 13:25:36 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2008-02-07 13:25:36 +0000 |
commit | 481741edaa615e8d9176c9c65aebe0217ff1b23a (patch) | |
tree | d0a6a089e515b20648dfcd3e0feb23ad5b895649 /test/files/jvm | |
parent | b3d232dbbe5a9a6debdaac526589b67389153ff9 (diff) | |
download | scala-481741edaa615e8d9176c9c65aebe0217ff1b23a.tar.gz scala-481741edaa615e8d9176c9c65aebe0217ff1b23a.tar.bz2 scala-481741edaa615e8d9176c9c65aebe0217ff1b23a.zip |
Fixed "natives" test to work on my Mac.
Diffstat (limited to 'test/files/jvm')
-rwxr-xr-x | test/files/jvm/libnatives.jnilib | bin | 0 -> 8456 bytes | |||
-rwxr-xr-x | test/files/jvm/mkLibNatives.sh | 20 | ||||
-rw-r--r-- | test/files/jvm/natives.scala | 14 |
3 files changed, 26 insertions, 8 deletions
diff --git a/test/files/jvm/libnatives.jnilib b/test/files/jvm/libnatives.jnilib Binary files differnew file mode 100755 index 0000000000..370a72648f --- /dev/null +++ b/test/files/jvm/libnatives.jnilib diff --git a/test/files/jvm/mkLibNatives.sh b/test/files/jvm/mkLibNatives.sh index e1a4330cf6..0d530a7ac9 100755 --- a/test/files/jvm/mkLibNatives.sh +++ b/test/files/jvm/mkLibNatives.sh @@ -19,7 +19,7 @@ case "`uname`" in esac CLASS_NAME=Test\$ -CLASS_DIR=natives-jvm +CLASS_DIR=natives-jvm.obj OBJ_NAME=natives LIB_NAME=libnatives @@ -36,10 +36,18 @@ JAVAH=${JAVA_HOME}/bin/javah JAVAH_OPTIONS="-jni -force -classpath ${CLASS_DIR} -o ${OBJ_NAME}.h" CC=gcc -CC_OPTIONS=-c -CC_INCLUDES="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/${OSTYPE}" -LNK_OPTIONS="-shared -Wl,-soname,${LIB_NAME}" +if $darwin; then + CC_OPTIONS="-c -arch ppc -arch i386" + CC_INCLUDES="-I/System/Library/Frameworks/JavaVM.framework/Headers" + LNK_OPTIONS="-dynamiclib -framework JavaVM" + FULL_LIB_NAME=${LIB_NAME}.jnilib +else + CC_OPTIONS=-c + CC_INCLUDES="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/${OSTYPE}" + LNK_OPTIONS="-shared -Wl,-soname,${LIB_NAME}" + FULL_LIB_NAME=${LIB_NAME}.so +fi ############################################################################## # commands @@ -50,5 +58,5 @@ ${JAVAH} ${JAVAH_OPTIONS} ${CLASS_NAME} [ $debug ] && echo ${CC} ${CC_OPTIONS} ${CC_INCLUDES} -o ${OBJ_NAME}.o natives.c ${CC} ${CC_OPTIONS} ${CC_INCLUDES} -o ${OBJ_NAME}.o natives.c -[ $debug ] && echo ${CC} -shared -Wl,-soname,${LIB_NAME} -o ${LIB_NAME}.so ${OBJ_NAME}.o -${CC} ${LNK_OPTIONS} -o ${LIB_NAME}.so ${OBJ_NAME}.o +[ $debug ] && echo ${CC} ${LNK_OPTIONS} -o ${FULL_LIB_NAME} ${OBJ_NAME}.o +${CC} ${LNK_OPTIONS} -o ${FULL_LIB_NAME} ${OBJ_NAME}.o diff --git a/test/files/jvm/natives.scala b/test/files/jvm/natives.scala index 4cea731cd3..14ee4e1c1b 100644 --- a/test/files/jvm/natives.scala +++ b/test/files/jvm/natives.scala @@ -1,7 +1,17 @@ object Test { + //println("java.library.path=" + System.getProperty("java.library.path")) - val model = System.getProperty("sun.arch.data.model", "32") - System.loadLibrary("natives-" + model) + + val sysWordSize = System.getProperty("sun.arch.data.model", "32") + val sysType = System.getProperty("os.name") + + val libName = + if (sysType == "Mac OS X") + "natives" + else + "natives-" + sysWordSize + + System.loadLibrary(libName) @native def sayHello(s: String): String = null |