Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (101709 => 101710)
--- trunk/Source/_javascript_Core/ChangeLog 2011-12-01 22:25:47 UTC (rev 101709)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-12-01 22:31:26 UTC (rev 101710)
@@ -1,3 +1,18 @@
+2011-12-01 Martin Robinson <[email protected]>
+
+ [GTK] Add a helper function to find the current executable's path
+ https://bugs.webkit.org/show_bug.cgi?id=73473
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Add a WTF helper which gets the binary path. This is currently only used
+ in WebKit2.
+
+ * GNUmakefile.list.am: Add the new file to the source list.
+ * wtf/gobject/GlibUtilities.cpp: Added.
+ (getCurrentExecutablePath):
+ * wtf/gobject/GlibUtilities.h: Added.
+
2011-12-01 Sheriff Bot <[email protected]>
Unreviewed, rolling out r101691.
Modified: trunk/Source/_javascript_Core/GNUmakefile.list.am (101709 => 101710)
--- trunk/Source/_javascript_Core/GNUmakefile.list.am 2011-12-01 22:25:47 UTC (rev 101709)
+++ trunk/Source/_javascript_Core/GNUmakefile.list.am 2011-12-01 22:31:26 UTC (rev 101710)
@@ -564,6 +564,8 @@
Source/_javascript_Core/wtf/gobject/GRefPtr.cpp \
Source/_javascript_Core/wtf/gobject/GRefPtr.h \
Source/_javascript_Core/wtf/gobject/GTypedefs.h \
+ Source/_javascript_Core/wtf/gobject/GlibUtilities.cpp \
+ Source/_javascript_Core/wtf/gobject/GlibUtilities.h \
Source/_javascript_Core/wtf/gtk/MainThreadGtk.cpp \
Source/_javascript_Core/wtf/HashCountedSet.h \
Source/_javascript_Core/wtf/HashFunctions.h \
Added: trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.cpp (0 => 101710)
--- trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.cpp (rev 0)
+++ trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.cpp 2011-12-01 22:31:26 UTC (rev 101710)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Igalia, S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "GlibUtilities.h"
+
+#include <limits.h>
+#include <unistd.h>
+
+#if OS(LINUX)
+CString getCurrentExecutablePath()
+{
+ static char readLinkBuffer[PATH_MAX];
+ ssize_t result = readlink("/proc/self/exe", readLinkBuffer, PATH_MAX);
+ if (result == -1)
+ return CString();
+ return CString(readLinkBuffer, result);
+}
+#elif OS(UNIX)
+CString getCurrentExecutablePath()
+{
+ static char readLinkBuffer[PATH_MAX];
+ ssize_t result = readlink("/proc/curproc/file", readLinkBuffer, PATH_MAX);
+ if (result == -1)
+ return CString();
+ return CString(readLinkBuffer, result);
+}
+#endif
Property changes on: trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.cpp
___________________________________________________________________
Added: svn:eol-style
Added: trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.h (0 => 101710)
--- trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.h (rev 0)
+++ trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.h 2011-12-01 22:31:26 UTC (rev 101710)
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010 Igalia, S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GlibUtilities_h
+#define GlibUtilities_h
+
+#include "CString.h"
+
+CString getCurrentExecutablePath();
+
+#endif
Property changes on: trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.h
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (101709 => 101710)
--- trunk/Source/WebCore/ChangeLog 2011-12-01 22:25:47 UTC (rev 101709)
+++ trunk/Source/WebCore/ChangeLog 2011-12-01 22:31:26 UTC (rev 101710)
@@ -1,3 +1,16 @@
+2011-12-01 Martin Robinson <[email protected]>
+
+ [GTK] Add a helper function to find the current executable's path
+ https://bugs.webkit.org/show_bug.cgi?id=73473
+
+ Reviewed by Gustavo Noronha Silva.
+
+ No new tests. This should not change behavior.
+
+ * platform/gtk/FileSystemGtk.cpp:
+ (WebCore::applicationDirectoryPath): Now use the new WTF function to get the
+ current executable's path.
+
2011-12-01 Andreas Kling <[email protected]>
StyledElement: Clean up inline style accessors.
Modified: trunk/Source/WebCore/platform/gtk/FileSystemGtk.cpp (101709 => 101710)
--- trunk/Source/WebCore/platform/gtk/FileSystemGtk.cpp 2011-12-01 22:25:47 UTC (rev 101709)
+++ trunk/Source/WebCore/platform/gtk/FileSystemGtk.cpp 2011-12-01 22:31:26 UTC (rev 101710)
@@ -29,6 +29,7 @@
#include <gio/gio.h>
#include <glib.h>
#include <glib/gstdio.h>
+#include <wtf/gobject/GlibUtilities.h>
#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/CString.h>
@@ -176,15 +177,10 @@
CString applicationDirectoryPath()
{
-#if OS(LINUX)
- // Handle the /proc filesystem case.
- char pathFromProc[PATH_MAX] = {0};
- if (readlink("/proc/self/exe", pathFromProc, sizeof(pathFromProc) - 1) == -1)
- return CString();
+ CString path = getCurrentExecutablePath();
+ if (!path.isNull())
+ return path;
- GOwnPtr<char> dirname(g_path_get_dirname(pathFromProc));
- return dirname.get();
-#elif OS(UNIX)
// If the above fails, check the PATH env variable.
GOwnPtr<char> currentExePath(g_find_program_in_path(g_get_prgname()));
if (!currentExePath.get())
@@ -192,9 +188,6 @@
GOwnPtr<char> dirname(g_path_get_dirname(currentExePath.get()));
return dirname.get();
-#else
- return CString();
-#endif
}
uint64_t getVolumeFreeSizeForPath(const char* path)
Modified: trunk/Source/WebKit2/ChangeLog (101709 => 101710)
--- trunk/Source/WebKit2/ChangeLog 2011-12-01 22:25:47 UTC (rev 101709)
+++ trunk/Source/WebKit2/ChangeLog 2011-12-01 22:31:26 UTC (rev 101710)
@@ -1,3 +1,19 @@
+2011-12-01 Martin Robinson <[email protected]>
+
+ [GTK] Add a helper function to find the current executable's path
+ https://bugs.webkit.org/show_bug.cgi?id=73473
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Do a series of tests when looking for processes. First search the directory
+ specified by the environment variable, then the directory of the binary and
+ then the LIBEXECDIR.
+
+ * UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp:
+ (WebKit::findWebKitProcess): Added.
+ (WebKit::ProcessLauncher::launchProcess): Call the new helper to get the
+ binary location.
+
2011-12-01 Viatcheslav Ostapenko <[email protected]>
[Qt] [WK2] QQuickWebView covers QML elements that should be rendered on top.
Modified: trunk/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp (101709 => 101710)
--- trunk/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp 2011-12-01 22:25:47 UTC (rev 101709)
+++ trunk/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp 2011-12-01 22:31:26 UTC (rev 101710)
@@ -38,6 +38,7 @@
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GlibUtilities.h>
#ifdef SOCK_SEQPACKET
#define SOCKET_TYPE SOCK_SEQPACKET
@@ -71,6 +72,34 @@
close(GPOINTER_TO_INT(userData));
}
+static CString findWebKitProcess(const char* processName)
+{
+ const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
+ if (execDirectory) {
+ String processPath = pathByAppendingComponent(filenameToString(execDirectory), processName);
+ if (fileExists(processPath))
+ return fileSystemRepresentation(processPath);
+ }
+
+ static bool gotExecutablePath = false;
+ static String executablePath;
+ if (!gotExecutablePath) {
+ gotExecutablePath = true;
+
+ CString executableFile = getCurrentExecutablePath();
+ if (!executableFile.isNull())
+ executablePath = directoryName(filenameToString(executableFile.data()));
+ }
+
+ if (!executablePath.isNull()) {
+ String processPath = pathByAppendingComponent(executablePath, processName);
+ if (fileExists(processPath))
+ return fileSystemRepresentation(processPath);
+ }
+
+ return fileSystemRepresentation(pathByAppendingComponent(filenameToString(LIBEXECDIR), processName));
+}
+
void ProcessLauncher::launchProcess()
{
GPid pid = 0;
@@ -82,12 +111,10 @@
return;
}
- const gchar* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
- GOwnPtr<gchar> binaryPath(g_build_filename(execDirectory ? execDirectory : LIBEXECDIR,
- m_launchOptions.processType == ProcessLauncher::WebProcess ? gWebKitWebProcessName : gWebKitPluginProcessName, NULL));
+ CString binaryPath = findWebKitProcess(m_launchOptions.processType == ProcessLauncher::WebProcess ? gWebKitWebProcessName : gWebKitPluginProcessName);
GOwnPtr<gchar> socket(g_strdup_printf("%d", sockets[0]));
char* argv[3];
- argv[0] = binaryPath.get();
+ argv[0] = const_cast<char*>(binaryPath.data());
argv[1] = socket.get();
argv[2] = 0;
Modified: trunk/Tools/ChangeLog (101709 => 101710)
--- trunk/Tools/ChangeLog 2011-12-01 22:25:47 UTC (rev 101709)
+++ trunk/Tools/ChangeLog 2011-12-01 22:31:26 UTC (rev 101710)
@@ -1,3 +1,18 @@
+2011-12-01 Martin Robinson <[email protected]>
+
+ [GTK] Add a helper function to find the current executable's path
+ https://bugs.webkit.org/show_bug.cgi?id=73473
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Update MiniBrowser to not pass the binary directory as an environment variable.
+ This means that you can move the binaries around without it breaking.
+
+ * MiniBrowser/gtk/main.c:
+ (main): No longer set the environment variable.
+ * WebKitTestRunner/GNUmakefile.am: No longer add the directory path define.
+ * WebKitTestRunner/gtk/main.cpp: Ditto.
+
2011-12-01 Gustavo Noronha Silva <[email protected]>
[GTK] Add freetype to our jhbuild setup
Modified: trunk/Tools/MiniBrowser/gtk/main.c (101709 => 101710)
--- trunk/Tools/MiniBrowser/gtk/main.c 2011-12-01 22:25:47 UTC (rev 101709)
+++ trunk/Tools/MiniBrowser/gtk/main.c 2011-12-01 22:31:26 UTC (rev 101710)
@@ -76,9 +76,6 @@
}
g_option_context_free (context);
- // Prefer the not installed web and plugin processes.
- g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE);
-
if (uriArguments) {
int i;
Modified: trunk/Tools/WebKitTestRunner/GNUmakefile.am (101709 => 101710)
--- trunk/Tools/WebKitTestRunner/GNUmakefile.am 2011-12-01 22:25:47 UTC (rev 101709)
+++ trunk/Tools/WebKitTestRunner/GNUmakefile.am 2011-12-01 22:31:26 UTC (rev 101710)
@@ -33,7 +33,6 @@
-I$(srcdir)/Tools/WebKitTestRunner \
-I$(srcdir)/Source/WebCore/platform/gtk \
-I$(top_builddir)/DerivedSources/WebKit2/include \
- -DWEBKIT_EXEC_PATH=\"${shell pwd}/$(top_builddir)/Programs/\" \
$(global_cppflags) \
$(_javascript_core_cppflags) \
$(GLOBALDEPS_CFLAGS) \
Modified: trunk/Tools/WebKitTestRunner/gtk/main.cpp (101709 => 101710)
--- trunk/Tools/WebKitTestRunner/gtk/main.cpp 2011-12-01 22:25:47 UTC (rev 101709)
+++ trunk/Tools/WebKitTestRunner/gtk/main.cpp 2011-12-01 22:31:26 UTC (rev 101710)
@@ -32,7 +32,6 @@
{
gtk_init(&argc, &argv);
// Prefer the not installed web and plugin processes.
- g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE);
WTR::TestController controller(argc, const_cast<const char**>(argv));
return 0;
}