Merge pull request #704 from jgagnon/master
[mono.git] / mono / metadata / mono-config.c
index 1e85012dd0fb002c192bb4b0c973ddfb8b02bcb1..a361f617911e9f22c11d9f98dc86584c63b8eb73 100644 (file)
@@ -277,9 +277,21 @@ dllmap_start (gpointer user_data,
                for (i = 0; attribute_names [i]; ++i) {
                        if (strcmp (attribute_names [i], "dll") == 0)
                                info->dll = g_strdup (attribute_values [i]);
-                       else if (strcmp (attribute_names [i], "target") == 0)
-                               info->target = g_strdup (attribute_values [i]);
-                       else if (strcmp (attribute_names [i], "os") == 0 && !arch_matches (CONFIG_OS, attribute_values [i]))
+                       else if (strcmp (attribute_names [i], "target") == 0){
+                               char *p = strstr (attribute_values [i], "$mono_libdir");
+                               if (p != NULL){
+                                       const char *libdir = mono_assembly_getrootdir ();
+                                       int libdir_len = strlen (libdir);
+                                       char *result;
+                                       
+                                       result = g_malloc (libdir_len-strlen("$mono_libdir")+strlen(attribute_values[i])+1);
+                                       strncpy (result, attribute_names[i], p-attribute_values[i]);
+                                       strcat (result, libdir);
+                                       strcat (result, p+strlen("$mono_libdir"));
+                                       info->target = result;
+                               } else 
+                                       info->target = g_strdup (attribute_values [i]);
+                       } else if (strcmp (attribute_names [i], "os") == 0 && !arch_matches (CONFIG_OS, attribute_values [i]))
                                info->ignore = TRUE;
                        else if (strcmp (attribute_names [i], "cpu") == 0 && !arch_matches (CONFIG_CPU, attribute_values [i]))
                                info->ignore = TRUE;
@@ -375,7 +387,6 @@ aot_cache_start (gpointer user_data,
        for (i = 0; attribute_names [i]; ++i) {
                if (!strcmp (attribute_names [i], "app")) {
                        config->apps = g_slist_prepend (config->apps, g_strdup (attribute_values [i]));
-                       return;
                }
        }
 
@@ -391,6 +402,8 @@ aot_cache_start (gpointer user_data,
                                config->assemblies = g_slist_prepend (config->assemblies, g_strdup (part));
                        }
                        g_strfreev (parts);
+               } else if (!strcmp (attribute_names [i], "options")) {
+                       config->aot_options = g_strdup (attribute_values [i]);
                }
        }
 }
@@ -550,7 +563,6 @@ mono_config_for_assembly (MonoImage *assembly)
        int got_it = 0, i;
        char *aname, *cfg, *cfg_name;
        const char *bundled_config;
-       const char *home;
        
        state.assembly = assembly;
 
@@ -566,14 +578,13 @@ mono_config_for_assembly (MonoImage *assembly)
 
        cfg_name = g_strdup_printf ("%s.config", mono_image_get_name (assembly));
 
-       home = g_get_home_dir ();
-
        for (i = 0; (aname = get_assembly_filename (assembly, i)) != NULL; ++i) {
                cfg = g_build_filename (mono_get_config_dir (), "mono", "assemblies", aname, cfg_name, NULL);
                got_it += mono_config_parse_file_with_context (&state, cfg);
                g_free (cfg);
 
 #ifdef TARGET_WIN32
+               const char *home = g_get_home_dir ();
                cfg = g_build_filename (home, ".mono", "assemblies", aname, cfg_name, NULL);
                got_it += mono_config_parse_file_with_context (&state, cfg);
                g_free (cfg);