]> gerrit.simantics Code Review - simantics/fmil.git/commitdiff
Changed FMIL core and fragments logic to properly find files 64/1664/5
authormeklund <miro.eklund@semantum.fi>
Thu, 29 Mar 2018 10:53:16 +0000 (13:53 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 29 Mar 2018 13:54:57 +0000 (15:54 +0200)
Required .dll and .so files on window and linux are found in fragments
.win32, .win64 and .linux64. Added a "Requires-Capability" and
"Provides-Capability" tag to the project's MANIFEST.MF files, which now
correctly resolves the fragments on Linux and Windows.

Also added first build of linux FMI shared object files (still missing
FMUSimulator.so!)

Amend 1: Updated to tycho 1.1.0 build

Amend 2: Added README.md to linux64 FMI Library with build from source
instructions

Change-Id: I5cfd24d1890c73eb4f39effbb7e26a67ef920df9

17 files changed:
org.simantics.fmil.core/META-INF/MANIFEST.MF
org.simantics.fmil.core/src/org/simantics/fmil/core/FMIL.java
org.simantics.fmil.linux64/META-INF/MANIFEST.MF
org.simantics.fmil.linux64/README.md [new file with mode: 0644]
org.simantics.fmil.linux64/libraries/debug/libfmilib_shared.so [new file with mode: 0644]
org.simantics.fmil.linux64/libraries/debug/libfmu1_dll_cs.so [new file with mode: 0644]
org.simantics.fmil.linux64/libraries/debug/libfmu1_dll_me.so [new file with mode: 0644]
org.simantics.fmil.linux64/libraries/debug/libfmu2_dll_cs.so [new file with mode: 0644]
org.simantics.fmil.linux64/libraries/debug/libfmu2_dll_me.so [new file with mode: 0644]
org.simantics.fmil.linux64/libraries/libfmilib_shared.so [new file with mode: 0644]
org.simantics.fmil.linux64/libraries/libfmu1_dll_cs.so [new file with mode: 0644]
org.simantics.fmil.linux64/libraries/libfmu1_dll_me.so [new file with mode: 0644]
org.simantics.fmil.linux64/libraries/libfmu2_dll_cs.so [new file with mode: 0644]
org.simantics.fmil.linux64/libraries/libfmu2_dll_me.so [new file with mode: 0644]
org.simantics.fmil.parent/pom.xml
org.simantics.fmil.win32/META-INF/MANIFEST.MF
org.simantics.fmil.win64/META-INF/MANIFEST.MF

index ba74f08f862b006d899cafbbf1ccb749177998eb..7d115541a95c049145745d8d13858ef0b7bf046b 100644 (file)
@@ -10,3 +10,4 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
  org.slf4j.api,
  gnu.trove3;bundle-version="3.0.3"
 Export-Package: org.simantics.fmil.core
+Require-Capability: org.simantics.fmil.simulator.implementation.capability;filter:="(type=fmi)";effective:="active"
index 41ebf95522967d70ede8c7bc856f4e6f636ec2f7..3a7c031dc2522a60d8d1ff2e2028947a0e16cb8b 100644 (file)
@@ -3,6 +3,7 @@ package org.simantics.fmil.core;
 import java.io.File;
 import java.io.IOException;
 import java.io.RandomAccessFile;
+import java.net.URL;
 import java.nio.channels.FileChannel;
 import java.nio.channels.FileLock;
 import java.nio.file.Paths;
@@ -13,9 +14,9 @@ import java.util.Set;
 import java.util.UUID;
 
 import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
 import org.osgi.framework.Bundle;
-import org.simantics.fmil.core.ExecEnvironment.ARCHType;
 import org.simantics.fmil.core.ExecEnvironment.OSType;
 import org.simantics.utils.FileUtils;
 import org.slf4j.Logger;
@@ -34,9 +35,9 @@ public class FMIL {
      */
     private static int      OK                  = 0;
     private static int      ERROR               = 1;
-    private static String   UNSATISFIED_LINK    = "Method not found. DLL might not be loaded properly.";      
-    public static final String TEMP_FMU_DIRECTORY_NAME = "fmil";  
-    public static String    TEMP_FMU_COMMON_DIRECTORY;  
+    private static String   UNSATISFIED_LINK    = "Method not found. DLL might not be loaded properly.";
+    public static final String TEMP_FMU_DIRECTORY_NAME = "fmil";
+    public static String    TEMP_FMU_COMMON_DIRECTORY;
     public static String    LOCK_FILE_NAME      = "fmil.lock";
 
     public static Object syncObject = new Object();
@@ -45,35 +46,28 @@ public class FMIL {
      * Static: load native libraries required for the FMU simulation to work.
      */
     static {
-       
+
         File[] libraries = new File[2];
 
-        Bundle bundle = null;
-        
         ExecEnvironment env = ExecEnvironment.calculate();
-        if (env.os == OSType.WINDOWS) {
-            if (env.arch == ARCHType.X86) {
-                bundle = Platform.getBundle("org.simantics.fmil.win32");
-            } else if (env.arch == ARCHType.X86_64) {
-                bundle = Platform.getBundle("org.simantics.fmil.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[0] = new File(root, "libraries/fmilib_shared.dll");
-                libraries[1] = new File(root, "libraries/FMUSimulator.dll");
-            }
-            catch (Exception e) {
-                e.printStackTrace();
+
+        try {
+            URL sharedFMILIBUrl = null;
+            URL simulatorFMIUrl = null;
+            Bundle b = Platform.getBundle("org.simantics.fmil.core");
+
+            if (env.os == OSType.WINDOWS) {
+                sharedFMILIBUrl = FileLocator.find(b, new Path("libraries/fmilib_shared.dll"), null);
+                simulatorFMIUrl = FileLocator.find(b, new Path("libraries/FMUSimulator.dll"), null);
+            } else if(env.os == OSType.LINUX) {
+                sharedFMILIBUrl = FileLocator.find(b, new Path("libraries/libfmilib_shared.so"), null);
+                simulatorFMIUrl = FileLocator.find(b, new Path("libraries/FMUSimulator.so"), null);
             }
+
+            libraries[0] = new File(FileLocator.toFileURL(sharedFMILIBUrl).getPath());
+            libraries[1] = new File(FileLocator.toFileURL(simulatorFMIUrl).getPath());
+        } catch (Exception e) {
+            LOGGER.error("Failed to resolve native FMU simulation library for execution environment {}.{}", env.os, env.arch, e);
         }
 
         for(File library : libraries) {
@@ -873,7 +867,7 @@ public class FMIL {
         synchronized(syncObject) {
 
             try {
-                // TODO: printtaa id ja name, jotta saadaan virheessä kiinni
+                // TODO: printtaa id ja name, jotta saadaan virheessä kiinni
                double result = getRealValue_(getModelIDNew(), variableMap.get(name));
                System.err.println("getRealValue " + name + " = " + result);
                 return  result;
index 1c60e2b74dddc2c78387d31f7fa4028dab53d0de..72adc7410f692e7fffeec3c21d8d3fa327fcecc5 100644 (file)
@@ -4,7 +4,8 @@ Bundle-Name: FMI Library 64-bit Linux Fragment
 Bundle-SymbolicName: org.simantics.fmil.linux64
 Bundle-Version: 1.0.0.qualifier
 Bundle-Vendor: Semantum Oy
-Fragment-Host: org.simantics.fmil.core;bundle-version="1.0.0"
+Fragment-Host: org.simantics.fmil.core
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Eclipse-PlatformFilter: (& (osgi.os=linux) (osgi.arch=x86_64))
 Eclipse-BundleShape: dir
+Provide-Capability: org.simantics.fmil.simulator.implementation.capability;type:"fmi";effective:="active"
diff --git a/org.simantics.fmil.linux64/README.md b/org.simantics.fmil.linux64/README.md
new file mode 100644 (file)
index 0000000..5511597
--- /dev/null
@@ -0,0 +1,23 @@
+Build FMI Library for Linux:
+Download 2.0.3-src.zip from here http://www.jmodelica.org/FMILibrary
+Derived guide: http://www.jmodelica.org/page/27916
+
+1) Download cmake (apt-get install -y cmake)
+2) Unzip the source file to a source directory (/path/to/source)
+3) Make an empty build directory (mkdir /path/to/build)
+4) Change directory to the build directory
+5) cmake /path/to/source
+6) make
+7) make install test
+       7.1) If tests fail, look at the error and fix it
+       7.2) Otherwise move on to step 8.
+8) Under your build directory should be five files:
+       - libfmu1_dll_me.so
+       - libfmu2_dll_me.so
+       - libfmu1_dll_cs.so
+       - libfmu2_dll_cs.so
+       - libfmilib_shared.so
+9) Copy the above files to where you want them (i.e. under org.simantics.fmil.linux64 libraries directory)
+10) Repeat steps 3 to 9 for "debug" shared objects, but replace the following steps:
+       "5") cmake -DFMILIB_ENABLE_LOG_LEVEL_DEBUG=ON /path/to/source (note the added param)
+       "9") Copy the files to libraries/debug directory (instead of libraries)
\ No newline at end of file
diff --git a/org.simantics.fmil.linux64/libraries/debug/libfmilib_shared.so b/org.simantics.fmil.linux64/libraries/debug/libfmilib_shared.so
new file mode 100644 (file)
index 0000000..572b3fb
Binary files /dev/null and b/org.simantics.fmil.linux64/libraries/debug/libfmilib_shared.so differ
diff --git a/org.simantics.fmil.linux64/libraries/debug/libfmu1_dll_cs.so b/org.simantics.fmil.linux64/libraries/debug/libfmu1_dll_cs.so
new file mode 100644 (file)
index 0000000..b0a3485
Binary files /dev/null and b/org.simantics.fmil.linux64/libraries/debug/libfmu1_dll_cs.so differ
diff --git a/org.simantics.fmil.linux64/libraries/debug/libfmu1_dll_me.so b/org.simantics.fmil.linux64/libraries/debug/libfmu1_dll_me.so
new file mode 100644 (file)
index 0000000..9dd42bb
Binary files /dev/null and b/org.simantics.fmil.linux64/libraries/debug/libfmu1_dll_me.so differ
diff --git a/org.simantics.fmil.linux64/libraries/debug/libfmu2_dll_cs.so b/org.simantics.fmil.linux64/libraries/debug/libfmu2_dll_cs.so
new file mode 100644 (file)
index 0000000..4e402f7
Binary files /dev/null and b/org.simantics.fmil.linux64/libraries/debug/libfmu2_dll_cs.so differ
diff --git a/org.simantics.fmil.linux64/libraries/debug/libfmu2_dll_me.so b/org.simantics.fmil.linux64/libraries/debug/libfmu2_dll_me.so
new file mode 100644 (file)
index 0000000..686dea2
Binary files /dev/null and b/org.simantics.fmil.linux64/libraries/debug/libfmu2_dll_me.so differ
diff --git a/org.simantics.fmil.linux64/libraries/libfmilib_shared.so b/org.simantics.fmil.linux64/libraries/libfmilib_shared.so
new file mode 100644 (file)
index 0000000..6e5d495
Binary files /dev/null and b/org.simantics.fmil.linux64/libraries/libfmilib_shared.so differ
diff --git a/org.simantics.fmil.linux64/libraries/libfmu1_dll_cs.so b/org.simantics.fmil.linux64/libraries/libfmu1_dll_cs.so
new file mode 100644 (file)
index 0000000..b0a3485
Binary files /dev/null and b/org.simantics.fmil.linux64/libraries/libfmu1_dll_cs.so differ
diff --git a/org.simantics.fmil.linux64/libraries/libfmu1_dll_me.so b/org.simantics.fmil.linux64/libraries/libfmu1_dll_me.so
new file mode 100644 (file)
index 0000000..9dd42bb
Binary files /dev/null and b/org.simantics.fmil.linux64/libraries/libfmu1_dll_me.so differ
diff --git a/org.simantics.fmil.linux64/libraries/libfmu2_dll_cs.so b/org.simantics.fmil.linux64/libraries/libfmu2_dll_cs.so
new file mode 100644 (file)
index 0000000..4e402f7
Binary files /dev/null and b/org.simantics.fmil.linux64/libraries/libfmu2_dll_cs.so differ
diff --git a/org.simantics.fmil.linux64/libraries/libfmu2_dll_me.so b/org.simantics.fmil.linux64/libraries/libfmu2_dll_me.so
new file mode 100644 (file)
index 0000000..686dea2
Binary files /dev/null and b/org.simantics.fmil.linux64/libraries/libfmu2_dll_me.so differ
index d2cc399ba1b6cc057b86e9654adbaf7ba956e9e2..7790ee1c093362665a519048c0c9a08af95b7737 100644 (file)
@@ -1,79 +1,84 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
-       <modelVersion>4.0.0</modelVersion>\r
-       <groupId>org.simantics.fmi</groupId>\r
-       <artifactId>org.simantics.fmil.parent</artifactId>\r
-       <version>0.0.1-SNAPSHOT</version>\r
-       <packaging>pom</packaging>\r
-\r
-       <!-- common settings for all modules -->\r
-       <properties>\r
-               <branch-spec>master</branch-spec>\r
-               <simantics-download-site>http://www.simantics.org/download</simantics-download-site>\r
-               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
-               <tycho-version>1.0.0</tycho-version>\r
-       </properties>\r
-\r
-       <repositories>\r
-               <!-- configure p2 repository to resolve against -->\r
-               <repository>\r
-                       <id>simantics-sdk</id>\r
-                       <layout>p2</layout>\r
-                       <url>${simantics-download-site}/${branch-spec}/sdk</url>\r
-               </repository>\r
-       </repositories>\r
-\r
-       <build>\r
-               <plugins>\r
-                       <plugin>\r
-                               <groupId>org.eclipse.tycho</groupId>\r
-                               <artifactId>tycho-compiler-plugin</artifactId>\r
-                               <version>${tycho-version}</version>\r
-                               <configuration>\r
-                                       <compilerArgument>-err:-forbidden</compilerArgument>\r
-                               </configuration>\r
-                       </plugin>\r
-                       <plugin>\r
-                               <groupId>org.eclipse.tycho</groupId>\r
-                               <artifactId>tycho-maven-plugin</artifactId>\r
-                               <version>${tycho-version}</version>\r
-                               <extensions>true</extensions>\r
-                       </plugin>\r
-                       <plugin>\r
-                               <groupId>org.eclipse.tycho</groupId>\r
-                               <artifactId>tycho-versions-plugin</artifactId>\r
-                               <version>${tycho-version}</version>\r
-                       </plugin>\r
-                       <plugin>\r
-                               <groupId>org.eclipse.tycho</groupId>\r
-                               <artifactId>target-platform-configuration</artifactId>\r
-                               <version>${tycho-version}</version>\r
-                               <configuration>\r
-                                       <ignoreTychoRepositories>true</ignoreTychoRepositories>\r
-                                       <resolver>p2</resolver>\r
-                                       <environments>\r
-                                               <environment>\r
-                                                       <os>win32</os>\r
-                                                       <ws>win32</ws>\r
-                                                       <arch>x86</arch>\r
-                                               </environment>\r
-                                               <environment>\r
-                                                       <os>win32</os>\r
-                                                       <ws>win32</ws>\r
-                                                       <arch>x86_64</arch>\r
-                                               </environment>\r
-                                       </environments>\r
-                               </configuration>\r
-                       </plugin>\r
-               </plugins>\r
-       </build>\r
-\r
-       <modules>\r
-               <module>../org.simantics.fmil.core</module>\r
-               <module>../org.simantics.fmil.feature</module>\r
-               <module>../org.simantics.fmil.linux64</module>\r
-               <module>../org.simantics.fmil.win32</module>\r
-               <module>../org.simantics.fmil.win64</module>\r
-               <module>../org.simantics.fmil.repository</module>\r
-       </modules>\r
-</project>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <groupId>org.simantics.fmi</groupId>
+       <artifactId>org.simantics.fmil.parent</artifactId>
+       <version>0.0.1-SNAPSHOT</version>
+       <packaging>pom</packaging>
+
+       <!-- common settings for all modules -->
+       <properties>
+               <branch-spec>master</branch-spec>
+               <simantics-download-site>http://www.simantics.org/download</simantics-download-site>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <tycho-version>1.1.0</tycho-version>
+       </properties>
+
+       <repositories>
+               <!-- configure p2 repository to resolve against -->
+               <repository>
+                       <id>simantics-sdk</id>
+                       <layout>p2</layout>
+                       <url>${simantics-download-site}/${branch-spec}/sdk</url>
+               </repository>
+       </repositories>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.eclipse.tycho</groupId>
+                               <artifactId>tycho-compiler-plugin</artifactId>
+                               <version>${tycho-version}</version>
+                               <configuration>
+                                       <compilerArgument>-err:-forbidden</compilerArgument>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.eclipse.tycho</groupId>
+                               <artifactId>tycho-maven-plugin</artifactId>
+                               <version>${tycho-version}</version>
+                               <extensions>true</extensions>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.eclipse.tycho</groupId>
+                               <artifactId>tycho-versions-plugin</artifactId>
+                               <version>${tycho-version}</version>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.eclipse.tycho</groupId>
+                               <artifactId>target-platform-configuration</artifactId>
+                               <version>${tycho-version}</version>
+                               <configuration>
+                                       <ignoreTychoRepositories>true</ignoreTychoRepositories>
+                                       <resolver>p2</resolver>
+                                       <environments>
+                                               <environment>
+                                                       <os>linux</os>
+                                                       <ws>gtk</ws>
+                                                       <arch>x86_64</arch>
+                                               </environment>
+                                               <environment>
+                                                       <os>win32</os>
+                                                       <ws>win32</ws>
+                                                       <arch>x86</arch>
+                                               </environment>
+                                               <environment>
+                                                       <os>win32</os>
+                                                       <ws>win32</ws>
+                                                       <arch>x86_64</arch>
+                                               </environment>
+                                       </environments>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
+       <modules>
+               <module>../org.simantics.fmil.core</module>
+               <module>../org.simantics.fmil.feature</module>
+               <module>../org.simantics.fmil.linux64</module>
+               <module>../org.simantics.fmil.win32</module>
+               <module>../org.simantics.fmil.win64</module>
+               <module>../org.simantics.fmil.repository</module>
+       </modules>
+</project>
index 4d71f7ef2ef8aa2495c2e21fa7783d95446b8a70..ef755c2f95a2837406c9160ad763cfe1b212b4d0 100644 (file)
@@ -8,3 +8,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86))
 Bundle-Vendor: Semantum Oy
 Eclipse-BundleShape: dir
+Provide-Capability: org.simantics.fmil.simulator.implementation.capability;type:"fmi";effective:="active"
index 884cbceb5789e7ba2c64324af436466a40324359..3a45e01cf627c6a6457faa33465506834149dad5 100644 (file)
@@ -8,3 +8,4 @@ Fragment-Host: org.simantics.fmil.core;bundle-version="1.0.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86_64))
 Eclipse-BundleShape: dir
+Provide-Capability: org.simantics.fmil.simulator.implementation.capability;type:"fmi";effective:="active"