diff --git a/BUILD.gn b/BUILD.gn index 1aa1834ad..996801562 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1267,7 +1267,10 @@ if (is_mac) { sources = [ "libcef_dll/sandbox/sandbox_mac.mm" ] # CEF sources use include paths relative to the CEF root directory. include_dirs = [ "." ] - deps = [ "//sandbox/mac:seatbelt" ] + deps = [ + "//build/config:executable_deps", + "//sandbox/mac:seatbelt" + ] } } diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 51aa74554..a567a846e 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -12,7 +12,7 @@ # distribution include: # # Linux: Ninja, Unix Makefiles -# MacOS: Ninja, Xcode 8+ +# MacOS: Ninja, Xcode 8+ (x64) or Xcode 12.2+ (ARM64) # Windows: Ninja, Visual Studio 2015+ # # Ninja is a cross-platform open-source tool for running fast builds using @@ -84,6 +84,15 @@ # > cmake -G "Ninja" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug .. # > ninja cefclient cefsimple # +# To perform a MacOS build using an ARM64 CEF binary distribution: +# Using the Xcode IDE: +# > cmake -G "Xcode" -DPROJECT_ARCH="arm64" .. +# Open build\cef.xcodeproj in Xcode and select Product > Build. +# +# Using Ninja: +# > cmake -G "Ninja" -DPROJECT_ARCH="arm64" -DCMAKE_BUILD_TYPE=Debug .. +# > ninja cefclient cefsimple +# # To perform a Windows build using a 32-bit CEF binary distribution: # Using the Visual Studio 2019 IDE: # > cmake -G "Visual Studio 16" -A Win32 .. diff --git a/cmake/cef_variables.cmake.in b/cmake/cef_variables.cmake.in index 6ce498210..f29c6f113 100644 --- a/cmake/cef_variables.cmake.in +++ b/cmake/cef_variables.cmake.in @@ -328,6 +328,8 @@ if(OS_MAC) # Target architecture. if(PROJECT_ARCH STREQUAL "x86_64") set(CMAKE_OSX_ARCHITECTURES "x86_64") + elseif(PROJECT_ARCH STREQUAL "arm64") + set(CMAKE_OSX_ARCHITECTURES "arm64") else() set(CMAKE_OSX_ARCHITECTURES "i386") endif() diff --git a/tools/automate/automate-git.py b/tools/automate/automate-git.py index e37478a82..6abe1fa58 100644 --- a/tools/automate/automate-git.py +++ b/tools/automate/automate-git.py @@ -921,7 +921,8 @@ parser.add_option( '--distrib-subdir-suffix', dest='distribsubdirsuffix', default='', - help='CEF distrib dir name suffix, child of chromium/src/cef/binary_distrib') + help='CEF distrib dir name suffix, child of chromium/src/cef/binary_distrib' +) (options, args) = parser.parse_args() @@ -1032,16 +1033,11 @@ if options.armbuild: print('The ARM build option is only supported on Linux.') sys.exit() -if options.arm64build: - if platform != 'linux' and platform != 'windows': - print('The ARM64 build option is only supported on Linux and Windows.') - sys.exit() - deps_file = 'DEPS' -if platform == 'mac' and not options.x64build: +if platform == 'mac' and not (options.x64build or options.arm64build): print('32-bit MacOS builds are not supported. ' + - 'Add --x64-build flag to generate a 64-bit build.') + 'Add --x64-build or --arm64-build flag to generate a 64-bit build.') sys.exit() # Platforms that build a cef_sandbox library. diff --git a/tools/distrib/mac/README.redistrib.txt b/tools/distrib/mac/README.redistrib.txt index fed1936e0..19fd17c1f 100644 --- a/tools/distrib/mac/README.redistrib.txt +++ b/tools/distrib/mac/README.redistrib.txt @@ -26,7 +26,7 @@ cefclient.app/ cef_extensions.pak <=====^ devtools_resources.pak <=^ icudtl.dat <= unicode support - snapshot_blob.bin, v8_context_snapshot.x86_64.bin <= V8 initial snapshot + snapshot_blob.bin, v8_context_snapshot.[x86_64|arm64].bin <= V8 initial snapshot en.lproj/, ... <= locale-specific resources and strings Info.plist cefclient Helper.app/ diff --git a/tools/gn_args.py b/tools/gn_args.py index 452904edf..d844f9aa0 100644 --- a/tools/gn_args.py +++ b/tools/gn_args.py @@ -327,11 +327,11 @@ def ValidateArgs(args): windows_sdk_path = GetArgValue(args, 'windows_sdk_path') # Target CPU architecture. - # - Windows supports "x86" and "x64". - # - Mac supports only "x64". + # - Windows supports "x86", "x64" and "arm64". + # - Mac supports "x64" and "arm64". # - Linux supports only "x64" unless using a sysroot environment. if platform == 'mac': - assert target_cpu == 'x64', 'target_cpu must be "x64"' + assert target_cpu in ('x64', 'arm64'), 'target_cpu must be "x64" or "arm64"' elif platform == 'windows': assert target_cpu in ('x86', 'x64', 'arm64'), 'target_cpu must be "x86", "x64" or "arm64"' @@ -548,6 +548,8 @@ def GetAllPlatformConfigs(build_args): supported_cpus.append('arm64') elif platform == 'mac': supported_cpus = ['x64'] + if os.environ.get('CEF_ENABLE_ARM64', '') == '1': + supported_cpus.append('arm64') else: raise Exception('Unsupported platform') diff --git a/tools/make_distrib.py b/tools/make_distrib.py index 641f317a2..4666d8ee7 100644 --- a/tools/make_distrib.py +++ b/tools/make_distrib.py @@ -381,7 +381,8 @@ def combine_libs(platform, build_dir, libs, dest_lib): # Create an intermediate object file that combines all other object files. # Symbols not identified above will be made private (local). intermediate_obj = os.path.splitext(dest_lib)[0] + '.o' - cmdline = 'ld -arch x86_64 -r -o "%s"' % intermediate_obj + arch = 'arm64' if options.arm64build else 'x86_64' + cmdline = 'ld -arch %s -r -o "%s"' % (arch, intermediate_obj) for symbol in symbols: cmdline += ' -exported_symbol %s' % symbol @@ -410,6 +411,10 @@ def combine_libs(platform, build_dir, libs, dest_lib): # Verify that no C++ symbols are imported by the archive file. If the # archive imports C++ symbols and the client app links an incompatible C++ # library, the result will be undefined behavior. + # For example, to avoid importing libc++ symbols the cef_sandbox target + # should have a dependency on libc++abi. This dependency can be verified + # with the following command: + # gn path out/[config] //cef:cef_sandbox //buildtools/third_party/libc++abi print('Verifying imported (undefined) symbols...') undefined_symbols = get_undefined_symbols(dest_lib) cpp_symbols = list( @@ -565,10 +570,6 @@ if options.armbuild and platform != 'linux': print_error('--arm-build is only supported on Linux.') sys.exit() -if options.arm64build and not platform in ('linux', 'windows'): - print_error('--arm64-build is only supported on Linux and Windows.') - sys.exit() - if options.sandbox and not platform in ('mac', 'windows'): print_error('--sandbox is only supported on macOS and Windows.') sys.exit() @@ -632,8 +633,11 @@ else: output_dir_base = 'cef_binary_' + cef_ver if options.distribsubdir == '': - # For backwards compatibility keep the old default directory name on mac. - platform_name = 'macosx' if platform == 'mac' else platform + if platform == 'mac': + # For backwards compatibility keep the old default directory name on mac. + platform_name = 'macos' + ('x' if platform_arch == '64' else '') + else: + platform_name = platform output_dir_name = output_dir_base + '_' + platform_name + platform_arch if options.distribsubdirsuffix != '':