Commit 9e3fe3d3 authored by dmaclach@chromium.org's avatar dmaclach@chromium.org

Fix up PathProvider on the Mac for FILE_MODULE.

PathProvider on the Mac always returned the FILE_EXE for FILE_MODULE,
which isn't necessarily correct.

BUG=NONE
TEST=BUILD


Review URL: http://codereview.chromium.org/7019041

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86631 0039d316-1c4b-4281-b951-d872f2087c98
parent dbbab208
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/base_paths_mac.h"
#include <dlfcn.h>
#import <Foundation/Foundation.h>
#include <mach-o/dyld.h>
......@@ -37,6 +38,19 @@ bool GetNSExecutablePath(FilePath* path) {
return true;
}
// Returns true if the module for |address| is found. |path| will contain
// the path to the module. Note that |path| may not be absolute.
bool GetModulePathForAddress(FilePath* path,
const void* address) WARN_UNUSED_RESULT;
bool GetModulePathForAddress(FilePath* path, const void* address) {
Dl_info info;
if (dladdr(address, &info) == 0)
return false;
*path = FilePath(info.dli_fname);
return true;
}
} // namespace
namespace base {
......@@ -44,9 +58,10 @@ namespace base {
bool PathProviderMac(int key, FilePath* result) {
switch (key) {
case base::FILE_EXE:
case base::FILE_MODULE: {
return GetNSExecutablePath(result);
}
case base::FILE_MODULE:
return GetModulePathForAddress(result,
reinterpret_cast<const void*>(&base::PathProviderMac));
case base::DIR_CACHE:
return base::mac::GetUserDirectory(NSCachesDirectory, result);
case base::DIR_APP_DATA:
......
......@@ -484,7 +484,7 @@
'conditions': [
['OS=="mac"', {
'copies': [{
'destination': '<(PRODUCT_DIR)/<(mac_product_name).app/Contents/Versions/<(version_full)/<(mac_product_name) Helper.app/Contents/MacOS/',
'destination': '<(PRODUCT_DIR)/<(mac_product_name).app/Contents/Versions/<(version_full)/<(mac_product_name) Framework.framework/Libraries/',
'files': ['<(PRODUCT_DIR)/osmesa.so'],
}],
}],
......
......@@ -31,6 +31,10 @@ bool InitializeGLBindings(GLImplementation implementation) {
return false;
}
// osmesa.so is located in:
// Contents/Versions/<vers>/Chromium Framework.framework/Libraries
module_path = module_path.DirName().Append("Libraries");
// When using OSMesa, just use OSMesaGetProcAddress to find entry points.
base::NativeLibrary library = base::LoadNativeLibrary(
module_path.Append("osmesa.so"), NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment