diff options
47 files changed, 791 insertions, 195 deletions
@@ -26,8 +26,8 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Ant"/> <classpathentry kind="lib" path="make/lib/antlr.jar" sourcepath="make/lib/antlr-src.zip"/> - <classpathentry kind="lib" path="make/lib/android-sdk/15/android.jar" sourcepath="make/lib/android-sdk/15/android-java-src.zip"/> <classpathentry kind="lib" path="make/lib/junit.jar" sourcepath="make/lib/junit-sources.jar"/> <classpathentry kind="lib" path="make/lib/semantic-versioning/semver.jar" sourcepath="make/lib/semantic-versioning/semver-src.zip"/> + <classpathentry kind="lib" path="make/lib/android-sdk/15/android.jar" sourcepath="make/lib/android-sdk/15/android-java-src.zip"/> <classpathentry kind="output" path="build/eclipse-classes"/> </classpath> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..0969a09 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,69 @@ +before_script: + - git submodule sync --recursive + - git submodule update --init --recursive + +stages: + - build + - package + - test + +build_amd64-linux_job: + tags: + - amd64 + - linux + stage: build + script: + - cd make + - ant + artifacts: + paths: + - build/* + +build_arm64-linux_job: + tags: + - arm64 + - linux + stage: build + script: + - cd make + - ant + artifacts: + paths: + - build/* + +package_job: + tags: + - amd64 + - linux + stage: package + script: + - cd build + artifacts: + paths: + - build/*.jar + +test_amd64-linux_job: + tags: + - amd64 + - linux + stage: test + script: + - cd make + - ant junit.run + - bash ./scripts/check-junit.sh ../build + artifacts: + paths: + - build/*test-results*.7z + +test_arm64-linux_job: + tags: + - arm64 + - linux + stage: test + script: + - cd make + - ant junit.run + - bash ./scripts/check-junit.sh ../build + artifacts: + paths: + - build/*test-results*.7z
\ No newline at end of file diff --git a/doc/HowToBuild.html b/doc/HowToBuild.html index dcfe3ba..7c15e74 100644 --- a/doc/HowToBuild.html +++ b/doc/HowToBuild.html @@ -65,9 +65,16 @@ <li>gcc</li> </ul> One liner install command: - <pre> + <ul> + <li><b>Debian</b> 5.00 or later + <pre> apt-get install openjdk-7-jre openjdk-7-jdk ant git-all p7zip-full gcc - </pre> + </pre></li> + <li><b>Debian</b> 9.00 Stretch + <pre> +apt-get install openjdk-8-jre openjdk-8-jdk ant git-all p7zip-full gcc + </pre></li> + </ul> Optional: Add <i>kernel</i> build utilities: <pre> apt-get install kernel-package build-essential @@ -87,6 +94,12 @@ dpkg --add-architecture i386 apt-get update apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 gcc-multilib lib32gcc1 lib32gomp1 lib32itm1 lib32quadmath0 libc6-i386 libc6-dev-i386 g++-multilib lib32stdc++6 openjdk-7-jre:i386 openjdk-7-jdk:i386 </pre></li> + <li><b>Debian</b> 9.00 Stretch + <pre> +dpkg --add-architecture i386 +apt-get update +apt-get install lib32z1 lib32ncurses5 gcc-multilib lib32gcc1 lib32gomp1 lib32itm1 lib32quadmath0 libudev1:i386 libc6-i386 libc6-dev-i386 g++-multilib lib32stdc++6 openjdk-8-jre:i386 openjdk-8-jdk:i386 + </pre></li> </ul> </li> <li> <b>OpenSuSE</b> 10.2 or later @@ -237,7 +250,7 @@ apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 gcc-multilib lib32gcc1 lib32g </li> <li> - <b>CharScanner; panic: ClassNotFoundException: com.sun.gluegen.cgram.CToken</b> + <b>CharScanner; panic: ClassNotFoundException: com.jogamp.gluegen.cgram.CToken</b> This occurs because ANTLR was dropped into the Extensions directory of the JRE/JDK. On Windows and Linux, delete any ANTLR jars from jre/lib/ext, diff --git a/doc/manual/example1/gen.sh b/doc/manual/example1/gen.sh index 047b448..63943e9 100644 --- a/doc/manual/example1/gen.sh +++ b/doc/manual/example1/gen.sh @@ -14,5 +14,5 @@ else SEP=: fi -echo java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.sun.gluegen.GlueGen -I. -Ecom.sun.gluegen.JavaEmitter -Cfunction.cfg function.h -java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.sun.gluegen.GlueGen -I. -Ecom.sun.gluegen.JavaEmitter -Cfunction.cfg function.h +echo java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.jogamp.gluegen.GlueGen -I. -Ecom.jogamp.gluegen.JavaEmitter -Cfunction.cfg function.h +java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.jogamp.gluegen.GlueGen -I. -Ecom.jogamp.gluegen.JavaEmitter -Cfunction.cfg function.h diff --git a/doc/manual/example2/gen.sh b/doc/manual/example2/gen.sh index 99adddd..e1b34cc 100644 --- a/doc/manual/example2/gen.sh +++ b/doc/manual/example2/gen.sh @@ -14,4 +14,4 @@ else SEP=: fi -java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.sun.gluegen.GlueGen -I. -Ecom.sun.gluegen.JavaEmitter -Cfunction.cfg function.h +java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.jogamp.gluegen.GlueGen -I. -Ecom.jogamp.gluegen.JavaEmitter -Cfunction.cfg function.h diff --git a/doc/manual/example3/gen.sh b/doc/manual/example3/gen.sh index c44676f..9708851 100644 --- a/doc/manual/example3/gen.sh +++ b/doc/manual/example3/gen.sh @@ -14,4 +14,4 @@ else SEP=: fi -java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.sun.gluegen.GlueGen -I. -Ecom.sun.gluegen.JavaEmitter -Cfunction.cfg function.h +java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.jogamp.gluegen.GlueGen -I. -Ecom.jogamp.gluegen.JavaEmitter -Cfunction.cfg function.h diff --git a/doc/manual/example4/gen.sh b/doc/manual/example4/gen.sh index c44676f..9708851 100644 --- a/doc/manual/example4/gen.sh +++ b/doc/manual/example4/gen.sh @@ -14,4 +14,4 @@ else SEP=: fi -java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.sun.gluegen.GlueGen -I. -Ecom.sun.gluegen.JavaEmitter -Cfunction.cfg function.h +java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.jogamp.gluegen.GlueGen -I. -Ecom.jogamp.gluegen.JavaEmitter -Cfunction.cfg function.h diff --git a/doc/manual/example5/gen.sh b/doc/manual/example5/gen.sh index c44676f..9708851 100644 --- a/doc/manual/example5/gen.sh +++ b/doc/manual/example5/gen.sh @@ -14,4 +14,4 @@ else SEP=: fi -java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.sun.gluegen.GlueGen -I. -Ecom.sun.gluegen.JavaEmitter -Cfunction.cfg function.h +java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.jogamp.gluegen.GlueGen -I. -Ecom.jogamp.gluegen.JavaEmitter -Cfunction.cfg function.h diff --git a/doc/manual/example6/gen.sh b/doc/manual/example6/gen.sh index c44676f..9708851 100644 --- a/doc/manual/example6/gen.sh +++ b/doc/manual/example6/gen.sh @@ -14,4 +14,4 @@ else SEP=: fi -java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.sun.gluegen.GlueGen -I. -Ecom.sun.gluegen.JavaEmitter -Cfunction.cfg function.h +java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.jogamp.gluegen.GlueGen -I. -Ecom.jogamp.gluegen.JavaEmitter -Cfunction.cfg function.h diff --git a/doc/manual/example7/gen.sh b/doc/manual/example7/gen.sh index c44676f..9708851 100644 --- a/doc/manual/example7/gen.sh +++ b/doc/manual/example7/gen.sh @@ -14,4 +14,4 @@ else SEP=: fi -java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.sun.gluegen.GlueGen -I. -Ecom.sun.gluegen.JavaEmitter -Cfunction.cfg function.h +java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.jogamp.gluegen.GlueGen -I. -Ecom.jogamp.gluegen.JavaEmitter -Cfunction.cfg function.h diff --git a/doc/manual/index.html b/doc/manual/index.html index d89f626..15f1482 100755 --- a/doc/manual/index.html +++ b/doc/manual/index.html @@ -363,7 +363,7 @@ <dl> - <dt> <strong>CharScanner; panic: ClassNotFoundException: com.sun.gluegen.cgram.CToken</strong></dt> + <dt> <strong>CharScanner; panic: ClassNotFoundException: com.jogamp.gluegen.cgram.CToken</strong></dt> <dd> This occurs because ANTLR was dropped into the Extensions directory of the JRE/JDK. On Windows and Linux, delete any ANTLR jars from jre/lib/ext, and on Mac OS X, delete them from @@ -397,9 +397,9 @@ <em>emitterClassName</em> as the fully-qualified name of the emitter class which will be used by GlueGen to generate the glue code. The emitter class must implement the - <code>com.sun.gluegen.GlueEmitter</code> interface. If this + <code>com.jogamp.gluegen.GlueEmitter</code> interface. If this option is not specified, a - <code>com.sun.gluegen.JavaEmitter</code> will be used by default. + <code>com.jogamp.gluegen.JavaEmitter</code> will be used by default. </li> <li> -C<em>cfgFile</em> adds <em>cfgFile</em> to the list of configuration files used to set up the chosen emitter. This is @@ -435,7 +435,7 @@ <pre> <taskdef name="gluegen" - classname="com.sun.gluegen.ant.GlueGenTask" + classname="com.jogamp.gluegen.ant.GlueGenTask" classpathref="gluegen.classpath" /> </pre> @@ -445,7 +445,7 @@ <gluegen src="[header to parse]" config="[configuration file]" includeRefid="[dirset for include path]" - emitter="com.sun.gluegen.JavaEmitter"> + emitter="com.jogamp.gluegen.JavaEmitter"> <classpath refid="gluegen.classpath" /> </gluegen> </pre> @@ -1679,8 +1679,8 @@ </p> <pre> - java -cp gluegen.jar:antlr.jar com.sun.gluegen.GlueGen \ - -I. -Ecom.sun.gluegen.JavaEmitter -Cfunction.cfg function.h + java -cp gluegen.jar:antlr.jar com.jogamp.gluegen.GlueGen \ + -I. -Ecom.jogamp.gluegen.JavaEmitter -Cfunction.cfg function.h </pre> <p> The resulting Java and native code needs to be compiled, and the diff --git a/make/build.xml b/make/build.xml index 218030f..77a0ec0 100644 --- a/make/build.xml +++ b/make/build.xml @@ -276,6 +276,12 @@ <property name="linker.cfg.id" value="linker.cfg.linux.armv6" /> </target> + <target name="declare.linux.aarch64" if="isLinuxARM64"> + <echo message="Linux.aarch64" /> + <property name="compiler.cfg.id" value="compiler.cfg.linux.aarch64" /> + <property name="linker.cfg.id" value="linker.cfg.linux.aarch64" /> + </target> + <target name="declare.linux.alpha" if="isLinuxAlpha"> <echo message="Linux.alpha" /> <property name="compiler.cfg.id" value="compiler.cfg.linux" /> @@ -336,7 +342,7 @@ <property name="linker.cfg.id" value="linker.cfg.linux.sparc" /> </target> - <target name="declare.linux" depends="declare.linux.x86,declare.linux.amd64,declare.linux.ia64,declare.linux.hppa,declare.linux.mips,declare.linux.mipsel,declare.linux.ppc,declare.linux.ppc64,declare.linux.ppc64le,declare.linux.s390,declare.linux.s390x,declare.linux.sparc,declare.linux.armv6" if="isLinux" > + <target name="declare.linux" depends="declare.linux.x86,declare.linux.amd64,declare.linux.ia64,declare.linux.hppa,declare.linux.mips,declare.linux.mipsel,declare.linux.ppc,declare.linux.ppc64,declare.linux.ppc64le,declare.linux.s390,declare.linux.s390x,declare.linux.sparc,declare.linux.armv6,declare.linux.aarch64" if="isLinux" > <property name="c.src.dir.os" value="unix" /> </target> diff --git a/make/gluegen-cpptasks-base.xml b/make/gluegen-cpptasks-base.xml index 139ad0e..3837055 100755 --- a/make/gluegen-cpptasks-base.xml +++ b/make/gluegen-cpptasks-base.xml @@ -35,6 +35,7 @@ - isAndroidARM64 - isAndroidARMv6Armel (set in gluegen.cpptasks.detected.os.2) - isAndroidARMv6Armhf (set in gluegen.cpptasks.detected.os.2) + - isAndroidX86 - isLinux - isLinuxAMD64 - isLinuxIA64 @@ -344,6 +345,12 @@ </or> </and> </condition> + <condition property="isAndroidX86"> + <and> + <istrue value="${isAndroid}" /> + <os arch="x86" /> + </and> + </condition> <condition property="isLinuxARMv6"> <and> <istrue value="${isLinux}" /> @@ -611,6 +618,7 @@ <echo message="AndroidARM64=${isAndroidARM64}" /> <echo message="AndroidARMv6Armel=${isAndroidARMv6Armel}" /> <echo message="AndroidARMv6Armhf=${isAndroidARMv6Armhf}" /> + <echo message="AndroidX86=${isAndroidX86}" /> <echo message="Linux=${isLinux}" /> <echo message="LinuxAMD64=${isLinuxAMD64}" /> <echo message="LinuxIA64=${isLinuxIA64}" /> @@ -740,7 +748,11 @@ <property name="os.and.arch" value="android-aarch64" /> </target> - <target name="gluegen.cpptasks.detect.os.linux" depends="gluegen.cpptasks.detect.os.linux.amd64,gluegen.cpptasks.detect.os.linux.ia64,gluegen.cpptasks.detect.os.linux.x86,gluegen.cpptasks.detect.os.linux.armv6.armel,gluegen.cpptasks.detect.os.linux.armv6.armhf,gluegen.cpptasks.detect.os.android.armv6.armel,gluegen.cpptasks.detect.os.linux.aarch64,gluegen.cpptasks.detect.os.android.armv6.armhf,gluegen.cpptasks.detect.os.android.aarch64,gluegen.cpptasks.detect.os.linux.alpha,gluegen.cpptasks.detect.os.linux.hppa,gluegen.cpptasks.detect.os.linux.mips,gluegen.cpptasks.detect.os.linux.mipsel,gluegen.cpptasks.detect.os.linux.ppc,gluegen.cpptasks.detect.os.linux.ppc64,gluegen.cpptasks.detect.os.linux.ppc64le,gluegen.cpptasks.detect.os.linux.s390,gluegen.cpptasks.detect.os.linux.s390x,gluegen.cpptasks.detect.os.linux.sparc" unless="gluegen.cpptasks.detected.os.2" /> + <target name="gluegen.cpptasks.detect.os.android.x86" unless="gluegen.cpptasks.detected.os.2" if="isAndroidX86"> + <property name="os.and.arch" value="android-x86" /> + </target> + + <target name="gluegen.cpptasks.detect.os.linux" depends="gluegen.cpptasks.detect.os.linux.amd64,gluegen.cpptasks.detect.os.linux.ia64,gluegen.cpptasks.detect.os.linux.x86,gluegen.cpptasks.detect.os.linux.armv6.armel,gluegen.cpptasks.detect.os.linux.armv6.armhf,gluegen.cpptasks.detect.os.android.armv6.armel,gluegen.cpptasks.detect.os.linux.aarch64,gluegen.cpptasks.detect.os.android.armv6.armhf,gluegen.cpptasks.detect.os.android.aarch64,gluegen.cpptasks.detect.os.android.x86,gluegen.cpptasks.detect.os.linux.alpha,gluegen.cpptasks.detect.os.linux.hppa,gluegen.cpptasks.detect.os.linux.mips,gluegen.cpptasks.detect.os.linux.mipsel,gluegen.cpptasks.detect.os.linux.ppc,gluegen.cpptasks.detect.os.linux.ppc64,gluegen.cpptasks.detect.os.linux.ppc64le,gluegen.cpptasks.detect.os.linux.s390,gluegen.cpptasks.detect.os.linux.s390x,gluegen.cpptasks.detect.os.linux.sparc" unless="gluegen.cpptasks.detected.os.2" /> <target name="gluegen.cpptasks.detect.os.osx" unless="gluegen.cpptasks.detected.os.2" if="isOSX"> <property name="native.library.suffix" value="*lib" /> @@ -1506,7 +1518,7 @@ <echo message="Linux.aarch64" /> <property name="compiler.cfg.id.base" value="compiler.cfg.linux.aarch64" /> <property name="linker.cfg.id.base" value="linker.cfg.linux.aarch64" /> - <property name="java.lib.dir.platform" value="${java.home.dir}/jre/lib/arm" /> + <property name="java.lib.dir.platform" value="${java.home.dir}/jre/lib/aarch64" /> </target> <target name="gluegen.cpptasks.declare.compiler.linux.ia64" if="isLinuxIA64"> diff --git a/make/lib/gluegen-cpptasks-android-x86.xml b/make/lib/gluegen-cpptasks-android-x86.xml new file mode 100644 index 0000000..1cb0216 --- /dev/null +++ b/make/lib/gluegen-cpptasks-android-x86.xml @@ -0,0 +1,132 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + This is an example of how to add custom compiler/linker + arguments for a crosscompiler. + + You can use such files with setting the property 'gluegen-cpptasks.file', ie: + + -Dgluegen-cpptasks.file=`pwd`/lib/gluegen-cpptasks-linux-32bit.xml + + In case you want to compile for 32bit on a 64bit machine, + you might also need to set the 'os.arch' to 'x86'. + Example: gluegen/make/make.gluegen.all.linux-x86.sh + --> + +<project name="GlueGen-cpptasks-android-x86" basedir="." > + +<!-- Set OS and ARCH for crosscompilation compiler configuration --> +<target name="gluegen.cpptasks.detect.os.custom"> + <property name="gluegen.cpptasks.detected.os" value="true" /> + <property name="isUnix" value="true" /> + <property name="isAndroid" value="true" /> + <property name="isAndroidX86" value="true" /> + <property name="jvmDataModel.arg" value="-Djnlp.no.jvm.data.model.set=true" /> + <property name="isCrosscompilation" value="true" /> + <property name="android.abi" value="x86" /> + <echo message="gluegen.cpptasks.detect.os.custom: GLUEGEN_CPPTASKS_FILE 'gluegen-cpptasks-android-x86' done"/> +</target> + +<import file="${gluegen.root.abs-path}/make/gluegen-cpptasks-base.xml" optional="false" /> + +<target name="gluegen.cpptasks.configure.compiler" depends="setup.java.home.dir,declare.linux.android"> + <echo message="Custom forced compiler Android NDK, linker.cfg.android" /> + <compiler id="compiler.cfg.android" name="gcc"> + <compilerarg value="--sysroot=${env.TARGET_PLATFORM_ROOT}" /> + <!-- The default search dirs for 'gcc from $NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin will not find + subprograms properly (see gcc -print-search-dirs). Not sure if this is a bug in the NDK + or not. Need to explicitly indicate where subprograms are with -B. + NOTE: This is not necessary if using '$TARGET_TRIPLE-gcc' from $NDK_TOOLCHAIN_ROOT/bin. --> + <compilerarg value="-B${env.NDK_TOOLCHAIN_ROOT}/libexec/gcc/${env.TARGET_TRIPLE}/${env.GCC_VERSION}" /> + + <compilerarg value="-fpic" /> + <!-- compilerarg value="-fPIE" / --> <!-- not for shared libs, won't produce symbols --> + <!-- compilerarg value="-pie" / --> <!-- not for shared libs, won't produce symbols --> + <compilerarg value="-ffunction-sections" /> + <compilerarg value="-funwind-tables" /> + <compilerarg value="-fno-stack-protector" /> + <!-- compilerarg value="-no-canonical-prefixes" / --> <!-- will disallow creating shared library --> + <compilerarg value="-Wa,--noexecstack" /> + + <compilerarg value="-mtune=atom" /> + <compilerarg value="-mssse3" /> + <compilerarg value="-mfpmath=sse" /> + <compilerarg value="-mlong-double-80" /> + + <!-- Generic Flags --> + <compilerarg value="-O2" unless="c.compiler.use-debug" /> + <!-- compilerarg value="-g" unless="c.compiler.use-debug" / --> + <compilerarg value="-fomit-frame-pointer" unless="c.compiler.use-debug"/> + <compilerarg value="-fno-strict-aliasing" unless="c.compiler.use-debug"/> + <compilerarg value="-funswitch-loops" unless="c.compiler.use-debug"/> + <compilerarg value="-finline-limit=300" unless="c.compiler.use-debug"/> + + <compilerarg value="-O0" if="c.compiler.use-debug" /> + <compilerarg value="-g" if="c.compiler.use-debug" /> + <compilerarg value="-fno-omit-frame-pointer" if="c.compiler.use-debug" /> + <compilerarg value="-fno-strict-aliasing" if="c.compiler.use-debug" /> + + <includepath path="${env.NDK_TOOLCHAIN_ROOT}/lib/gcc/${env.TARGET_TRIPLE}/${env.GCC_VERSION}/include" /> <!-- for stdarg.h --> + <defineset> + <define name="__unix__" /> + + <define name="ANDROID" /> + <define name="_DEBUG" if="c.compiler.use-debug"/> + <define name="DEBUG" if="c.compiler.use-debug"/> + <define name="NDEBUG" unless="c.compiler.use-debug"/> + </defineset> + </compiler> + + <linker id="linker.cfg.android" name="gcc"> + <linkerarg value="--sysroot=${env.TARGET_PLATFORM_ROOT}" /> + + <linkerarg value="-fpic" /> + <!-- linkerarg value="-fPIE" / --> <!-- not for shared libs, won't produce symbols --> + <!-- linkerarg value="-pie" / --> <!-- not for shared libs, won't produce symbols --> + <!-- linkerarg value="-no-canonical-prefixes" / --> <!-- will disallow creating shared library --> + + <linkerarg value="-fno-use-linker-plugin" /> + + <linkerarg value="-mtune=atom" /> + <linkerarg value="-mssse3" /> + <linkerarg value="-mfpmath=sse" /> + <linkerarg value="-mlong-double-80" /> + + <linkerarg value="-nostdlib" /> + <linkerarg value="-Bdynamic" /> + <linkerarg value="-Wl,-dynamic-linker,/system/bin/linker" /> + <linkerarg value="-Wl,-z,nocopyreloc" /> + + <linkerarg value="--demangle" /> + <linkerarg value="--gc-sections" /> + <linkerarg value="--no-undefined" /> + <linkerarg value="-static-libgcc"/> + <!-- The gcc from $NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin needs to be told + where to find libgcc as the default location (gcc -print-search-dirs) + is not correct. Not sure if this is a bug in the NDK or not. We also + enforce that libgcc is linked after source files but before other shared + libraries. --> + <libset dir="${env.NDK_TOOLCHAIN_ROOT}/lib/gcc/${env.TARGET_TRIPLE}/${env.GCC_VERSION}" libs="gcc" /> + <!-- libset libs="c,m,dl,log" / --> + <libset libs="c,m,dl" /> + </linker> + +</target> + +<target name="gluegen.cpptasks.declare.compiler" depends="setup.java.home.dir"> + <echo message="Custom forced Linux.x86 cross compile android" /> + <property name="compiler.cfg.id.base" value="compiler.cfg.android" /> + <property name="linker.cfg.id.base" value="linker.cfg.android" /> + <property name="java.lib.dir.platform" value="${java.home.dir}/jre/lib/i386" /> + <property name="java.includes.dir.platform" value="${java.includes.dir}/linux" /> +</target> + +<target name="declare.linux.android"> + <echo message="android.x86" /> + <property name="compiler.cfg.id" value="compiler.cfg.android" /> + <property name="linker.cfg.id" value="linker.cfg.android" /> +</target> + +</project> + + diff --git a/make/lib/gluegen-cpptasks-linux-aarch64.xml b/make/lib/gluegen-cpptasks-linux-aarch64.xml new file mode 100644 index 0000000..8606fae --- /dev/null +++ b/make/lib/gluegen-cpptasks-linux-aarch64.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + This is an example of how to add custom compiler/linker + arguments for a crosscompiler. + + You can use such files with setting the property 'gluegen-cpptasks.file', ie: + + -Dgluegen-cpptasks.file=`pwd`/lib/gluegen-cpptasks-linux-aarch64.xml + + In case you want to compile for 32bit on a 64bit machine, + you might also need to set the 'os.arch' to 'x86'. + Example: gluegen/make/make.gluegen.all.linux-x86.sh + --> + +<project name="GlueGen-cpptasks-linux-aarch64" basedir="." > + +<!-- Set OS and ARCH for crosscompilation compiler configuration --> +<target name="gluegen.cpptasks.detect.os.custom"> + <property name="gluegen.cpptasks.detected.os" value="true" /> + <property name="isUnix" value="true" /> + <property name="isLinux" value="true" /> + <property name="isLinuxARM64" value="true" /> + <property name="isX11" value="true" /> + <property name="jvmDataModel.arg" value="-Djnlp.no.jvm.data.model.set=true" /> + <property name="isAbiEabiGnuArmhf" value="true" /> + <echo message="gluegen.cpptasks.detect.os.custom: GLUEGEN_CPPTASKS_FILE 'gluegen-cpptasks-linux-aarch64' done"/> +</target> + +<import file="${gluegen.root.abs-path}/make/gluegen-cpptasks-base.xml" optional="false" /> + +<target name="gluegen.cpptasks.configure.compiler" depends="setup.java.home.dir"> + <echo message="Custom forced compiler Linux aarch64 hard float" /> + + <compiler id="compiler.cfg.linux.aarch64" name="gcc"> + <defineset> + <define name="__unix__"/> + <define name="__X11__" if="isX11"/> + <define name="_DEBUG" if="c.compiler.use-debug"/> + <define name="DEBUG" if="c.compiler.use-debug"/> + <define name="NDEBUG" unless="c.compiler.use-debug"/> + </defineset> + <compilerarg value="-fpic" /> + <compilerarg value="-include"/> + <compilerarg value="${gluegen.root.abs-path}/make/stub_includes/platform/glibc-compat-symbols.h" /> + </compiler> + + <linker id="linker.cfg.linux.aarch64" name="gcc"> + <linkerarg value="-fpic" /> + <linkerarg value="-march=armv8-a" /> + <linkerarg value="-nostdlib" /> + <linkerarg value="-Bdynamic" /> + <linkerarg value="-static-libgcc" if="isGCC"/> + <linkerarg value="-static-libstdc++" if="isGCC"/> + </linker> + +</target> + +</project> diff --git a/make/lib/toolchain/aarch64-linux-gnueabi/bin/c++ b/make/lib/toolchain/aarch64-linux-gnueabi/bin/c++ new file mode 120000 index 0000000..15c86f4 --- /dev/null +++ b/make/lib/toolchain/aarch64-linux-gnueabi/bin/c++ @@ -0,0 +1 @@ +/usr/local/x-tools/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-c++
\ No newline at end of file diff --git a/make/lib/toolchain/aarch64-linux-gnueabi/bin/cc b/make/lib/toolchain/aarch64-linux-gnueabi/bin/cc new file mode 120000 index 0000000..925bc00 --- /dev/null +++ b/make/lib/toolchain/aarch64-linux-gnueabi/bin/cc @@ -0,0 +1 @@ +/usr/local/x-tools/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-cc
\ No newline at end of file diff --git a/make/lib/toolchain/aarch64-linux-gnueabi/bin/g++ b/make/lib/toolchain/aarch64-linux-gnueabi/bin/g++ new file mode 120000 index 0000000..eabecfb --- /dev/null +++ b/make/lib/toolchain/aarch64-linux-gnueabi/bin/g++ @@ -0,0 +1 @@ +/usr/local/x-tools/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-g++
\ No newline at end of file diff --git a/make/lib/toolchain/aarch64-linux-gnueabi/bin/gcc b/make/lib/toolchain/aarch64-linux-gnueabi/bin/gcc new file mode 120000 index 0000000..9b6db98 --- /dev/null +++ b/make/lib/toolchain/aarch64-linux-gnueabi/bin/gcc @@ -0,0 +1 @@ +/usr/local/x-tools/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-gcc
\ No newline at end of file diff --git a/make/lib/toolchain/aarch64-linux-gnueabi/bin/ld b/make/lib/toolchain/aarch64-linux-gnueabi/bin/ld new file mode 120000 index 0000000..38af46a --- /dev/null +++ b/make/lib/toolchain/aarch64-linux-gnueabi/bin/ld @@ -0,0 +1 @@ +/usr/local/x-tools/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-ld
\ No newline at end of file diff --git a/make/lib/toolchain/aarch64-linux-gnueabi/bin/objdump b/make/lib/toolchain/aarch64-linux-gnueabi/bin/objdump new file mode 120000 index 0000000..3fafc10 --- /dev/null +++ b/make/lib/toolchain/aarch64-linux-gnueabi/bin/objdump @@ -0,0 +1 @@ +/usr/local/x-tools/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-objdump
\ No newline at end of file diff --git a/make/lib/toolchain/aarch64-linux-gnueabi/bin/strip b/make/lib/toolchain/aarch64-linux-gnueabi/bin/strip new file mode 120000 index 0000000..de7e179 --- /dev/null +++ b/make/lib/toolchain/aarch64-linux-gnueabi/bin/strip @@ -0,0 +1 @@ +/usr/local/x-tools/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-strip
\ No newline at end of file diff --git a/make/scripts/adb-install-all-x86.sh b/make/scripts/adb-install-all-x86.sh new file mode 100755 index 0000000..138e7d1 --- /dev/null +++ b/make/scripts/adb-install-all-x86.sh @@ -0,0 +1,2 @@ +adb $* install ../build-android-x86/jogamp-android-launcher.apk +adb $* install ../build-android-x86/gluegen-rt-android-x86.apk diff --git a/make/scripts/adb-reinstall-all-x86.sh b/make/scripts/adb-reinstall-all-x86.sh new file mode 100755 index 0000000..7db988d --- /dev/null +++ b/make/scripts/adb-reinstall-all-x86.sh @@ -0,0 +1,5 @@ +sdir=`dirname $0` + +$sdir/adb-uninstall-all.sh $* +$sdir/adb-install-all-x86.sh $* + diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat index 23fbb64..c1afa47 100755 --- a/make/scripts/java-win32.bat +++ b/make/scripts/java-win32.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win32
-set J2RE_HOME=c:\jre1.8.0_60_x32
-set JAVA_HOME=c:\jdk1.8.0_60_x32
+set J2RE_HOME=c:\jre1.8.0_66_x32
+set JAVA_HOME=c:\jdk1.8.0_66_x32
set ANT_PATH=C:\apache-ant-1.9.4
set BLD_DIR=..\%BLD_SUB%
diff --git a/make/scripts/java-win64.bat b/make/scripts/java-win64.bat index 03a77f5..ee854cf 100755 --- a/make/scripts/java-win64.bat +++ b/make/scripts/java-win64.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win64
-set J2RE_HOME=c:\jre1.8.0_60_x64
-set JAVA_HOME=c:\jdk1.8.0_60_x64
+set J2RE_HOME=c:\jre1.8.0_66_x64
+set JAVA_HOME=c:\jdk1.8.0_66_x64
set ANT_PATH=C:\apache-ant-1.9.4
set BLD_DIR=..\%BLD_SUB%
@@ -18,7 +18,9 @@ echo CP_ALL %CP_ALL% set X_ARGS="-Drootrel.build=%BLD_SUB%" "-Dgluegen.root=.."
REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.JNILibLoader" "-Djogamp.debug.TempFileCache" "-Djogamp.debug.JarUtil" "-Djogamp.debug.TempJarCache"
REM set D_ARGS="-Djogamp.debug.Platform" "-Djogamp.debug.NativeLibrary" "-Djogamp.debug.IOUtil"
-set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.IOUtil.Exe" "-Djogamp.debug.IOUtil.Exe.NoStream"
+REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.IOUtil.Exe" "-Djogamp.debug.IOUtil.Exe.NoStream"
+REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.TempFileCache" "-Djogamp.debug.TempJarCache" "-Djogamp.debug.IOUtil.Exe" "-Djogamp.gluegen.UseNativeExeFile=true" "-Djava.io.tmpdir=c:\temp_noexec"
+set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.TempFileCache" "-Djogamp.debug.TempJarCache" "-Djava.io.tmpdir=c:\temp_noexec"
REM set D_ARGS="-Djogamp.debug=all"
REM %J2RE_HOME%\bin\java -classpath %CP_ALL% %X_ARGS% %D_ARGS% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win64.log 2>&1
diff --git a/make/scripts/make.gluegen.all.android-x86-cross.sh b/make/scripts/make.gluegen.all.android-x86-cross.sh new file mode 100755 index 0000000..0889ca7 --- /dev/null +++ b/make/scripts/make.gluegen.all.android-x86-cross.sh @@ -0,0 +1,63 @@ +#! /bin/sh + +SDIR=`dirname $0` + +if [ -e $SDIR/setenv-build-jogl-x86_64.sh ] ; then + . $SDIR/setenv-build-jogl-x86_64.sh +fi + +if [ -e $SDIR/setenv-android-tools.sh ] ; then + . $SDIR/setenv-android-tools.sh +fi + +export NODE_LABEL=. + +export HOST_UID=jogamp +# jogamp02 - 10.1.0.122 +export HOST_IP=10.1.0.122 +export HOST_RSYNC_ROOT=PROJECTS/JOGL + +export TARGET_UID=jogamp +export TARGET_IP=panda02 +#export TARGET_IP=jautab03 +#export TARGET_IP=jauphone04 +export TARGET_ADB_PORT=5555 +# needs executable bit (probably su) +export TARGET_ROOT=/data/projects +export TARGET_ANT_HOME=/usr/share/ant + +export ANDROID_VERSION=15 +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +#export GCC_VERSION=4.4.3 +export GCC_VERSION=4.8 +HOST_ARCH=linux-x86_64 +export TARGET_TRIPLE=i686-linux-android +export TOOLCHAIN_NAME=x86 + +export NDK_TOOLCHAIN_ROOT=$NDK_ROOT/toolchains/${TOOLCHAIN_NAME}-${GCC_VERSION}/prebuilt/${HOST_ARCH} +export TARGET_PLATFORM_ROOT=${NDK_ROOT}/platforms/android-${ANDROID_VERSION}/arch-x86 + +# Need to add toolchain bins to the PATH. +# May need to create symbolic links within $NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin +# cd $NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin +# ln -s ../../bin/i686-linux-android-gcc gcc +export PATH="$NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/$ANDROID_BUILD_TOOLS_VERSION:$PATH" + +export GLUEGEN_CPPTASKS_FILE="lib/gluegen-cpptasks-android-x86.xml" + +#export JUNIT_DISABLED="true" +#export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" + +echo PATH $PATH 2>&1 | tee make.gluegen.all.android-x86-cross.log +echo gcc `which gcc` 2>&1 | tee -a make.gluegen.all.android-x86-cross.log + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + +#BUILD_ARCHIVE=true \ +ant \ + -Drootrel.build=build-android-x86 \ + $* 2>&1 | tee -a make.gluegen.all.android-x86-cross.log diff --git a/make/scripts/make.gluegen.all.linux-aarch64-cross.sh b/make/scripts/make.gluegen.all.linux-aarch64-cross.sh new file mode 100755 index 0000000..5d050cd --- /dev/null +++ b/make/scripts/make.gluegen.all.linux-aarch64-cross.sh @@ -0,0 +1,38 @@ +#! /bin/sh + +SDIR=`dirname $0` + +if [ -e $SDIR/setenv-build-jogl-x86_64.sh ] ; then + . $SDIR/setenv-build-jogl-x86_64.sh +fi + +# aarch64-linux-gnueabi == aarch64 triplet +PATH=`pwd`/lib/toolchain/aarch64-linux-gnueabi/bin:$PATH +export PATH + +# -Dc.compiler.debug=true +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxARM64=true \ +# -DisX11=true \ + +export TARGET_PLATFORM_ROOT=/opt-linux-arm64 +export TARGET_PLATFORM_LIBS=$TARGET_PLATFORM_ROOT/usr/lib +export TARGET_JAVA_LIBS=$TARGET_PLATFORM_ROOT/jre/lib/aarch64 + +export GLUEGEN_CPPTASKS_FILE="lib/gluegen-cpptasks-linux-aarch64.xml" + +#export JUNIT_DISABLED="true" +export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" + +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + +ant \ + -Drootrel.build=build-linux-aarch64 \ + $* 2>&1 | tee make.gluegen.all.linux-aarch64-cross.log diff --git a/make/scripts/make.gluegen.all.linux-aarch64.sh b/make/scripts/make.gluegen.all.linux-aarch64.sh new file mode 100755 index 0000000..53d2851 --- /dev/null +++ b/make/scripts/make.gluegen.all.linux-aarch64.sh @@ -0,0 +1,21 @@ +#! /bin/sh + +# -Dc.compiler.debug=true +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxX86=true \ +# -DisX11=true \ + +# aarch64-linux-gnue == aarch64 triplet +export TARGET_PLATFORM_LIBS=/usr/lib/aarch64-linux-gnu +export TARGET_JAVA_LIBS=/usr/lib/jvm/java-8-openjdk-aarch64/jre/lib/aarch64 + +export GLUEGEN_CPPTASKS_FILE="lib/gluegen-cpptasks-linux-aarch64.xml" + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + +ant \ + -Drootrel.build=build-linux-aarch64 \ + $* 2>&1 | tee make.gluegen.all.linux-aarch64.log diff --git a/make/scripts/make.gluegen.all.sh b/make/scripts/make.gluegen.all.sh index ec97d04..1e1ce0b 100755 --- a/make/scripts/make.gluegen.all.sh +++ b/make/scripts/make.gluegen.all.sh @@ -7,3 +7,4 @@ $SDIR/make.gluegen.all.linux-armv6-cross.sh \ && $SDIR/make.gluegen.all.linux-x86_64.sh \ && $SDIR/make.gluegen.all.linux-x86.sh \ && $SDIR/make.gluegen.all.android-armv6-cross.sh \ +&& $SDIR/make.gluegen.all.android-x86-cross.sh \ diff --git a/make/scripts/make.gluegen.all.win32.bat b/make/scripts/make.gluegen.all.win32.bat index 7d1e832..32b75c2 100755 --- a/make/scripts/make.gluegen.all.win32.bat +++ b/make/scripts/make.gluegen.all.win32.bat @@ -1,7 +1,7 @@ set THISDIR="C:\JOGL"
-set J2RE_HOME=c:\jre1.8.0_60_x32
-set JAVA_HOME=c:\jdk1.8.0_60_x32
+set J2RE_HOME=c:\jre1.8.0_66_x32
+set JAVA_HOME=c:\jdk1.8.0_66_x32
set ANT_PATH=C:\apache-ant-1.9.4
set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/make.gluegen.all.win64.bat b/make/scripts/make.gluegen.all.win64.bat index ad2714d..65429b5 100755 --- a/make/scripts/make.gluegen.all.win64.bat +++ b/make/scripts/make.gluegen.all.win64.bat @@ -1,10 +1,12 @@ set THISDIR="C:\JOGL"
-set J2RE_HOME=c:\jre1.8.0_60_x64
-set JAVA_HOME=c:\jdk1.8.0_60_x64
+set J2RE_HOME=c:\jre1.8.0_66_x64
+set JAVA_HOME=c:\jdk1.8.0_66_x64
set ANT_PATH=C:\apache-ant-1.9.4
+set GIT_PATH=C:\cygwin\bin
+set SEVENZIP=C:\Program Files\7-Zip
-set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;c:\mingw\bin;%PATH%
+set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;c:\mingw\bin;%GIT_PATH%;%SEVENZIP%;%PATH%
set LIB_GEN=%THISDIR%\lib
set CLASSPATH=.;%THISDIR%\build-win64\classes
diff --git a/make/scripts/runtest-x64.bat b/make/scripts/runtest-x64.bat index 70a0ec3..1457174 100755 --- a/make/scripts/runtest-x64.bat +++ b/make/scripts/runtest-x64.bat @@ -4,7 +4,7 @@ REM set TEMP=C:\Users\jogamp\temp-exec REM set TMP=C:\Users\jogamp\temp-exec REM scripts\java-win64.bat com.jogamp.common.GlueGenVersion -REM scripts\java-win64.bat com.jogamp.common.util.TestVersionInfo +scripts\java-win64.bat com.jogamp.common.util.TestVersionInfo REM scripts\java-win64.bat com.jogamp.gluegen.jcpp.IncludeAbsoluteTest @@ -12,7 +12,7 @@ REM scripts\java-win64.bat com.jogamp.gluegen.test.junit.generation.Test1p1JavaE REM scripts\java-win64.bat com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter REM scripts\java-win64.bat com.jogamp.common.util.TestTempJarCache REM scripts\java-win64.bat com.jogamp.common.os.TestElfReader01 -scripts\java-win64.bat com.jogamp.common.util.TestPlatform01 +REM scripts\java-win64.bat com.jogamp.common.util.TestPlatform01 REM scripts\java-win64.bat com.jogamp.common.util.TestIOUtil01 REM scripts\java-win64.bat com.jogamp.common.util.TestJarUtil diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh index a35220e..be2e415 100755 --- a/make/scripts/runtest.sh +++ b/make/scripts/runtest.sh @@ -61,8 +61,10 @@ X_ARGS="-Drootrel.build=$ROOTREL_BUILD -Dgluegen.root=$GLUEGEN_ROOT" #D_ARGS="-Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogamp.debug.IOUtil -Djogamp.debug.IOUtil.Exe -Djogamp.debug.IOUtil.Exe.NoStream" -#D_ARGS="-Djogamp.debug.IOUtil -Djogamp.debug.IOUtil.Exe" +#D_ARGS="-Djogamp.debug.IOUtil -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.IOUtil.Exe" +D_ARGS="-Djogamp.debug.IOUtil -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djava.io.tmpdir=/run/501" #D_ARGS="-Djogamp.debug.ByteBufferInputStream" +#D_ARGS="-Djogamp.debug.Buffers" #D_ARGS="-Djogamp.debug.Bitstream" #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug.Logging" @@ -90,9 +92,9 @@ function onetest() { # #onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestSystemPropsAndEnvs 2>&1 | tee -a $LOG -#onetest com.jogamp.common.util.TestVersionInfo 2>&1 | tee -a $LOG +onetest com.jogamp.common.util.TestVersionInfo 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestVersionNumber 2>&1 | tee -a $LOG -onetest com.jogamp.common.util.TestVersionSemantics 2>&1 | tee -a $LOG +#onetest com.jogamp.common.util.TestVersionSemantics 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestIteratorIndexCORE 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.locks.TestRecursiveLock01 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.locks.TestRecursiveThreadGroupLock01 2>&1 | tee -a $LOG diff --git a/make/stub_includes/platform/glibc-compat-symbols.h b/make/stub_includes/platform/glibc-compat-symbols.h index 1163c78..e390bcb 100644 --- a/make/stub_includes/platform/glibc-compat-symbols.h +++ b/make/stub_includes/platform/glibc-compat-symbols.h @@ -18,7 +18,9 @@ #if defined(__linux__) /* Actually we like to test whether we link against GLIBC .. */ #if defined(__GNUC__) #if defined(__aarch64__) - #define GLIBC_COMPAT_SYMBOL(FFF) __asm__(".symver " #FFF "," #FFF "@GLIBC_2.4"); + /* glibc 2.17 is the first glibc version that support aarch64 + however memcpy is not versioned for aarch64 */ + #define GLIBC_COMPAT_SYMBOL(FFF) #elif defined(__arm__) #define GLIBC_COMPAT_SYMBOL(FFF) __asm__(".symver " #FFF "," #FFF "@GLIBC_2.4"); #elif defined(__amd64__) @@ -28,7 +30,9 @@ #endif /*__amd64__*/ #elif defined(__clang__) #if defined(__aarch64__) - #define GLIBC_COMPAT_SYMBOL(FFF) asm(".symver " #FFF "," #FFF "@GLIBC_2.4"); + /* glibc 2.17 is the first glibc version that support aarch64 + however memcpy is not versioned for aarch64 */ + #define GLIBC_COMPAT_SYMBOL(FFF) #elif defined(__arm__) #define GLIBC_COMPAT_SYMBOL(FFF) asm(".symver " #FFF "," #FFF "@GLIBC_2.4"); #elif defined(__amd64__) diff --git a/src/java/com/jogamp/common/nio/Buffers.java b/src/java/com/jogamp/common/nio/Buffers.java index aae2be8..fb23627 100644 --- a/src/java/com/jogamp/common/nio/Buffers.java +++ b/src/java/com/jogamp/common/nio/Buffers.java @@ -39,6 +39,7 @@ */ package com.jogamp.common.nio; +import java.lang.reflect.Method; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -48,9 +49,14 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.LongBuffer; import java.nio.ShortBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.ValueConv; +import jogamp.common.Debug; + /** * Utility methods allowing easy {@link java.nio.Buffer} manipulations. * @@ -60,6 +66,11 @@ import com.jogamp.common.util.ValueConv; */ public class Buffers { + static final boolean DEBUG; + static { + DEBUG = Debug.debug("Buffers"); + } + public static final int SIZEOF_BYTE = 1; public static final int SIZEOF_SHORT = 2; public static final int SIZEOF_CHAR = 2; @@ -1150,4 +1161,64 @@ public class Buffers { return sb; } + /** + * Access to NIO {@link sun.misc.Cleaner}, allowing caller to deterministically clean a given {@link sun.nio.ch.DirectBuffer}. + */ + public static class Cleaner { + private static final Method mbbCleaner; + private static final Method cClean; + private static final boolean hasCleaner; + /** OK to be lazy on thread synchronization, just for early out **/ + private static volatile boolean cleanerError; + static { + final Method[] _mbbCleaner = { null }; + final Method[] _cClean = { null }; + if( AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + @Override + public Boolean run() { + try { + _mbbCleaner[0] = ReflectionUtil.getMethod("sun.nio.ch.DirectBuffer", "cleaner", null, Buffers.class.getClassLoader()); + _mbbCleaner[0].setAccessible(true); + _cClean[0] = Class.forName("sun.misc.Cleaner").getMethod("clean"); + _cClean[0].setAccessible(true); + return Boolean.TRUE; + } catch(final Throwable t) { + if( DEBUG ) { + System.err.println("Caught "+t.getMessage()); + t.printStackTrace(); + } + return Boolean.FALSE; + } } } ).booleanValue() ) { + mbbCleaner = _mbbCleaner[0]; + cClean = _cClean[0]; + hasCleaner = null != mbbCleaner && null != cClean; + } else { + mbbCleaner = null; + cClean = null; + hasCleaner = false; + } + cleanerError = !hasCleaner; + } + /** + * If {@code b} is an direct NIO buffer, i.e {@link sun.nio.ch.DirectBuffer}, + * calls it's {@link sun.misc.Cleaner} instance {@code clean()} method. + * @return {@code true} if successful, otherwise {@code false}. + */ + public static boolean clean(final Buffer b) { + if( !hasCleaner || cleanerError || !b.isDirect() ) { + return false; + } + try { + cClean.invoke(mbbCleaner.invoke(b)); + return true; + } catch(final Throwable t) { + cleanerError = true; + if( DEBUG ) { + System.err.println("Caught "+t.getMessage()); + t.printStackTrace(); + } + return false; + } + } + } } diff --git a/src/java/com/jogamp/common/nio/MappedByteBufferInputStream.java b/src/java/com/jogamp/common/nio/MappedByteBufferInputStream.java index f8d5857..6a56d6e 100644 --- a/src/java/com/jogamp/common/nio/MappedByteBufferInputStream.java +++ b/src/java/com/jogamp/common/nio/MappedByteBufferInputStream.java @@ -33,13 +33,10 @@ import java.io.OutputStream; import java.io.PrintStream; import java.io.RandomAccessFile; import java.lang.ref.WeakReference; -import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.nio.channels.FileChannel.MapMode; -import java.security.AccessController; -import java.security.PrivilegedAction; import jogamp.common.Debug; @@ -163,10 +160,6 @@ public class MappedByteBufferInputStream extends InputStream { private int refCount; - private Method mbbCleaner; - private Method cClean; - private boolean cleanerInit; - private boolean hasCleaner; private CacheMode cmode; private int sliceIdx; @@ -191,10 +184,12 @@ public class MappedByteBufferInputStream extends InputStream { } } long fcSz = 0, pos = 0, rem = 0; - try { - fcSz = fc.size(); - } catch (final IOException e) { - e.printStackTrace(); + if( fc.isOpen() ) { + try { + fcSz = fc.size(); + } catch (final IOException e) { + e.printStackTrace(); + } } if( 0 < refCount ) { try { @@ -229,14 +224,16 @@ public class MappedByteBufferInputStream extends InputStream { notifyLengthChange( totalSize ); this.refCount = 1; - this.cleanerInit = false; - this.hasCleaner = false; this.cmode = cmode; this.sliceIdx = currSliceIdx; this.mark = -1; currentSlice().position(0); + + if( MappedByteBufferInputStream.DEBUG ) { + this.dbgDump("CTOR", System.err); + } } /** @@ -330,6 +327,9 @@ public class MappedByteBufferInputStream extends InputStream { } } } + if( MappedByteBufferInputStream.DEBUG ) { + this.dbgDump("Close", System.err); + } } final FileChannel.MapMode getMapMode() { return mmode; } @@ -441,10 +441,9 @@ public class MappedByteBufferInputStream extends InputStream { } position2( Math.min(prePosition, newTotalSize) ); // -> clipped position (set currSlice and re-map/-pos buffer) } - /* if( DEBUG ) { - System.err.println("notifyLengthChange.X: "+slices[currSlice]); - dbgDump("notifyLengthChange.X:", System.err); - } */ + if( MappedByteBufferInputStream.DEBUG ) { + this.dbgDump("NotifyLengthChange", System.err); + } } /** @@ -551,6 +550,21 @@ public class MappedByteBufferInputStream extends InputStream { } } + /** + * Releases the mapped {@link ByteBuffer} slices. + * @throws IOException if a buffer slice operation failed. + */ + public final synchronized void flushSlices() throws IOException { + if( null != slices ) { + for(int i=0; i<sliceCount; i++) { + flushSlice(i, synchronous); + } + } + if( MappedByteBufferInputStream.DEBUG ) { + this.dbgDump("FlushSlices", System.err); + } + } + synchronized void syncSlice(final ByteBuffer s) throws IOException { syncSlice(s, synchronous); } @@ -630,58 +644,16 @@ public class MappedByteBufferInputStream extends InputStream { } } private synchronized boolean cleanBuffer(final ByteBuffer mbb, final boolean syncBuffer) throws IOException { - if( !cleanerInit ) { - initCleaner(mbb); - } syncSlice(mbb, syncBuffer); if( !mbb.isDirect() ) { return false; } - boolean res = false; - if ( hasCleaner ) { - try { - cClean.invoke(mbbCleaner.invoke(mbb)); - res = true; - } catch(final Throwable t) { - hasCleaner = false; - if( DEBUG ) { - System.err.println("Caught "+t.getMessage()); - t.printStackTrace(); - } - } - } - if( !res && CacheMode.FLUSH_PRE_HARD == cmode ) { + if( !Buffers.Cleaner.clean(mbb) && CacheMode.FLUSH_PRE_HARD == cmode ) { cmode = CacheMode.FLUSH_PRE_SOFT; + return false; + } else { + return true; } - return res; - } - private synchronized void initCleaner(final ByteBuffer bb) { - final Method[] _mbbCleaner = { null }; - final Method[] _cClean = { null }; - AccessController.doPrivileged(new PrivilegedAction<Object>() { - @Override - public Object run() { - try { - _mbbCleaner[0] = bb.getClass().getMethod("cleaner"); - _mbbCleaner[0].setAccessible(true); - _cClean[0] = Class.forName("sun.misc.Cleaner").getMethod("clean"); - _cClean[0].setAccessible(true); - } catch(final Throwable t) { - if( DEBUG ) { - System.err.println("Caught "+t.getMessage()); - t.printStackTrace(); - } - } - return null; - } } ); - mbbCleaner = _mbbCleaner[0]; - cClean = _cClean[0]; - final boolean res = null != mbbCleaner && null != cClean; - if( DEBUG ) { - System.err.println("initCleaner: Has cleaner: "+res+", mbbCleaner "+mbbCleaner+", cClean "+cClean); - } - hasCleaner = res; - cleanerInit = true; } /** diff --git a/src/java/com/jogamp/common/os/AndroidVersion.java b/src/java/com/jogamp/common/os/AndroidVersion.java index 840933f..c2c2159 100644 --- a/src/java/com/jogamp/common/os/AndroidVersion.java +++ b/src/java/com/jogamp/common/os/AndroidVersion.java @@ -74,15 +74,20 @@ public class AndroidVersion { Object abvObject= null; Class<?> abvcClass = null; Object abvcObject= null; - try { - abClass = ReflectionUtil.getClass(androidBuild, true, cl); - abObject = abClass.newInstance(); - abvClass = ReflectionUtil.getClass(androidBuildVersion, true, cl); - abvObject = abvClass.newInstance(); - abvcClass = ReflectionUtil.getClass(androidBuildVersionCodes, true, cl); - abvcObject = abvcClass.newInstance(); - } catch (final Exception e) { /* n/a */ } - isAvailable = null != abObject && null != abvObject; + + boolean isDalvikVm = "Dalvik".equals(System.getProperty("java.vm.name")); + + if (isDalvikVm) { + try { + abClass = ReflectionUtil.getClass(androidBuild, true, cl); + abObject = abClass.newInstance(); + abvClass = ReflectionUtil.getClass(androidBuildVersion, true, cl); + abvObject = abvClass.newInstance(); + abvcClass = ReflectionUtil.getClass(androidBuildVersionCodes, true, cl); + abvcObject = abvcClass.newInstance(); + } catch (final Exception e) { /* n/a */ } + } + isAvailable = isDalvikVm && null != abObject && null != abvObject; if(isAvailable) { CPU_ABI = getString(abClass, abObject, "CPU_ABI", true); CPU_ABI2 = getString(abClass, abObject, "CPU_ABI2", true); diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java index 66a24eb..a3d6198 100644 --- a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java +++ b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java @@ -249,9 +249,12 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { return aptr; } - protected static final NativeLibrary loadFirstAvailable(final List<String> libNames, final ClassLoader loader, final boolean global) throws SecurityException { + protected static final NativeLibrary loadFirstAvailable(final List<String> libNames, + final boolean searchSystemPath, + final boolean searchSystemPathFirst, + final ClassLoader loader, final boolean global) throws SecurityException { for (int i=0; i < libNames.size(); i++) { - final NativeLibrary lib = NativeLibrary.open(libNames.get(i), loader, global); + final NativeLibrary lib = NativeLibrary.open(libNames.get(i), searchSystemPath, searchSystemPathFirst, loader, global); if (lib != null) { return lib; } @@ -269,7 +272,10 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { for (i=0; i < toolLibNames.size(); i++) { final List<String> libNames = toolLibNames.get(i); if( null != libNames && libNames.size() > 0 ) { - lib = loadFirstAvailable(libNames, cl, info.shallLinkGlobal()); + lib = loadFirstAvailable(libNames, + info.searchToolLibInSystemPath(), + info.searchToolLibSystemPathFirst(), + cl, info.shallLinkGlobal()); if ( null == lib ) { if(DEBUG) { System.err.println("Unable to load any Tool library of: "+libNames); diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java b/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java index 7be5f25..01068b4 100644 --- a/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java +++ b/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java @@ -37,6 +37,21 @@ public interface DynamicLibraryBundleInfo { public static final boolean DEBUG = DynamicLibraryBundle.DEBUG; /** + * Returns {@code true} if tool libraries shall be searched in the system path <i>(default)</i>, otherwise {@code false}. + * @since 2.4.0 + */ + public boolean searchToolLibInSystemPath(); + + /** + * Returns {@code true} if system path shall be searched <i>first</i> <i>(default)</i>, rather than searching it last. + * <p> + * If {@link #searchToolLibInSystemPath()} is {@code false} the return value is ignored. + * </p> + * @since 2.4.0 + */ + public boolean searchToolLibSystemPathFirst(); + + /** * If a {@link SecurityManager} is installed, user needs link permissions * for the named libraries. * diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java index 49e921f..2ba2581 100644 --- a/src/java/com/jogamp/common/os/NativeLibrary.java +++ b/src/java/com/jogamp/common/os/NativeLibrary.java @@ -138,23 +138,31 @@ public final class NativeLibrary implements DynamicLookupHelper { } /** Opens the given native library, assuming it has the same base - name on all platforms, looking first in the system's search - path, and in the context of the specified ClassLoader, which is - used to help find the library in the case of e.g. Java Web Start. - * @throws SecurityException if user is not granted access for the named library. - */ - public static final NativeLibrary open(final String libName, final ClassLoader loader) throws SecurityException { - return open(libName, libName, libName, true, loader, true); - } - - /** Opens the given native library, assuming it has the same base - name on all platforms, looking first in the system's search - path, and in the context of the specified ClassLoader, which is - used to help find the library in the case of e.g. Java Web Start. + name on all platforms. + <p> + The {@code searchSystemPath} argument changes the behavior to + either use the default system path or not at all. + </p> + <p> + Assuming {@code searchSystemPath} is {@code true}, + the {@code searchSystemPathFirst} argument changes the behavior to first + search the default system path rather than searching it last. + </p> + * @param libName library name, with or without prefix and suffix + * @param searchSystemPath if {@code true} library shall be searched in the system path <i>(default)</i>, otherwise {@code false}. + * @param searchSystemPathFirst if {@code true} system path shall be searched <i>first</i> <i>(default)</i>, rather than searching it last. + * if {@code searchSystemPath} is {@code false} this argument is ignored. + * @param loader {@link ClassLoader} to locate the library + * @param global if {@code true} allows system wide access of the loaded library, otherwise access is restricted to the process. + * @return {@link NativeLibrary} instance or {@code null} if library could not be loaded. * @throws SecurityException if user is not granted access for the named library. + * @since 2.4.0 */ - public static final NativeLibrary open(final String libName, final ClassLoader loader, final boolean global) throws SecurityException { - return open(libName, libName, libName, true, loader, global); + public static final NativeLibrary open(final String libName, + final boolean searchSystemPath, + final boolean searchSystemPathFirst, + final ClassLoader loader, final boolean global) throws SecurityException { + return open(libName, libName, libName, searchSystemPath, searchSystemPathFirst, loader, global); } /** Opens the given native library, assuming it has the given base @@ -163,7 +171,12 @@ public final class NativeLibrary implements DynamicLookupHelper { context of the specified ClassLoader, which is used to help find the library in the case of e.g. Java Web Start. <p> - The {@code searchSystemPathFirst} argument changes the behavior to first + The {@code searchSystemPath} argument changes the behavior to + either use the default system path or not at all. + </p> + <p> + Assuming {@code searchSystemPath} is {@code true}, + the {@code searchSystemPathFirst} argument changes the behavior to first search the default system path rather than searching it last. </p> Note that we do not currently handle DSO versioning on Unix. @@ -173,29 +186,27 @@ public final class NativeLibrary implements DynamicLookupHelper { ending in .so, for example .so.0), and in general if this dynamic loading facility is used correctly the version number will be irrelevant. + * @param windowsLibName windows library name, with or without prefix and suffix + * @param unixLibName unix library name, with or without prefix and suffix + * @param macOSXLibName mac-osx library name, with or without prefix and suffix + * @param searchSystemPath if {@code true} library shall be searched in the system path <i>(default)</i>, otherwise {@code false}. + * @param searchSystemPathFirst if {@code true} system path shall be searched <i>first</i> <i>(default)</i>, rather than searching it last. + * if {@code searchSystemPath} is {@code false} this argument is ignored. + * @param loader {@link ClassLoader} to locate the library + * @param global if {@code true} allows system wide access of the loaded library, otherwise access is restricted to the process. + * @return {@link NativeLibrary} instance or {@code null} if library could not be loaded. * @throws SecurityException if user is not granted access for the named library. */ public static final NativeLibrary open(final String windowsLibName, final String unixLibName, final String macOSXLibName, + final boolean searchSystemPath, final boolean searchSystemPathFirst, - final ClassLoader loader) throws SecurityException { - return open(windowsLibName, unixLibName, macOSXLibName, searchSystemPathFirst, loader, true); - } - - /** - * @throws SecurityException if user is not granted access for the named library. - */ - public static final NativeLibrary open(final String windowsLibName, - final String unixLibName, - final String macOSXLibName, - final boolean searchSystemPathFirst, - final ClassLoader loader, - final boolean global) throws SecurityException { + final ClassLoader loader, final boolean global) throws SecurityException { final List<String> possiblePaths = enumerateLibraryPaths(windowsLibName, unixLibName, macOSXLibName, - searchSystemPathFirst, + searchSystemPath, searchSystemPathFirst, loader); Platform.initSingleton(); // loads native gluegen-rt library diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index 517c21c..0381ebc 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -43,10 +43,13 @@ import java.io.Reader; import java.io.SyncFailedException; import java.lang.ref.WeakReference; import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; import java.nio.ByteBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.regex.Pattern; import jogamp.common.Debug; @@ -54,6 +57,7 @@ import jogamp.common.os.AndroidUtils; import jogamp.common.os.PlatformPropsImpl; import com.jogamp.common.ExceptionUtils; +import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.net.AssetURLContext; import com.jogamp.common.net.Uri; import com.jogamp.common.nio.Buffers; @@ -65,14 +69,56 @@ public class IOUtil { private static final boolean DEBUG_EXE; private static final boolean DEBUG_EXE_NOSTREAM; private static final boolean DEBUG_EXE_EXISTING_FILE; + private static final boolean testTempDirExec; + private static final Method fileToPathGetter; + private static final Method isExecutableQuery; + private static final boolean useNativeExeFile; static { - Debug.initSingleton(); - DEBUG = Debug.debug("IOUtil"); - DEBUG_EXE = PropertyAccess.isPropertyDefined("jogamp.debug.IOUtil.Exe", true); - DEBUG_EXE_NOSTREAM = PropertyAccess.isPropertyDefined("jogamp.debug.IOUtil.Exe.NoStream", true); - // For security reasons, we have to hardcode this, i.e. disable this manual debug feature! - DEBUG_EXE_EXISTING_FILE = false; // PropertyAccess.isPropertyDefined("jogamp.debug.IOUtil.Exe.ExistingFile", true); + final boolean _props[] = { false, false, false, false, false, false }; + final Method[] res = AccessController.doPrivileged(new PrivilegedAction<Method[]>() { + @Override + public Method[] run() { + final Method[] res = new Method[] { null, null }; + try { + int i=0; + _props[i++] = Debug.debug("IOUtil"); + _props[i++] = PropertyAccess.isPropertyDefined("jogamp.debug.IOUtil.Exe", true); + _props[i++] = PropertyAccess.isPropertyDefined("jogamp.debug.IOUtil.Exe.NoStream", true); + // For security reasons, we have to hardcode this, i.e. disable this manual debug feature! + _props[i++] = false; // PropertyAccess.isPropertyDefined("jogamp.debug.IOUtil.Exe.ExistingFile", true); + _props[i++] = PropertyAccess.getBooleanProperty("jogamp.gluegen.TestTempDirExec", true, true); + _props[i++] = PropertyAccess.getBooleanProperty("jogamp.gluegen.UseNativeExeFile", true, false); + + // Java 1.7 + i=0; + res[i] = File.class.getDeclaredMethod("toPath"); + res[i++].setAccessible(true); + final Class<?> nioPathClz = ReflectionUtil.getClass("java.nio.file.Path", false, IOUtil.class.getClassLoader()); + final Class<?> nioFilesClz = ReflectionUtil.getClass("java.nio.file.Files", false, IOUtil.class.getClassLoader()); + res[i] = nioFilesClz.getDeclaredMethod("isExecutable", nioPathClz); + res[i++].setAccessible(true); + } catch (final Throwable t) { + if(_props[0]) { + ExceptionUtils.dumpThrowable("ioutil-init", t); + } + } + return res; + } + }); + { + int i=0; + DEBUG = _props[i++]; + DEBUG_EXE = _props[i++]; + DEBUG_EXE_NOSTREAM = _props[i++]; + DEBUG_EXE_EXISTING_FILE = _props[i++]; + testTempDirExec = _props[i++]; + useNativeExeFile = _props[i++]; + + i=0; + fileToPathGetter = res[i++]; + isExecutableQuery = res[i++]; + } } /** Std. temporary directory property key <code>java.io.tmpdir</code>. */ @@ -708,7 +754,7 @@ public class IOUtil { private static String getExeTestFileSuffix() { switch(PlatformPropsImpl.OS_TYPE) { case WINDOWS: - if( Platform.CPUFamily.X86 == PlatformPropsImpl.CPU_ARCH.family ) { + if( useNativeExeFile && Platform.CPUFamily.X86 == PlatformPropsImpl.CPU_ARCH.family ) { return ".exe"; } else { return ".bat"; @@ -722,7 +768,7 @@ public class IOUtil { case WINDOWS: return "echo off"+PlatformPropsImpl.NEWLINE; default: - return null; + return "#!/bin/true"+PlatformPropsImpl.NEWLINE; } } private static String[] getExeTestCommandArgs(final String scriptFile) { @@ -749,7 +795,8 @@ public class IOUtil { private static WeakReference<byte[]> exeTestCodeRef = null; private static void fillExeTestFile(final File exefile) throws IOException { - if( Platform.OSType.WINDOWS == PlatformPropsImpl.OS_TYPE && + if( useNativeExeFile && + Platform.OSType.WINDOWS == PlatformPropsImpl.OS_TYPE && Platform.CPUFamily.X86 == PlatformPropsImpl.CPU_ARCH.family ) { final byte[] exeTestCode; @@ -906,6 +953,18 @@ public class IOUtil { } } + private static final Boolean isNioExecutableFile(final File file) { + if( null != fileToPathGetter && null != isExecutableQuery ) { + try { + return (Boolean) isExecutableQuery.invoke(null, fileToPathGetter.invoke(file)); + } catch (final Throwable t) { + throw new JogampRuntimeException("error invoking Files.isExecutable(file.toPath())", t); + } + } else { + return null; + } + } + /** * Returns true if the given {@code dir} * <ol> @@ -923,6 +982,12 @@ public class IOUtil { { final boolean debug = DEBUG_EXE || DEBUG; + if( !testTempDirExec ) { + if(DEBUG) { + System.err.println("IOUtil.testDirExec: <"+dir.getAbsolutePath()+">: Disabled TestTempDirExec"); + } + return false; + } if (!testFile(dir, true, true)) { if( debug ) { System.err.println("IOUtil.testDirExec: <"+dir.getAbsolutePath()+">: Not writeable dir"); @@ -947,6 +1012,7 @@ public class IOUtil { } else { exeTestFile = File.createTempFile("jogamp_exe_tst", getExeTestFileSuffix(), dir); existingExe = false; + fillExeTestFile(exeTestFile); } } catch (final SecurityException se) { throw se; // fwd Security exception @@ -960,41 +1026,52 @@ public class IOUtil { long t2; int res = -1; int exitValue = -1; + Boolean isNioExec = null; if( existingExe || exeTestFile.setExecutable(true /* exec */, true /* ownerOnly */) ) { - Process pr = null; - try { - if( !existingExe ) { - fillExeTestFile(exeTestFile); - } - t2 = debug ? System.currentTimeMillis() : 0; - // Using 'Process.exec(String[])' avoids StringTokenizer of 'Process.exec(String)' - // and hence splitting up command by spaces! - // Note: All no-exec cases throw an IOExceptions at ProcessBuilder.start(), i.e. below exec() call! - pr = Runtime.getRuntime().exec( getExeTestCommandArgs( exeTestFile.getCanonicalPath() ), null, null ); - if( DEBUG_EXE && !DEBUG_EXE_NOSTREAM ) { - new StreamMonitor(new InputStream[] { pr.getInputStream(), pr.getErrorStream() }, System.err, "Exe-Tst: "); - } - pr.waitFor(); - exitValue = pr.exitValue(); // Note: Bug 1219 Comment 50: On reporter's machine exit value 1 is being returned - res = 0; // file has been executed - } catch (final SecurityException se) { - throw se; // fwd Security exception - } catch (final Throwable t) { - t2 = debug ? System.currentTimeMillis() : 0; - res = -2; - if( debug ) { - System.err.println("IOUtil.testDirExec: <"+exeTestFile.getAbsolutePath()+">: Caught "+t.getClass().getSimpleName()+": "+t.getMessage()); - t.printStackTrace(); - } - } finally { - if( null != pr ) { - // Bug 1219 Comment 58: Ensure that the launched process gets terminated! - // This is Process implementation specific and varies on different platforms, - // hence it may be required. - try { - pr.destroy(); - } catch (final Throwable t) { - ExceptionUtils.dumpThrowable("", t); + t2 = debug ? System.currentTimeMillis() : 0; + // First soft exec test via NIO's ACL check, if available + isNioExec = isNioExecutableFile(exeTestFile); + if( null != isNioExec ) { + res = isNioExec.booleanValue() ? 0 : -1; + } + if( null == isNioExec || 0 <= res ) { + // Hard exec test via actual execution, if NIO's ACL check succeeded or not available. + // Required, since Windows 'Software Restriction Policies (SRP)' won't be triggered merely by NIO's ACL check. + Process pr = null; + try { + // Using 'Process.exec(String[])' avoids StringTokenizer of 'Process.exec(String)' + // and hence splitting up command by spaces! + // Note: All no-exec cases throw an IOExceptions at ProcessBuilder.start(), i.e. below exec() call! + pr = Runtime.getRuntime().exec( getExeTestCommandArgs( exeTestFile.getCanonicalPath() ), null, null ); + if( DEBUG_EXE && !DEBUG_EXE_NOSTREAM ) { + new StreamMonitor(new InputStream[] { pr.getInputStream(), pr.getErrorStream() }, System.err, "Exe-Tst: "); + } + pr.waitFor(); + exitValue = pr.exitValue(); // Note: Bug 1219 Comment 50: On reporter's machine exit value 1 is being returned + if( 0 == exitValue ) { + res++; // file has been executed and exited normally + } else { + res = -2; // abnormal termination + } + } catch (final SecurityException se) { + throw se; // fwd Security exception + } catch (final Throwable t) { + t2 = debug ? System.currentTimeMillis() : 0; + res = -3; + if( debug ) { + System.err.println("IOUtil.testDirExec: <"+exeTestFile.getAbsolutePath()+">: Caught "+t.getClass().getSimpleName()+": "+t.getMessage()); + t.printStackTrace(); + } + } finally { + if( null != pr ) { + // Bug 1219 Comment 58: Ensure that the launched process gets terminated! + // This is Process implementation specific and varies on different platforms, + // hence it may be required. + try { + pr.destroy(); + } catch (final Throwable t) { + ExceptionUtils.dumpThrowable("", t); + } } } } @@ -1002,13 +1079,13 @@ public class IOUtil { t2 = debug ? System.currentTimeMillis() : 0; } - final boolean ok = 0 == res; + final boolean ok = 0 <= res; if( !DEBUG_EXE && !existingExe ) { exeTestFile.delete(); } if( debug ) { final long t3 = System.currentTimeMillis(); - System.err.println("IOUtil.testDirExec(): test-exe <"+exeTestFile.getAbsolutePath()+">, existingFile "+existingExe+", returned "+exitValue); + System.err.println("IOUtil.testDirExec(): test-exe <"+exeTestFile.getAbsolutePath()+">, existingFile "+existingExe+", isNioExec "+isNioExec+", returned "+exitValue); System.err.println("IOUtil.testDirExec(): abs-path <"+dir.getAbsolutePath()+">: res "+res+" -> "+ok); System.err.println("IOUtil.testDirExec(): total "+(t3-t0)+"ms, create "+(t1-t0)+"ms, fill "+(t2-t1)+"ms, execute "+(t3-t2)+"ms"); } diff --git a/src/java/jogamp/common/os/PlatformPropsImpl.java b/src/java/jogamp/common/os/PlatformPropsImpl.java index 81bdfef..55335c1 100644 --- a/src/java/jogamp/common/os/PlatformPropsImpl.java +++ b/src/java/jogamp/common/os/PlatformPropsImpl.java @@ -275,9 +275,9 @@ public abstract class PlatformPropsImpl { } ABI_TYPE = elfABIType; } else { - if( AndroidVersion.CPU_TYPE.family == CPUFamily.ARM || + if( AndroidVersion.CPU_TYPE.family == CPUFamily.ARM || AndroidVersion.CPU_TYPE.family == CPUFamily.X86 || null == AndroidVersion.CPU_TYPE2 ) { - // Favor Android-1: Either b/c ARM Family, or no Android-2 + // Favor Android-1: Either b/c ARM or x86 Family, or no Android-2 ARCH = AndroidVersion.CPU_ABI; ARCH_lower = ARCH; CPU_ARCH = AndroidVersion.CPU_TYPE; @@ -511,6 +511,7 @@ public abstract class PlatformPropsImpl { * <ul> * <li>android-armv6</li> * <li>android-aarch64</li> + * <li>android-x86</li> * <li>linux-armv6</li> * <li>linux-armv6hf</li> * <li>linux-i586</li> diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java index 701342f..e61c600 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java @@ -48,7 +48,7 @@ public class Test1p2LoadJNIAndImplLib extends BaseClass { @BeforeClass public static void chapter__TestLoadLibrary() throws Exception { BindingJNILibLoader.loadBindingtest1p2(); - dynamicLookupHelper = NativeLibrary.open("test1", Test1p2LoadJNIAndImplLib.class.getClassLoader(), true); + dynamicLookupHelper = NativeLibrary.open("test1", true, true, Test1p2LoadJNIAndImplLib.class.getClassLoader(), true); Assert.assertNotNull("NativeLibrary.open(test1) failed", dynamicLookupHelper); Bindingtest1p2Impl.resetProcAddressTable(dynamicLookupHelper); 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 917ca96..fa99915 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java @@ -57,7 +57,7 @@ public class Test1p2ProcAddressEmitter extends BaseClass { @BeforeClass public static void chapter__TestLoadLibrary() throws Exception { BindingJNILibLoader.loadBindingtest1p2(); - dynamicLookupHelper = NativeLibrary.open("test1", Test1p2ProcAddressEmitter.class.getClassLoader(), true); + dynamicLookupHelper = NativeLibrary.open("test1", false, false, Test1p2ProcAddressEmitter.class.getClassLoader(), true); Assert.assertNotNull("NativeLibrary.open(test1) failed", dynamicLookupHelper); Bindingtest1p2Impl.resetProcAddressTable(dynamicLookupHelper); diff --git a/src/junit/com/jogamp/junit/sec/Applet01.java b/src/junit/com/jogamp/junit/sec/Applet01.java index f028d7c..fd13207 100644 --- a/src/junit/com/jogamp/junit/sec/Applet01.java +++ b/src/junit/com/jogamp/junit/sec/Applet01.java @@ -201,7 +201,7 @@ public class Applet01 extends Applet { final Uri absLib = libDir1.concat(Uri.Encoded.cast("natives/" + libBaseName)); Exception sec01 = null; try { - final NativeLibrary nlib = NativeLibrary.open(absLib.toFile().getPath(), cl); + final NativeLibrary nlib = NativeLibrary.open(absLib.toFile().getPath(), true, true, cl, true); System.err.println("NativeLibrary: "+nlib); } catch (final SecurityException e) { sec01 = e; diff --git a/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java b/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java index b3a1877..27f8d0b 100644 --- a/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java +++ b/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java @@ -183,7 +183,7 @@ public class TestSecIOUtil01 extends SingletonJunitCase { Exception se0 = null; NativeLibrary nlib = null; try { - nlib = NativeLibrary.open(absLib.toFile().getPath(), cl); + nlib = NativeLibrary.open(absLib.toFile().getPath(), true, true, cl, true); System.err.println("NativeLibrary: "+nlib); } catch (final SecurityException e) { se0 = e; |