From b1f0605dde2d4e3f004690c550c606ff36353af9 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 19 Mar 2015 02:04:56 -0400 Subject: [PATCH] [runtime] Add a new mono-config-dirs.c file which is the only one depending on the MONO_CFG_DIR etc. defines defined in metadata/Makefile.am. --- mono/metadata/Makefile.am | 7 +++--- mono/metadata/assembly.c | 16 ++++++------ mono/metadata/mono-config-dirs.c | 42 ++++++++++++++++++++++++++++++++ mono/metadata/mono-config-dirs.h | 16 ++++++++++++ mono/metadata/profiler.c | 6 ++--- msvc/libmonoruntime.vcxproj | 4 ++- 6 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 mono/metadata/mono-config-dirs.c create mode 100644 mono/metadata/mono-config-dirs.h diff --git a/mono/metadata/Makefile.am b/mono/metadata/Makefile.am index 03143e62c235..4c2aa23a3814 100644 --- a/mono/metadata/Makefile.am +++ b/mono/metadata/Makefile.am @@ -71,13 +71,10 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/mono $(LIBGC_CPPFLAGS) $(GLIB_CFLA # # Make sure any prefix changes are updated in the binaries too. # -# assembly.c uses MONO_ASSEMBLIES -# mono-config.c uses MONO_CFG_DIR -# # This won't result in many more false positives than AC_DEFINEing them # in configure.ac. # -assembly.lo mono-config.lo: Makefile +mono-config-dirs.lo: Makefile CLEANFILES = mono-bundle.stamp @@ -143,6 +140,8 @@ common_sources = \ mono-basic-block.c \ mono-basic-block.h \ mono-config.c \ + mono-config-dirs.h \ + mono-config-dirs.c \ mono-cq.c \ mono-cq.h \ mono-debug.h \ diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index 6be8db5154f0..a82195d0e171 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -562,14 +563,10 @@ mono_assembly_getrootdir (void) void mono_set_dirs (const char *assembly_dir, const char *config_dir) { -#if defined (MONO_ASSEMBLIES) if (assembly_dir == NULL) - assembly_dir = MONO_ASSEMBLIES; -#endif -#if defined (MONO_CFG_DIR) + assembly_dir = mono_config_get_assemblies_dir (); if (config_dir == NULL) - config_dir = MONO_CFG_DIR; -#endif + config_dir = mono_config_get_cfg_dir (); mono_assembly_setrootdir (assembly_dir); mono_set_config_dir (config_dir); } @@ -601,7 +598,7 @@ compute_base (char *path) static void fallback (void) { - mono_set_dirs (MONO_ASSEMBLIES, MONO_CFG_DIR); + mono_set_dirs (mono_config_get_assemblies_dir (), mono_config_get_cfg_dir ()); } static G_GNUC_UNUSED void @@ -610,11 +607,14 @@ set_dirs (char *exe) char *base; char *config, *lib, *mono; struct stat buf; + const char *bindir; /* * Only /usr prefix is treated specially */ - if (strncmp (exe, MONO_BINDIR, strlen (MONO_BINDIR)) == 0 || (base = compute_base (exe)) == NULL){ + bindir = mono_config_get_bin_dir (); + g_assert (bindir); + if (strncmp (exe, bindir, strlen (bindir)) == 0 || (base = compute_base (exe)) == NULL){ fallback (); return; } diff --git a/mono/metadata/mono-config-dirs.c b/mono/metadata/mono-config-dirs.c new file mode 100644 index 000000000000..01e2773a9b81 --- /dev/null +++ b/mono/metadata/mono-config-dirs.c @@ -0,0 +1,42 @@ +/* + * mono-config-dirs.c: + * + * Copyright 2015 Xamarin Inc (http://www.xamarin.com) + */ + +/* + * This file contains functions to return the values of various directories defined in Makefile.am. + */ + +#include + +const char* +mono_config_get_assemblies_dir (void) +{ +#ifdef MONO_ASSEMBLIES + return MONO_ASSEMBLIES; +#else + return NULL; +#endif +} + +const char* +mono_config_get_cfg_dir (void) +{ +#ifdef MONO_CFG_DIR + return MONO_CFG_DIR; +#else + return NULL; +#endif +} + +const char* +mono_config_get_bin_dir (void) +{ +#ifdef MONO_BINDIR + return MONO_BINDIR; +#else + return NULL; +#endif +} + diff --git a/mono/metadata/mono-config-dirs.h b/mono/metadata/mono-config-dirs.h new file mode 100644 index 000000000000..9488511bde4b --- /dev/null +++ b/mono/metadata/mono-config-dirs.h @@ -0,0 +1,16 @@ +#ifndef __MONO_CONFIG_INTERNAL_H__ +#define __MONO_CONFIG_INTERNAL_H__ + +#include +#include + +const char* +mono_config_get_assemblies_dir (void); + +const char* +mono_config_get_cfg_dir (void); + +const char* +mono_config_get_bin_dir (void); + +#endif diff --git a/mono/metadata/profiler.c b/mono/metadata/profiler.c index f5891ccd38f5..6c99a60b788f 100644 --- a/mono/metadata/profiler.c +++ b/mono/metadata/profiler.c @@ -19,6 +19,7 @@ #include "mono/metadata/class-internals.h" #include "mono/metadata/domain-internals.h" #include "mono/metadata/gc-internal.h" +#include "mono/metadata/mono-config-dirs.h" #include "mono/io-layer/io-layer.h" #include "mono/utils/mono-dl.h" #include @@ -1197,9 +1198,8 @@ mono_profiler_load (const char *desc) } if (!load_embedded_profiler (desc, mname)) { libname = g_strdup_printf ("mono-profiler-%s", mname); -#if defined (MONO_ASSEMBLIES) - res = load_profiler_from_directory (mono_assembly_getrootdir (), libname, desc); -#endif + if (mono_config_get_assemblies_dir ()) + res = load_profiler_from_directory (mono_assembly_getrootdir (), libname, desc); if (!res) res = load_profiler_from_directory (NULL, libname, desc); if (!res) diff --git a/msvc/libmonoruntime.vcxproj b/msvc/libmonoruntime.vcxproj index 0e88ca8394ad..488a1fa1c303 100644 --- a/msvc/libmonoruntime.vcxproj +++ b/msvc/libmonoruntime.vcxproj @@ -1,4 +1,4 @@ - + @@ -69,6 +69,7 @@ + @@ -163,6 +164,7 @@ +