macOS: Add support for and enable the V2 sandbox (issue #2459)

The CEF_USE_SANDBOX define is now used on all platforms.
This commit is contained in:
Marshall Greenblatt
2018-07-27 17:28:12 -04:00
parent fcad76b405
commit dec98a5534
25 changed files with 461 additions and 108 deletions

View File

@@ -1002,11 +1002,6 @@ if options.clientdistrib or options.clientdistribonly:
parser.print_help(sys.stderr)
sys.exit()
if platform != 'windows' and (options.sandboxdistrib or
options.sandboxdistribonly):
print 'The sandbox distribution is only supported on Windows.'
sys.exit()
# CEF branch.
if options.branch != 'trunk' and not options.branch.isdigit():
print 'Invalid branch value: %s' % (options.branch)
@@ -1033,6 +1028,9 @@ branch_is_newer_than_2785 = (cef_branch == 'trunk' or int(cef_branch) > 2785)
# True if the requested branch is 3029 or older.
branch_is_3029_or_older = (cef_branch != 'trunk' and int(cef_branch) <= 3029)
# True if the requested branch is newer than 3497.
branch_is_newer_than_3497 = (cef_branch == 'trunk' or int(cef_branch) > 3497)
# Enable GN by default for branches newer than 2785.
if branch_is_newer_than_2785 and not 'CEF_USE_GN' in os.environ.keys():
os.environ['CEF_USE_GN'] = '1'
@@ -1082,6 +1080,16 @@ if platform == 'macosx' and not options.x64build and branch_is_2272_or_newer:
'newer. Add --x64-build flag to generate a 64-bit build.'
sys.exit()
# Platforms that build a cef_sandbox library.
sandbox_lib_platforms = ['windows']
if branch_is_newer_than_3497:
sandbox_lib_platforms.append('macosx')
if not platform in sandbox_lib_platforms and (options.sandboxdistrib or
options.sandboxdistribonly):
print 'The sandbox distribution is not supported on this platform.'
sys.exit()
# Options that force the sources to change.
force_change = options.forceclean or options.forceupdate
@@ -1519,8 +1527,8 @@ if not options.nobuild and (chromium_checkout_changed or \
os.path.join(download_dir, 'build-%s-debug.log' % (cef_branch)) \
if options.buildlogfile else None)
if use_gn and platform == 'windows':
# Make the separate cef_sandbox.lib build when GN is_official_build=true.
if use_gn and platform in sandbox_lib_platforms:
# Make the separate cef_sandbox build when GN is_official_build=true.
build_path += '_sandbox'
if os.path.exists(os.path.join(chromium_src_dir, build_path)):
args_path = os.path.join(chromium_src_dir, build_path, 'args.gn')
@@ -1541,8 +1549,8 @@ if not options.nobuild and (chromium_checkout_changed or \
os.path.join(download_dir, 'build-%s-release.log' % (cef_branch)) \
if options.buildlogfile else None)
if use_gn and platform == 'windows':
# Make the separate cef_sandbox.lib build when GN is_official_build=true.
if use_gn and platform in sandbox_lib_platforms:
# Make the separate cef_sandbox build when GN is_official_build=true.
build_path += '_sandbox'
if os.path.exists(os.path.join(chromium_src_dir, build_path)):
args_path = os.path.join(chromium_src_dir, build_path, 'args.gn')

View File

@@ -436,10 +436,9 @@ def GetConfigArgs(args, is_debug, cpu):
return result
def WinGetConfigArgsSandbox(args, is_debug, cpu):
def GetConfigArgsSandbox(platform, args, is_debug, cpu):
"""
Return merged GN args for the Windows cef_sandbox.lib configuration and
validate.
Return merged GN args for the cef_sandbox configuration and validate.
"""
add_args = {
# Avoid libucrt.lib linker errors.
@@ -520,13 +519,14 @@ def GetAllPlatformConfigs(build_args):
result['Debug_GN_' + cpu] = GetConfigArgs(args, True, cpu)
result['Release_GN_' + cpu] = GetConfigArgs(args, False, cpu)
if platform == 'windows' and GetArgValue(args, 'is_official_build'):
if platform in ('windows', 'macosx') and GetArgValue(
args, 'is_official_build'):
# Build cef_sandbox.lib with a different configuration.
if create_debug:
result['Debug_GN_' + cpu + '_sandbox'] = WinGetConfigArgsSandbox(
args, True, cpu)
result['Release_GN_' + cpu + '_sandbox'] = WinGetConfigArgsSandbox(
args, False, cpu)
result['Debug_GN_' + cpu + '_sandbox'] = GetConfigArgsSandbox(
platform, args, True, cpu)
result['Release_GN_' + cpu + '_sandbox'] = GetConfigArgsSandbox(
platform, args, False, cpu)
return result

View File

@@ -301,16 +301,19 @@ def copy_files_list(build_dir, dst_dir, paths):
raise Exception('Missing required path: %s' % source_path)
def combine_libs(build_dir, libs, dest_lib):
def combine_libs(platform, build_dir, libs, dest_lib):
""" Combine multiple static libraries into a single static library. """
cmdline = 'msvs_env.bat win%s python combine_libs.py -o "%s"' % (
platform_arch, dest_lib)
if platform == 'windows':
cmdline = 'msvs_env.bat win%s python combine_libs.py -o "%s"' % (
platform_arch, dest_lib)
else:
cmdline = 'libtool -static -o "%s"' % dest_lib
for lib in libs:
lib_path = os.path.join(build_dir, lib)
for path in get_files(lib_path): # Expand wildcards in |lib_path|.
if not path_exists(path):
raise Exception('File not found: ' + path)
cmdline = cmdline + ' "%s"' % path
cmdline += ' "%s"' % path
run(cmdline, os.path.join(cef_dir, 'tools'))
@@ -745,7 +748,7 @@ if platform == 'windows':
if path_exists(os.path.join(src_dir, cef_sandbox_lib)):
dst_dir = os.path.join(output_dir, dir_name)
make_dir(dst_dir, options.quiet)
combine_libs(src_dir, sandbox_libs,
combine_libs(platform, src_dir, sandbox_libs,
os.path.join(dst_dir, 'cef_sandbox.lib'))
break
@@ -849,6 +852,30 @@ elif platform == 'macosx':
framework_dsym = '%s.dSYM' % framework_name
cefclient_app = 'cefclient.app'
cef_sandbox_lib = 'obj/cef/libcef_sandbox.a'
sandbox_libs = [
cef_sandbox_lib,
'obj/sandbox/mac/libseatbelt.a',
'obj/sandbox/mac/libseatbelt_proto.a',
'obj/third_party/protobuf/libprotobuf_lite.a',
]
# Generate the cef_sandbox.a merged library. A separate *_sandbox build
# should exist when GN is_official_build=true.
if mode in ('standard', 'minimal', 'sandbox'):
dirs = {
'Debug': (build_dir_debug + '_sandbox', build_dir_debug),
'Release': (build_dir_release + '_sandbox', build_dir_release)
}
for dir_name in dirs.keys():
for src_dir in dirs[dir_name]:
if path_exists(os.path.join(src_dir, cef_sandbox_lib)):
dst_dir = os.path.join(output_dir, dir_name)
make_dir(dst_dir, options.quiet)
combine_libs(platform, src_dir, sandbox_libs,
os.path.join(dst_dir, 'cef_sandbox.a'))
break
valid_build_dir = None
if mode == 'standard':
@@ -879,42 +906,44 @@ elif platform == 'macosx':
else:
sys.stdout.write("No Debug build files.\n")
# transfer Release files
build_dir = build_dir_release
if not options.allowpartial or path_exists(
os.path.join(build_dir, cefclient_app)):
valid_build_dir = build_dir
dst_dir = os.path.join(output_dir, 'Release')
make_dir(dst_dir, options.quiet)
framework_src_dir = os.path.join(
build_dir, '%s/Contents/Frameworks/%s.framework/Versions/A' %
(cefclient_app, framework_name))
if mode != 'client':
framework_dst_dir = os.path.join(dst_dir, '%s.framework' % framework_name)
if mode != 'sandbox':
# transfer Release files
build_dir = build_dir_release
if not options.allowpartial or path_exists(
os.path.join(build_dir, cefclient_app)):
valid_build_dir = build_dir
dst_dir = os.path.join(output_dir, 'Release')
make_dir(dst_dir, options.quiet)
framework_src_dir = os.path.join(
build_dir, '%s/Contents/Frameworks/%s.framework/Versions/A' %
(cefclient_app, framework_name))
if mode != 'client':
framework_dst_dir = os.path.join(dst_dir,
'%s.framework' % framework_name)
else:
copy_dir(
os.path.join(build_dir, cefclient_app),
os.path.join(dst_dir, cefclient_app), options.quiet)
# Replace the versioned framework with an unversioned framework in the sample app.
framework_dst_dir = os.path.join(
dst_dir, '%s/Contents/Frameworks/%s.framework' % (cefclient_app,
framework_name))
remove_dir(framework_dst_dir, options.quiet)
copy_dir(framework_src_dir, framework_dst_dir, options.quiet)
if not options.nosymbols:
# create the symbol output directory
symbol_output_dir = create_output_dir(
output_dir_name + '_release_symbols', options.outputdir)
# The real dSYM already exists, just copy it to the output directory.
# dSYMs are only generated when is_official_build=true or enable_dsyms=true.
# See //build/config/mac/symbols.gni.
copy_dir(
os.path.join(build_dir, framework_dsym),
os.path.join(symbol_output_dir, framework_dsym), options.quiet)
else:
copy_dir(
os.path.join(build_dir, cefclient_app),
os.path.join(dst_dir, cefclient_app), options.quiet)
# Replace the versioned framework with an unversioned framework in the sample app.
framework_dst_dir = os.path.join(
dst_dir, '%s/Contents/Frameworks/%s.framework' % (cefclient_app,
framework_name))
remove_dir(framework_dst_dir, options.quiet)
copy_dir(framework_src_dir, framework_dst_dir, options.quiet)
if not options.nosymbols:
# create the symbol output directory
symbol_output_dir = create_output_dir(
output_dir_name + '_release_symbols', options.outputdir)
# The real dSYM already exists, just copy it to the output directory.
# dSYMs are only generated when is_official_build=true or enable_dsyms=true.
# See //build/config/mac/symbols.gni.
copy_dir(
os.path.join(build_dir, framework_dsym),
os.path.join(symbol_output_dir, framework_dsym), options.quiet)
else:
sys.stdout.write("No Release build files.\n")
sys.stdout.write("No Release build files.\n")
if mode == 'standard' or mode == 'minimal':
# transfer include files