2016-06-23 19:42:00 +02:00
|
|
|
# Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
|
|
|
|
# 2012 Google Inc. All rights reserved. Use of this source code is governed by
|
|
|
|
# a BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
2016-10-29 02:27:55 +02:00
|
|
|
# This script determines the contents of the per-configuration `args.gn` files
|
|
|
|
# that are used to build CEF/Chromium with GN. See comments in CEF's top-level
|
|
|
|
# BUILD.gn file for general GN usage instructions.
|
|
|
|
#
|
|
|
|
# This script performs the following tasks:
|
|
|
|
#
|
|
|
|
# - Defines CEF's default and required arg values in cases where they differ
|
|
|
|
# from Chromium's.
|
|
|
|
# - Accepts user-defined arg values via the GN_DEFINES environment variable.
|
|
|
|
# - Verifies that user-defined arg values do not conflict with CEF's
|
|
|
|
# requirements.
|
|
|
|
# - Generates multiple configurations by combining user-defined arg values with
|
|
|
|
# CEF's default and required values.
|
|
|
|
#
|
|
|
|
# Before adding a new arg value in this script determine the following:
|
|
|
|
#
|
|
|
|
# - Chromium's default value. Default values are defined in the declare_args()
|
|
|
|
# sections of *.gni files.
|
|
|
|
# - Chromium's value requirements. Check for assert()s related to the value in
|
|
|
|
# Chromium code.
|
|
|
|
# - Whether a particular value is optional or required for CEF.
|
|
|
|
# - Under what conditions a particular value is required for CEF (platform,
|
|
|
|
# build type, CPU architecture, etc).
|
|
|
|
#
|
|
|
|
# If CEF can use Chromium's default value and has no additional validation
|
|
|
|
# requirements then do nothing.
|
|
|
|
#
|
|
|
|
# If CEF can use Chromium's default value but would like to enforce additional
|
|
|
|
# validation requirements then go to 3B.
|
|
|
|
#
|
|
|
|
# If CEF cannot or should not use Chromium's default value then choose one of
|
|
|
|
# the following:
|
|
|
|
#
|
|
|
|
# 1. If CEF requires a different value either globally or based on the platform:
|
|
|
|
# - Add an assert() for the value in CEF's top-level BUILD.gn file.
|
|
|
|
# - Add the required value in GetRequiredArgs().
|
|
|
|
# - Result: CEF's required value will be used. The user cannot override the
|
|
|
|
# value via GN_DEFINES.
|
|
|
|
#
|
|
|
|
# 2. If CEF requires a different value based on the build type or CPU
|
|
|
|
# architecture:
|
|
|
|
# - Add an assert() for the value in CEF's top-level BUILD.gn file.
|
|
|
|
# - Add the required value in GetConfigArgs().
|
|
|
|
# - Result: CEF's required value will be used. The user cannot override the
|
|
|
|
# value via GN_DEFINES.
|
|
|
|
#
|
|
|
|
# 3. If CEF recommends (but does not require) a different value either globally
|
|
|
|
# or based on the platform:
|
|
|
|
# A. Set the default value:
|
|
|
|
# - Add the recommended value in GetRecommendedDefaultArgs().
|
|
|
|
# - Result: CEF's recommended value will be used by default. The user can
|
|
|
|
# override the value via GN_DEFINES.
|
|
|
|
#
|
|
|
|
# B. If CEF has additional validation requirements:
|
|
|
|
# - Add the default Chromium value in GetChromiumDefaultArgs().
|
|
|
|
# - Perform validation in ValidateArgs().
|
|
|
|
# - Result: An AssertionError will be thrown if validation fails.
|
|
|
|
|
2020-01-09 14:49:11 +01:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
2016-06-23 19:42:00 +02:00
|
|
|
import os
|
2021-07-29 19:29:41 +02:00
|
|
|
import platform as python_platform
|
2016-06-23 19:42:00 +02:00
|
|
|
import shlex
|
|
|
|
import sys
|
|
|
|
|
2016-10-17 20:00:03 +02:00
|
|
|
# The CEF directory is the parent directory of _this_ script.
|
|
|
|
cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
|
|
|
# The src directory is the parent directory of the CEF directory.
|
|
|
|
src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir))
|
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
# Determine the platform.
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
platform = 'windows'
|
2021-07-29 19:29:41 +02:00
|
|
|
# Windows machines report 'ARM64' or 'AMD64'.
|
|
|
|
machine = 'arm64' if python_platform.machine() == 'ARM64' else 'amd64'
|
2016-06-23 19:42:00 +02:00
|
|
|
elif sys.platform == 'darwin':
|
2020-08-29 00:39:23 +02:00
|
|
|
platform = 'mac'
|
2021-07-29 19:29:41 +02:00
|
|
|
# Mac machines report 'arm64' or 'x86_64'.
|
|
|
|
machine = 'arm64' if python_platform.machine() == 'arm64' else 'amd64'
|
2016-06-23 19:42:00 +02:00
|
|
|
elif sys.platform.startswith('linux'):
|
|
|
|
platform = 'linux'
|
|
|
|
else:
|
2020-01-09 14:49:11 +01:00
|
|
|
print('Unknown operating system platform')
|
2016-06-23 19:42:00 +02:00
|
|
|
sys.exit()
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def msg(msg):
|
2020-01-09 14:49:11 +01:00
|
|
|
print('NOTE: ' + msg)
|
2016-06-23 19:42:00 +02:00
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def NameValueListToDict(name_value_list):
|
|
|
|
"""
|
|
|
|
Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary
|
|
|
|
of the pairs. If a string is simply NAME, then the value in the dictionary
|
|
|
|
is set to True. If VALUE can be converted to a boolean or integer, it is.
|
|
|
|
"""
|
2017-05-28 15:04:18 +02:00
|
|
|
result = {}
|
2016-06-23 19:42:00 +02:00
|
|
|
for item in name_value_list:
|
|
|
|
tokens = item.split('=', 1)
|
|
|
|
if len(tokens) == 2:
|
|
|
|
token_value = tokens[1]
|
|
|
|
if token_value.lower() == 'true':
|
|
|
|
token_value = True
|
|
|
|
elif token_value.lower() == 'false':
|
|
|
|
token_value = False
|
|
|
|
else:
|
|
|
|
# If we can make it an int, use that, otherwise, use the string.
|
|
|
|
try:
|
|
|
|
token_value = int(token_value)
|
|
|
|
except ValueError:
|
2020-01-13 16:21:09 +01:00
|
|
|
pass
|
2016-06-23 19:42:00 +02:00
|
|
|
# Set the variable to the supplied value.
|
|
|
|
result[tokens[0]] = token_value
|
|
|
|
else:
|
|
|
|
# No value supplied, treat it as a boolean and set it.
|
|
|
|
result[tokens[0]] = True
|
|
|
|
return result
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def ShlexEnv(env_name):
|
|
|
|
"""
|
|
|
|
Split an environment variable using shell-like syntax.
|
|
|
|
"""
|
|
|
|
flags = os.environ.get(env_name, [])
|
|
|
|
if flags:
|
|
|
|
flags = shlex.split(flags)
|
|
|
|
return flags
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def MergeDicts(*dict_args):
|
|
|
|
"""
|
|
|
|
Given any number of dicts, shallow copy and merge into a new dict.
|
|
|
|
Precedence goes to key value pairs in latter dicts.
|
|
|
|
"""
|
|
|
|
result = {}
|
|
|
|
for dictionary in dict_args:
|
|
|
|
result.update(dictionary)
|
|
|
|
return result
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-10-29 02:27:55 +02:00
|
|
|
def GetValueString(val):
|
|
|
|
"""
|
|
|
|
Return the string representation of |val| expected by GN.
|
|
|
|
"""
|
2020-01-09 14:49:11 +01:00
|
|
|
if isinstance(val, bool):
|
2016-10-29 02:27:55 +02:00
|
|
|
if val:
|
|
|
|
return 'true'
|
|
|
|
else:
|
|
|
|
return 'false'
|
2020-01-13 16:50:00 +01:00
|
|
|
elif isinstance(val, int):
|
|
|
|
return val
|
2020-01-09 14:49:11 +01:00
|
|
|
else:
|
|
|
|
return '"%s"' % val
|
2016-10-29 02:27:55 +02:00
|
|
|
return val
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def GetChromiumDefaultArgs():
|
|
|
|
"""
|
|
|
|
Return default GN args. These must match the Chromium defaults.
|
2016-08-31 13:25:56 +02:00
|
|
|
Only args that may be retrieved via GetArgValue() need to be specified here.
|
2016-06-23 19:42:00 +02:00
|
|
|
"""
|
|
|
|
# Search for these values in declare_args() sections of *.gni files to find
|
|
|
|
# the defaults.
|
|
|
|
|
|
|
|
defaults = {
|
2017-05-28 15:04:18 +02:00
|
|
|
'dcheck_always_on': False,
|
|
|
|
'is_asan': False,
|
|
|
|
'is_debug': True,
|
|
|
|
'is_official_build': False,
|
|
|
|
'target_cpu': 'x64',
|
2016-06-23 19:42:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if platform == 'linux':
|
|
|
|
defaults['use_sysroot'] = True
|
|
|
|
|
|
|
|
if platform == 'windows':
|
|
|
|
defaults['is_win_fastlink'] = False
|
|
|
|
defaults['visual_studio_path'] = ''
|
|
|
|
defaults['visual_studio_version'] = ''
|
2016-08-25 14:25:27 +02:00
|
|
|
defaults['visual_studio_runtime_dirs'] = ''
|
2016-06-23 19:42:00 +02:00
|
|
|
defaults['windows_sdk_path'] = ''
|
|
|
|
|
|
|
|
return defaults
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def GetArgValue(args, key):
|
|
|
|
"""
|
|
|
|
Return an existing GN arg value or the Chromium default.
|
|
|
|
"""
|
|
|
|
defaults = GetChromiumDefaultArgs()
|
|
|
|
assert key in defaults, "No default Chromium value specified for %s" % key
|
|
|
|
return args.get(key, defaults[key])
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def GetRecommendedDefaultArgs():
|
|
|
|
"""
|
|
|
|
Return recommended default GN args that differ from Chromium defaults.
|
|
|
|
"""
|
|
|
|
# Search for these values in declare_args() sections of *.gni files to find
|
|
|
|
# the defaults.
|
|
|
|
|
|
|
|
result = {
|
2017-05-28 15:04:18 +02:00
|
|
|
# Enable NaCL. Default is true. False is recommended for faster builds.
|
|
|
|
'enable_nacl': False,
|
2017-07-06 22:39:37 +02:00
|
|
|
|
|
|
|
# Disable component builds. Default depends on the platform. True results
|
|
|
|
# in faster local builds but False is required to create a CEF binary
|
|
|
|
# distribution.
|
|
|
|
'is_component_build': False,
|
2019-09-04 17:13:32 +02:00
|
|
|
|
2020-06-09 19:48:00 +02:00
|
|
|
# Specify the current PGO phase. Default is 0 (turned off) for normal
|
|
|
|
# builds and 2 (used during the optimization phase) for official Windows
|
|
|
|
# and macOS builds. Currently turned off for CEF because it requires
|
|
|
|
# additional setup and is not yet tested. See issue #2956.
|
|
|
|
'chrome_pgo_phase': 0,
|
2020-06-27 22:43:23 +02:00
|
|
|
|
|
|
|
# Disable support for background apps, which don't make sense with CEF.
|
|
|
|
# Default is enabled on desktop platforms. This feature was also causing
|
|
|
|
# strange shutdown crashes when using the Chrome runtime with a Debug
|
|
|
|
# component build on Windows.
|
|
|
|
'enable_background_mode': False,
|
2020-07-14 19:38:13 +02:00
|
|
|
|
2020-10-08 21:54:42 +02:00
|
|
|
# Disable support for resource allowlist generation. When enabled this
|
2020-07-14 19:38:13 +02:00
|
|
|
# introduces a Windows official build dependency on the
|
|
|
|
# "//chrome:chrome_dll" target, which will fail to build with CEF.
|
2020-10-08 21:54:42 +02:00
|
|
|
'enable_resource_allowlist_generation': False,
|
2016-06-23 19:42:00 +02:00
|
|
|
}
|
|
|
|
|
2021-06-11 17:52:44 +02:00
|
|
|
if platform != 'windows':
|
|
|
|
# Only allow non-component Debug builds on non-Windows platforms. These
|
|
|
|
# builds will fail on Windows due to linker issues (running out of memory,
|
|
|
|
# etc). See https://bitbucket.org/chromiumembedded/cef/issues/2679.
|
|
|
|
result['forbid_non_component_debug_builds'] = False
|
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
if platform == 'linux':
|
|
|
|
# Use a sysroot environment. Default is true. False is recommended for local
|
|
|
|
# builds.
|
|
|
|
# Run the following commands to download the sysroot environment:
|
|
|
|
# x86 build only: $ export GYP_DEFINES='target_arch=ia32'
|
|
|
|
# x86 or x64 build: $ gclient runhooks
|
|
|
|
result['use_sysroot'] = False
|
|
|
|
|
2018-02-15 01:12:09 +01:00
|
|
|
# Don't add the `-Wl,--fatal-warnings` linker flag when building on Ubuntu
|
|
|
|
# 14 (Trusty) host systems. It results in errors like the following:
|
|
|
|
# ld.lld: error: found local symbol '__bss_start' in global part of symbol
|
|
|
|
# table in file /usr/lib/x86_64-linux-gnu/libGL.so
|
|
|
|
# TODO(cef): Remove this flag once we require a newer host system.
|
|
|
|
result['fatal_linker_warnings'] = False
|
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
return result
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def GetGNEnvArgs():
|
|
|
|
"""
|
|
|
|
Return GN args specified via the GN_DEFINES env variable.
|
|
|
|
"""
|
|
|
|
return NameValueListToDict(ShlexEnv('GN_DEFINES'))
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def GetRequiredArgs():
|
|
|
|
"""
|
2016-08-31 13:25:56 +02:00
|
|
|
Return required GN args. Also enforced by assert() in //cef/BUILD.gn.
|
2016-06-23 19:42:00 +02:00
|
|
|
"""
|
|
|
|
result = {
|
2017-05-28 15:04:18 +02:00
|
|
|
# Set ENABLE_PRINTING=1 ENABLE_BASIC_PRINTING=1.
|
|
|
|
'enable_basic_printing': True,
|
2019-07-17 20:47:27 +02:00
|
|
|
# ENABLE_SERVICE_DISCOVERY=0 for print preview support
|
|
|
|
'enable_print_preview': True,
|
|
|
|
'optimize_webui': True,
|
2017-05-28 15:04:18 +02:00
|
|
|
# Enable support for Widevine CDM.
|
|
|
|
'enable_widevine': True,
|
2016-06-23 19:42:00 +02:00
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
# Don't use the chrome style plugin.
|
|
|
|
'clang_use_chrome_plugins': False,
|
|
|
|
}
|
2016-06-23 19:42:00 +02:00
|
|
|
|
2017-11-16 01:28:16 +01:00
|
|
|
if platform == 'linux':
|
|
|
|
# Don't generate Chromium installer packages. This avoids GN dependency
|
|
|
|
# errors with CEF (see issue #2301).
|
2018-04-14 03:21:17 +02:00
|
|
|
# Due to the way this variable is declared in chrome/installer/BUILD.gn it
|
|
|
|
# can't be enforced by assert().
|
2017-11-16 01:28:16 +01:00
|
|
|
result['enable_linux_installer'] = False
|
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
return result
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def GetMergedArgs(build_args):
|
|
|
|
"""
|
|
|
|
Return merged GN args.
|
|
|
|
"""
|
2016-10-29 02:27:55 +02:00
|
|
|
dict = MergeDicts(GetRecommendedDefaultArgs(), GetGNEnvArgs(), build_args)
|
|
|
|
|
|
|
|
# Verify that the user is not trying to override required args.
|
|
|
|
required = GetRequiredArgs()
|
|
|
|
for key in required.keys():
|
|
|
|
if key in dict:
|
|
|
|
assert dict[key] == required[key], \
|
|
|
|
"%s=%s is required" % (key, GetValueString(required[key]))
|
|
|
|
|
|
|
|
return MergeDicts(dict, required)
|
2016-06-23 19:42:00 +02:00
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def ValidateArgs(args):
|
|
|
|
"""
|
|
|
|
Validate GN arg combinations that we know about. Also provide suggestions
|
|
|
|
where appropriate.
|
|
|
|
"""
|
|
|
|
dcheck_always_on = GetArgValue(args, 'dcheck_always_on')
|
|
|
|
is_asan = GetArgValue(args, 'is_asan')
|
|
|
|
is_debug = GetArgValue(args, 'is_debug')
|
|
|
|
is_official_build = GetArgValue(args, 'is_official_build')
|
|
|
|
target_cpu = GetArgValue(args, 'target_cpu')
|
|
|
|
|
|
|
|
if platform == 'linux':
|
|
|
|
use_sysroot = GetArgValue(args, 'use_sysroot')
|
|
|
|
|
|
|
|
if platform == 'windows':
|
|
|
|
is_win_fastlink = GetArgValue(args, 'is_win_fastlink')
|
|
|
|
visual_studio_path = GetArgValue(args, 'visual_studio_path')
|
|
|
|
visual_studio_version = GetArgValue(args, 'visual_studio_version')
|
2016-08-25 14:25:27 +02:00
|
|
|
visual_studio_runtime_dirs = GetArgValue(args, 'visual_studio_runtime_dirs')
|
2016-06-23 19:42:00 +02:00
|
|
|
windows_sdk_path = GetArgValue(args, 'windows_sdk_path')
|
|
|
|
|
|
|
|
# Target CPU architecture.
|
2020-11-20 22:00:56 +01:00
|
|
|
# - Windows supports "x86", "x64" and "arm64".
|
|
|
|
# - Mac supports "x64" and "arm64".
|
2016-06-23 19:42:00 +02:00
|
|
|
# - Linux supports only "x64" unless using a sysroot environment.
|
2020-08-29 00:39:23 +02:00
|
|
|
if platform == 'mac':
|
2020-11-20 22:00:56 +01:00
|
|
|
assert target_cpu in ('x64', 'arm64'), 'target_cpu must be "x64" or "arm64"'
|
2016-09-10 03:03:17 +02:00
|
|
|
elif platform == 'windows':
|
2020-10-08 21:54:42 +02:00
|
|
|
assert target_cpu in ('x86', 'x64',
|
|
|
|
'arm64'), 'target_cpu must be "x86", "x64" or "arm64"'
|
2016-09-10 03:03:17 +02:00
|
|
|
elif platform == 'linux':
|
2019-06-13 11:45:50 +02:00
|
|
|
assert target_cpu in (
|
|
|
|
'x86', 'x64', 'arm',
|
|
|
|
'arm64'), 'target_cpu must be "x86", "x64", "arm" or "arm64"'
|
2016-06-23 19:42:00 +02:00
|
|
|
|
2016-09-10 03:03:17 +02:00
|
|
|
if platform == 'linux':
|
|
|
|
if target_cpu == 'x86':
|
|
|
|
assert use_sysroot, 'target_cpu="x86" requires use_sysroot=true'
|
|
|
|
elif target_cpu == 'arm':
|
|
|
|
assert use_sysroot, 'target_cpu="arm" requires use_sysroot=true'
|
2019-06-13 11:45:50 +02:00
|
|
|
elif target_cpu == 'arm64':
|
|
|
|
assert use_sysroot, 'target_cpu="arm64" requires use_sysroot=true'
|
2016-06-23 19:42:00 +02:00
|
|
|
|
|
|
|
# ASAN requires Release builds.
|
|
|
|
if is_asan:
|
|
|
|
assert not is_debug, "is_asan=true requires is_debug=false"
|
|
|
|
if not dcheck_always_on:
|
|
|
|
msg('is_asan=true recommends dcheck_always_on=true')
|
|
|
|
|
2016-08-25 13:36:39 +02:00
|
|
|
# Official build requires Release builds.
|
|
|
|
if is_official_build:
|
|
|
|
assert not is_debug, "is_official_build=true requires is_debug=false"
|
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
if platform == 'windows':
|
|
|
|
# Official builds should not use /DEBUG:FASTLINK.
|
|
|
|
if is_official_build:
|
|
|
|
assert not is_win_fastlink, "is_official_build=true precludes is_win_fastlink=true"
|
|
|
|
|
|
|
|
# Windows custom toolchain requirements.
|
|
|
|
#
|
|
|
|
# Required GN arguments:
|
|
|
|
# visual_studio_path="<path to VS root>"
|
|
|
|
# The directory that contains Visual Studio. For example, a subset of
|
|
|
|
# "C:\Program Files (x86)\Microsoft Visual Studio 14.0".
|
2016-08-26 12:08:37 +02:00
|
|
|
# visual_studio_version="<VS version>"
|
2016-06-23 19:42:00 +02:00
|
|
|
# The VS version. For example, "2015".
|
|
|
|
# visual_studio_runtime_dirs="<path to VS CRT>"
|
|
|
|
# The directory that contains the VS CRT. For example, the contents of
|
|
|
|
# "C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x64" plus
|
|
|
|
# "C:\Windows\System32\ucrtbased.dll"
|
|
|
|
# windows_sdk_path="<path to WinSDK>"
|
|
|
|
# The directory that contains the Win SDK. For example, a subset of
|
|
|
|
# "C:\Program Files (x86)\Windows Kits\10".
|
|
|
|
#
|
|
|
|
# Required environment variables:
|
|
|
|
# DEPOT_TOOLS_WIN_TOOLCHAIN=0
|
2016-08-08 13:31:57 +02:00
|
|
|
# GYP_MSVS_OVERRIDE_PATH=<path to VS root, must match visual_studio_path>
|
2016-08-26 12:08:37 +02:00
|
|
|
# GYP_MSVS_VERSION=<VS version, must match visual_studio_version>
|
2016-06-23 19:42:00 +02:00
|
|
|
# CEF_VCVARS=none
|
2021-01-06 00:05:45 +01:00
|
|
|
#
|
|
|
|
# Optional environment variables (required if vcvarsall.bat does not exist):
|
2016-06-23 19:42:00 +02:00
|
|
|
# INCLUDE=<VS include paths>
|
2016-08-08 13:31:57 +02:00
|
|
|
# LIB=<VS library paths>
|
|
|
|
# PATH=<VS executable paths>
|
|
|
|
#
|
2016-08-26 12:08:37 +02:00
|
|
|
# See comments in gclient_hook.py for environment variable usage.
|
|
|
|
#
|
2016-06-23 19:42:00 +02:00
|
|
|
if visual_studio_path != '':
|
|
|
|
assert visual_studio_version != '', 'visual_studio_path requires visual_studio_version'
|
|
|
|
assert visual_studio_runtime_dirs != '', 'visual_studio_path requires visual_studio_runtime_dirs'
|
|
|
|
assert windows_sdk_path != '', 'visual_studio_path requires windows_sdk_path'
|
2016-08-08 13:31:57 +02:00
|
|
|
|
2016-08-26 12:08:37 +02:00
|
|
|
assert os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '') == '0', \
|
|
|
|
"visual_studio_path requires DEPOT_TOOLS_WIN_TOOLCHAIN=0 env variable"
|
|
|
|
|
|
|
|
msvs_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH', '')
|
|
|
|
assert msvs_path == visual_studio_path and os.path.exists(msvs_path), \
|
|
|
|
"visual_studio_path requires matching GYP_MSVS_OVERRIDE_PATH env variable"
|
|
|
|
|
|
|
|
msvs_version = os.environ.get('GYP_MSVS_VERSION', '')
|
|
|
|
assert msvs_version == visual_studio_version, \
|
|
|
|
"visual_studio_version requires matching GYP_MSVS_VERSION env variable"
|
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
assert os.environ.get('CEF_VCVARS', '') == 'none', \
|
|
|
|
"visual_studio_path requires CEF_VCVARS=none env variable"
|
2016-08-26 12:08:37 +02:00
|
|
|
|
2021-01-06 00:05:45 +01:00
|
|
|
# If vcvarsall.bat exists then environment variables will be derived from
|
|
|
|
# there and any specified INCLUDE/LIB values will be ignored by Chromium
|
|
|
|
# (PATH is retained because it might contain required VS runtime
|
|
|
|
# libraries). If this file does not exist then the INCLUDE/LIB/PATH values
|
|
|
|
# are also required by Chromium.
|
2016-08-08 13:31:57 +02:00
|
|
|
vcvars_path = os.path.join(msvs_path, 'VC', 'vcvarsall.bat')
|
2021-01-06 00:05:45 +01:00
|
|
|
if not os.path.exists(vcvars_path):
|
|
|
|
vcvars_path = os.path.join(msvs_path, 'VC', 'Auxiliary', 'Build',
|
|
|
|
'vcvarsall.bat')
|
|
|
|
if os.path.exists(vcvars_path):
|
|
|
|
if 'INCLUDE' in os.environ:
|
|
|
|
del os.environ['INCLUDE']
|
|
|
|
if 'LIB' in os.environ:
|
|
|
|
del os.environ['LIB']
|
|
|
|
if 'LIBPATH' in os.environ:
|
|
|
|
del os.environ['LIBPATH']
|
|
|
|
else:
|
|
|
|
assert 'INCLUDE' in os.environ \
|
|
|
|
and 'LIB' in os.environ \
|
|
|
|
and 'PATH' in os.environ, \
|
|
|
|
"visual_studio_path requires INCLUDE, LIB and PATH env variables"
|
2016-06-23 19:42:00 +02:00
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-09-10 03:03:17 +02:00
|
|
|
def GetConfigArgs(args, is_debug, cpu):
|
2016-06-23 19:42:00 +02:00
|
|
|
"""
|
|
|
|
Return merged GN args for the configuration and validate.
|
|
|
|
"""
|
2016-08-25 13:36:39 +02:00
|
|
|
add_args = {}
|
|
|
|
|
|
|
|
# Cannot create is_official_build=true is_debug=true builds.
|
|
|
|
# This restriction is enforced in //build/config/BUILDCONFIG.gn.
|
|
|
|
# Instead, our "official Debug" build is a Release build with dchecks and
|
|
|
|
# symbols. Symbols will be generated by default for official builds; see the
|
|
|
|
# definition of 'symbol_level' in //build/config/compiler/compiler.gni.
|
|
|
|
if is_debug and GetArgValue(args, 'is_official_build'):
|
|
|
|
is_debug = False
|
|
|
|
add_args['dcheck_always_on'] = True
|
|
|
|
|
|
|
|
result = MergeDicts(args, add_args, {
|
2017-05-28 15:04:18 +02:00
|
|
|
'is_debug': is_debug,
|
|
|
|
'target_cpu': cpu,
|
2016-06-23 19:42:00 +02:00
|
|
|
})
|
2016-09-10 03:03:17 +02:00
|
|
|
|
2019-06-13 11:45:50 +02:00
|
|
|
if platform == 'linux' and not cpu.startswith('arm'):
|
2016-09-10 03:03:17 +02:00
|
|
|
# Remove any arm-related values from non-arm configs.
|
|
|
|
for key in result.keys():
|
|
|
|
if key.startswith('arm_'):
|
|
|
|
del result[key]
|
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
ValidateArgs(result)
|
|
|
|
return result
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2018-07-27 23:28:12 +02:00
|
|
|
def GetConfigArgsSandbox(platform, args, is_debug, cpu):
|
2017-07-18 21:25:11 +02:00
|
|
|
"""
|
2018-07-27 23:28:12 +02:00
|
|
|
Return merged GN args for the cef_sandbox configuration and validate.
|
2017-07-18 21:25:11 +02:00
|
|
|
"""
|
|
|
|
add_args = {
|
|
|
|
# Avoid libucrt.lib linker errors.
|
|
|
|
'use_allocator_shim': False,
|
|
|
|
|
2021-01-28 00:13:12 +01:00
|
|
|
# PartitionAlloc is selected as the default allocator in some cases.
|
|
|
|
# We can't use it because it requires use_allocator_shim=true.
|
|
|
|
'use_allocator': "none",
|
|
|
|
|
2017-07-18 21:25:11 +02:00
|
|
|
# Avoid /LTCG linker warnings and generate smaller lib files.
|
2019-06-11 18:08:26 +02:00
|
|
|
'is_official_build': False,
|
2019-10-01 13:30:07 +02:00
|
|
|
|
|
|
|
# Enable base target customizations necessary for distribution of the
|
|
|
|
# cef_sandbox static library.
|
|
|
|
'is_cef_sandbox_build': True,
|
2017-07-18 21:25:11 +02:00
|
|
|
}
|
|
|
|
|
2019-06-12 12:00:50 +02:00
|
|
|
if platform == 'windows':
|
|
|
|
# Avoid Debug build linker errors caused by custom libc++.
|
|
|
|
add_args['use_custom_libcxx'] = False
|
|
|
|
|
2020-07-16 18:26:53 +02:00
|
|
|
# Avoid dependency on //third_party/perfetto:libperfetto which fails to
|
|
|
|
# build with MSVC libc++.
|
|
|
|
add_args['enable_base_tracing'] = False
|
|
|
|
|
2021-03-04 23:36:57 +01:00
|
|
|
# Don't enable -Wmax-tokens in combination with MSVC libc++.
|
|
|
|
add_args['enable_wmax_tokens'] = False
|
|
|
|
|
2021-06-12 02:54:30 +02:00
|
|
|
# Allow non-component Debug builds for the sandbox.
|
|
|
|
add_args['forbid_non_component_debug_builds'] = False
|
|
|
|
|
2017-07-18 21:25:11 +02:00
|
|
|
result = MergeDicts(args, add_args, {
|
|
|
|
'is_debug': is_debug,
|
|
|
|
'target_cpu': cpu,
|
|
|
|
})
|
|
|
|
|
|
|
|
ValidateArgs(result)
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
2016-10-17 20:00:03 +02:00
|
|
|
def LinuxSysrootExists(cpu):
|
|
|
|
"""
|
|
|
|
Returns true if the sysroot for the specified |cpu| architecture exists.
|
|
|
|
"""
|
|
|
|
# Directory that contains sysroots.
|
|
|
|
sysroot_root = os.path.join(src_dir, 'build', 'linux')
|
|
|
|
# CPU-specific sysroot directory names.
|
2017-06-05 13:07:54 +02:00
|
|
|
# Should match the values in build/config/sysroot.gni.
|
2016-10-17 20:00:03 +02:00
|
|
|
if cpu == 'x86':
|
2018-03-28 18:42:55 +02:00
|
|
|
sysroot_name = 'debian_sid_i386-sysroot'
|
2016-10-17 20:00:03 +02:00
|
|
|
elif cpu == 'x64':
|
2018-03-28 18:42:55 +02:00
|
|
|
sysroot_name = 'debian_sid_amd64-sysroot'
|
2016-10-17 20:00:03 +02:00
|
|
|
elif cpu == 'arm':
|
2018-03-28 18:42:55 +02:00
|
|
|
sysroot_name = 'debian_sid_arm-sysroot'
|
2019-06-13 11:45:50 +02:00
|
|
|
elif cpu == 'arm64':
|
|
|
|
sysroot_name = 'debian_sid_arm64-sysroot'
|
2016-10-17 20:00:03 +02:00
|
|
|
else:
|
|
|
|
raise Exception('Unrecognized sysroot CPU: %s' % cpu)
|
|
|
|
|
|
|
|
return os.path.isdir(os.path.join(sysroot_root, sysroot_name))
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def GetAllPlatformConfigs(build_args):
|
|
|
|
"""
|
|
|
|
Return a map of directory name to GN args for the current platform.
|
|
|
|
"""
|
|
|
|
result = {}
|
|
|
|
|
|
|
|
# Merged args without validation.
|
|
|
|
args = GetMergedArgs(build_args)
|
|
|
|
|
2016-08-25 13:36:39 +02:00
|
|
|
create_debug = True
|
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
# Don't create debug directories for asan builds.
|
2016-08-25 13:36:39 +02:00
|
|
|
if GetArgValue(args, 'is_asan'):
|
|
|
|
create_debug = False
|
|
|
|
msg('Not generating Debug configuration due to is_asan=true')
|
2016-06-23 19:42:00 +02:00
|
|
|
|
2016-10-17 20:00:03 +02:00
|
|
|
supported_cpus = []
|
2016-06-23 19:42:00 +02:00
|
|
|
|
2016-10-17 20:00:03 +02:00
|
|
|
if platform == 'linux':
|
|
|
|
use_sysroot = GetArgValue(args, 'use_sysroot')
|
|
|
|
if use_sysroot:
|
|
|
|
# Only generate configurations for sysroots that have been installed.
|
2019-06-13 11:45:50 +02:00
|
|
|
for cpu in ('x86', 'x64', 'arm', 'arm64'):
|
2016-10-17 20:00:03 +02:00
|
|
|
if LinuxSysrootExists(cpu):
|
|
|
|
supported_cpus.append(cpu)
|
|
|
|
else:
|
2017-05-28 15:04:18 +02:00
|
|
|
msg('Not generating %s configuration due to missing sysroot directory'
|
|
|
|
% cpu)
|
2016-10-17 20:00:03 +02:00
|
|
|
else:
|
|
|
|
supported_cpus = ['x64']
|
2021-07-29 19:29:41 +02:00
|
|
|
elif platform in ('windows', 'mac'):
|
|
|
|
if machine == 'amd64' or os.environ.get('CEF_ENABLE_AMD64', '') == '1':
|
|
|
|
supported_cpus.append('x64')
|
|
|
|
if platform == 'windows':
|
|
|
|
supported_cpus.append('x86')
|
|
|
|
if machine == 'arm64' or os.environ.get('CEF_ENABLE_ARM64', '') == '1':
|
2020-11-20 22:00:56 +01:00
|
|
|
supported_cpus.append('arm64')
|
2016-10-17 20:00:03 +02:00
|
|
|
else:
|
|
|
|
raise Exception('Unsupported platform')
|
2016-09-10 03:03:17 +02:00
|
|
|
|
2021-07-29 19:29:41 +02:00
|
|
|
if len(supported_cpus) == 0:
|
|
|
|
raise Exception('No supported architectures')
|
|
|
|
|
2016-10-17 20:00:03 +02:00
|
|
|
for cpu in supported_cpus:
|
2016-08-25 13:36:39 +02:00
|
|
|
if create_debug:
|
2016-10-17 20:00:03 +02:00
|
|
|
result['Debug_GN_' + cpu] = GetConfigArgs(args, True, cpu)
|
|
|
|
result['Release_GN_' + cpu] = GetConfigArgs(args, False, cpu)
|
2016-06-23 19:42:00 +02:00
|
|
|
|
2020-10-08 21:54:42 +02:00
|
|
|
if platform in ('windows', 'mac') and GetArgValue(args,
|
|
|
|
'is_official_build'):
|
2017-07-18 21:25:11 +02:00
|
|
|
# Build cef_sandbox.lib with a different configuration.
|
|
|
|
if create_debug:
|
2018-07-27 23:28:12 +02:00
|
|
|
result['Debug_GN_' + cpu + '_sandbox'] = GetConfigArgsSandbox(
|
|
|
|
platform, args, True, cpu)
|
|
|
|
result['Release_GN_' + cpu + '_sandbox'] = GetConfigArgsSandbox(
|
|
|
|
platform, args, False, cpu)
|
2017-07-18 21:25:11 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
return result
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
def GetConfigFileContents(args):
|
|
|
|
"""
|
|
|
|
Generate config file contents for the arguments.
|
|
|
|
"""
|
|
|
|
pairs = []
|
|
|
|
for k in sorted(args.keys()):
|
2016-10-29 02:27:55 +02:00
|
|
|
pairs.append("%s=%s" % (k, GetValueString(args[k])))
|
2016-06-23 19:42:00 +02:00
|
|
|
return "\n".join(pairs)
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
# Program entry point.
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# Allow override of the platform via the command-line for testing.
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
platform = sys.argv[1]
|
2020-08-29 00:39:23 +02:00
|
|
|
if not platform in ('linux', 'mac', 'windows'):
|
2020-01-09 14:49:11 +01:00
|
|
|
sys.stderr.write('Usage: %s <platform>\n' % sys.argv[0])
|
2016-06-23 19:42:00 +02:00
|
|
|
sys.exit()
|
|
|
|
|
2020-01-09 14:49:11 +01:00
|
|
|
print('Platform: %s' % platform)
|
2016-06-23 19:42:00 +02:00
|
|
|
|
|
|
|
# Dump the configuration based on platform and environment.
|
|
|
|
configs = GetAllPlatformConfigs({})
|
|
|
|
for dir, config in configs.items():
|
2020-01-09 14:49:11 +01:00
|
|
|
print('\n\nout/%s:\n' % dir)
|
|
|
|
print(GetConfigFileContents(config))
|