X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fmono-config.c;h=e73a86b94d28c186bff61876870d5d243bc4a4b2;hb=6b5f6dd0434b66062110cf764688975ecfed646f;hp=5d7d9429b1ddaa16f4a5c96ae3e5206d17e5d0f4;hpb=99b5aad5ee74b270b33e3779cf14cf18d847db50;p=mono.git diff --git a/mono/metadata/mono-config.c b/mono/metadata/mono-config.c index 5d7d9429b1d..e73a86b94d2 100644 --- a/mono/metadata/mono-config.c +++ b/mono/metadata/mono-config.c @@ -277,9 +277,24 @@ 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 *match = strstr (attribute_values [i], "$mono_libdir"); + if (match != NULL) { + /* substitude $mono_libdir */ + const char *libdir = mono_assembly_getrootdir (); + const int libdir_len = strlen (libdir); + const int varname_len = strlen ("$mono_libdir"); + const int pre_len = match - attribute_values [i]; + const int post_len = strlen (match) - varname_len + 3; + + char *result = g_malloc (pre_len + libdir_len + post_len + 1); + g_strlcpy (result, attribute_values [i], pre_len); + strncat (result, libdir, libdir_len); + strncat (result, match + varname_len, post_len); + 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; @@ -357,6 +372,55 @@ legacyUEP_handler = { NULL, /* finish */ }; +static void +aot_cache_start (gpointer user_data, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values) +{ + int i; + MonoAotCacheConfig *config; + + if (strcmp (element_name, "aotcache") != 0) + return; + + config = mono_get_aot_cache_config (); + + /* Per-app configuration */ + 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])); + } + } + + /* Global configuration */ + for (i = 0; attribute_names [i]; ++i) { + if (!strcmp (attribute_names [i], "assemblies")) { + char **parts, **ptr; + char *part; + + parts = g_strsplit (attribute_values [i], " ", -1); + for (ptr = parts; ptr && *ptr; ptr ++) { + part = *ptr; + 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]); + } + } +} + +static const MonoParseHandler +aot_cache_handler = { + "aotcache", + NULL, /* init */ + aot_cache_start, + NULL, /* text */ + NULL, /* end */ + NULL, /* finish */ +}; + static int inited = 0; static void @@ -366,6 +430,7 @@ mono_config_init (void) config_handlers = g_hash_table_new (g_str_hash, g_str_equal); g_hash_table_insert (config_handlers, (gpointer) dllmap_handler.element_name, (gpointer) &dllmap_handler); g_hash_table_insert (config_handlers, (gpointer) legacyUEP_handler.element_name, (gpointer) &legacyUEP_handler); + g_hash_table_insert (config_handlers, (gpointer) aot_cache_handler.element_name, (gpointer) &aot_cache_handler); } void @@ -407,7 +472,6 @@ mono_config_parse_file_with_context (ParseState *state, const char *filename) if (!g_file_get_contents (filename, &text, &len, NULL)) return 0; - offset = 0; if (len > 3 && text [0] == '\xef' && text [1] == (gchar) '\xbb' && text [2] == '\xbf') offset = 3; /* Skip UTF-8 BOM */ @@ -502,7 +566,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; @@ -518,14 +581,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);