Merge pull request #1447 from chrisvire/bug-25102
[mono.git] / mono / metadata / mono-config.c
index 5d7d9429b1ddaa16f4a5c96ae3e5206d17e5d0f4..c9e9e030b8c41354b5ddf2af83701ec657a40b3a 100644 (file)
@@ -357,6 +357,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 +415,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 +457,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 */