[mkbundle] Fix compiler warnings.
[mono.git] / mcs / tools / mkbundle / mkbundle.cs
index 89bab52384c3c670839772a90a8cfa499f8713fe..dbf21c44beb0b90cc5fb273b8e9215601c27eae8 100755 (executable)
@@ -299,7 +299,7 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
 
                        // Do the file reading and compression in parallel
                        Action<string> body = delegate (string url) {
-                               string fname = new Uri (url).LocalPath;
+                               string fname = LocateFile (new Uri (url).LocalPath);
                                Stream stream = File.OpenRead (fname);
 
                                long real_size = stream.Length;
@@ -334,7 +334,7 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                        // The non-parallel part
                        byte [] buffer = new byte [8192];
                        foreach (var url in files) {
-                               string fname = new Uri (url).LocalPath;
+                               string fname = LocateFile (new Uri (url).LocalPath);
                                string aname = Path.GetFileName (fname);
                                string encoded = aname.Replace ("-", "_").Replace (".", "_");
 
@@ -493,19 +493,20 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                                foreach (string include in includes)
                                        compilerArgs.Add(String.Format ("/I {0}", quote (include)));
 
-                               if (static_link) {
-                                       compilerArgs.Add("/MT");
-                                       monoFile = monoPath + @"\lib\mono-2.0.lib";
-                               }
-                               else {
-                                       compilerArgs.Add("/MD");
-                                       monoFile = monoPath + @"\lib\mono-2.0.dll";
-                               }
+                               if (static_link)
+                                       monoFile = LocateFile (monoPath + @"\lib\monosgen-2.0.lib");
+                               else
+                                       monoFile = LocateFile (monoPath + @"\lib\monosgen-2.0.dll");
 
+                               compilerArgs.Add("/MD");
                                compilerArgs.Add(temp_c);
                                compilerArgs.Add(temp_o);
                                compilerArgs.Add("/link");
 
+                               if (nomain)
+                                       compilerArgs.Add("/NOENTRY");
+                                       compilerArgs.Add("/DLL");
+
                                foreach (string lib in libs)
                                        compilerArgs.Add(String.Format ("/LIBPATH:{0}", quote(lib)));
                                compilerArgs.Add (quote(monoFile));
@@ -574,7 +575,7 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                                }
                        
                                assemblies.Add (a.CodeBase);
-                       } catch (Exception e) {
+                       } catch (Exception) {
                                if (skip_scan) {
                                        Console.WriteLine ("File will not be scanned: {0}", name);
                                        assemblies.Add (new Uri (new FileInfo (name).FullName).ToString ());
@@ -620,7 +621,7 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                                if (!QueueAssembly (files, a.CodeBase))
                                        return false;
                        }
-               } catch (Exception e) {
+               } catch (Exception) {
                        if (!skip_scan)
                                throw;
                }
@@ -835,4 +836,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);
+       }
 }