2004-05-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Wed, 12 May 2004 01:58:21 +0000 (01:58 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Wed, 12 May 2004 01:58:21 +0000 (01:58 -0000)
* metadata/Makefile.am: link to ../os/libmonoos.la on windows.

* metadata/assembly.c:
-If MONO_DEBUG, warn about non-existing directories in
MONO_PATH.
-Added mono_assembly_getrootdir() that replaces MONO_ASSEMBLIES
compile time variable.
-Removed init_default_path and call mono_set_rootdir from
libmonoos.a instead (windows only).

* metadata/assembly.h: declare mono_assembly_getrootdir().

* metadata/domain.c:
* metadata/icall.c: use mono_assembly_getrootdir() instead of
MONO_ASSEMBLIES.

* metadata/loader.c: s/getenv/g_getenv/
* os/win32/util.c: the path from GetModuleFileName is UTF-16.

svn path=/trunk/mono/; revision=27134

mono/metadata/ChangeLog
mono/metadata/Makefile.am
mono/metadata/assembly.c
mono/metadata/assembly.h
mono/metadata/domain.c
mono/metadata/icall.c
mono/metadata/loader.c
mono/os/win32/util.c

index 58c99bcdd34e4950f4edc046b8215c630b3f88fb..6daa0179abf309e1cc8ebbd1fa534d417a8acba1 100644 (file)
@@ -1,3 +1,22 @@
+2004-05-12  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * Makefile.am: link to ../os/libmonoos.la on windows.
+
+       * assembly.c:
+               -If MONO_DEBUG, warn about non-existing directories in
+               MONO_PATH.
+               -Added mono_assembly_getrootdir() that replaces MONO_ASSEMBLIES
+               compile time variable.
+               -Removed init_default_path and call mono_set_rootdir from
+               libmonoos.a instead (windows only).
+
+       * assembly.h: declare mono_assembly_getrootdir().
+
+       * domain.c:
+       * icall.c: use mono_assembly_getrootdir() instead of MONO_ASSEMBLIES.
+
+       * loader.c: s/getenv/g_getenv/
+
 2004-05-11  Zoltan Varga  <vargaz@freemail.hu>
 
        * marshal.{h,c}: Add support for UnmanagedType.AsAny.
 
        * metadata.h: Add new marshalling conversions.
 
-       * metadata.h metadata.c (mono_metadata_signature_dup): New helper function.
+       * metadata.h metadata.c (mono_metadata_signature_dup): New helper
+       function.
 
        * reflection.c (mono_reflection_get_type): Lookup the type in all
        modules of a multi-module assembly. Fixes #58291.
 
 2004-05-11  Lluis Sanchez Gual  <lluis@ximian.com>
 
-       * threads.c: Before aborting a background, set the StopRequested state (this
-       avoids throwing the Abort exception).
-       In mono_thread_manage, don't continue with the shutdown until all aborted
-       threads have actually stopped.
+       * threads.c: Before aborting a background, set the StopRequested
+       state.  This avoids throwing the Abort exception.
+       In mono_thread_manage, don't continue with the shutdown until all
+       aborted threads have actually stopped.
 
 2004-05-10  Jackson Harper  <jackson@ximian.com>
 
index dc1d73b8c9a8de2df00cef12fda8eebf42d5c0bb..f9ffe46e1ee33c8017f8590a59fc6ffd93aa787b 100644 (file)
@@ -31,6 +31,10 @@ else
 bundle_srcs =
 endif
 
+if PLATFORM_WIN32
+libmonoruntime_la_LIBADD = ../os/libmonoos.la
+endif
+
 libmonoruntime_la_SOURCES = \
        reflection.c    \
        object.c        \
index 5b00fc531498f0e75886abd76b0ac05107f1c0c9..5a997c9c22b9c13da065efbd6a990b5ea0020b7d 100644 (file)
@@ -28,6 +28,9 @@
 #include <mono/utils/mono-uri.h>
 #include <mono/metadata/mono-config.h>
 #include <mono/utils/mono-digest.h>
+#ifdef PLATFORM_WIN32
+#include <mono/os/util.h>
+#endif
 
 /* the default search path is just MONO_ASSEMBLIES */
 static const char*
@@ -52,22 +55,6 @@ static GHashTable *assemblies_loading;
 
 static gboolean allow_user_gac = FALSE;
 
-#ifdef PLATFORM_WIN32
-
-static void
-init_default_path (void)
-{
-       int i;
-
-       default_path [0] = g_strdup (MONO_ASSEMBLIES);
-       for (i = strlen (MONO_ASSEMBLIES) - 1; i >= 0; i--) {
-               if (default_path [0][i] == '/')
-                       ((char*) default_path [0])[i] = '\\';
-       }
-}
-#endif
-
-
 static gchar*
 encode_public_tok (const guchar *token, gint32 len)
 {
@@ -92,10 +79,20 @@ check_env (void) {
        path = getenv ("MONO_PATH");
        if (!path)
                return;
+
        splitted = g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 1000);
        if (assemblies_path)
                g_strfreev (assemblies_path);
        assemblies_path = splitted;
+       if (g_getenv ("MONO_DEBUG") == NULL)
+               return;
+
+       while (*splitted) {
+               if (**splitted && !g_file_test (*splitted, G_FILE_TEST_IS_DIR))
+                       g_warning ("'%s' in MONO_PATH doesn't exist or has wrong permissions.", *splitted);
+
+               splitted++;
+       }
 }
 
 static gboolean
@@ -199,6 +196,12 @@ mono_assembly_setrootdir (const char *root_dir)
        default_path [0] = g_strdup (root_dir);
 }
 
+G_CONST_RETURN gchar *
+mono_assembly_getrootdir (void)
+{
+       return default_path [0];
+}
+
 /**
  * mono_assemblies_init:
  *
@@ -208,7 +211,7 @@ void
 mono_assemblies_init (void)
 {
 #ifdef PLATFORM_WIN32
-       init_default_path ();
+       mono_set_rootdir ();
 #endif
 
        check_env ();
@@ -783,7 +786,7 @@ mono_assembly_load_with_partial_name (const char *name, MonoImageOpenStatus *sta
 
        fullname = g_strdup_printf ("%s.dll", name);
 
-       gacpath = g_build_path (G_DIR_SEPARATOR_S, MONO_ASSEMBLIES, "mono", "gac", name, NULL);
+       gacpath = g_build_path (G_DIR_SEPARATOR_S, mono_assembly_getrootdir (), "mono", "gac", name, NULL);
        res = probe_for_partial_name (gacpath, fullname, status);
        g_free (gacpath);
 
@@ -829,7 +832,7 @@ mono_assembly_load_from_gac (MonoAssemblyName *aname,  gchar *filename, MonoImag
                        aname->culture == NULL ? "" : aname->culture,
                        aname->public_tok_value);
        
-       fullpath = g_build_path (G_DIR_SEPARATOR_S, MONO_ASSEMBLIES, "mono", "gac",
+       fullpath = g_build_path (G_DIR_SEPARATOR_S, mono_assembly_getrootdir (), "mono", "gac",
                        name, version, filename, NULL);
        result = mono_assembly_open (fullpath, status);
 
index ecda932f805be248a6df28af8067c86b04105e2e..b4aad28684ddb2b73d27cfb4a2512b48d4258579 100644 (file)
@@ -12,7 +12,8 @@ MonoAssembly* mono_assembly_load       (MonoAssemblyName *aname,
                                                const char       *basedir, 
                                        MonoImageOpenStatus *status);
 MonoAssembly* mono_assembly_load_from  (MonoImage *image, const char *fname,
-                                                                               MonoImageOpenStatus *status);
+                                       MonoImageOpenStatus *status);
+
 MonoAssembly* mono_assembly_load_with_partial_name (const char *name, MonoImageOpenStatus *status);
 
 MonoAssembly* mono_assembly_loaded     (MonoAssemblyName *aname);
@@ -20,6 +21,7 @@ void          mono_assembly_load_references (MonoImage *image, MonoImageOpenStat
 MonoImage*    mono_assembly_load_module (MonoAssembly *assembly, guint32 idx);
 void          mono_assembly_close      (MonoAssembly *assembly);
 void          mono_assembly_setrootdir (const char *root_dir);
+G_CONST_RETURN gchar *mono_assembly_getrootdir (void);
 void         mono_assembly_foreach    (GFunc func, gpointer user_data);
 void          mono_assembly_set_main   (MonoAssembly *assembly);
 MonoAssembly *mono_assembly_get_main   (void);
index f561cf44691b1a97ae2441f88df6a123d0e3bacc..8eea630cf79897635adf5c2fb3c3cb730b1ac018 100644 (file)
@@ -265,13 +265,16 @@ mono_init (const char *filename)
                switch (status){
                case MONO_IMAGE_ERROR_ERRNO:
                        g_print ("The assembly mscorlib.dll was not found or could not be loaded.\n");
-                       g_print ("It should have been installed in the `%s' directory.\n", MONO_ASSEMBLIES);
+                       g_print ("It should have been installed in the `%s' directory.\n",
+                                mono_assembly_getrootdir ());
                        break;
                case MONO_IMAGE_IMAGE_INVALID:
-                       g_print ("The file %s/mscorlib.dll is an invalid CIL image\n", MONO_ASSEMBLIES);
+                       g_print ("The file %s/mscorlib.dll is an invalid CIL image\n",
+                                mono_assembly_getrootdir ());
                        break;
                case MONO_IMAGE_MISSING_ASSEMBLYREF:
-                       g_print ("Minning assembly reference in %s/mscorlib.dll\n", MONO_ASSEMBLIES);
+                       g_print ("Missing assembly reference in %s/mscorlib.dll\n",
+                                mono_assembly_getrootdir ());
                        break;
                case MONO_IMAGE_OK:
                        /* to suppress compiler warning */
index 059a128e860b57bee1bc11ac9cbdf3c37b69a0e3..8bd9c0fb19d985af1109267c7570ae7107a742ab 100644 (file)
@@ -4351,7 +4351,7 @@ ves_icall_System_Environment_Exit (int result)
 static MonoString*
 ves_icall_System_Environment_GetGacPath (void)
 {
-       return mono_string_new (mono_domain_get (), MONO_ASSEMBLIES);
+       return mono_string_new (mono_domain_get (), mono_assembly_getrootdir ());
 }
 
 static MonoString*
index 8bd1ff2c24caf8a47837619f74435b23036dc378..af41ebe55a68da2f538ac49fc5b6c1259a9e03c7 100644 (file)
@@ -636,7 +636,7 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
        }
 
        if (!gmodule) {
-               if (getenv ("MONO_DEBUG")) {
+               if (g_getenv ("MONO_DEBUG")) {
                        gchar *error = g_strdup (g_module_error ());
                        g_message ("Error loading '%s': %s\n", orig_scope, error);
                        g_free (error);
index 7de046690be6a3db119f59694f7196f8f76bc674..98b982bb0c8ec7ea339081f858e38cff05c23f61 100644 (file)
@@ -38,10 +38,12 @@ DWORD ceGetModuleFileNameA(HMODULE hModule, char* lpFilename, DWORD nSize)
 void
 mono_set_rootdir (void)
 {
-       char moddir[MAXPATHLEN], *bindir, *installdir, *root;
+       gunichar2 moddir [MAXPATHLEN];
+       gchar *bindir, *installdir, *root, *utf8name;
 
        GetModuleFileName (NULL, moddir, sizeof(moddir));
-       bindir = g_path_get_dirname (moddir);
+       utf8name = g_utf16_to_utf8 (moddir, -1, NULL, NULL, NULL);
+       bindir = g_path_get_dirname (utf8name);
        installdir = g_path_get_dirname (bindir);
        root = g_build_path (G_DIR_SEPARATOR_S, installdir, "lib", NULL);
 
@@ -49,6 +51,7 @@ mono_set_rootdir (void)
        g_free (root);
        g_free (installdir);
        g_free (bindir);
+       g_free (utf8name);
 }