Generate pack header files using GN (issue #1403)

This commit is contained in:
Marshall Greenblatt 2016-07-20 16:40:23 -04:00
parent 0e940c4128
commit 88a8dad9c9
4 changed files with 119 additions and 36 deletions

View File

@ -535,13 +535,9 @@ static_library("libcef_static") {
] ]
deps = [ deps = [
# Generate pack files and make include paths for grit headers discoverable. # Generate pack files and associated CEF header files.
":pak", ":make_pack_header_resources",
":pak_100_percent", ":make_pack_header_strings",
":pak_200_percent",
":pak_devtools",
":pak_extensions",
":repack_locales_pack",
# Generate API bindings for extensions. # Generate API bindings for extensions.
# TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See # TODO(cef): Enable if/when CEF exposes its own Mojo APIs. See
@ -849,7 +845,11 @@ static_library("libcef_static") {
config("libcef_dll_wrapper_config") { config("libcef_dll_wrapper_config") {
include_dirs = [ include_dirs = [
".", ".",
# Source files included in the binary distrib use include paths relative to
# the tests directory.
"tests", "tests",
# For generated include headers.
"$root_out_dir/includes",
] ]
defines = [ "USING_CEF_SHARED" ] defines = [ "USING_CEF_SHARED" ]
} }
@ -983,7 +983,10 @@ repack("pak_devtools") {
"$root_gen_dir/blink/devtools_resources.pak", "$root_gen_dir/blink/devtools_resources.pak",
] ]
deps = [ # 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 = [
"//content/browser/devtools:resources", "//content/browser/devtools:resources",
] ]
@ -1078,6 +1081,69 @@ repack("pak") {
output = "$root_out_dir/cef.pak" output = "$root_out_dir/cef.pak"
} }
# Helper for generating pack header files.
template("make_pack_header") {
assert(defined(invoker.header))
assert(defined(invoker.inputs))
action("make_pack_header_${target_name}") {
script = "tools/make_pack_header.py"
inputs = invoker.inputs
outputs = [ invoker.header ]
args = rebase_path(outputs, root_build_dir) +
rebase_path(inputs, root_build_dir)
deps = [
# List all targets that generate pack files here. The grit targets that
# generate |inputs| will be picked up via public_deps.
":pak",
":pak_100_percent",
":pak_200_percent",
":pak_devtools",
":pak_extensions",
":repack_locales_pack",
]
}
}
# Generate cef_pack_resources.h.
make_pack_header("resources") {
header = "$root_out_dir/includes/include/cef_pack_resources.h"
inputs = [
"$root_gen_dir/blink/grit/devtools_resources.h",
"$root_gen_dir/blink/public/resources/grit/blink_resources.h",
"$root_gen_dir/chrome/grit/browser_resources.h",
"$root_gen_dir/chrome/grit/common_resources.h",
"$root_gen_dir/chrome/grit/component_extension_resources.h",
"$root_gen_dir/content/grit/content_resources.h",
"$root_gen_dir/extensions/grit/extensions_browser_resources.h",
"$root_gen_dir/extensions/grit/extensions_renderer_resources.h",
"$root_gen_dir/extensions/grit/extensions_resources.h",
"$root_gen_dir/net/grit/net_resources.h",
"$root_gen_dir/ui/resources/grit/ui_resources.h",
"$root_gen_dir/ui/resources/grit/webui_resources.h",
"$root_gen_dir/ui/views/resources/grit/views_resources.h",
"$root_gen_dir/cef/grit/cef_resources.h",
]
}
# Generate cef_pack_strings.h.
make_pack_header("strings") {
header = "$root_out_dir/includes/include/cef_pack_strings.h"
inputs = [
"$root_gen_dir/chrome/grit/generated_resources.h",
"$root_gen_dir/chrome/grit/locale_settings.h",
"$root_gen_dir/chrome/grit/platform_locale_settings.h",
"$root_gen_dir/components/strings/grit/components_strings.h",
"$root_gen_dir/content/app/strings/grit/content_strings.h",
"$root_gen_dir/extensions/strings/grit/extensions_strings.h",
"$root_gen_dir/ui/strings/grit/ui_strings.h",
"$root_gen_dir/cef/grit/cef_strings.h",
]
}
# #
# libcef dll/framework target. # libcef dll/framework target.

10
cef.gyp
View File

@ -469,6 +469,8 @@
'.', '.',
# Necessary to allow unittest files to access cefclient files. # Necessary to allow unittest files to access cefclient files.
'tests', 'tests',
# For generated include headers.
'<(PRODUCT_DIR)/includes',
], ],
'conditions': [ 'conditions': [
[ 'OS=="win"', { [ 'OS=="win"', {
@ -870,7 +872,7 @@
'<@(header_inputs)', '<@(header_inputs)',
], ],
'outputs': [ 'outputs': [
'include/cef_pack_resources.h', '<(PRODUCT_DIR)/includes/include/cef_pack_resources.h',
], ],
'action': ['python', '<(make_pack_header_path)', '<@(_outputs)', 'action': ['python', '<(make_pack_header_path)', '<@(_outputs)',
'<@(header_inputs)'], '<@(header_inputs)'],
@ -894,7 +896,7 @@
'<@(header_inputs)', '<@(header_inputs)',
], ],
'outputs': [ 'outputs': [
'include/cef_pack_strings.h', '<(PRODUCT_DIR)/includes/include/cef_pack_strings.h',
], ],
'action': ['python', '<(make_pack_header_path)', '<@(_outputs)', 'action': ['python', '<(make_pack_header_path)', '<@(_outputs)',
'<@(header_inputs)'], '<@(header_inputs)'],
@ -1616,7 +1618,7 @@
'.', '.',
# cefclient includes are relative to the tests directory to make # cefclient includes are relative to the tests directory to make
# creation of binary releases easier. # creation of binary releases easier.
'tests' 'tests',
], ],
'link_settings': { 'link_settings': {
'libraries': [ 'libraries': [
@ -1765,6 +1767,8 @@
'.', '.',
# Necessary to allow unittest files to access cefclient files. # Necessary to allow unittest files to access cefclient files.
'tests', 'tests',
# For generated include headers.
'<(PRODUCT_DIR)/includes',
], ],
'sources': [ 'sources': [
'tests/cefclient/browser/resource_util.cc', 'tests/cefclient/browser/resource_util.cc',

View File

@ -40,8 +40,6 @@
'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h', 'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h',
'include/base/internal/cef_thread_checker_impl.h', 'include/base/internal/cef_thread_checker_impl.h',
'include/cef_base.h', 'include/cef_base.h',
'include/cef_pack_resources.h',
'include/cef_pack_strings.h',
'include/cef_version.h', 'include/cef_version.h',
'include/internal/cef_export.h', 'include/internal/cef_export.h',
'include/internal/cef_logging_internal.h', 'include/internal/cef_logging_internal.h',

View File

@ -388,6 +388,26 @@ cef_paths = cef_paths['variables']
cef_paths2 = eval_file(os.path.join(cef_dir, 'cef_paths2.gypi')) cef_paths2 = eval_file(os.path.join(cef_dir, 'cef_paths2.gypi'))
cef_paths2 = cef_paths2['variables'] cef_paths2 = cef_paths2['variables']
# Determine the build directory suffix.
build_dir_suffix = ''
if use_gn:
# CEF uses a consistent directory naming scheme for GN via
# GetAllPlatformConfigs in 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'
# Determine the build directory paths.
out_dir = os.path.join(src_dir, 'out')
build_dir_debug = os.path.join(out_dir, 'Debug' + build_dir_suffix)
build_dir_release = os.path.join(out_dir, 'Release' + build_dir_suffix)
if mode == 'standard' or mode == 'minimal': if mode == 'standard' or mode == 'minimal':
# create the include directory # create the include directory
include_dir = os.path.join(output_dir, 'include') include_dir = os.path.join(output_dir, 'include')
@ -413,6 +433,20 @@ if mode == 'standard' or mode == 'minimal':
transfer_gypi_files(cef_dir, cef_paths['autogen_capi_includes'], \ transfer_gypi_files(cef_dir, cef_paths['autogen_capi_includes'], \
'include/', include_dir, options.quiet) 'include/', include_dir, options.quiet)
# Transfer generated include files.
generated_includes = [
'cef_pack_resources.h',
'cef_pack_strings.h',
]
for include in generated_includes:
# Debug and Release build should be the same so grab whichever exists.
src_path = os.path.join(build_dir_release, 'includes', 'include', include)
if not os.path.exists(src_path):
src_path = os.path.join(build_dir_debug, 'includes', 'include', include)
if not os.path.exists(src_path):
raise Exception('Missing generated header file: %s' % include)
copy_file(src_path, os.path.join(include_dir, include), options.quiet)
# transfer common libcef_dll_wrapper files # transfer common libcef_dll_wrapper files
transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_base'], \ transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_base'], \
'libcef_dll/', libcef_dll_dir, options.quiet) 'libcef_dll/', libcef_dll_dir, options.quiet)
@ -484,28 +518,6 @@ if mode == 'standard':
copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \ copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \
os.path.join(output_dir, 'cef_paths.gypi'), options.quiet) os.path.join(output_dir, 'cef_paths.gypi'), options.quiet)
# Determine the build directory suffix.
build_dir_suffix = ''
if use_gn:
# CEF uses a consistent directory naming scheme for GN via
# GetAllPlatformConfigs in 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'
# Determine the build directory paths.
out_dir = os.path.join(src_dir, 'out')
build_dir_debug = os.path.join(out_dir, 'Debug' + build_dir_suffix)
build_dir_release = os.path.join(out_dir, 'Release' + build_dir_suffix)
if platform == 'windows': if platform == 'windows':
binaries = [ binaries = [
'd3dcompiler_47.dll', 'd3dcompiler_47.dll',
@ -525,8 +537,11 @@ if platform == 'windows':
'obj\\base\\base_static.lib', 'obj\\base\\base_static.lib',
'obj\\cef\\cef_sandbox.lib', 'obj\\cef\\cef_sandbox.lib',
'obj\\base\\third_party\\dynamic_annotations\\dynamic_annotations.lib', 'obj\\base\\third_party\\dynamic_annotations\\dynamic_annotations.lib',
'obj\\sandbox\\sandbox.lib',
] ]
if use_gn:
sandbox_libs.append('obj\\sandbox\\win\\sandbox.lib')
else:
sandbox_libs.append('obj\\sandbox\\sandbox.lib')
valid_build_dir = None valid_build_dir = None