[mkbundle] Allow overriding linked Mono library path
authorAlexis Christoforides <alexis@thenull.net>
Wed, 9 Dec 2015 23:05:32 +0000 (18:05 -0500)
committerAlexis Christoforides <alexis@thenull.net>
Thu, 17 Dec 2015 18:45:20 +0000 (13:45 -0500)
mcs/tools/mkbundle/mkbundle.cs

index 89bab52384c3c670839772a90a8cfa499f8713fe..e24b924e761fb78c394160fe22f9543f75117c1d 100755 (executable)
@@ -495,11 +495,11 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
 
                                if (static_link) {
                                        compilerArgs.Add("/MT");
-                                       monoFile = monoPath + @"\lib\mono-2.0.lib";
+                                       monoFile = LocateFile (monoPath + @"\lib\mono-2.0.lib");
                                }
                                else {
                                        compilerArgs.Add("/MD");
-                                       monoFile = monoPath + @"\lib\mono-2.0.dll";
+                                       monoFile = LocateFile (monoPath + @"\lib\mono-2.0.dll");
                                }
 
                                compilerArgs.Add(temp_c);
@@ -835,4 +835,15 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                }
                return val;
        }
+
+       static string LocateFile(string default_path)
+       {
+               var override_path = Path.Combine(Directory.GetCurrentDirectory(), Path.GetFileName(default_path));
+               if (File.Exists(override_path))
+                       return override_path;
+               else if (File.Exists(default_path))
+                       return default_path;
+               else
+                       throw new FileNotFoundException(default_path);
+       }
 }