From 7f3c21b64ac6cbe414eae22205adaf24dea8a4ec Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 25 Jul 2018 14:58:25 -0400 Subject: [PATCH] macOS: Add angle and swiftshader libraries to the app bundle (issue #2446)" --- BUILD.gn | 50 +++++++++++++++++++ patch/patch.cfg | 5 +- .../{mac_gpu_2398.patch => mac_gpu.patch} | 13 ++++- 3 files changed, 66 insertions(+), 2 deletions(-) rename patch/patches/{mac_gpu_2398.patch => mac_gpu.patch} (58%) diff --git a/BUILD.gn b/BUILD.gn index b244560e1..3dca86526 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -112,6 +112,7 @@ import("//third_party/widevine/cdm/widevine.gni") import("//tools/grit/repack.gni") import("//tools/grit/grit_rule.gni") import("//tools/v8_context_snapshot/v8_context_snapshot.gni") +import("//ui/gl/features.gni") import("//v8/gni/v8.gni") if (is_clang) { import("//build/config/clang/clang.gni") @@ -1387,11 +1388,58 @@ if (is_mac) { ] } + if (use_egl) { + # Add the ANGLE .dylibs in the MODULE_DIR of the Framework app bundle. + bundle_data("cef_framework_angle_binaries") { + sources = [ + "$root_out_dir/egl_intermediates/libEGL.dylib", + "$root_out_dir/egl_intermediates/libGLESv2.dylib", + ] + outputs = [ + "{{bundle_contents_dir}}/Libraries/{{source_file_part}}", + ] + public_deps = [ + "//ui/gl:angle_library_copy", + ] + } + + # Add the SwiftShader .dylibs in the MODULE_DIR of the Framework app bundle. + bundle_data("cef_framework_swiftshader_binaries") { + sources = [ + "$root_out_dir/egl_intermediates/libswiftshader_libEGL.dylib", + "$root_out_dir/egl_intermediates/libswiftshader_libGLESv2.dylib", + ] + outputs = [ + "{{bundle_contents_dir}}/Libraries/{{source_file_part}}", + ] + public_deps = [ + "//ui/gl:swiftshader_library_copy", + ] + } + } + + group("cef_framework_angle_library") { + if (use_egl) { + deps = [ + ":cef_framework_angle_binaries", + ] + } + } + + group("cef_framework_swiftshader_library") { + if (use_egl) { + deps = [ + ":cef_framework_swiftshader_binaries", + ] + } + } + mac_framework_bundle("cef_framework") { output_name = cef_framework_name framework_version = "A" framework_contents = [ + "Libraries", "Resources", ] @@ -1408,8 +1456,10 @@ if (is_mac) { # - crash_report_sender.app deps = [ + ":cef_framework_angle_library", ":cef_framework_locales", ":cef_framework_resources", + ":cef_framework_swiftshader_library", ":libcef_static", ] diff --git a/patch/patch.cfg b/patch/patch.cfg index 6707cb395..d40fb1a50 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -367,7 +367,10 @@ patches = [ { # macOS: Fix undesirable switch to discrete GPU during startup. # https://bitbucket.org/chromiumembedded/cef/issues/2398 - 'name': 'mac_gpu_2398', + # + # macOS: Rely on symlinks to find the Libraries directory. + # https://bugs.chromium.org/p/chromium/issues/detail?id=757974#c23 + 'name': 'mac_gpu', }, { # Fix crash in CookieMonsterChangeDispatcher::Subscription destructor. diff --git a/patch/patches/mac_gpu_2398.patch b/patch/patches/mac_gpu.patch similarity index 58% rename from patch/patches/mac_gpu_2398.patch rename to patch/patches/mac_gpu.patch index b9ed0cf53..3cc0be972 100644 --- a/patch/patches/mac_gpu_2398.patch +++ b/patch/patches/mac_gpu.patch @@ -1,5 +1,5 @@ diff --git ui/gl/init/gl_initializer_mac.cc ui/gl/init/gl_initializer_mac.cc -index f4789ebf3b0e..a7f5b21da372 100644 +index f4789ebf3b0e..73d66e8f5165 100644 --- ui/gl/init/gl_initializer_mac.cc +++ ui/gl/init/gl_initializer_mac.cc @@ -47,11 +47,8 @@ bool InitializeOneOffForSandbox() { @@ -16,3 +16,14 @@ index f4789ebf3b0e..a7f5b21da372 100644 if (GetGLImplementation() == kGLImplementationAppleGL) { attribs.push_back(kCGLPFARendererID); attribs.push_back( +@@ -146,8 +143,8 @@ bool InitializeStaticEGLInternal(GLImplementation implementation) { + // as app bundles. In that case, the .dylib is next to the executable. + base::FilePath base_dir; + if (base::mac::AmIBundled()) { +- base_dir = +- base::mac::FrameworkBundlePath().Append("Versions/Current/Libraries/"); ++ // Rely on symlinks to find the correct version. ++ base_dir = base::mac::FrameworkBundlePath().Append("Libraries/"); + } else { + if (!base::PathService::Get(base::FILE_EXE, &base_dir)) { + LOG(ERROR) << "PathService::Get failed.";