]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Removed rubbish included in previous commit 59/259/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 9 Jan 2017 20:08:20 +0000 (22:08 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 9 Jan 2017 20:25:19 +0000 (22:25 +0200)
org.simantics.msvc.runtime.x86_64 contained copies of other plug-ins,
sorry I missed it in the review for some reason.

Also put latest versions of Gnuplot and GnuplotSession in since I
imported old versions of both on the first try.

refs #6945

Change-Id: I7a703e4d76364efb4a5f2bddd568c6064b5d677a

16 files changed:
bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/Gnuplot.java
bundles/org.simantics.gnuplot/src/org/simantics/gnuplot/GnuplotSession.java
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.classpath [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.project [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/.settings/org.eclipse.jdt.core.prefs [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/META-INF/MANIFEST.MF [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/build.properties [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcp100.dll [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcr100.dll [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.classpath [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.project [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/.settings/org.eclipse.jdt.core.prefs [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/META-INF/MANIFEST.MF [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/build.properties [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Activator.java [deleted file]
bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime/src/org/simantics/msvc/runtime/Runtimes.java [deleted file]

index f1321796ab6fdd6b5f3407e3415f9d1dfa2e08ee..be2eda1dcb0db0ce76e6fe3459542b294172b1e0 100644 (file)
@@ -19,10 +19,19 @@ public class Gnuplot {
 
     private Path executable;
 
-    public Gnuplot(Path executable) {
+    public Gnuplot(Path executable) throws IOException {
+        if (!Files.exists(executable))
+            throw new IOException("Provided gnuplot executable does not exist: " + executable);
+        if (!Files.isExecutable(executable))
+            throw new IOException("Provided gnuplot executable is not marked executable: " + executable);
         this.executable = executable;
     }
 
+    @Override
+    public String toString() {
+        return executable.toString();
+    }
+
     public static Gnuplot detect() throws IOException {
         try {
             return new Gnuplot(findGnuplotPath());
@@ -104,23 +113,40 @@ public class Gnuplot {
     }
 
     private void execute0(Path workingDirectory, Path stdout, Path stderr, String... cmdline) throws IOException {
-        Process process = new ProcessBuilder(cmdline)
-                .directory(workingDirectory.toFile())
-                .start();
+        ProcessBuilder builder = new ProcessBuilder(cmdline)
+                .directory(workingDirectory.toFile());
+
+        if (stdout != null)
+            builder.redirectOutput(stdout.toFile());
+        if (stderr != null)
+            builder.redirectError(stderr.toFile());
+
+        Process process = builder.start();
+        Thread stdoutDumper = stdout == null ? new Thread(new InputStreamToFileCopier(process.getInputStream(), null)) : null;
+        Thread stderrDumper = stderr == null ? new Thread(new InputStreamToFileCopier(process.getErrorStream(), null)) : null;
+        if (stdoutDumper != null)
+            stdoutDumper.start();
+        if (stderrDumper != null)
+            stderrDumper.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();
+            if (stdoutDumper != null)
+                stdoutDumper.join();
+            if (stderrDumper != null)
+                stderrDumper.join();
             process.waitFor();
         } catch (InterruptedException e) {
             throw new IOException(e);
         }
     }
 
+    public void execute(Path workingDirectory, Path stdout, Path stderr, boolean redirectStderr, InputStream input, String charset) throws IOException {
+        try (GnuplotSession session = newSession(workingDirectory, stdout, stderr, redirectStderr)) {
+            session.evaluateStream(input, charset);
+        }
+    }
+
     public void execute(Path workingDirectory, Path stdout, Path stderr, Path script) throws IOException {
         execute0(workingDirectory, stdout, stderr, executable.toString(), "-c", script.toString());
     }
@@ -138,11 +164,24 @@ public class Gnuplot {
         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);
+    private ProcessBuilder buildSessionProcess(Path workingDirectory, Path stdout, Path stderr, boolean redirectErrorStream) {
+        ProcessBuilder builder = new ProcessBuilder(executable.toString())
+                .directory(workingDirectory != null ? workingDirectory.toFile() : null)
+                .redirectErrorStream(redirectErrorStream);
+        if (stdout != null)
+            builder.redirectOutput(stdout.toFile());
+        if (stderr != null)
+            builder.redirectError(stderr.toFile());
+        return builder;
+    }
+
+    public GnuplotSession newSession(Path workingDirectory, Path stdout) throws IOException {
+        return newSession(workingDirectory, stdout, null, true);
+    }
+
+    public GnuplotSession newSession(Path workingDirectory, Path stdout, Path stderr, boolean redirectStderr) throws IOException {
+        return new GnuplotSession(workingDirectory, stdout == null, stderr == null,
+                buildSessionProcess(workingDirectory, stdout, stderr, redirectStderr).start());
     }
 
     static enum OSType {
index 32534e0cf8baff32b0c4e4d9640966fdc50becac..6bc3e5bafa3f66f3472f5713fccfd780a52bc050 100644 (file)
@@ -1,7 +1,10 @@
 package org.simantics.gnuplot;
 
+import java.io.BufferedReader;
 import java.io.Closeable;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -18,13 +21,17 @@ public class GnuplotSession implements Closeable {
     private Thread stdoutDumper;
     private Thread stderrDumper;
 
-    GnuplotSession(Path workingDirectory, Path stdout, Path stderr, Process process) {
+    GnuplotSession(Path workingDirectory, boolean drainStdout, boolean drainStderr, 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();
+        if (drainStdout) {
+            stdoutDumper = new Thread(new InputStreamToFileCopier(process.getInputStream(), null));
+            stdoutDumper.start();
+        }
+        if (drainStderr) {
+            stderrDumper = new Thread(new InputStreamToFileCopier(process.getErrorStream(), null));
+            stderrDumper.start();
+        }
     }
 
     private void assertAlive() {
@@ -37,6 +44,15 @@ public class GnuplotSession implements Closeable {
         out.println(commands);
     }
 
+    public void evaluateStream(InputStream input, String charset) throws IOException {
+        try (BufferedReader br = new BufferedReader(new InputStreamReader(input, charset))) {
+            for (String line = br.readLine(); null != line; line = br.readLine()) {
+                out.println(line);
+                out.println();
+            }
+        }
+    }
+
     public void evaluateFile(Path file) throws IOException {
         try {
             Files.lines(file).forEachOrdered(l -> {
@@ -67,8 +83,10 @@ public class GnuplotSession implements Closeable {
         out.close();
         try {
             // Wait for the outputs to be closed by the process itself.
-            stdoutDumper.join();
-            stderrDumper.join();
+            if (stdoutDumper != null)
+                stdoutDumper.join();
+            if (stderrDumper != null)
+                stderrDumper.join();
             p.waitFor();
             //System.out.println("gnuplot process ended");
         } catch (InterruptedException e) {
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
deleted file mode 100644 (file)
index ad32c83..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
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
deleted file mode 100644 (file)
index 050f09e..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.simantics.msvc.runtime.x86</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.ManifestBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.SchemaBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.pde.PluginNature</nature>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
-</projectDescription>
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
deleted file mode 100644 (file)
index c537b63..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-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
deleted file mode 100644 (file)
index 864f441..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-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
deleted file mode 100644 (file)
index 47c6edf..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-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
deleted file mode 100644 (file)
index e9eae44..0000000
Binary files a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcp100.dll and /dev/null 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
deleted file mode 100644 (file)
index fd91c89..0000000
Binary files a/bundles/org.simantics.msvc.runtime.x86_64/org.simantics.msvc.runtime.x86/msvcr100.dll and /dev/null 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
deleted file mode 100644 (file)
index ad32c83..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
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
deleted file mode 100644 (file)
index 5c92a7c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.simantics.msvc.runtime</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.ManifestBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.SchemaBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.pde.PluginNature</nature>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
-</projectDescription>
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
deleted file mode 100644 (file)
index c537b63..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-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
deleted file mode 100644 (file)
index 42eebe1..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-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
deleted file mode 100644 (file)
index 34d2e4d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-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
deleted file mode 100644 (file)
index b956a44..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-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
deleted file mode 100644 (file)
index 31702fd..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-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;
-        }
-    }
-
-}