Skip to content

Commit

Permalink
[mkbundle] do not require dos2unix (and sh) on Windows. Skip it if it…
Browse files Browse the repository at this point in the history
… does not exist.
  • Loading branch information
Atsushi Eno committed May 31, 2013
1 parent ad85fd1 commit 6d153cd
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion mcs/tools/mkbundle/mkbundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class MakeBundle {
static string style = "linux";
static bool compress;
static bool nomain;
static bool? use_dos2unix = null;

static int Main (string [] args)
{
Expand Down Expand Up @@ -667,11 +668,42 @@ static int Execute (string cmdLine)
Console.WriteLine (cmdLine);
return system (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.
//
// But if it's *not* on cygwin, just skip it.

// check if dos2unix is applicable.
if (use_dos2unix == null) {
use_dos2unix = false;
try {
var dos2unix = Process.Start ("dos2unix");
dos2unix.StandardInput.WriteLine ("aaa");
dos2unix.StandardInput.WriteLine ("\u0004");
dos2unix.WaitForExit ();
if (dos2unix.ExitCode == 0)
use_dos2unix = true;
} catch {
// ignore
}
}
// and if there is no dos2unix, just run cmd /c.
if (use_dos2unix == false) {
Console.WriteLine (cmdLine);
ProcessStartInfo dos2unix = new ProcessStartInfo ();
dos2unix.UseShellExecute = false;
dos2unix.FileName = "cmd";
dos2unix.Arguments = String.Format ("/c \"{0}\"", cmdLine);

using (Process p = Process.Start (dos2unix)) {
p.WaitForExit ();
return p.ExitCode;
}
}

StringBuilder b = new StringBuilder ();
int count = 0;
for (int i = 0; i < cmdLine.Length; i++) {
Expand Down

0 comments on commit 6d153cd

Please sign in to comment.