do not bundle mscorlib.dll that is running mkbundle.exe. Bundle explicitly passed...
[mono.git] / mcs / tools / mkbundle / mkbundle.cs
index 36a05394c537241404ee8bb84441fc3341e22105..47365ca07c316266468a2645d69a1e200e3112f3 100644 (file)
@@ -144,6 +144,23 @@ class MakeBundle {
                ArrayList files = new ArrayList ();
                foreach (Assembly a in assemblies)
                        QueueAssembly (files, a.CodeBase);
+                       
+               // Special casing mscorlib.dll: any specified mscorlib.dll cannot be loaded
+               // by Assembly.ReflectionFromLoadFrom(). Instead the fx assembly which runs
+               // mkbundle.exe is loaded, which is not what we want.
+               // So, replace it with whatever actually specified.
+               foreach (string srcfile in sources) {
+                       if (Path.GetFileName (srcfile) == "mscorlib.dll") {
+                               foreach (string file in files) {
+                                       if (Path.GetFileName (new Uri (file).LocalPath) == "mscorlib.dll") {
+                                               files.Remove (file);
+                                               files.Add (new Uri (Path.GetFullPath (srcfile)).LocalPath);
+                                               break;
+                                       }
+                               }
+                               break;
+                       }
+               }
 
                GenerateBundles (files);
                //GenerateJitWrapper ();
@@ -206,6 +223,7 @@ class MakeBundle {
                        string prog = null;
 
                        tc.WriteLine ("/* This source code was produced by mkbundle, do not edit */");
+                       tc.WriteLine ("#include <mono/metadata/mono-config.h>");
                        tc.WriteLine ("#include <mono/metadata/assembly.h>\n");
 
                        if (compress) {
@@ -292,7 +310,7 @@ class MakeBundle {
                                        return;
                                }
                                Console.WriteLine ("System config from: " + config_file);
-                               tc.WriteLine ("extern const unsigned char system_config;");
+                               tc.WriteLine ("extern const char system_config;");
                                WriteSymbol (ts, "system_config", config_file.Length);
 
                                int n;
@@ -315,7 +333,7 @@ class MakeBundle {
                                        return;
                                }
                                Console.WriteLine ("Machine config from: " + machine_config_file);
-                               tc.WriteLine ("extern const unsigned char machine_config;");
+                               tc.WriteLine ("extern const char machine_config;");
                                WriteSymbol (ts, "machine_config", machine_config_file.Length);
 
                                int n;
@@ -535,7 +553,8 @@ class MakeBundle {
                                   "    --machine-config F  Use the given file as the machine.config for the application.\n" +
                                   "    --static            Statically link to mono libs\n" +
                                   "    --nomain            Don't include a main() function, for libraries\n" +
-                                  "    -z                  Compress the assemblies before embedding.\n");
+                                  "    -z                  Compress the assemblies before embedding.\n" +
+                                  "                        You need zlib development headers and libraries.\n");
        }
 
        [DllImport ("libc")]
@@ -554,6 +573,7 @@ class MakeBundle {
                IntPtr buf = UnixMarshal.AllocHeap(8192);
                if (uname (buf) != 0){
                        Console.WriteLine ("Warning: Unable to detect OS");
+                       UnixMarshal.FreeHeap(buf);
                        return;
                }
                string os = Marshal.PtrToStringAnsi (buf);