2012-04-03 03:34:16 +02:00
|
|
|
# Copyright (c) 2011 The Chromium Embedded Framework Authors.
|
|
|
|
# Portions copyright (c) 2006-2008 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.
|
|
|
|
|
2020-01-12 16:48:13 +01:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
2024-05-03 21:33:38 +02:00
|
|
|
from file_util import make_dir, write_file_if_changed
|
2012-04-03 03:34:16 +02:00
|
|
|
from gclient_util import *
|
2016-06-23 19:42:00 +02:00
|
|
|
from gn_args import GetAllPlatformConfigs, GetConfigFileContents
|
2016-10-27 18:04:25 +02:00
|
|
|
import issue_1999
|
2020-01-12 16:48:13 +01:00
|
|
|
import os
|
|
|
|
import sys
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2014-12-08 21:06:16 +01:00
|
|
|
# The CEF directory is the parent directory of _this_ script.
|
2012-04-03 03:34:16 +02:00
|
|
|
cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
2014-12-08 21:06:16 +01:00
|
|
|
# The src directory is the parent directory of the CEF directory.
|
|
|
|
src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir))
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
# Determine the platform.
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
platform = 'windows'
|
|
|
|
elif sys.platform == 'darwin':
|
2020-08-29 00:39:23 +02:00
|
|
|
platform = 'mac'
|
2016-06-23 19:42:00 +02:00
|
|
|
elif sys.platform.startswith('linux'):
|
|
|
|
platform = 'linux'
|
|
|
|
else:
|
2020-01-12 16:48:13 +01:00
|
|
|
print('Unknown operating system platform')
|
2016-06-23 19:42:00 +02:00
|
|
|
sys.exit()
|
|
|
|
|
2020-01-12 16:48:13 +01:00
|
|
|
print("\nGenerating CEF version header file...")
|
2020-04-30 21:59:23 +02:00
|
|
|
cmd = [sys.executable, 'tools/make_version_header.py', 'include/cef_version.h']
|
2016-08-08 13:31:57 +02:00
|
|
|
RunAction(cef_dir, cmd)
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2020-01-12 16:48:13 +01:00
|
|
|
print("\nPatching build configuration and source files for CEF...")
|
|
|
|
cmd = [sys.executable, 'tools/patcher.py']
|
2016-08-08 13:31:57 +02:00
|
|
|
RunAction(cef_dir, cmd)
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2020-01-16 15:07:55 +01:00
|
|
|
if platform == 'linux' and 'CEF_INSTALL_SYSROOT' in os.environ:
|
|
|
|
for arch in os.environ['CEF_INSTALL_SYSROOT'].split(','):
|
|
|
|
if len(arch) == 0:
|
|
|
|
continue
|
|
|
|
print("\nInstalling %s sysroot environment..." % arch)
|
|
|
|
cmd = [
|
|
|
|
sys.executable, 'build/linux/sysroot_scripts/install-sysroot.py',
|
|
|
|
'--arch', arch
|
|
|
|
]
|
|
|
|
RunAction(src_dir, cmd)
|
|
|
|
|
2020-01-12 16:48:13 +01:00
|
|
|
print("\nGenerating CEF project files...")
|
2014-06-10 19:01:49 +02:00
|
|
|
|
2016-06-23 19:42:00 +02:00
|
|
|
gn_args = {}
|
|
|
|
|
|
|
|
if platform == 'windows':
|
|
|
|
# Force use of the locally installed version of Visual Studio.
|
|
|
|
if not 'DEPOT_TOOLS_WIN_TOOLCHAIN' in os.environ:
|
|
|
|
os.environ['DEPOT_TOOLS_WIN_TOOLCHAIN'] = '0'
|
|
|
|
|
2021-01-06 00:05:45 +01:00
|
|
|
# By default GN+Ninja on Windows expects Visual Studio and Windows SDK to be
|
|
|
|
# installed on the local machine. To build when Visual Studio and/or SDK is
|
|
|
|
# extracted to a directory but not installed (e.g. via a custom toolchain) set
|
|
|
|
# the following environment variables:
|
2016-08-08 13:31:57 +02:00
|
|
|
#
|
2016-08-26 12:08:37 +02:00
|
|
|
# o Enable use of a custom toolchain on Windows.
|
|
|
|
#
|
2016-06-23 19:42:00 +02:00
|
|
|
# set WIN_CUSTOM_TOOLCHAIN=1
|
2016-08-26 12:08:37 +02:00
|
|
|
#
|
|
|
|
# o Used by tools/msvs_env.bat to configure the MSVS tools environment.
|
|
|
|
# Should be set to "none" because VC variables for CEF will be set via
|
|
|
|
# INCLUDE/LIB/PATH.
|
|
|
|
#
|
|
|
|
# set CEF_VCVARS=none
|
|
|
|
#
|
|
|
|
# o Used by the following scripts:
|
|
|
|
# (a) build/vs_toolchain.py SetEnvironmentAndGetRuntimeDllDirs when
|
|
|
|
# determining whether to copy VS runtime binaries to the output directory.
|
|
|
|
# If GYP_MSVS_OVERRIDE_PATH exists then binaries will not be copied and
|
|
|
|
# should instead be discoverable via the PATH env variable.
|
|
|
|
# (b) build/toolchain/win/setup_toolchain.py _LoadToolchainEnv when
|
|
|
|
# writing environment.* files that specify INCLUDE/LIB/PATH values. If
|
2021-01-06 00:05:45 +01:00
|
|
|
# vcvarsall.bat [1] exists then environment variables will be derived from
|
|
|
|
# there and the 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-26 12:22:22 +02:00
|
|
|
# TODO(cef): Rename to VS_ROOT and VS_VERSION after Chromium cleans up GYP
|
2016-08-26 12:08:37 +02:00
|
|
|
# dependencies.
|
|
|
|
#
|
|
|
|
# set GYP_MSVS_OVERRIDE_PATH=<VS root directory>
|
|
|
|
# set GYP_MSVS_VERSION=<VS version>
|
|
|
|
#
|
|
|
|
# o Used to configure GN arguments in this script.
|
|
|
|
#
|
2016-08-08 13:31:57 +02:00
|
|
|
# set VS_CRT_ROOT=<VS CRT root directory>
|
2016-06-23 19:42:00 +02:00
|
|
|
# set SDK_ROOT=<Platform SDK root directory>
|
2023-03-02 18:12:02 +01:00
|
|
|
# set SDK_VERSION=<Platform SDK version>
|
2016-08-26 12:08:37 +02:00
|
|
|
#
|
2021-01-06 00:05:45 +01:00
|
|
|
# o Used by various scripts as described above. These values are optional when
|
|
|
|
# vcvarsall.bat [1] exists.
|
2016-08-26 12:08:37 +02:00
|
|
|
#
|
2016-06-23 19:42:00 +02:00
|
|
|
# set INCLUDE=<VS include paths>
|
|
|
|
# set LIB=<VS library paths>
|
2016-08-08 13:31:57 +02:00
|
|
|
# set PATH=<VS executable paths>
|
|
|
|
#
|
2016-08-26 12:08:37 +02:00
|
|
|
# See tools/depot_tools/win_toolchain/package_from_installed.py for an example
|
|
|
|
# packaging script along with required directory contents and INCLUDE/LIB/PATH
|
|
|
|
# values.
|
|
|
|
#
|
2021-01-06 00:05:45 +01:00
|
|
|
# [1] The vcvarsall.bat script must exist in "%GYP_MSVS_OVERRIDE_PATH%\VC\" or
|
|
|
|
# "%GYP_MSVS_OVERRIDE_PATH%\VC\Auxiliary\Build\". If the Windows SDK is not
|
|
|
|
# installed (e.g. not discoverable via the Windows registry) then
|
|
|
|
# "%GYP_MSVS_OVERRIDE_PATH%\Common7\Tools\vsdevcmd\core\winsdk.bat" must be
|
|
|
|
# patched to support discovery via SDK_ROOT as described in
|
2023-03-13 18:45:20 +01:00
|
|
|
# https://github.com/chromiumembedded/cef/issues/2773#issuecomment-1465019898.
|
2021-01-06 00:05:45 +01:00
|
|
|
#
|
2016-06-23 19:42:00 +02:00
|
|
|
if bool(int(os.environ.get('WIN_CUSTOM_TOOLCHAIN', '0'))):
|
|
|
|
required_vars = [
|
2017-05-28 15:04:18 +02:00
|
|
|
'CEF_VCVARS',
|
|
|
|
'GYP_MSVS_OVERRIDE_PATH',
|
|
|
|
'GYP_MSVS_VERSION',
|
|
|
|
'VS_CRT_ROOT',
|
|
|
|
'SDK_ROOT',
|
2023-03-02 18:12:02 +01:00
|
|
|
'SDK_VERSION',
|
2016-06-23 19:42:00 +02:00
|
|
|
]
|
|
|
|
for var in required_vars:
|
|
|
|
if not var in os.environ.keys():
|
|
|
|
raise Exception('%s environment variable must be set' % var)
|
|
|
|
|
2016-08-08 13:31:57 +02:00
|
|
|
# Windows custom toolchain requirements. See comments in gn_args.py.
|
2016-08-26 12:08:37 +02:00
|
|
|
gn_args['visual_studio_path'] = os.environ['GYP_MSVS_OVERRIDE_PATH']
|
|
|
|
gn_args['visual_studio_version'] = os.environ['GYP_MSVS_VERSION']
|
2016-08-08 13:31:57 +02:00
|
|
|
gn_args['visual_studio_runtime_dirs'] = os.environ['VS_CRT_ROOT']
|
|
|
|
gn_args['windows_sdk_path'] = os.environ['SDK_ROOT']
|
2023-03-02 18:12:02 +01:00
|
|
|
gn_args['windows_sdk_version'] = os.environ['SDK_VERSION']
|
2016-08-08 13:31:57 +02:00
|
|
|
|
|
|
|
configs = GetAllPlatformConfigs(gn_args)
|
|
|
|
for dir, config in configs.items():
|
|
|
|
# Create out directories and write the args.gn file.
|
|
|
|
out_path = os.path.join(src_dir, 'out', dir)
|
|
|
|
make_dir(out_path, False)
|
|
|
|
args_gn_path = os.path.join(out_path, 'args.gn')
|
|
|
|
args_gn_contents = GetConfigFileContents(config)
|
2024-05-03 21:33:38 +02:00
|
|
|
write_file_if_changed(args_gn_path, args_gn_contents)
|
2016-08-08 13:31:57 +02:00
|
|
|
|
|
|
|
# Generate the Ninja config.
|
2017-05-28 15:04:18 +02:00
|
|
|
cmd = ['gn', 'gen', os.path.join('out', dir)]
|
2016-08-08 13:31:57 +02:00
|
|
|
if 'GN_ARGUMENTS' in os.environ.keys():
|
|
|
|
cmd.extend(os.environ['GN_ARGUMENTS'].split(' '))
|
|
|
|
RunAction(src_dir, cmd)
|
2016-10-27 18:04:25 +02:00
|
|
|
if platform == 'windows':
|
|
|
|
issue_1999.apply(out_path)
|