]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #5244
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 4 Sep 2014 06:32:08 +0000 (06:32 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 4 Sep 2014 06:32:08 +0000 (06:32 +0000)
Add libexpat.dll to 64bit FMUSimulator

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30202 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.fmu.me.win64/libraries/FMUSimulator.dll
org.simantics.fmu.me.win64/libraries/libexpat.dll [new file with mode: 0644]
org.simantics.fmu/src/org/simantics/fmu/ExecEnvironment.java [new file with mode: 0644]
org.simantics.fmu/src/org/simantics/fmu/FMUControlJNI.java

index 55da97efbd4846585ccb17d2250d01ded14fc0fc..4e7cdc76e27490d1d6fb2faf460cf7c72afbea9f 100644 (file)
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 (file)
index 0000000..0f8b01b
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 (file)
index 0000000..e2dcb4a
--- /dev/null
@@ -0,0 +1,54 @@
+package org.simantics.fmu;\r
+\r
+public class ExecEnvironment {\r
+\r
+    public enum OSType {\r
+        APPLE, LINUX, SUN, WINDOWS, UNKNOWN\r
+    }\r
+    \r
+    public enum ARCHType {\r
+        PPC, PPC_64, SPARC, X86, X86_64, UNKNOWN;\r
+    }\r
+    \r
+    public final OSType os;\r
+    public final ARCHType arch;\r
+\r
+    private ExecEnvironment(OSType os, ARCHType arch) {\r
+        this.os = os;\r
+        this.arch = arch;\r
+    }\r
+\r
+    public static ExecEnvironment calculate() {\r
+        return new ExecEnvironment(calculateOS(), calculateArch());\r
+    }\r
+\r
+    public static ARCHType calculateArch() {\r
+        String osArch = System.getProperty("os.arch", "");\r
+        osArch = osArch.toLowerCase();\r
+        if (osArch.equals("i386") || osArch.equals("i586") || osArch.equals("i686") || osArch.equals("x86"))\r
+            return ARCHType.X86;\r
+        if (osArch.startsWith("amd64") || osArch.startsWith("x86_64"))\r
+            return ARCHType.X86_64;\r
+        if (osArch.equals("ppc"))\r
+            return ARCHType.PPC;\r
+        if (osArch.startsWith("ppc"))\r
+            return ARCHType.PPC_64;\r
+        if (osArch.startsWith("sparc"))\r
+            return ARCHType.SPARC;\r
+        return ARCHType.UNKNOWN;\r
+    }\r
+\r
+    public static OSType calculateOS() {\r
+        String osName = System.getProperty("os.name", "");\r
+        osName = osName.toLowerCase();\r
+        if (osName.startsWith("mac os x"))\r
+            return OSType.APPLE;\r
+        if (osName.startsWith("windows"))\r
+            return OSType.WINDOWS;\r
+        if (osName.startsWith("linux"))\r
+            return OSType.LINUX;\r
+        if (osName.startsWith("sun"))\r
+            return OSType.SUN;\r
+        return OSType.UNKNOWN;\r
+    }\r
+}\r
index 459694b16f06a646f6ecc7e7e8a1cc1f887ac3e8..4fd80f18deed3965d37eca9706da7e7f4bec8a87 100644 (file)
@@ -11,6 +11,8 @@ import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Platform;\r
 import org.osgi.framework.Bundle;\r
 import org.simantics.Simantics;\r
+import org.simantics.fmu.ExecEnvironment.ARCHType;\r
+import org.simantics.fmu.ExecEnvironment.OSType;\r
 import org.simantics.utils.FileUtils;\r
 \r
 \r
@@ -35,16 +37,23 @@ public class FMUControlJNI {
         File[] libraries = new File[3];\r
 \r
         Bundle bundle = null;\r
-        String arch = System.getProperty("os.arch");\r
-        if (arch.equals("x86")){\r
-            bundle = Platform.getBundle("org.simantics.fmu.me.win32");\r
-        } else if (arch.equals("amd64")) {\r
-            bundle = Platform.getBundle("org.simantics.fmu.me.win64");\r
+        \r
+        ExecEnvironment env = ExecEnvironment.calculate();\r
+        if (env.os == OSType.WINDOWS) {\r
+            if (env.arch == ARCHType.X86) {\r
+                bundle = Platform.getBundle("org.simantics.fmu.me.win32");\r
+            } else if (env.arch == ARCHType.X86_64) {\r
+                bundle = Platform.getBundle("org.simantics.fmu.me.win64");\r
+            }\r
         }\r
         \r
         if (bundle != null) {\r
             try{\r
                 String root = FileLocator.getBundleFile(bundle).getAbsolutePath();\r
+                if (env.arch == ARCHType.X86_64) {\r
+                    File newFIle = new File(root, "libraries/libexpat.dll");\r
+                    System.load(newFIle.getAbsolutePath());\r
+                }\r
                 libraries[0] = new File(root, "libraries/zlibwapi.dll");\r
                 libraries[1] = new File(root, "libraries/miniunz.dll");\r
                 libraries[2] = new File(root, "libraries/FMUSimulator.dll");\r