2007-10-19 Robert Jordan <robertj@gmx.net>
authorRobert Jordan <robertj@gmx.net>
Fri, 19 Oct 2007 18:17:33 +0000 (18:17 -0000)
committerRobert Jordan <robertj@gmx.net>
Fri, 19 Oct 2007 18:17:33 +0000 (18:17 -0000)
* mkbundle.cs (Execute): [Windows] since recently (?) cygwin's bash
doesn't strip CRLFs from ``-style command interpolation anymore.
The superfluous CRLF was breaking the gcc command line.

* mkbundle.cs (Execute): [Windows] set UseShellExecute = false to
prevent the creation of a new console windows.

svn path=/trunk/mcs/; revision=87841

mcs/tools/mkbundle/ChangeLog
mcs/tools/mkbundle/mkbundle.cs

index fa0ef278b0b36d72854a1a4c352c7a7645e3a4f7..f707a4fe6ead65dd808933c04fe6df686ec728f1 100644 (file)
@@ -1,3 +1,12 @@
+2007-10-19  Robert Jordan  <robertj@gmx.net>
+
+       * mkbundle.cs (Execute): [Windows] since recently (?) cygwin's bash
+       doesn't strip CRLFs from ``-style command interpolation anymore.
+       The superfluous CRLF was breaking the gcc command line.
+
+       * mkbundle.cs (Execute): [Windows] set UseShellExecute = false to
+       prevent the creation of a new console windows.
+
 2007-01-03  Tor Lillqvist  <tml@novell.com>
 
        Add the possibility to bundle also the machine.config file, from
index 3fb9f87ad7850819cdb0eff112eb9f2a4504728b..293d4a6b9890bc8c803517ad8663fd828c9e90a3 100644 (file)
@@ -15,6 +15,7 @@ using System.Collections;
 using System.Reflection;
 using System.IO;
 using System.Runtime.InteropServices;
+using System.Text;
 using Mono.Unix;
 using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
 
@@ -569,11 +570,35 @@ class MakeBundle {
 
        static int Execute (string cmdLine)
        {
-               Console.WriteLine (cmdLine);
                if (IsUnix) {
+                       Console.WriteLine (cmdLine);
                        return system (cmdLine);
-               } else {
-                       Process p = Process.Start ("sh", String.Format ("-c \"{0}\"", cmdLine));
+               }
+
+               // on Windows, we have to pipe the output of a
+               // `cmd` interpolation to dos2unix, because the shell does not
+               // strip the CRLFs generated by the native pkg-config distributed
+               // with Mono.
+               StringBuilder b = new StringBuilder ();
+               int count = 0;
+               for (int i = 0; i < cmdLine.Length; i++) {
+                       if (cmdLine [i] == '`') {
+                               if (count % 2 != 0) {
+                                       b.Append ("|dos2unix");
+                               }
+                               count++;
+                       }
+                       b.Append (cmdLine [i]);
+               }
+               cmdLine = b.ToString ();
+               Console.WriteLine (cmdLine);
+                       
+               ProcessStartInfo psi = new ProcessStartInfo ();
+               psi.UseShellExecute = false;
+               psi.FileName = "sh";
+               psi.Arguments = String.Format ("-c \"{0}\"", cmdLine);
+
+               using (Process p = Process.Start (psi)) {
                        p.WaitForExit ();
                        return p.ExitCode;
                }