diff options
author | Sven Gothel <[email protected]> | 2012-03-28 03:09:39 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-03-28 03:09:39 +0200 |
commit | 0d486ab4bc73a53218cb015936aed755e8e9e6de (patch) | |
tree | f6d02062c504c3a23ba5bd9df0a1c50b725c1721 /src | |
parent | dd19355464d63ff2e77013f2e537e49d3ba750a1 (diff) |
Add support for armhf/gnueabihf resulting in new 'os.and.arch' := [ 'android-armv7hf' and 'linux-armv7hf' ]
- Platform gets new ABIType [ GENERIC, ARMEL, ARMHF ]
- Platform impl. needs to guess ABIType in case of ARM,
since no Java system property ('os.arch' ..) reflects the new EABI.
I consider this a bug, since this will also hinder JNLP to work.
The latter also uses 'os.arch' sys property to determine the nativelib resource!
(See Platform.guessABITypeImpl(..) for details how we guess the type.)
- Adding symbolic links to ubuntu's gnueabihf cross tool chain
- Adding armhf crossbuild script
Diffstat (limited to 'src')
5 files changed, 161 insertions, 40 deletions
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index 6553b07..461ed2a 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -148,6 +148,21 @@ public class Platform { } public static final CPUType CPU_ARCH; + public enum ABIType { + GENERIC_ABI ( 0x0000 ), + /** ARM GNU-EABI ARMEL -mfloat-abi=softfp */ + EABI_GNU_ARMEL ( 0x0001 ), + /** ARM GNU-EABI ARMHF -mfloat-abi=hard */ + EABI_GNU_ARMHF ( 0x0002 ); + + public final int id; + + ABIType(int id){ + this.id = id; + } + } + public static final ABIType ABI_TYPE; + private static final boolean is32Bit; private static final MachineDescription machineDescription; @@ -174,44 +189,16 @@ public class Platform { LITTLE_ENDIAN = queryIsLittleEndianImpl(); - if( ARCH_lower.equals("x86") || - ARCH_lower.equals("i386") || - ARCH_lower.equals("i486") || - ARCH_lower.equals("i586") || - ARCH_lower.equals("i686") ) { - CPU_ARCH = CPUType.X86_32; - } else if( ARCH_lower.equals("x86_64") || - ARCH_lower.equals("amd64") ) { - CPU_ARCH = CPUType.X86_64; - } else if( ARCH_lower.equals("ia64") ) { - CPU_ARCH = CPUType.IA64; - } else if( ARCH_lower.equals("arm") ) { - CPU_ARCH = CPUType.ARM; - } else if( ARCH_lower.equals("armv5l") ) { - CPU_ARCH = CPUType.ARMv5; - } else if( ARCH_lower.equals("armv6l") ) { - CPU_ARCH = CPUType.ARMv6; - } else if( ARCH_lower.equals("armv7l") ) { - CPU_ARCH = CPUType.ARMv7; - } else if( ARCH_lower.equals("sparc") ) { - CPU_ARCH = CPUType.SPARC_32; - } else if( ARCH_lower.equals("sparcv9") ) { - CPU_ARCH = CPUType.SPARCV9_64; - } else if( ARCH_lower.equals("pa_risc2.0") ) { - CPU_ARCH = CPUType.PA_RISC2_0; - } else if( ARCH_lower.equals("ppc") ) { - CPU_ARCH = CPUType.PPC; - } else { - throw new RuntimeException("Please port CPU detection to your platform (" + OS_lower + "/" + ARCH_lower + ")"); - } + CPU_ARCH = getCPUTypeImpl(ARCH_lower); + ABI_TYPE = guessABITypeImpl(CPU_ARCH); OS_TYPE = getOSTypeImpl(); - - os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH); + os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH, ABI_TYPE); USE_TEMP_JAR_CACHE = (OS_TYPE != OSType.ANDROID) && isRunningFromJarURL() && Debug.getBooleanProperty(useTempJarCachePropName, true, true); loadGlueGenRTImpl(); + JVMUtil.initSingleton(); // requires gluegen-rt, one-time init. MachineDescription md = MachineDescriptionRuntime.getRuntime(); @@ -267,6 +254,65 @@ public class Platform { return 0x0C0D == tst_s.get(0); } + private static CPUType getCPUTypeImpl(String archLower) { + if( archLower.equals("x86") || + archLower.equals("i386") || + archLower.equals("i486") || + archLower.equals("i586") || + archLower.equals("i686") ) { + return CPUType.X86_32; + } else if( archLower.equals("x86_64") || + archLower.equals("amd64") ) { + return CPUType.X86_64; + } else if( archLower.equals("ia64") ) { + return CPUType.IA64; + } else if( archLower.equals("arm") ) { + return CPUType.ARM; + } else if( archLower.equals("armv5l") ) { + return CPUType.ARMv5; + } else if( archLower.equals("armv6l") ) { + return CPUType.ARMv6; + } else if( archLower.equals("armv7l") ) { + return CPUType.ARMv7; + } else if( archLower.equals("sparc") ) { + return CPUType.SPARC_32; + } else if( archLower.equals("sparcv9") ) { + return CPUType.SPARCV9_64; + } else if( archLower.equals("pa_risc2.0") ) { + return CPUType.PA_RISC2_0; + } else if( archLower.equals("ppc") ) { + return CPUType.PPC; + } else { + throw new RuntimeException("Please port CPU detection to your platform (" + OS_lower + "/" + archLower + ")"); + } + } + + private static boolean contains(String data, String[] search) { + if(null != data && null != search) { + for(int i=0; i<search.length; i++) { + if(data.indexOf(search[i]) >= 0) { + return true; + } + } + } + return false; + } + private static ABIType guessABITypeImpl(CPUType cpuType) { + if(CPUFamily.ARM != cpuType.family) { + return ABIType.GENERIC_ABI; + } + return AccessController.doPrivileged(new PrivilegedAction<ABIType>() { + private final String[] gnueabihf = new String[] { "gnueabihf", "armhf" }; + public ABIType run() { + if ( contains(System.getProperty("sun.boot.library.path"), gnueabihf) || + contains(System.getProperty("java.library.path"), gnueabihf) || + contains(System.getProperty("java.home"), gnueabihf) ) { + return ABIType.EABI_GNU_ARMHF; + } + return ABIType.EABI_GNU_ARMEL; + } } ); + } + private static OSType getOSTypeImpl() throws RuntimeException { if ( AndroidVersion.isAvailable ) { return OSType.ANDROID; @@ -451,10 +497,10 @@ public class Platform { * </ul> * @return */ - public static String getOSAndArch(OSType osType, CPUType cpuType) { + public static String getOSAndArch(OSType osType, CPUType cpuType, ABIType abiType) { String _os_and_arch; - switch( CPU_ARCH ) { + switch( cpuType ) { case X86_32: _os_and_arch = "i586"; break; @@ -491,7 +537,10 @@ public class Platform { default: throw new InternalError("Complete case block"); } - switch(OS_TYPE) { + if( ABIType.EABI_GNU_ARMHF == abiType ) { + _os_and_arch = _os_and_arch + "hf" ; + } + switch( osType ) { case ANDROID: _os_and_arch = "android-" + _os_and_arch; break; diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java index 4d2d0f2..820035c 100644 --- a/src/java/com/jogamp/common/util/VersionUtil.java +++ b/src/java/com/jogamp/common/util/VersionUtil.java @@ -56,7 +56,8 @@ public class VersionUtil { // environment sb.append("Platform: ").append(Platform.getOSType()).append(" / ").append(Platform.getOSName()).append(' ').append(Platform.getOSVersion()).append(" (os), "); - sb.append(Platform.getArchName()).append(" (arch) ").append(Runtime.getRuntime().availableProcessors()).append(" cores"); + sb.append(Platform.getArchName()).append(" (arch), ").append(Platform.ABI_TYPE).append(", "); + sb.append(Runtime.getRuntime().availableProcessors()).append(" cores"); sb.append(Platform.getNewline()); if( AndroidVersion.isAvailable) { sb.append("Platform: Android Version: ").append(AndroidVersion.CODENAME).append(", "); diff --git a/src/java/com/jogamp/common/util/cache/TempJarCache.java b/src/java/com/jogamp/common/util/cache/TempJarCache.java index 96e68df..8aaab94 100644 --- a/src/java/com/jogamp/common/util/cache/TempJarCache.java +++ b/src/java/com/jogamp/common/util/cache/TempJarCache.java @@ -96,6 +96,9 @@ public class TempJarCache { classFileJars = new HashSet<URL>(); resourceFileJars = new HashSet<URL>(); } + if(DEBUG) { + System.err.println("TempJarCache.initSingleton(): ok "+(false==staticInitError)+", "+ tmpFileCache.getTempDir()); + } } } } @@ -109,11 +112,20 @@ public class TempJarCache { * <p> * In JogAmp, JNI native libraries loaded and registered by {@link JNILibLoaderBase} * derivations, where the native JARs might be loaded via {@link JNILibLoaderBase#addNativeJarLibs(Class, String) }. + * </p> + * <p> + * The only valid use case to shutdown the TempJarCache is at bootstrapping, + * i.e. when no native library is guaranteed to be loaded. This could be useful + * if bootstrapping needs to find the proper native library type. * </p> + * public static void shutdown() { if (isInit) { // volatile: ok synchronized (TempJarCache.class) { if (isInit) { + if(DEBUG) { + System.err.println("TempJarCache.shutdown(): real "+(false==staticInitError)+", "+ tmpFileCache.getTempDir()); + } isInit = false; if(!staticInitError) { nativeLibMap.clear(); diff --git a/src/junit/com/jogamp/common/util/TestSystemProperties.java b/src/junit/com/jogamp/common/util/TestSystemProperties.java new file mode 100644 index 0000000..8ede038 --- /dev/null +++ b/src/junit/com/jogamp/common/util/TestSystemProperties.java @@ -0,0 +1,60 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.common.util; + +import java.io.IOException; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; + +import org.junit.Test; + +import com.jogamp.junit.util.JunitTracer; + +public class TestSystemProperties extends JunitTracer { + + @Test + public void dumpProperties() { + int i=0; + Properties props = System.getProperties(); + Iterator<Map.Entry<Object,Object>> iter = props.entrySet().iterator(); + while (iter.hasNext()) { + i++; + Map.Entry<Object, Object> entry = iter.next(); + System.out.println(i+": "+entry.getKey() + " = " + entry.getValue()); + } + System.out.println("Property count: "+i); + } + + public static void main(String args[]) throws IOException { + String tstname = TestSystemProperties.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + +} diff --git a/src/junit/com/jogamp/common/util/TestVersionInfo.java b/src/junit/com/jogamp/common/util/TestVersionInfo.java index 272ef73..f9c748b 100644 --- a/src/junit/com/jogamp/common/util/TestVersionInfo.java +++ b/src/junit/com/jogamp/common/util/TestVersionInfo.java @@ -28,13 +28,12 @@ package com.jogamp.common.util; -import com.jogamp.common.GlueGenVersion; -import com.jogamp.junit.util.JunitTracer; - import java.io.IOException; - import org.junit.Test; +import com.jogamp.common.GlueGenVersion; +import com.jogamp.junit.util.JunitTracer; + public class TestVersionInfo extends JunitTracer { @Test |