[mkbundle] Add diagnostics, fix crash, fix registered path to match runtime name...
authorMiguel de Icaza <miguel@gnome.org>
Thu, 29 Sep 2016 19:13:41 +0000 (15:13 -0400)
committerGitHub <noreply@github.com>
Thu, 29 Sep 2016 19:13:41 +0000 (15:13 -0400)
mcs/tools/mkbundle/mkbundle.cs
mono/mini/main.c

index cc891536b8af26f751fb8fa1aebc08c5a5a42487..447540860f50024ec14df5685b4cf49d5fc3218d 100755 (executable)
@@ -386,11 +386,11 @@ class MakeBundle {
                                        }
                                }
                                
-                               Console.WriteLine ("Using runtime {0} for {1}", runtime, output);
                        }
                        GeneratePackage (files);
                }
-               
+               Console.WriteLine ("Generated {0}", output);
+
                return 0;
        }
 
@@ -608,6 +608,7 @@ class MakeBundle {
                }
                
                var maker = new PackageMaker (output);
+               Console.WriteLine ("Using runtime: " + runtime);
                maker.AddFile (runtime);
                
                foreach (var url in files){
@@ -615,9 +616,13 @@ class MakeBundle {
                        string aname = MakeBundle.GetAssemblyName (fname);
 
                        maker.Add ("assembly:" + aname, fname);
-                       if (File.Exists (fname + ".config"))
+                       Console.WriteLine ("     Assembly: " + fname);
+                       if (File.Exists (fname + ".config")){
                                maker.Add ("config:" + aname, fname + ".config");
+                               Console.WriteLine ("       Config: " + runtime);
+                       }
                }
+               
                if (!MaybeAddFile (maker, "systemconfig:", config_file) || !MaybeAddFile (maker, "machineconfig:", machine_config_file))
                        return false;
 
@@ -631,6 +636,7 @@ class MakeBundle {
                }
                if (libraries.Count > 0){
                        foreach (var alias_and_path in libraries){
+                               Console.WriteLine ("     Library:  " + alias_and_path.Value);
                                maker.Add ("library:" + alias_and_path.Key, alias_and_path.Value);
                        }
                }
index 6149ca75fa0996be2da5c08a5ed076fd8685a539..8d73080631e424bf475d8bab179cde569b069fa9 100644 (file)
@@ -149,7 +149,7 @@ static void
 bundle_save_library_initialize ()
 {
        bundle_save_library_initialized = 1;
-       char *path = g_build_filename (g_get_tmp_dir (), "mono-bundle-XXXXXX");
+       char *path = g_build_filename (g_get_tmp_dir (), "mono-bundle-XXXXXX", NULL);
        bundled_dylibrary_directory = g_mkdtemp (path);
        g_free (path);
        if (bundled_dylibrary_directory == NULL)
@@ -161,19 +161,23 @@ static void
 save_library (int fd, uint64_t offset, uint64_t size, const char *destfname)
 {
        MonoDl *lib;
-       char *file, *buffer, *err;
+       char *file, *buffer, *err, *internal_path;
        if (!bundle_save_library_initialized)
                bundle_save_library_initialize ();
        
-       file = g_build_filename (bundled_dylibrary_directory, destfname);
+       file = g_build_filename (bundled_dylibrary_directory, destfname, NULL);
        buffer = load_from_region (fd, offset, size);
        g_file_set_contents (file, buffer, size, NULL);
+
        lib = mono_dl_open (file, MONO_DL_LAZY, &err);
-       if (err != NULL){
-               fprintf (stderr, "Error loading shared library: %s\n", file);
+       if (lib == NULL){
+               fprintf (stderr, "Error loading shared library: %s %s\n", file, err);
                exit (1);
        }
-       mono_loader_register_module (destfname, lib);
+       // Register the name with "." as this is how it will be found when embedded
+       internal_path = g_build_filename (".", destfname, NULL);
+       mono_loader_register_module (internal_path, lib);
+       g_free (internal_path);
        bundle_library_paths = g_slist_append (bundle_library_paths, file);
        
        g_free (buffer);