From: jsimomaa Date: Thu, 4 Sep 2014 06:32:08 +0000 (+0000) Subject: refs #5244 X-Git-Tag: v1.29.0~196 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=404a36d2af7e7ec986489f5c2f0b3b4fe086f90a;p=simantics%2Fsysdyn.git refs #5244 Add libexpat.dll to 64bit FMUSimulator git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30202 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.fmu.me.win64/libraries/FMUSimulator.dll b/org.simantics.fmu.me.win64/libraries/FMUSimulator.dll index 55da97ef..4e7cdc76 100644 Binary files a/org.simantics.fmu.me.win64/libraries/FMUSimulator.dll and b/org.simantics.fmu.me.win64/libraries/FMUSimulator.dll differ diff --git a/org.simantics.fmu.me.win64/libraries/libexpat.dll b/org.simantics.fmu.me.win64/libraries/libexpat.dll new file mode 100644 index 00000000..0f8b01be Binary files /dev/null and b/org.simantics.fmu.me.win64/libraries/libexpat.dll differ 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 459694b1..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; @@ -35,16 +37,23 @@ public class FMUControlJNI { File[] libraries = new File[3]; Bundle bundle = null; - String arch = System.getProperty("os.arch"); - if (arch.equals("x86")){ - bundle = Platform.getBundle("org.simantics.fmu.me.win32"); - } else if (arch.equals("amd64")) { - bundle = Platform.getBundle("org.simantics.fmu.me.win64"); + + 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");