[mkbundle] Add `mkbundle --dos2unix` parameter.
authorJonathan Pryor <jonpryor@vt.edu>
Fri, 31 Jul 2015 19:21:57 +0000 (15:21 -0400)
committerJonathan Pryor <jonpryor@vt.edu>
Fri, 31 Jul 2015 19:35:37 +0000 (15:35 -0400)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=25086
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=31875
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=32171

Reverts and reworks commit bcfec743.

The problem is that when Xamarin.Android is running mkbundle, dos2unix
should NEVER be used, because the Android NDK NEVER wants Unix-like
paths, which is what dos2unix creates.

Commit bcfec743 attempted to fix this by removing dos2unix invocation
from the Xamarin.Android codepath.

The problem is that the logic was backwards: it removed dos2unix
invocation when XAMARIN_ANDROID was NOT defined, and PRESERVED
dos2unix invocation when XAMARIN_ANDROID WAS defined.

Meaning commit bcfec743 broke normal/default mkbundle.exe use on
Windows -- it would no longer probe for and use dos2unix if present --
and Xamarin.Android use of mkbundle continued to check for and use
dos2unix if it was present, continuing the buggy behavior.

Doh!

Thus, a reworking: Add a `mkbundle --dos2unix` parameter.
If `mkbundle --dos2unix=false` is specified, dos2unix will NOT be
probed for, and will NOT be used. If `mkbundle --dos2unix` or
`mkbundle --dos2unix=true` is used, then dos2unix WILL be used.

This allows the caller to consistently, ahead of time, control
mkbundle's behavior regarding dos2unix, which will e.g. allow
Xamarin.Android to *always* specify --dos2unix=false, allowing things
to build as desired there.

mcs/tools/mkbundle/mkbundle.cs

index 2dc2bf799d94c473556fc5796cc6f619e2b5e27b..ec5c1f10aabad6e73e5b4e84fa54d1b42b21a954 100755 (executable)
@@ -156,6 +156,13 @@ class MakeBundle {
                                }
                                ctor_func = args [++i];
                                break;
+                       case "--dos2unix":
+                       case "--dos2unix=true":
+                               use_dos2unix = true;
+                               break;
+                       case "--dos2unix=false":
+                               use_dos2unix = false;
+                               break;
                        default:
                                sources.Add (args [i]);
                                break;
@@ -651,6 +658,10 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                                   "    -L path             Adds `path' to the search path for assemblies\n" +
                                   "    --nodeps            Turns off automatic dependency embedding (default)\n" +
                                   "    --deps              Turns on automatic dependency embedding\n" +
+                                  "    --dos2unix[=true|false]\n" +
+                                  "                        When no value provided, or when `true` specified\n" +
+                                  "                        `dos2unix` will be invoked to convert paths on Windows.\n" +
+                                  "                        When `--dos2unix=false` used, dos2unix is NEVER used.\n" +
                                   "    --keeptemp          Keeps the temporary files\n" +
                                   "    --config F          Bundle system config file `F'\n" +
                                   "    --config-dir D      Set MONO_CFG_DIR to `D'\n" +
@@ -704,7 +715,6 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                        return system (cmdLine);
                }
                
-#if XAMARIN_ANDROID
                // 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
@@ -733,7 +743,6 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                }
                // and if there is no dos2unix, just run cmd /c.
                if (use_dos2unix == false) {
-#endif
                        Console.WriteLine (cmdLine);
                        ProcessStartInfo dos2unix = new ProcessStartInfo ();
                        dos2unix.UseShellExecute = false;
@@ -744,19 +753,15 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                                p.WaitForExit ();
                                return p.ExitCode;
                        }
-#if XAMARIN_ANDROID
                }
-#endif
 
                StringBuilder b = new StringBuilder ();
                int count = 0;
                for (int i = 0; i < cmdLine.Length; i++) {
                        if (cmdLine [i] == '`') {
-#if XAMARIN_ANDROID
                                if (count % 2 != 0) {
                                        b.Append ("|dos2unix");
                                }
-#endif
                                count++;
                        }
                        b.Append (cmdLine [i]);