summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/base_paths_mac.mm21
-rw-r--r--chrome/chrome_exe.gypi16
-rw-r--r--chrome/chrome_tests.gypi6
-rw-r--r--ui/gfx/gl/gl_implementation_mac.cc15
-rw-r--r--webkit/tools/test_shell/test_shell.gypi12
5 files changed, 33 insertions, 37 deletions
diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm
index ec1398b..90a274c 100644
--- a/base/base_paths_mac.mm
+++ b/base/base_paths_mac.mm
@@ -1,9 +1,10 @@
-// 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:
diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi
index a11d90b..547d7bd 100644
--- a/chrome/chrome_exe.gypi
+++ b/chrome/chrome_exe.gypi
@@ -474,22 +474,6 @@
}],
],
},
- {
- 'target_name': 'chrome_mesa',
- 'type': 'none',
- 'dependencies': [
- 'chrome',
- '../third_party/mesa/mesa.gyp:osmesa',
- ],
- 'conditions': [
- ['OS=="mac"', {
- 'copies': [{
- 'destination': '<(PRODUCT_DIR)/<(mac_product_name).app/Contents/Versions/<(version_full)/<(mac_product_name) Helper.app/Contents/MacOS/',
- 'files': ['<(PRODUCT_DIR)/osmesa.so'],
- }],
- }],
- ],
- },
],
'conditions': [
['OS=="win"', {
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 40a9fe4..b4e68e4 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -613,9 +613,9 @@
'../third_party/icu/icu.gyp:icuuc',
'../third_party/libxml/libxml.gyp:libxml',
# run time dependencies
- 'chrome_mesa',
'default_plugin/default_plugin.gyp:default_plugin',
'../ppapi/ppapi_internal.gyp:ppapi_tests',
+ '../third_party/mesa/mesa.gyp:osmesa',
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:copy_TestNetscapePlugIn',
],
'include_dirs': [
@@ -2225,7 +2225,7 @@
'../third_party/icu/icu.gyp:icuuc',
'../v8/tools/gyp/v8.gyp:v8',
# Runtime dependencies
- 'chrome_mesa',
+ '../third_party/mesa/mesa.gyp:osmesa',
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:copy_TestNetscapePlugIn',
],
'include_dirs': [
@@ -3359,7 +3359,7 @@
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
# Runtime dependencies
- 'chrome_mesa',
+ '../third_party/mesa/mesa.gyp:osmesa',
],
'include_dirs': [
'..',
diff --git a/ui/gfx/gl/gl_implementation_mac.cc b/ui/gfx/gl/gl_implementation_mac.cc
index a8b3ddd..a9537b89 100644
--- a/ui/gfx/gl/gl_implementation_mac.cc
+++ b/ui/gfx/gl/gl_implementation_mac.cc
@@ -5,6 +5,7 @@
#include "base/base_paths.h"
#include "base/file_path.h"
#include "base/logging.h"
+#include "base/mac/foundation_util.h"
#include "base/native_library.h"
#include "base/path_service.h"
#include "ui/gfx/gl/gl_bindings.h"
@@ -25,17 +26,21 @@ bool InitializeGLBindings(GLImplementation implementation) {
switch (implementation) {
case kGLImplementationOSMesaGL: {
- FilePath module_path;
- if (!PathService::Get(base::DIR_MODULE, &module_path)) {
+ // osmesa.so is located in the build directory. This code path is only
+ // valid in a developer build environment.
+ FilePath exe_path;
+ if (!PathService::Get(base::FILE_EXE, &exe_path)) {
LOG(ERROR) << "PathService::Get failed.";
return false;
}
+ FilePath bundle_path = base::mac::GetAppBundlePath(exe_path);
+ FilePath build_dir_path = bundle_path.DirName();
+ FilePath osmesa_path = build_dir_path.Append("osmesa.so");
// When using OSMesa, just use OSMesaGetProcAddress to find entry points.
- base::NativeLibrary library = base::LoadNativeLibrary(
- module_path.Append("osmesa.so"), NULL);
+ base::NativeLibrary library = base::LoadNativeLibrary(osmesa_path, NULL);
if (!library) {
- VLOG(1) << "osmesa.so not found";
+ LOG(ERROR) << "osmesa.so not found at " << osmesa_path.value();
return false;
}
diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi
index 3ba3abb..4c77a2f 100644
--- a/webkit/tools/test_shell/test_shell.gypi
+++ b/webkit/tools/test_shell/test_shell.gypi
@@ -282,7 +282,8 @@
['OS=="mac"', {
'product_name': 'TestShell',
'dependencies': [
- 'layout_test_helper', 'copy_mesa',
+ 'layout_test_helper',
+ '<(DEPTH)/third_party/mesa/mesa.gyp:osmesa',
],
'variables': {
'repack_path': '../../../tools/data_pack/repack.py',
@@ -749,15 +750,6 @@
],
},
},
- {
- 'target_name': 'copy_mesa',
- 'type': 'none',
- 'dependencies': ['<(DEPTH)/third_party/mesa/mesa.gyp:osmesa'],
- 'copies': [{
- 'destination': '<(PRODUCT_DIR)/TestShell.app/Contents/MacOS/',
- 'files': ['<(PRODUCT_DIR)/osmesa.so'],
- }],
- },
],
}],
],