<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[173020] trunk/Source/JavaScriptCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/173020">173020</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-08-27 15:04:14 -0700 (Wed, 27 Aug 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Win] Build fix after last commit.
Check in new DLLLauncherMain.cpp file.
* JavaScriptCore.vcxproj/jsc/DLLLauncherMain.cpp: Added.
(enableTerminationOnHeapCorruption):
(getStringValue):
(applePathFromRegistry):
(appleApplicationSupportDirectory):
(copyEnvironmentVariable):
(prependPath):
(fatalError):
(directoryExists):
(modifyPath):
(getLastErrorString):
(wWinMain):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorevcxprojjscDLLLauncherMaincpp">trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/jsc/DLLLauncherMain.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (173019 => 173020)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-08-27 21:48:02 UTC (rev 173019)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-08-27 22:04:14 UTC (rev 173020)
</span><span class="lines">@@ -1,5 +1,24 @@
</span><span class="cx"> 2014-08-27 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><ins>+ [Win] Build fix after last commit.
+
+ Check in new DLLLauncherMain.cpp file.
+
+ * JavaScriptCore.vcxproj/jsc/DLLLauncherMain.cpp: Added.
+ (enableTerminationOnHeapCorruption):
+ (getStringValue):
+ (applePathFromRegistry):
+ (appleApplicationSupportDirectory):
+ (copyEnvironmentVariable):
+ (prependPath):
+ (fatalError):
+ (directoryExists):
+ (modifyPath):
+ (getLastErrorString):
+ (wWinMain):
+
+2014-08-27 Brent Fulgham <bfulgham@apple.com>
+
</ins><span class="cx"> [Win] testapi and testRegExp need to find support libraries.
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=136008.
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojjscDLLLauncherMaincpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/jsc/DLLLauncherMain.cpp (0 => 173020)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/jsc/DLLLauncherMain.cpp         (rev 0)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/jsc/DLLLauncherMain.cpp        2014-08-27 22:04:14 UTC (rev 173020)
</span><span class="lines">@@ -0,0 +1,235 @@
</span><ins>+/*
+ * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// This file contains code for a launcher executable for WebKit apps. When compiled into foo.exe, it
+// will set PATH so that Apple Application Support DLLs can be found, then will load foo.dll and
+// call its dllLauncherEntryPoint function, which should be declared like so:
+// extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstCmdLine, int nCmdShow);
+// If USE_CONSOLE_ENTRY_POINT is defined, this function will be called instead:
+// extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(int argc, const char* argv[]);
+
+#include <shlwapi.h>
+#include <string>
+#include <vector>
+#include <windows.h>
+
+using namespace std;
+
+#if defined _M_IX86
+#define PROCESSORARCHITECTURE "x86"
+#elif defined _M_IA64
+#define PROCESSORARCHITECTURE "ia64"
+#elif defined _M_X64
+#define PROCESSORARCHITECTURE "amd64"
+#else
+#define PROCESSORARCHITECTURE "*"
+#endif
+
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='" PROCESSORARCHITECTURE "' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#if defined(_MSC_VER) && (_MSC_VER >= 1600) && !defined(WIN_CAIRO)
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.6195' processorArchitecture='" PROCESSORARCHITECTURE "' publicKeyToken='1fc8b3b9a1e18e3b' language='*'\"")
+#endif
+
+static void enableTerminationOnHeapCorruption()
+{
+ // Enable termination on heap corruption on OSes that support it (Vista and XPSP3).
+ // http://msdn.microsoft.com/en-us/library/aa366705(VS.85).aspx
+
+ HEAP_INFORMATION_CLASS heapEnableTerminationOnCorruption = static_cast<HEAP_INFORMATION_CLASS>(1);
+
+ HMODULE module = ::GetModuleHandleW(L"kernel32.dll");
+ if (!module)
+ return;
+
+ typedef BOOL (WINAPI*HSI)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
+ HSI heapSetInformation = reinterpret_cast<HSI>(::GetProcAddress(module, "HeapSetInformation"));
+ if (!heapSetInformation)
+ return;
+
+ heapSetInformation(0, heapEnableTerminationOnCorruption, 0, 0);
+}
+
+static wstring getStringValue(HKEY key, const wstring& valueName)
+{
+ DWORD type = 0;
+ DWORD bufferSize = 0;
+ if (::RegQueryValueExW(key, valueName.c_str(), 0, &type, 0, &bufferSize) != ERROR_SUCCESS || type != REG_SZ)
+ return wstring();
+
+ vector<wchar_t> buffer(bufferSize / sizeof(wchar_t));
+ if (::RegQueryValueExW(key, valueName.c_str(), 0, &type, reinterpret_cast<LPBYTE>(&buffer[0]), &bufferSize) != ERROR_SUCCESS)
+ return wstring();
+
+ return &buffer[0];
+}
+
+static wstring applePathFromRegistry(const wstring& key, const wstring& value)
+{
+ HKEY applePathKey = 0;
+ if (::RegOpenKeyExW(HKEY_LOCAL_MACHINE, key.c_str(), 0, KEY_READ, &applePathKey) != ERROR_SUCCESS)
+ return wstring();
+ wstring path = getStringValue(applePathKey, value);
+ ::RegCloseKey(applePathKey);
+ return path;
+}
+
+static wstring appleApplicationSupportDirectory()
+{
+ return applePathFromRegistry(L"SOFTWARE\\Apple Inc.\\Apple Application Support", L"InstallDir");
+}
+
+static wstring copyEnvironmentVariable(const wstring& variable)
+{
+ DWORD length = ::GetEnvironmentVariableW(variable.c_str(), 0, 0);
+ if (!length)
+ return wstring();
+ vector<wchar_t> buffer(length);
+ if (!GetEnvironmentVariable(variable.c_str(), &buffer[0], buffer.size()) || !buffer[0])
+ return wstring();
+ return &buffer[0];
+}
+
+static bool prependPath(const wstring& directoryToPrepend)
+{
+ wstring pathVariable = L"PATH";
+ wstring oldPath = copyEnvironmentVariable(pathVariable);
+ wstring newPath = directoryToPrepend + L';' + oldPath;
+ return ::SetEnvironmentVariableW(pathVariable.c_str(), newPath.c_str());
+}
+
+static int fatalError(const wstring& programName, const wstring& message)
+{
+ wstring caption = programName + L" can't open.";
+ ::MessageBoxW(0, message.c_str(), caption.c_str(), MB_ICONERROR);
+ return 1;
+}
+
+static bool directoryExists(const wstring& path)
+{
+ DWORD attrib = ::GetFileAttributes(path.c_str());
+
+ return ((attrib != INVALID_FILE_ATTRIBUTES) && (attrib & FILE_ATTRIBUTE_DIRECTORY));
+}
+
+static bool modifyPath(const wstring& programName)
+{
+#ifdef WIN_CAIRO
+
+#if defined(_M_X64)
+ wstring pathWinCairo = copyEnvironmentVariable(L"WEBKIT_LIBRARIES") + L"\\bin64";
+#else
+ wstring pathWinCairo = copyEnvironmentVariable(L"WEBKIT_LIBRARIES") + L"\\bin32";
+#endif
+ prependPath(pathWinCairo);
+ return true;
+
+#else
+
+ const wstring& pathPrefix = appleApplicationSupportDirectory();
+
+ if (!directoryExists(pathPrefix)) {
+ fatalError(programName, L"Failed to determine path to AAS directory.");
+ return false;
+ }
+
+ if (prependPath(pathPrefix))
+ return true;
+
+ fatalError(programName, L"Failed to modify PATH environment variable.");
+ return false;
+#endif
+}
+
+static wstring getLastErrorString(HRESULT hr)
+{
+ static const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
+ static const size_t bufSize = 4096;
+
+ wchar_t errorMessage[bufSize];
+ DWORD len = ::FormatMessageW(kFlags, 0, hr, 0, errorMessage, bufSize, 0);
+ if (len >= bufSize)
+ len = bufSize - 1;
+
+ errorMessage[len] = 0;
+
+ return errorMessage;
+}
+
+#if USE_CONSOLE_ENTRY_POINT
+int main(int argc, const char* argv[])
+#else
+int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpstrCmdLine, int nCmdShow)
+#endif
+{
+ enableTerminationOnHeapCorruption();
+
+ // Get the path of our executable.
+ wchar_t exePath[MAX_PATH];
+ if (!::GetModuleFileNameW(0, exePath, _countof(exePath)))
+ return fatalError(L"Unknown Program", L"Failed to determine name of executable: " + getLastErrorString(::GetLastError()));
+
+ ::PathRemoveExtensionW(exePath);
+
+ wstring programName = ::PathFindFileNameW(exePath);
+
+ if (!modifyPath(programName))
+ return 1;
+
+ // Load our corresponding DLL.
+ wstring dllName = programName + L".dll";
+ if (!::PathRemoveFileSpecW(exePath))
+ return fatalError(programName, L"::PathRemoveFileSpecW failed: " + getLastErrorString(::GetLastError()));
+ if (!::PathAppendW(exePath, dllName.c_str()))
+ return fatalError(programName, L"::PathAppendW failed: " + getLastErrorString(::GetLastError()));
+ HMODULE module = ::LoadLibraryW(exePath);
+ if (!module)
+ return fatalError(programName, L"::LoadLibraryW failed: \npath=" + wstring(exePath) + L"\n" + getLastErrorString(::GetLastError()));
+
+#if USE_CONSOLE_ENTRY_POINT
+ typedef int (WINAPI*EntryPoint)(int, const char*[]);
+#if defined _M_AMD64 || defined _WIN64
+ const char* entryPointName = "dllLauncherEntryPoint";
+#else
+ const char* entryPointName = "_dllLauncherEntryPoint@8";
+#endif
+#else
+ typedef int (WINAPI*EntryPoint)(HINSTANCE, HINSTANCE, LPWSTR, int);
+#if defined _M_AMD64 || defined _WIN64
+ const char* entryPointName = "dllLauncherEntryPoint";
+#else
+ const char* entryPointName = "_dllLauncherEntryPoint@16";
+#endif
+#endif
+
+ EntryPoint entryPoint = reinterpret_cast<EntryPoint>(::GetProcAddress(module, entryPointName));
+ if (!entryPoint)
+ return fatalError(programName, L"Failed to find dllLauncherEntryPoint function: " + getLastErrorString(::GetLastError()));
+
+#if USE_CONSOLE_ENTRY_POINT
+ return entryPoint(argc, argv);
+#else
+ return entryPoint(hInstance, hPrevInstance, lpstrCmdLine, nCmdShow);
+#endif
+}
</ins></span></pre>
</div>
</div>
</body>
</html>