diff options
author | LRN <lrn1986@gmail.com> | 2012-05-18 08:40:38 -0700 |
---|---|---|
committer | Dan Nicholson <dbn.lists@gmail.com> | 2012-05-21 21:08:49 -0700 |
commit | 7ac6f32625254a14180677694a0a98d333fc5813 (patch) | |
tree | 82ecf16d51173b58c2944dcfa3efc0e240503595 /main.c | |
parent | b87359cc9b9039b30ab0f76b67fad52980b7913a (diff) |
Don't use deprecated glib function to construct path on win32
g_win32_get_package_installation_subdirectory() has been deprecated
since GLib 2.18 and in recent (2.31) GLib versions disabled entirely by
default. This patch replaces usage of that function by
g_win32_get_package_installation_directory_of_module() and
g_build_filename(). Use the new functions and rework the code a bit so
it leaks less memory.
g_win32_get_package_installation_directory_of_module() is supported
since GLib 2.16. The minimal GLib version is bumped accordingly.
Freedesktop #45742
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 43 |
1 files changed, 42 insertions, 1 deletions
@@ -39,6 +39,7 @@ static int want_debug_spew = 0; static int want_verbose_errors = 0; static int want_stdout_errors = 0; char *pcsysrootdir = NULL; +char *pkg_config_pc_path = NULL; void debug_spew (const char *format, ...) @@ -162,6 +163,34 @@ print_hashtable_key (gpointer key, printf("%s\n", (gchar*)key); } +static void +init_pc_path (void) +{ +#ifdef G_OS_WIN32 + char *instdir, *lpath, *shpath; + + instdir = g_win32_get_package_installation_directory_of_module (NULL); + if (instdir == NULL) + { + /* This only happens when GetModuleFilename() fails. If it does, that + * failure should be investigated and fixed. + */ + debug_spew ("g_win32_get_package_installation_directory_of_module failed\n"); + return; + } + + lpath = g_build_filename (instdir, "lib", "pkgconfig", NULL); + shpath = g_build_filename (instdir, "share", "pkgconfig", NULL); + pkg_config_pc_path = g_strconcat (lpath, G_SEARCHPATH_SEPARATOR_S, shpath, + NULL); + free (instdir); + free (lpath); + free (shpath); +#else + pkg_config_pc_path = PKG_CONFIG_PC_PATH; +#endif +} + int main (int argc, char **argv) { @@ -283,6 +312,18 @@ main (int argc, char **argv) debug_spew ("PKG_CONFIG_DEBUG_SPEW variable enabling debug spew\n"); } + + /* Get the built-in search path */ + init_pc_path (); + if (pkg_config_pc_path == NULL) + { + /* Even when we override the built-in search path, we still use it later + * to add pc_path to the virtual pkg-config package. + */ + verbose_error ("Failed to get default search path\n"); + exit (1); + } + search_path = getenv ("PKG_CONFIG_PATH"); if (search_path) { @@ -294,7 +335,7 @@ main (int argc, char **argv) } else { - add_search_dirs(PKG_CONFIG_PC_PATH, G_SEARCHPATH_SEPARATOR_S); + add_search_dirs(pkg_config_pc_path, G_SEARCHPATH_SEPARATOR_S); } pcsysrootdir = getenv ("PKG_CONFIG_SYSROOT_DIR"); |