From 01a966eec38532b2d165e31419aca4ff0e0a4304 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?utf8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Tue, 4 May 2010 13:29:02 +0400 Subject: [PATCH] tools: fix gst-run wrapper to work on Windows Fixes #617625 --- tools/gst-run.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tools/gst-run.c b/tools/gst-run.c index ac6e64a..ea6103c 100644 --- a/tools/gst-run.c +++ b/tools/gst-run.c @@ -129,13 +129,21 @@ unmangle_libtool (gchar ** dir, gchar ** base) if (!*base) return; - /* we assume libtool when base starts with lt- and dir ends with .libs */ + /* We assume libtool when base starts with "lt-" and dir ends with ".libs". + * On Windows libtool doesn't seem to be adding "lt-" prefix. */ +#ifndef G_OS_WIN32 if (!g_str_has_prefix (*base, "lt-")) return; +#endif + if (!g_str_has_suffix (*dir, ".libs")) return; +#ifndef G_OS_WIN32 new_base = g_strdup (&((*base)[3])); +#else + new_base = g_strdup (*base); +#endif new_dir = g_path_get_dirname (*dir); g_free (*base); g_free (*dir); @@ -163,6 +171,23 @@ get_dir_of_binary (const gchar * binary) * specified which caused get_basename to return "." */ full = g_build_filename (dir, base, NULL); +#ifdef G_OS_WIN32 + + /* g_build_filename() should be using the last path separator used in the + * input according to the docs, but doesn't actually do that, so we have + * to fix up the result. */ + { + gchar *tmp; + + for (tmp = (gchar *) binary + strlen (binary) - 1; tmp >= binary; tmp--) { + if (*tmp == '/' || *tmp == '\\') { + full[strlen (dir)] = *tmp; + break; + } + } + } +#endif + if (strcmp (full, binary) != 0) { if (strcmp (dir, ".") != 0) { g_warning ("This should not happen, g_path_get_dirname () has changed."); @@ -320,6 +345,13 @@ main (int argc, char **argv) /* unmangle libtool if necessary */ unmangle_libtool (&dir, &base); +#ifdef G_OS_WIN32 + /* remove .exe suffix, otherwise we'll be looking for gst-blah.exe-*.* */ + if (strlen (base) > 4 && g_str_has_suffix (base, ".exe")) { + base[strlen (base) - 4] = '\0'; + } +#endif + /* get all candidate binaries */ candidates = get_candidates (dir, base); g_free (dir); -- 2.7.4