From: Tuukka Lehtonen Date: Mon, 9 Jan 2017 16:55:23 +0000 (+0200) Subject: Added missing plug-ins from old SVN repository trunk X-Git-Tag: v1.27.0~30 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=68e5274fbda4c51b920db69b2e87d5646c446ce4;p=simantics%2Fplatform.git Added missing plug-ins from old SVN repository trunk Included the following plug-ins in bundles/: * org.simantics.gnuplot * org.simantics.msvc.runtime{,x86,x86_64} refs #6945 Change-Id: Ibf8709f4cb22945dce4925897ee7de684a46675b --- diff --git a/bundles/org.simantics.gnuplot/.classpath b/bundles/org.simantics.gnuplot/.classpath new file mode 100644 index 000000000..eca7bdba8 --- /dev/null +++ b/bundles/org.simantics.gnuplot/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/org.simantics.gnuplot/.project b/bundles/org.simantics.gnuplot/.project new file mode 100644 index 000000000..4c9d741f3 --- /dev/null +++ b/bundles/org.simantics.gnuplot/.project @@ -0,0 +1,34 @@ + + + org.simantics.gnuplot + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.simantics.gnuplot/.settings/org.eclipse.core.resources.prefs b/bundles/org.simantics.gnuplot/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..99f26c020 --- /dev/null +++ b/bundles/org.simantics.gnuplot/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/bundles/org.simantics.gnuplot/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.gnuplot/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..0c68a61dc --- /dev/null +++ b/bundles/org.simantics.gnuplot/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bundles/org.simantics.gnuplot/.settings/org.eclipse.m2e.core.prefs b/bundles/org.simantics.gnuplot/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..f897a7f1c --- /dev/null +++ b/bundles/org.simantics.gnuplot/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/bundles/org.simantics.gnuplot/.settings/org.eclipse.pde.core.prefs b/bundles/org.simantics.gnuplot/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..f29e940a0 --- /dev/null +++ b/bundles/org.simantics.gnuplot/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/bundles/org.simantics.gnuplot/META-INF/MANIFEST.MF b/bundles/org.simantics.gnuplot/META-INF/MANIFEST.MF new file mode 100644 index 000000000..d0dd4a084 --- /dev/null +++ b/bundles/org.simantics.gnuplot/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Gnuplot front end +Bundle-SymbolicName: org.simantics.gnuplot +Bundle-Version: 0.0.1.qualifier +Bundle-Vendor: Semantum Oy +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.simantics.gnuplot +Bundle-ClassPath: . diff --git a/bundles/org.simantics.gnuplot/build.properties b/bundles/org.simantics.gnuplot/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/bundles/org.simantics.gnuplot/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/bundles/org.simantics.gnuplot/pom.xml b/bundles/org.simantics.gnuplot/pom.xml new file mode 100644 index 000000000..cc1b5c25a --- /dev/null +++ b/bundles/org.simantics.gnuplot/pom.xml @@ -0,0 +1,129 @@ + + + 4.0.0 + + org.simantics + org.simantics.gnuplot + 0.0.1-SNAPSHOT + eclipse-plugin + + + org.simantics + org.simantics.root.bundles + 1.0.0-SNAPSHOT + .. + + + + + UTF-8 + 0.26.0 + + + + src + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho-version} + true + + + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + + + + maven-assembly-plugin + 2.6 + + + jar-with-dependencies + + + + + standalone + package + + single + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.eclipse.tycho + + + tycho-packaging-plugin + + + [0.24.0,) + + + validate-id + build-qualifier + + validate-version + + + + + + + + + + + org.eclipse.tycho + + + tycho-compiler-plugin + + + [0.24.0,) + + + compile + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/Gnuplot.java b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/Gnuplot.java new file mode 100644 index 000000000..f1321796a --- /dev/null +++ b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/Gnuplot.java @@ -0,0 +1,167 @@ +package org.simantics.gnuplot; + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * @author Tuukka Lehtonen + * @since 1.24 + */ +public class Gnuplot { + + private static final String GNUPLOT_VERSION_STRING_STARTS_WITH = "gnuplot "; + private static final String GNUPLOT_ENV = "GNUPLOT"; + private static final String PATH_ENV = "PATH"; + + private Path executable; + + public Gnuplot(Path executable) { + this.executable = executable; + } + + public static Gnuplot detect() throws IOException { + try { + return new Gnuplot(findGnuplotPath()); + } catch (InterruptedException e) { + throw new IOException(e); + } + } + + private static String readInput(InputStream in) throws IOException { + StringWriter sw = new StringWriter(); + for (int l = 0; l < GNUPLOT_VERSION_STRING_STARTS_WITH.length(); ++l) { + int c; + c = in.read(); + if(c <= 0) + break; + sw.write(c); + } + return sw.toString(); + } + + private static boolean testExecutable(Path exe) throws IOException, InterruptedException { + Process process = new ProcessBuilder(exe.toString(), "-V").start(); + try { + if (GNUPLOT_VERSION_STRING_STARTS_WITH.startsWith( readInput(process.getInputStream()) )) + return true; + return false; + } finally { + process.getInputStream().close(); + process.getErrorStream().close(); + process.waitFor(); + } + } + + private static Path findExecutable(String[] paths, String executableName, boolean fail) throws IOException, InterruptedException { + for (String p : paths) { + Path exe = Paths.get(p); + if (executableName != null) + exe = exe.resolve(executableName); + if (Files.exists(exe) && Files.isExecutable(exe) && testExecutable(exe)) { + return exe; + } + } + if (fail) + throw new UnsupportedOperationException("Couldn't find executable '" + executableName + "' on the system path."); + return null; + } + + private static Path findExecutable(String path, boolean splitPath, boolean fail) throws IOException, InterruptedException { + switch (OSType.calculate()) { + case APPLE: + case SUN: + case LINUX: + return findExecutable(splitPath ? path.split(":") : new String[] { path }, "gnuplot", fail); + case WINDOWS: + return findExecutable(splitPath ? path.split(";") : new String[] { path }, "gnuplot.exe", fail); + default: + throw new UnsupportedOperationException("unsupported platform"); + } + } + + private static Path findGnuplotPath() throws IOException, InterruptedException { + String path = System.getenv(GNUPLOT_ENV); + if (path != null) { + // Does GNUPLOT point directly to the executable? + Path p = findExecutable(new String[] { path }, null, false); + if (p != null) + return p; + // Does GNUPLOT point to the gnuplot installation bin directory? + p = findExecutable(path, false, false); + if (p != null) + return p; + // Does GNUPLOT point to the gnuplot installation root directory? + p = findExecutable(path + "/bin", false, false); + if (p != null) + return p; + } + path = System.getenv(PATH_ENV); + return findExecutable(path, true, true); + } + + private void execute0(Path workingDirectory, Path stdout, Path stderr, String... cmdline) throws IOException { + Process process = new ProcessBuilder(cmdline) + .directory(workingDirectory.toFile()) + .start(); + process.getOutputStream().close(); + Thread stdoutDumper = new Thread(new InputStreamToFileCopier(process.getInputStream(), stdout)); + Thread stderrDumper = new Thread(new InputStreamToFileCopier(process.getErrorStream(), stderr)); + stdoutDumper.start(); + stderrDumper.start(); + try { + stdoutDumper.join(); + stderrDumper.join(); + process.waitFor(); + } catch (InterruptedException e) { + throw new IOException(e); + } + } + + public void execute(Path workingDirectory, Path stdout, Path stderr, Path script) throws IOException { + execute0(workingDirectory, stdout, stderr, executable.toString(), "-c", script.toString()); + } + + public void execute(Path workingDirectory, Path stdout, Path stderr, String... commands) throws IOException { + StringBuilder e = new StringBuilder().append('"'); + boolean first = true; + for (String cmd : commands) { + if (!first) + e.append("; "); + first = false; + e.append(cmd); + } + e.append('"'); + execute0(workingDirectory, stdout, stderr, executable.toString(), "-e", e.toString()); + } + + public GnuplotSession newSession(Path workingDirectory, Path stdout, Path stderr) throws IOException { + Process process = new ProcessBuilder(executable.toString()) + .directory(workingDirectory.toFile()) + .start(); + return new GnuplotSession(workingDirectory, stdout, stderr, process); + } + + static enum OSType { + APPLE, LINUX, SUN, WINDOWS, UNKNOWN; + + public static OSType calculate() { + String osName = System.getProperty("os.name"); + assert osName != null; + osName = osName.toLowerCase(); + if (osName.startsWith("mac os x")) + return APPLE; + if (osName.startsWith("windows")) + return WINDOWS; + if (osName.startsWith("linux")) + return LINUX; + if (osName.startsWith("sun")) + return SUN; + return UNKNOWN; + } + } + +} diff --git a/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/GnuplotSession.java b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/GnuplotSession.java new file mode 100644 index 000000000..32534e0cf --- /dev/null +++ b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/GnuplotSession.java @@ -0,0 +1,79 @@ +package org.simantics.gnuplot; + +import java.io.Closeable; +import java.io.IOException; +import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.Path; + +/** + * @author Tuukka Lehtonen + * @since 1.24 + */ +public class GnuplotSession implements Closeable { + + private Process process; + private PrintStream out; + + private Thread stdoutDumper; + private Thread stderrDumper; + + GnuplotSession(Path workingDirectory, Path stdout, Path stderr, Process process) { + this.process = process; + this.out = new PrintStream(process.getOutputStream()); + stdoutDumper = new Thread(new InputStreamToFileCopier(process.getInputStream(), stdout)); + stderrDumper = new Thread(new InputStreamToFileCopier(process.getErrorStream(), stderr)); + stdoutDumper.start(); + stderrDumper.start(); + } + + private void assertAlive() { + if (process == null) + throw new IllegalStateException("session has been closed already"); + } + + public void evaluate(String commands) throws IOException { + assertAlive(); + out.println(commands); + } + + public void evaluateFile(Path file) throws IOException { + try { + Files.lines(file).forEachOrdered(l -> { + try { + evaluate(l); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + } catch (RuntimeException e) { + Throwable t = e.getCause(); + if (t instanceof IOException) + throw (IOException) t; + throw e; + } + } + + @Override + public void close() throws IOException { + Process p = process; + synchronized (this) { + if (process == null) + return; + process = null; + } + + // Inform the process that its stdin has closed, i.e. is done. + out.close(); + try { + // Wait for the outputs to be closed by the process itself. + stdoutDumper.join(); + stderrDumper.join(); + p.waitFor(); + //System.out.println("gnuplot process ended"); + } catch (InterruptedException e) { + throw new IOException(e); + } + } + +} diff --git a/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/InputStreamToFileCopier.java b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/InputStreamToFileCopier.java new file mode 100644 index 000000000..02720d030 --- /dev/null +++ b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/InputStreamToFileCopier.java @@ -0,0 +1,40 @@ +package org.simantics.gnuplot; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; + +/** + * @author Tuukka Lehtonen + * @since 1.24 + */ +class InputStreamToFileCopier implements Runnable { + + private final InputStream in; + private final Path out; + + public InputStreamToFileCopier(InputStream in, Path out) { + this.in = in; + this.out = out; + } + + @Override + public void run() { + try { + if (out != null) { + Files.copy(in, out, StandardCopyOption.REPLACE_EXISTING); + } else { + drain(in); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void drain(InputStream in) throws IOException { + while (in.read() >= 0); + } + +} \ No newline at end of file diff --git a/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/package-info.java b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/package-info.java new file mode 100644 index 000000000..2fc4e58d0 --- /dev/null +++ b/bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/package-info.java @@ -0,0 +1,29 @@ +/** + * Contains simple gnuplot installation detection and + * gnuplot execution facilities. + * + *

+ * The installation detection logic relies purely on two environment variables. + * Primarily the GNUPLOT variable and secondarily on + * PATH. GNUPLOT can be set to point to one of the + * following: + *

+ * Secondarily the detection will check whether the PATH variable + * contains any files system path that corresponds to a gnuplot installation + * bin directory, i.e. the directory contains a + * gnuplot excutable. + * + *

+ * In both cases the detection will also ensure that the discovered gnuplot + * executable responds to the -V (version) argument as expected, + * i.e. returns a line starting with "gnuplot ". + * + * @author Tuukka Lehtonen + * @since 1.24 + */ +package org.simantics.gnuplot; \ No newline at end of file diff --git a/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/GnuplotTest.java b/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/GnuplotTest.java new file mode 100644 index 000000000..ccc144486 --- /dev/null +++ b/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/GnuplotTest.java @@ -0,0 +1,58 @@ +package org.simantics.gnuplot.tests; + +import java.io.IOException; +import java.net.URL; +import java.net.URLDecoder; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.simantics.gnuplot.Gnuplot; +import org.simantics.gnuplot.GnuplotSession; + +public class GnuplotTest { + + private Path dataPath; + private Path plot; + private Path stdout; + private Path stderr; + private Path stdout2; + private Path stderr2; + + private Path getDir() throws IOException { + URL path = getClass().getResource("."); + // Avoid the beginning '/' + String p = path.getPath().substring(1); + String dp = URLDecoder.decode(p, "UTF-8"); + return Paths.get(dp).toAbsolutePath(); + } + + @Before + public void before() throws IOException { + dataPath = getDir(); + plot = dataPath.resolve("hexagons.plt"); + stdout = dataPath.resolve("hexagons.svg"); + stderr = dataPath.resolve("hexagons.stderr.txt"); + stdout2 = dataPath.resolve("hexagons2.svg"); + stderr2 = dataPath.resolve("hexagons2.stderr.txt"); + } + + @After + public void after() { + } + + @Test + public void testGnuplot() throws IOException { + Gnuplot.detect().execute(dataPath, stdout, stderr, plot); + } + + @Test + public void testGnuplotSession() throws IOException { + try (GnuplotSession session = Gnuplot.detect().newSession(dataPath, stdout2, stderr2)) { + session.evaluateFile(plot); + } + } + +} \ No newline at end of file diff --git a/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.dat b/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.dat new file mode 100644 index 000000000..912b30c3d --- /dev/null +++ b/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.dat @@ -0,0 +1,11 @@ +3 1.73205080756888 0.627868065218539 +2 3.46410161513775 0.0381587751648738 +3 5.19615242270663 0.372697677268786 +2 6.92820323027551 0.421502736487078 +3 8.66025403784439 0.274237128801435 +5 1.73205080756888 0.202129157245494 +4 3.46410161513775 0.769320237819866 +5 5.19615242270663 0.031500208931071 +4 6.92820323027551 0.562379837027411 +5 8.66025403784439 0.504284749332101 +7 1.73205080756888 0.217345187922358 diff --git a/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.plt b/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.plt new file mode 100644 index 000000000..8b5aca101 --- /dev/null +++ b/bundles/org.simantics.gnuplot/test/org/simantics/gnuplot/tests/hexagons.plt @@ -0,0 +1,31 @@ +reset +fn = 'hexagons.dat' +S = 0.5 +C = sqrt(3)/2 +A = 1/C +a = 0.95*A + +hex_id = 1 + +cmd = '' + +hex_cmd(x, y, c) = sprintf("set obj hex_id poly from %g,%g-a to %g+a*C, %g-a*S to %g+a*C,%g+a*S to %g,%g+a to %g-a*C,%g+a*S to %g-a*C,%g-a*S to %g,%g-a fs solid 0.8 border lc pal cb %g lw 2 fc pal cb %g; hex_id = hex_id + 1;", x,y,x,y,x,y,x,y,x,y,x,y,x,y,c,c) + +read_f(x, y, c) = (cmd=cmd.hex_cmd(x, y, c), y) + +set term unknown + +plot fn using 1:(read_f($1,$2,$3)) + +set term pop + +print cmd +eval cmd + +set size ratio -1 +set xr [GPVAL_X_MIN-A:GPVAL_X_MAX+A] +set yr [GPVAL_Y_MIN-A:GPVAL_Y_MAX+A] + +set term svg +#plot fn using 1:2:3 w d lc pal notit +plot fn using 1:2:3 notitle lc pal w d diff --git a/bundles/org.simantics.msvc.runtime.x86/.classpath b/bundles/org.simantics.msvc.runtime.x86/.classpath new file mode 100644 index 000000000..ad32c83a7 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/org.simantics.msvc.runtime.x86/.project b/bundles/org.simantics.msvc.runtime.x86/.project new file mode 100644 index 000000000..050f09e08 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86/.project @@ -0,0 +1,28 @@ + + + org.simantics.msvc.runtime.x86 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..c537b6306 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/bundles/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF b/bundles/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF new file mode 100644 index 000000000..864f441ec --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Microsoft Visual C++ Runtime x86 libraries +Bundle-SymbolicName: org.simantics.msvc.runtime.x86 +Bundle-Version: 10.0.40219.qualifier +Bundle-Vendor: Semantum Oy +Fragment-Host: org.simantics.msvc.runtime +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86)) +Bundle-NativeCode: msvcr100.dll; msvcp100.dll; processor=x86 diff --git a/bundles/org.simantics.msvc.runtime.x86/build.properties b/bundles/org.simantics.msvc.runtime.x86/build.properties new file mode 100644 index 000000000..47c6edf6d --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + msvcp100.dll,\ + msvcr100.dll diff --git a/bundles/org.simantics.msvc.runtime.x86/msvcp100.dll b/bundles/org.simantics.msvc.runtime.x86/msvcp100.dll new file mode 100644 index 000000000..e9eae444e Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86/msvcp100.dll differ diff --git a/bundles/org.simantics.msvc.runtime.x86/msvcr100.dll b/bundles/org.simantics.msvc.runtime.x86/msvcr100.dll new file mode 100644 index 000000000..fd91c89d8 Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86/msvcr100.dll differ diff --git a/bundles/org.simantics.msvc.runtime.x86/pom.xml b/bundles/org.simantics.msvc.runtime.x86/pom.xml new file mode 100644 index 000000000..256c95cd1 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + org.simantics.msvc.runtime.x86 + eclipse-plugin + 10.0.40219-SNAPSHOT + + + org.simantics + org.simantics.root.bundles + 1.0.0-SNAPSHOT + .. + + + + + + org.eclipse.tycho + target-platform-configuration + + + + win32 + x86 + + + + + + + + \ No newline at end of file diff --git a/bundles/org.simantics.msvc.runtime.x86/src/.keep b/bundles/org.simantics.msvc.runtime.x86/src/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/bundles/org.simantics.msvc.runtime.x86_64/.classpath b/bundles/org.simantics.msvc.runtime.x86_64/.classpath new file mode 100644 index 000000000..ad32c83a7 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/org.simantics.msvc.runtime.x86_64/.project b/bundles/org.simantics.msvc.runtime.x86_64/.project new file mode 100644 index 000000000..e11e7180f --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/.project @@ -0,0 +1,28 @@ + + + org.simantics.msvc.runtime.x86_64 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.simantics.msvc.runtime.x86_64/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.msvc.runtime.x86_64/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..c537b6306 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/bundles/org.simantics.msvc.runtime.x86_64/META-INF/MANIFEST.MF b/bundles/org.simantics.msvc.runtime.x86_64/META-INF/MANIFEST.MF new file mode 100644 index 000000000..df0f3ae66 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Microsoft Visual C++ Runtime x86-64 libraries +Bundle-SymbolicName: org.simantics.msvc.runtime.x86_64 +Bundle-Version: 10.0.40219.qualifier +Bundle-Vendor: Semantum Oy +Fragment-Host: org.simantics.msvc.runtime +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86_64)) +Bundle-NativeCode: msvcr100.dll; msvcp100.dll; processor=x86_64 diff --git a/bundles/org.simantics.msvc.runtime.x86_64/build.properties b/bundles/org.simantics.msvc.runtime.x86_64/build.properties new file mode 100644 index 000000000..47c6edf6d --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + msvcp100.dll,\ + msvcr100.dll diff --git a/bundles/org.simantics.msvc.runtime.x86_64/msvcp100.dll b/bundles/org.simantics.msvc.runtime.x86_64/msvcp100.dll new file mode 100644 index 000000000..6f0cdf160 Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86_64/msvcp100.dll differ diff --git a/bundles/org.simantics.msvc.runtime.x86_64/msvcr100.dll b/bundles/org.simantics.msvc.runtime.x86_64/msvcr100.dll new file mode 100644 index 000000000..b1c3a5e77 Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86_64/msvcr100.dll differ diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.classpath b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.classpath new file mode 100644 index 000000000..ad32c83a7 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.project b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.project new file mode 100644 index 000000000..050f09e08 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.project @@ -0,0 +1,28 @@ + + + org.simantics.msvc.runtime.x86 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..c537b6306 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF new file mode 100644 index 000000000..864f441ec --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Microsoft Visual C++ Runtime x86 libraries +Bundle-SymbolicName: org.simantics.msvc.runtime.x86 +Bundle-Version: 10.0.40219.qualifier +Bundle-Vendor: Semantum Oy +Fragment-Host: org.simantics.msvc.runtime +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86)) +Bundle-NativeCode: msvcr100.dll; msvcp100.dll; processor=x86 diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/build.properties b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/build.properties new file mode 100644 index 000000000..47c6edf6d --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + msvcp100.dll,\ + msvcr100.dll diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcp100.dll b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcp100.dll new file mode 100644 index 000000000..e9eae444e Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcp100.dll differ diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcr100.dll b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcr100.dll new file mode 100644 index 000000000..fd91c89d8 Binary files /dev/null and b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcr100.dll differ diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.classpath b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.classpath new file mode 100644 index 000000000..ad32c83a7 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.project b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.project new file mode 100644 index 000000000..5c92a7c84 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.project @@ -0,0 +1,28 @@ + + + org.simantics.msvc.runtime + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..c537b6306 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/META-INF/MANIFEST.MF b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/META-INF/MANIFEST.MF new file mode 100644 index 000000000..42eebe12d --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Microsoft Visual C++ Runtimes +Bundle-SymbolicName: org.simantics.msvc.runtime +Bundle-Version: 10.0.40219.qualifier +Bundle-Activator: org.simantics.msvc.runtime.Activator +Bundle-Vendor: Semantum Oy +Require-Bundle: org.eclipse.core.runtime +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Export-Package: org.simantics.msvc.runtime diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/build.properties b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java new file mode 100644 index 000000000..b956a448e --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java @@ -0,0 +1,31 @@ +package org.simantics.msvc.runtime; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + Runtimes.initialize(Runtimes.VC_2010); + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } + +} diff --git a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java new file mode 100644 index 000000000..31702fd10 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java @@ -0,0 +1,92 @@ +package org.simantics.msvc.runtime; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.net.URLDecoder; + +import org.eclipse.core.runtime.Path; + +/** + * @author Tuukka Lehtonen + */ +public final class Runtimes { + + public static final String VC_2010 = "vc2010"; + + static boolean vc100Initialized = false; + + public static void initialize(String vc) { + OSType os = OSType.calculate(); + if (os == OSType.WINDOWS) { + if (VC_2010.equals(vc) && !vc100Initialized) { + initializeVC100(); + } + } + } + + static synchronized void initializeVC100() { + try { + // Works in OSGi environment. + System.loadLibrary("msvcr100"); + System.loadLibrary("msvcp100"); + vc100Initialized = true; + } catch (UnsatisfiedLinkError e) { + // Try to load from a workspace in POJO environment. + try { + String archStr = ARCHType.calculate().toString().toLowerCase(); + URL url = Runtimes.class.getResource("."); + File dir = new File(URLDecoder.decode(url.getPath(), "UTF-8") + "../../../../../../org.simantics.msvc.runtime." + archStr); + dir = new Path(dir.getAbsolutePath()).toFile(); + String vcr = new File(dir, "msvcr100.dll").getAbsolutePath(); + String vcp = new File(dir, "msvcp100.dll").getAbsolutePath(); + System.load(vcr); + System.load(vcp); + vc100Initialized = true; + } catch (UnsupportedEncodingException e1) { + throw new Error("UTF-8 not supported, impossible"); + } + } + } + + public enum ARCHType { + PPC, PPC_64, SPARC, X86, X86_64, UNKNOWN; + + public static ARCHType calculate() { + String osArch = System.getProperty("os.arch"); + assert osArch != null; + osArch = osArch.toLowerCase(); + if (osArch.equals("i386") || osArch.equals("i586") || osArch.equals("i686") || osArch.equals("x86")) + return X86; + if (osArch.startsWith("amd64") || osArch.startsWith("x86_64")) + return X86_64; + if (osArch.equals("ppc")) + return PPC; + if (osArch.startsWith("ppc")) + return PPC_64; + if (osArch.startsWith("sparc")) + return SPARC; + return UNKNOWN; + } + } + + public enum OSType { + APPLE, LINUX, SUN, WINDOWS, UNKNOWN; + + public static OSType calculate() { + String osName = System.getProperty("os.name"); + assert osName != null; + osName = osName.toLowerCase(); + if (osName.startsWith("mac os x")) + return APPLE; + if (osName.startsWith("windows")) + return WINDOWS; + if (osName.startsWith("linux")) + return LINUX; + if (osName.startsWith("sun")) + return SUN; + return UNKNOWN; + } + } + +} diff --git a/bundles/org.simantics.msvc.runtime.x86_64/pom.xml b/bundles/org.simantics.msvc.runtime.x86_64/pom.xml new file mode 100644 index 000000000..ca89cf878 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime.x86_64/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + org.simantics.msvc.runtime.x86_64 + eclipse-plugin + 10.0.40219-SNAPSHOT + + + org.simantics + org.simantics.root.bundles + 1.0.0-SNAPSHOT + .. + + + + + + org.eclipse.tycho + target-platform-configuration + + + + win32 + x86_64 + + + + + + + + \ No newline at end of file diff --git a/bundles/org.simantics.msvc.runtime.x86_64/src/.keep b/bundles/org.simantics.msvc.runtime.x86_64/src/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/bundles/org.simantics.msvc.runtime/.classpath b/bundles/org.simantics.msvc.runtime/.classpath new file mode 100644 index 000000000..ad32c83a7 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/org.simantics.msvc.runtime/.project b/bundles/org.simantics.msvc.runtime/.project new file mode 100644 index 000000000..5c92a7c84 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime/.project @@ -0,0 +1,28 @@ + + + org.simantics.msvc.runtime + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..c537b6306 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/bundles/org.simantics.msvc.runtime/META-INF/MANIFEST.MF b/bundles/org.simantics.msvc.runtime/META-INF/MANIFEST.MF new file mode 100644 index 000000000..42eebe12d --- /dev/null +++ b/bundles/org.simantics.msvc.runtime/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Microsoft Visual C++ Runtimes +Bundle-SymbolicName: org.simantics.msvc.runtime +Bundle-Version: 10.0.40219.qualifier +Bundle-Activator: org.simantics.msvc.runtime.Activator +Bundle-Vendor: Semantum Oy +Require-Bundle: org.eclipse.core.runtime +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Export-Package: org.simantics.msvc.runtime diff --git a/bundles/org.simantics.msvc.runtime/build.properties b/bundles/org.simantics.msvc.runtime/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/bundles/org.simantics.msvc.runtime/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java b/bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java new file mode 100644 index 000000000..b956a448e --- /dev/null +++ b/bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java @@ -0,0 +1,31 @@ +package org.simantics.msvc.runtime; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + Runtimes.initialize(Runtimes.VC_2010); + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } + +} diff --git a/bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java b/bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java new file mode 100644 index 000000000..31702fd10 --- /dev/null +++ b/bundles/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java @@ -0,0 +1,92 @@ +package org.simantics.msvc.runtime; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.net.URLDecoder; + +import org.eclipse.core.runtime.Path; + +/** + * @author Tuukka Lehtonen + */ +public final class Runtimes { + + public static final String VC_2010 = "vc2010"; + + static boolean vc100Initialized = false; + + public static void initialize(String vc) { + OSType os = OSType.calculate(); + if (os == OSType.WINDOWS) { + if (VC_2010.equals(vc) && !vc100Initialized) { + initializeVC100(); + } + } + } + + static synchronized void initializeVC100() { + try { + // Works in OSGi environment. + System.loadLibrary("msvcr100"); + System.loadLibrary("msvcp100"); + vc100Initialized = true; + } catch (UnsatisfiedLinkError e) { + // Try to load from a workspace in POJO environment. + try { + String archStr = ARCHType.calculate().toString().toLowerCase(); + URL url = Runtimes.class.getResource("."); + File dir = new File(URLDecoder.decode(url.getPath(), "UTF-8") + "../../../../../../org.simantics.msvc.runtime." + archStr); + dir = new Path(dir.getAbsolutePath()).toFile(); + String vcr = new File(dir, "msvcr100.dll").getAbsolutePath(); + String vcp = new File(dir, "msvcp100.dll").getAbsolutePath(); + System.load(vcr); + System.load(vcp); + vc100Initialized = true; + } catch (UnsupportedEncodingException e1) { + throw new Error("UTF-8 not supported, impossible"); + } + } + } + + public enum ARCHType { + PPC, PPC_64, SPARC, X86, X86_64, UNKNOWN; + + public static ARCHType calculate() { + String osArch = System.getProperty("os.arch"); + assert osArch != null; + osArch = osArch.toLowerCase(); + if (osArch.equals("i386") || osArch.equals("i586") || osArch.equals("i686") || osArch.equals("x86")) + return X86; + if (osArch.startsWith("amd64") || osArch.startsWith("x86_64")) + return X86_64; + if (osArch.equals("ppc")) + return PPC; + if (osArch.startsWith("ppc")) + return PPC_64; + if (osArch.startsWith("sparc")) + return SPARC; + return UNKNOWN; + } + } + + public enum OSType { + APPLE, LINUX, SUN, WINDOWS, UNKNOWN; + + public static OSType calculate() { + String osName = System.getProperty("os.name"); + assert osName != null; + osName = osName.toLowerCase(); + if (osName.startsWith("mac os x")) + return APPLE; + if (osName.startsWith("windows")) + return WINDOWS; + if (osName.startsWith("linux")) + return LINUX; + if (osName.startsWith("sun")) + return SUN; + return UNKNOWN; + } + } + +} diff --git a/bundles/pom.xml b/bundles/pom.xml index 3765819c5..bbc378243 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -123,6 +123,7 @@ org.simantics.graphfile.ontology org.simantics.graphviz org.simantics.graphviz.ui + org.simantics.gnuplot org.simantics.help.base org.simantics.help.core org.simantics.help.files @@ -154,6 +155,9 @@ org.simantics.modeling.template2d.ui org.simantics.modeling.ui org.simantics.modeling.ui.workbench + org.simantics.msvc.runtime + org.simantics.msvc.runtime.x86 + org.simantics.msvc.runtime.x86_64 org.simantics.nativemem org.simantics.objmap2 org.simantics.platform.ui.ontology diff --git a/features/org.simantics.sdk.feature/feature.xml b/features/org.simantics.sdk.feature/feature.xml index 211e549d9..1190496c1 100644 --- a/features/org.simantics.sdk.feature/feature.xml +++ b/features/org.simantics.sdk.feature/feature.xml @@ -215,4 +215,39 @@ version="0.0.0" unpack="false"/> + + + + + + + +