From 4181d0770d49d5629b719fbc8a88766bc4ef45ad Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Thu, 16 Oct 2014 06:58:22 +0000 Subject: [PATCH] Merged trunk@30159, @30202 to branches/sysdyn-1.8 on 2014-10-16 for 1.8.2 release. refs #5244 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/1.8@30414 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../org/simantics/fmu/ExecEnvironment.java | 54 +++++++++++++++++++ .../src/org/simantics/fmu/FMUControlJNI.java | 19 ++++++- 2 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 org.simantics.fmu/src/org/simantics/fmu/ExecEnvironment.java diff --git a/org.simantics.fmu/src/org/simantics/fmu/ExecEnvironment.java b/org.simantics.fmu/src/org/simantics/fmu/ExecEnvironment.java new file mode 100644 index 00000000..e2dcb4a2 --- /dev/null +++ b/org.simantics.fmu/src/org/simantics/fmu/ExecEnvironment.java @@ -0,0 +1,54 @@ +package org.simantics.fmu; + +public class ExecEnvironment { + + public enum OSType { + APPLE, LINUX, SUN, WINDOWS, UNKNOWN + } + + public enum ARCHType { + PPC, PPC_64, SPARC, X86, X86_64, UNKNOWN; + } + + public final OSType os; + public final ARCHType arch; + + private ExecEnvironment(OSType os, ARCHType arch) { + this.os = os; + this.arch = arch; + } + + public static ExecEnvironment calculate() { + return new ExecEnvironment(calculateOS(), calculateArch()); + } + + public static ARCHType calculateArch() { + String osArch = System.getProperty("os.arch", ""); + osArch = osArch.toLowerCase(); + if (osArch.equals("i386") || osArch.equals("i586") || osArch.equals("i686") || osArch.equals("x86")) + return ARCHType.X86; + if (osArch.startsWith("amd64") || osArch.startsWith("x86_64")) + return ARCHType.X86_64; + if (osArch.equals("ppc")) + return ARCHType.PPC; + if (osArch.startsWith("ppc")) + return ARCHType.PPC_64; + if (osArch.startsWith("sparc")) + return ARCHType.SPARC; + return ARCHType.UNKNOWN; + } + + public static OSType calculateOS() { + String osName = System.getProperty("os.name", ""); + osName = osName.toLowerCase(); + if (osName.startsWith("mac os x")) + return OSType.APPLE; + if (osName.startsWith("windows")) + return OSType.WINDOWS; + if (osName.startsWith("linux")) + return OSType.LINUX; + if (osName.startsWith("sun")) + return OSType.SUN; + return OSType.UNKNOWN; + } +} diff --git a/org.simantics.fmu/src/org/simantics/fmu/FMUControlJNI.java b/org.simantics.fmu/src/org/simantics/fmu/FMUControlJNI.java index 0ea50c2d..4fd80f18 100644 --- a/org.simantics.fmu/src/org/simantics/fmu/FMUControlJNI.java +++ b/org.simantics.fmu/src/org/simantics/fmu/FMUControlJNI.java @@ -11,6 +11,8 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; import org.simantics.Simantics; +import org.simantics.fmu.ExecEnvironment.ARCHType; +import org.simantics.fmu.ExecEnvironment.OSType; import org.simantics.utils.FileUtils; @@ -34,11 +36,24 @@ public class FMUControlJNI { static { File[] libraries = new File[3]; - Bundle bundle = Platform.getBundle("org.simantics.fmu.me.win32"); - + Bundle bundle = null; + + ExecEnvironment env = ExecEnvironment.calculate(); + if (env.os == OSType.WINDOWS) { + if (env.arch == ARCHType.X86) { + bundle = Platform.getBundle("org.simantics.fmu.me.win32"); + } else if (env.arch == ARCHType.X86_64) { + bundle = Platform.getBundle("org.simantics.fmu.me.win64"); + } + } + if (bundle != null) { try{ String root = FileLocator.getBundleFile(bundle).getAbsolutePath(); + if (env.arch == ARCHType.X86_64) { + File newFIle = new File(root, "libraries/libexpat.dll"); + System.load(newFIle.getAbsolutePath()); + } libraries[0] = new File(root, "libraries/zlibwapi.dll"); libraries[1] = new File(root, "libraries/miniunz.dll"); libraries[2] = new File(root, "libraries/FMUSimulator.dll"); -- 2.47.1