Commit d0a2e217 authored by Marshall Greenblatt's avatar Marshall Greenblatt
Browse files

Add GN configuration (issue #1403)

parent 05ee60b7
This diff is collapsed.
# Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
# 2014 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.
#
# This is a copy of src/chrome/chrome_repack_locales.gni with the necessary
# modifications to meet CEF's requirements.
import("//build/config/chrome_build.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//tools/grit/repack.gni")
# Arguments:
#
# locale
# Internal name of locale. e.g. "pt-BR"
#
# output
# Output file name.
#
# visibility
# Normal meaning.
template("_repack_one_locale") {
locale = invoker.locale
repack(target_name) {
visibility = invoker.visibility
# Each input pak file should also have a deps line for completeness.
sources = [
"${root_gen_dir}/cef/cef_strings_${locale}.pak",
"${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak",
"${root_gen_dir}/components/strings/components_locale_settings_${locale}.pak",
"${root_gen_dir}/components/strings/components_strings_${locale}.pak",
"${root_gen_dir}/content/app/strings/content_strings_${locale}.pak",
"${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak",
"${root_gen_dir}/ui/strings/app_locale_settings_${locale}.pak",
"${root_gen_dir}/ui/strings/ui_strings_${locale}.pak",
]
# Use public_deps so that generated grit headers are discoverable from
# the libcef_static target. Grit deps that generate .cc files must be
# listed both here and in the libcef_static target.
public_deps = [
":cef_strings",
"//chrome/app/resources:platform_locale_settings",
"//components/strings:components_locale_settings",
"//components/strings:components_strings",
"//content/app/strings",
"//extensions/strings",
"//ui/strings:app_locale_settings",
"//ui/strings:ui_strings",
]
output = invoker.output
}
}
# Creates an action to call the repack_locales script.
#
# The GYP version generates the locales in the "gen" directory and then copies
# it to the root build directory. This isn't easy to express in a GN copy
# rule since the files on Mac have a complex structure. So we generate the
# files into the final place and skip the "gen" directory.
#
# This template uses GN's looping constructs to avoid the complex call to
# chrome/tools/build/repack_locales.py which wraps the repack commands in the
# GYP build.
#
# Arguments
#
# input_locales
# List of locale names to use as inputs.
#
# output_locales
# A list containing the corresponding output names for each of the
# input names. Mac uses different names in some cases.
#
# visibility
template("cef_repack_locales") {
# This is the name of the group below that will collect all the invidual
# locale targets. External targets will depend on this.
group_target_name = target_name
# GN's subscript is too stupid to do invoker.output_locales[foo] so we need
# to make a copy and do output_locales[foo].
output_locales = invoker.output_locales
# Collects all targets the loop generates.
locale_targets = []
# This loop iterates over the input locales and also keeps a counter so it
# can simultaneously iterate over the output locales (using GN's very
# limited looping capabilities).
current_index = 0
foreach(input_locale, invoker.input_locales) {
output_locale = output_locales[current_index]
# Compute the name of the target for the current file. Save it for the deps.
current_name = "${target_name}_${input_locale}"
locale_targets += [ ":$current_name" ]
_repack_one_locale(current_name) {
visibility = [ ":$group_target_name" ]
locale = input_locale
# Compute the output name. Mac uses a different location.
if (is_mac || is_ios) {
output = "${root_gen_dir}/repack/locales/${output_locale}.pak"
} else {
output = "${root_out_dir}/locales/${output_locale}.pak"
}
}
current_index = current_index + 1
}
# The group that external targets depend on which collects all deps.
group(group_target_name) {
forward_variables_from(invoker, [ "visibility" ])
public_deps = locale_targets
}
}
......@@ -18,9 +18,9 @@
#include "base/threading/thread_restrictions.h"
#include "content/public/common/file_chooser_params.h"
#include "grit/cef_strings.h"
#include "grit/ui_strings.h"
#include "net/base/mime_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/strings/grit/ui_strings.h"
namespace {
......
......@@ -17,10 +17,10 @@
#include "base/win/registry.h"
#include "base/win/scoped_comptr.h"
#include "grit/cef_strings.h"
#include "grit/ui_strings.h"
#include "net/base/mime_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/win/shell.h"
#include "ui/strings/grit/ui_strings.h"
namespace {
......
# Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
# 2014 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.
import("//build/json_schema_api.gni")
import("schemas.gni")
json_schema_api("api") {
schemas = true
bundle = true
configs = [ "//build/config:precompiled_headers" ]
bundle_name = "Chrome"
deps = schema_dependencies
}
json_schema_api("api_registration") {
impl_dir = "//cef/libcef/browser/extensions/api"
bundle_registration = true
configs = [ "//build/config:precompiled_headers" ]
bundle_name = "Chrome"
deps = [
":api",
]
deps += schema_dependencies
}
# Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
# 2014 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.
gypi_values = exec_script("//build/gypi_to_gn.py",
[ rebase_path("schemas.gypi") ],
"scope",
[ "schemas.gypi" ])
sources = gypi_values.schema_files
uncompiled_sources = gypi_values.non_compiled_schema_files
root_namespace = "extensions::api::%(namespace)s"
schema_include_rules = "//cef/libcef/browser/extensions/api:extensions::api::%(namespace)s"
schema_dependencies = [ "//extensions/common/api" ]
......@@ -7,14 +7,37 @@
patches = [
{
# Necessary for grit integration
# Necessary for grit integration.
'name': 'gritsettings',
'path': '../tools/gritsettings/',
},
{
# Necessary for GN integration.
#
# Move chrome target locales output to a chrome/ directory to avoid
# conflicts with the CEF configuration.
#
# Add public_deps support to the GN repack template.
# TODO(cef): Remove this once all grit includes are relative to the "gen"
# directory.
# https://bugs.chromium.org/p/chromium/issues/detail?id=623085
#
# Use a unique output path for the compile_xibs template on Mac.
# https://bugs.chromium.org/p/chromium/issues/detail?id=623237
#
# Fix broken GN configuration for enable_print_preview = false on Mac.
# https://bugs.chromium.org/p/chromium/issues/detail?id=617477
#
# Support custom VS toolchain on Windows.
# https://bugs.chromium.org/p/chromium/issues/detail?id=623342
'name': 'gn_config',
'path': '../',
},
{
# Disable use of the sysroot image for CEF because it does not include
# the GTK dependency required by cefclient. It would be nice to enable
# this functionality in the future. See http://crbug.com/504446.
# TODO(cef): Remove this patch when GYP support is removed.
'name': 'build',
'path': '../build/',
},
......@@ -36,6 +59,7 @@ patches = [
{
# Fix ninja output for localization directories on OS X.
# https://bugs.chromium.org/p/gyp/issues/detail?id=331
# TODO(cef): Remove this patch when GYP support is removed.
'name': 'gyp_331',
'path': '../tools/gyp/pylib/',
},
......
diff --git .gn .gn
index 3bd6bc4..0abf820 100644
--- .gn
+++ .gn
@@ -247,6 +247,8 @@ exec_script_whitelist = [
"//build/toolchain/win/BUILD.gn",
"//build/util/branding.gni",
"//build/util/version.gni",
+ "//cef/BUILD.gn",
+ "//cef/libcef/common/extensions/api/schemas.gni",
"//chrome/android/BUILD.gn",
"//chrome/browser/BUILD.gn",
"//chrome/browser/chromeos/BUILD.gn",
diff --git BUILD.gn BUILD.gn
index 0a7fe56..467f536 100644
--- BUILD.gn
+++ BUILD.gn
@@ -206,6 +206,7 @@ group("both_gn_and_gyp") {
# and whether there should be other targets that are iOS-only and missing.
deps += [
"//cc:cc_unittests",
+ "//cef",
"//chrome/test:telemetry_perf_unittests",
"//chrome/test:unit_tests",
"//components:components_browsertests",
diff --git build/config/features.gni build/config/features.gni
index 9d33d91..d460e86 100644
--- build/config/features.gni
+++ build/config/features.gni
@@ -148,7 +148,7 @@ enable_web_speech = !is_android && !is_ios
enable_task_manager = !is_ios && !is_android
-enable_themes = !is_android && !is_ios
+enable_themes = !is_android && !is_ios && !is_linux
# Whether we are using the rlz library or not. Platforms like Android send
# rlz codes for searches but do not use the library.
diff --git build/config/mac/base_rules.gni build/config/mac/base_rules.gni
index 76610cc..7d17aba 100644
--- build/config/mac/base_rules.gni
+++ build/config/mac/base_rules.gni
@@ -366,13 +366,13 @@ template("compile_xibs") {
script = "//build/config/mac/compile_xib.py"
sources = invoker.sources
outputs = [
- "$target_gen_dir/{{source_name_part}}.nib",
+ "$target_gen_dir/$target_name/{{source_name_part}}.nib",
]
args = [
"--input",
"{{source}}",
"--output",
- rebase_path("$target_gen_dir/{{source_name_part}}.nib"),
+ rebase_path("$target_gen_dir/$target_name/{{source_name_part}}.nib"),
] + ibtool_flags
}
}
diff --git build/config/win/visual_studio_version.gni build/config/win/visual_studio_version.gni
index 05b369f..8be3a47 100644
--- build/config/win/visual_studio_version.gni
+++ build/config/win/visual_studio_version.gni
@@ -12,9 +12,8 @@ declare_args() {
# Use "2013" for Visual Studio 2013, or "2013e" for the Express version.
visual_studio_version = ""
- # Directory of the Windows driver kit. If visual_studio_path is empty, this
- # will be auto-filled.
- wdk_path = ""
+ # Path to Visual Studio runtime libraries.
+ visual_studio_runtime_dirs = ""
# Full path to the Windows SDK, not including a backslash at the end.
# This value is the default location, override if you have a different
@@ -33,12 +32,11 @@ if (visual_studio_path == "") {
visual_studio_path = toolchain_data.vs_path
windows_sdk_path = toolchain_data.sdk_path
visual_studio_version = toolchain_data.vs_version
- wdk_path = toolchain_data.wdk_dir
visual_studio_runtime_dirs = toolchain_data.runtime_dirs
} else {
assert(visual_studio_version != "",
"You must set the visual_studio_version if you set the path")
- assert(wdk_path != "",
- "You must set the wdk_path if you set the visual studio path")
- visual_studio_runtime_dirs = []
+ assert(visual_studio_runtime_dirs != "",
+ "You must set the visual_studio_runtime_dirs if you set the visual " +
+ "studio path")
}
diff --git build/toolchain/win/setup_toolchain.py build/toolchain/win/setup_toolchain.py
index d58cb85..fd608ba 100644
--- build/toolchain/win/setup_toolchain.py
+++ build/toolchain/win/setup_toolchain.py
@@ -124,11 +124,14 @@ def _LoadToolchainEnv(cpu, sdk_dir):
script_path = os.path.normpath(os.path.join(
os.environ['GYP_MSVS_OVERRIDE_PATH'],
'VC/vcvarsall.bat'))
- if not os.path.exists(script_path):
- raise Exception('%s is missing - make sure VC++ tools are installed.' %
- script_path)
- args = [script_path, 'amd64_x86' if cpu == 'x86' else 'amd64']
- variables = _LoadEnvFromBat(args)
+ if os.path.exists(script_path):
+ args = [script_path, 'amd64_x86' if cpu == 'x86' else 'amd64']
+ variables = _LoadEnvFromBat(args)
+ else:
+ variables = []
+ for k in sorted(os.environ.keys()):
+ variables.append('%s=%s' % (str(k), str(os.environ[k])))
+ variables = '\n'.join(variables)
return _ExtractImportantEnvironment(variables)
diff --git chrome/BUILD.gn chrome/BUILD.gn
index fa6cd4c..eaab973 100644
--- chrome/BUILD.gn
+++ chrome/BUILD.gn
@@ -647,7 +647,7 @@ if (is_win) {
]
foreach(locale, locales_as_mac_outputs) {
- sources += [ "$root_gen_dir/repack/locales/$locale.pak" ]
+ sources += [ "$root_gen_dir/chrome/repack/locales/$locale.pak" ]
}
outputs = [
diff --git chrome/chrome_repack_locales.gni chrome/chrome_repack_locales.gni
index 9601dd4..9a7734a 100644
--- chrome/chrome_repack_locales.gni
+++ chrome/chrome_repack_locales.gni
@@ -161,9 +161,9 @@ template("chrome_repack_locales") {
# Compute the output name. Mac uses a different location.
if (is_mac || is_ios) {
- output = "${root_gen_dir}/repack/locales/${output_locale}.pak"
+ output = "${root_gen_dir}/chrome/repack/locales/${output_locale}.pak"
} else {
- output = "${root_out_dir}/locales/${output_locale}.pak"
+ output = "${root_out_dir}/chrome/locales/${output_locale}.pak"
}
}
diff --git chrome/installer/mini_installer/BUILD.gn chrome/installer/mini_installer/BUILD.gn
index a3dcae8..ea60e17 100644
--- chrome/installer/mini_installer/BUILD.gn
+++ chrome/installer/mini_installer/BUILD.gn
@@ -76,7 +76,7 @@ action("archive") {
inputs = [
"$root_out_dir/chrome.exe",
"$root_out_dir/chrome.dll",
- "$root_out_dir/locales/en-US.pak",
+ "$root_out_dir/chrome/locales/en-US.pak",
"$root_out_dir/setup.exe",
release_file,
]
diff --git chrome/test/BUILD.gn chrome/test/BUILD.gn
index e0f20cf..ba7aa8f 100644
--- chrome/test/BUILD.gn
+++ chrome/test/BUILD.gn
@@ -1428,7 +1428,6 @@ if (!is_android) {
if (!enable_print_preview) {
sources -= [
"../browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc",
- "../browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc",
"../browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc",
"../browser/printing/print_preview_dialog_controller_browsertest.cc",
"../browser/printing/print_preview_pdf_generated_browsertest.cc",
diff --git tools/grit/repack.gni tools/grit/repack.gni
index 42087f9..7dd1520 100644
--- tools/grit/repack.gni
+++ tools/grit/repack.gni
@@ -18,6 +18,7 @@ declare_args() {
# File name (single string) of the output file.
#
# deps [optional]
+# public_deps [optional]
# visibility [optional]
# Normal meaning.
template("repack") {
@@ -25,6 +26,7 @@ template("repack") {
forward_variables_from(invoker,
[
"deps",
+ "public_deps",
"testonly",
"visibility",
])
......@@ -169,17 +169,20 @@ def download_and_extract(src, target):
if temporary and os.path.exists(archive_path):
os.remove(archive_path)
def read_config_file(path):
""" Read a configuration file. """
def read_file(path):
""" Read a file. """
if os.path.exists(path):
fp = open(path, 'r')
data = fp.read()
fp.close()
return data
else:
raise Exception("Path does not exist: %s" % (path))
def read_config_file(path):
""" Read a configuration file. """
# Parse the contents.
return eval(data, {'__builtins__': None}, None)
return eval(read_file(path), {'__builtins__': None}, None)
def write_config_file(path, contents):
""" Write a configuration file. """
......@@ -399,7 +402,7 @@ parser.add_option('--build-log-file',
'directory.')
parser.add_option('--x64-build',
action='store_true', dest='x64build', default=False,
help='Build for 64-bit systems (Windows and Mac OS X only).')
help='Create a 64-bit build.')
# Distribution-related options.
parser.add_option('--force-distrib',
......@@ -496,14 +499,6 @@ if options.clientdistrib or options.clientdistribonly:
parser.print_help(sys.stderr)
sys.exit()
if options.x64build and platform != 'windows' and platform != 'macosx':
print 'The x64 build option is only used on Windows and Mac OS X.'
sys.exit()
if platform == 'windows' and not 'GYP_MSVS_VERSION' in os.environ.keys():
print 'You must set the GYP_MSVS_VERSION environment variable on Windows.'
sys.exit()
# CEF branch.
if options.branch != 'trunk' and not options.branch.isdigit():
print 'Invalid branch value: %s' % (options.branch)
......@@ -519,6 +514,29 @@ branch_is_2272_or_newer = (cef_branch == 'trunk' or int(cef_branch) >= 2272)
# True if the requested branch is 2357 or newer.
branch_is_2357_or_newer = (cef_branch == 'trunk' or int(cef_branch) >= 2357)
# True if the requested branch is 2743 or older.
branch_is_2743_or_older = (cef_branch != 'trunk' and int(cef_branch) <= 2743)
# Whether to use GN or GYP. GYP is currently the default.
use_gn = bool(int(os.environ.get('CEF_USE_GN', '0')))
if use_gn:
if branch_is_2743_or_older:
print 'GN is not supported with branch 2743 and older.'
sys.exit()
else:
if options.x64build and platform != 'windows' and platform != 'macosx':
print 'The x64 build option is only used on Windows and Mac OS X.'
sys.exit()
if platform == 'windows' and not 'GYP_MSVS_VERSION' in os.environ.keys():
print 'You must set the GYP_MSVS_VERSION environment variable on Windows.'
sys.exit()
# True if GYP_DEFINES=target_arch=x64 must be set.
gyp_needs_target_arch_x64 = options.x64build and \
(platform == 'windows' or \
(platform == 'macosx' and not branch_is_2272_or_newer))
# Starting with 43.0.2357.126 the DEPS file is now 100% Git and the .DEPS.git
# file is no longer created.
if branch_is_2357_or_newer:
......@@ -531,11 +549,6 @@ 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()
# True if GYP_DEFINES=target_arch=x64 must be set.
gyp_needs_target_arch_x64 = options.x64build and \
(platform == 'windows' or \
(platform == 'macosx' and not branch_is_2272_or_newer))
# Options that force the sources to change.
force_change = options.forceclean or options.forceupdate
......@@ -869,19 +882,21 @@ if not options.nobuild and (chromium_checkout_changed or \
# Building should also force a distribution.
options.forcedistrib = True
# Set GYP environment variables.
os.environ['GYP_GENERATORS'] = 'ninja'
if gyp_needs_target_arch_x64:
if 'GYP_DEFINES' in os.environ.keys():
os.environ['GYP_DEFINES'] = os.environ['GYP_DEFINES'] + ' ' + \
'target_arch=x64'
else:
os.environ['GYP_DEFINES'] = 'target_arch=x64'
if not use_gn:
# Set GYP environment variables.
os.environ['GYP_GENERATORS'] = 'ninja'
if gyp_needs_target_arch_x64:
if 'GYP_DEFINES' in os.environ.keys():
os.environ['GYP_DEFINES'] = os.environ['GYP_DEFINES'] + ' ' + \
'target_arch=x64'
else:
os.environ['GYP_DEFINES'] = 'target_arch=x64'
# Print all build-related environment variables including any that were set
# previously.
for key in os.environ.keys():
if key.startswith('GYP_') or key.startswith('DEPOT_TOOLS_'):
if key.startswith('CEF_') or key.startswith('GN_') or \
key.startswith('GYP_') or key.startswith('DEPOT_TOOLS_'):
msg('%s=%s' % (key, os.environ[key]))
# Run the cef_create_projects script to generate project files.
......@@ -897,21 +912,42 @@ if not options.nobuild and (chromium_checkout_changed or \
target = target + ' cef_unittests'
if platform == 'linux':
target = target + ' chrome_sandbox'
build_dir_suffix = ''
if platform == 'windows' and options.x64build:
build_dir_suffix = '_x64'
if use_gn:
# CEF uses a consistent directory naming scheme for GN via
# GetAllPlatformConfigs in tools/gn_args.py.
if options.x64build:
build_dir_suffix = '_GN_x64'
else:
build_dir_suffix = '_GN_x86'
else:
# GYP outputs both x86 and x64 builds to the same directory on Linux and
# Mac OS X. On Windows it suffixes the directory name for x64 builds.
if platform == 'windows' and options.x64build:
build_dir_suffix = '_x64'
if not options.nodebugbuild:
build_path = os.path.join('out', 'Debug' + build_dir_suffix)
if use_gn:
args_path = os.path.join(chromium_src_dir, build_path, 'args.gn')
if os.path.exists(args_path):
msg(args_path + ' contents:\n' + read_file(args_path))
# Make a CEF Debug build.
run(command + os.path.join('out', 'Debug' + build_dir_suffix) + target, \
chromium_src_dir, depot_tools_dir,
run(command + build_path + target, chromium_src_dir, depot_tools_dir,
os.path.join(download_dir, 'build-%s-debug.log' % (cef_branch)) \
if options.buildlogfile else None)
if not options.noreleasebuild:
build_path = os.path.join('out', 'Release' + build_dir_suffix)
if use_gn:
args_path = os.path.join(chromium_src_dir, build_path, 'args.gn')
if os.path.exists(args_path):
msg(args_path + ' contents:\n' + read_file(args_path))
# Make a CEF Release build.
run(command + os.path.join('out', 'Release' + build_dir_suffix) + target, \
chromium_src_dir, depot_tools_dir,
run(command + build_path + target, chromium_src_dir, depot_tools_dir,
os.path.join(download_dir, 'build-%s-release.log' % (cef_branch)) \
if options.buildlogfile else None)
......
......@@ -4,6 +4,8 @@
# found in the LICENSE file.
from gclient_util import *
from gn_args import GetAllPlatformConfigs, GetConfigFileContents
from file_util import make_dir, write_file
import os, sys
# The CEF directory is the parent directory of _this_ script.
......@@ -11,6 +13,18 @@ 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))
# Determine the platform.
if sys.platform == 'win32':
platform = 'windows'
elif sys.platform == 'darwin':
platform = 'macosx'
elif sys.platform.startswith('linux'):
platform = 'linux'
else:
print 'Unknown operating system platform'
sys.exit()
print "\nGenerating CEF version header file..."
gyper = [ 'python', 'tools/make_version_header.py',
'--header', 'include/cef_version.h',
......@@ -26,81 +40,104 @@ RunAction(cef_dir, patcher)
print "\nGenerating CEF project files..."
# depot_tools currently bundles VS2013 Express Update 1 which causes linker
# errors with Debug builds (see issue #1304). Don't use the bundled version
# unless explicitly requested.
if not 'DEPOT_TOOLS_WIN_TOOLCHAIN' in os.environ.keys():
os.environ['DEPOT_TOOLS_WIN_TOOLCHAIN'] = '0'
# By default GYP+Ninja on Windows expects Visual Studio to be installed on the
# local machine. To build when Visual Studio is extracted to a directory but not
# installed (e.g. via a custom toolchain) you have two options: