--- /dev/null
+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
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
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