blob: 3228260714432aa3cd18dcfd5549825edce45b83 [file] [log] [blame]
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//cobalt/bindings/bindings_templates.gni")
import("//cobalt/browser/idl_files.gni")
import("//cobalt/script/v8c/v8c_variables.gni")
##########################################################
# Configuration variables for bindings generation scripts.
##########################################################
_bindings_output_dir = "$root_gen_dir/bindings/browser"
_bindings_scripts_output_dir = "$_bindings_output_dir/scripts"
# Blink interface info is calculated in two stages. First at a per-component level
# (in Blink this is core or modules) and then these are combined. While Cobalt
# currently does not and may not need to distinguish between components, we adhere to
# Blink's process for simplicity.
_component_info_pickle = "$_bindings_scripts_output_dir/component_info.pickle"
_interfaces_info_individual_pickle =
"$_bindings_scripts_output_dir/interfaces_info_individual.pickle"
_interfaces_info_combined_pickle =
"$_bindings_scripts_output_dir/interfaces_info_overall.pickle"
_global_objects_pickle = "$_bindings_scripts_output_dir/GlobalObjects.pickle"
# Base directory into which generated bindings source files will be
# generated. Directory structure will mirror the directory structure
# that the .idl files came from.
_generated_source_output_dir = "$_bindings_output_dir/source"
# Directory containing generated IDL files.
_generated_idls_output_dir = "$_bindings_output_dir/idl"
# Array of all interfaces that need global constructors.
_global_constructor_interfaces = [
"Window",
"DedicatedWorkerGlobalScope",
"ServiceWorkerGlobalScope",
]
target(final_executable_type, "cobalt") {
sources = [ "main.cc" ]
deps = [
":browser",
":browser_switches",
"//cobalt/base",
"//net",
]
data_deps = [
"//cobalt/network:copy_ssl_certificates",
"//third_party/icu:icudata",
]
if (cobalt_font_package == "empty") {
data_deps += [ "//cobalt/content/fonts:copy_font_data" ]
} else {
data_deps += [
"//cobalt/content/fonts:copy_fonts",
"//cobalt/content/fonts:fonts_xml",
]
}
if (sb_is_evergreen) {
data_deps += [ "//cobalt/updater/version_manifest:copy_version_manifest" ]
}
if (!is_gold) {
data_deps += [
"//cobalt/debug/backend/content:copy_backend_web_files",
"//cobalt/debug/console/content:copy_console_web_files",
"//cobalt/debug/remote/content:copy_remote_web_files",
"//cobalt/speech:speech_testdata",
"//cobalt/webdriver:copy_webdriver_data",
"//third_party/devtools:build_release_devtools",
"//third_party/devtools:copy_devtools_modules",
"//third_party/devtools:copy_inspector_images",
"//third_party/devtools:frontend_protocol_sources",
"//third_party/devtools:supported_css_properties",
]
}
}
##############################
# Bindings generation targets.
##############################
config("bindings_includes") {
include_dirs = [ _generated_source_output_dir ]
}
source_set("browser_switches") {
has_pedantic_warnings = true
sources = [
"switches.cc",
"switches.h",
]
public_deps = [ "//starboard:starboard_headers_only" ]
}
static_library("browser") {
has_pedantic_warnings = true
sources = [
"application.cc",
"application.h",
"browser_module.cc",
"browser_module.h",
"client_hint_headers.cc",
"client_hint_headers.h",
"device_authentication.cc",
"device_authentication.h",
"lifecycle_observer.h",
"on_screen_keyboard_starboard_bridge.cc",
"on_screen_keyboard_starboard_bridge.h",
"render_tree_combiner.cc",
"render_tree_combiner.h",
"screen_shot_writer.cc",
"screen_shot_writer.h",
"service_worker_registry.cc",
"service_worker_registry.h",
"splash_screen.cc",
"splash_screen.h",
"splash_screen_cache.cc",
"splash_screen_cache.h",
"suspend_fuzzer.cc",
"suspend_fuzzer.h",
"system_platform_error_handler.cc",
"system_platform_error_handler.h",
"url_handler.cc",
"url_handler.h",
"user_agent_platform_info.cc",
"user_agent_platform_info.h",
"user_agent_string.cc",
"user_agent_string.h",
"web_module.cc",
"web_module.h",
"web_module_stat_tracker.cc",
"web_module_stat_tracker.h",
]
public_deps = [ "//cobalt/dom" ]
deps = [
":bindings",
":browser_switches",
":generated_bindings",
":generated_types",
"//cobalt/audio",
"//cobalt/base",
"//cobalt/browser/memory_settings:browser_memory_settings",
"//cobalt/browser/metrics",
"//cobalt/build:cobalt_build_id",
"//cobalt/build:cobalt_build_info",
"//cobalt/cache",
"//cobalt/configuration",
"//cobalt/css_parser",
"//cobalt/cssom",
"//cobalt/dom_parser",
"//cobalt/encoding:text_encoding",
"//cobalt/fetch",
"//cobalt/h5vcc",
"//cobalt/input",
"//cobalt/layout",
"//cobalt/loader",
"//cobalt/math",
"//cobalt/media",
"//cobalt/media_capture",
"//cobalt/media_session",
"//cobalt/network",
"//cobalt/overlay_info",
"//cobalt/persistent_storage:persistent_settings",
"//cobalt/render_tree",
"//cobalt/renderer",
"//cobalt/renderer/test/png_utils",
"//cobalt/script",
"//cobalt/script:engine",
"//cobalt/speech",
"//cobalt/storage",
"//cobalt/subtlecrypto",
"//cobalt/system_window",
"//cobalt/trace_event",
"//cobalt/ui_navigation",
"//cobalt/ui_navigation/scroll_engine",
"//cobalt/watchdog",
"//cobalt/web",
"//cobalt/webdriver",
"//cobalt/websocket",
"//cobalt/worker",
"//cobalt/xhr",
"//components/metrics",
"//components/metrics_services_manager",
"//crypto",
"//nb",
"//net",
"//starboard",
"//starboard/common",
"//third_party/icu:icui18n",
"//third_party/protobuf:protobuf_lite",
"//url",
]
if (is_gold) {
defines = [ "COBALT_FORCE_HTTPS" ]
} else {
sources += [
"debug_console.cc",
"debug_console.h",
"lifecycle_console_commands.cc",
"lifecycle_console_commands.h",
]
defines = [ "ENABLE_ABOUT_SCHEME" ]
deps += [
"//cobalt/debug",
"//cobalt/debug:console_command_manager",
]
}
if (sb_is_evergreen) {
deps += [ "//cobalt/updater" ]
} else {
deps += cobalt_platform_dependencies
}
}
target(gtest_target_type, "browser_test") {
testonly = true
has_pedantic_warnings = true
sources = [
"client_hint_headers_test.cc",
"device_authentication_test.cc",
"memory_settings/auto_mem_settings_test.cc",
"memory_settings/auto_mem_test.cc",
"memory_settings/calculations_test.cc",
"memory_settings/memory_settings_test.cc",
"memory_settings/pretty_print_test.cc",
"memory_settings/table_printer_test.cc",
"memory_settings/test_common.h",
"user_agent_string_test.cc",
]
deps = [
":browser",
":browser_switches",
"//cobalt/base",
"//cobalt/browser/memory_settings:browser_memory_settings",
"//cobalt/dom",
"//cobalt/loader",
"//cobalt/math",
"//cobalt/network",
"//cobalt/speech",
"//cobalt/storage",
"//cobalt/test:run_all_unittests",
"//nb",
"//testing/gmock",
"//testing/gtest",
]
}
group("bindings") {
public_configs = [ ":bindings_includes" ]
deps = [
":generated_bindings_sources",
":generated_types_sources",
"//cobalt/h5vcc",
"//cobalt/webdriver",
]
}
idl_compile("generated_bindings") {
sources = source_idl_files
cache_directory = _bindings_scripts_output_dir
component_info = _component_info_pickle
interfaces_info = _interfaces_info_combined_pickle
output_directory = _generated_source_output_dir
header_prefix = "${generated_bindings_prefix}"
# TODO(b/211055528): Missing deps from generated sources.
deps = [
":cached_jinja_templates",
":cached_lex_yacc_tables",
":generated_type_conversion",
":generated_types",
":global_constructors_idls",
":interfaces_info_individual",
":interfaces_info_overall",
"//cobalt/script:engine",
]
public_deps = engine_dependencies
public_configs = [ ":bindings_includes" ]
}
source_set("generated_bindings_sources") {
sources = get_target_outputs(":generated_bindings")
public_deps = [ ":generated_bindings" ]
deps = [
# Ensure that all the files have been generated before trying to compile.
":generated_types",
"//cobalt/h5vcc",
"//cobalt/webdriver",
]
}
idl_compile("generated_types") {
sources = generated_header_idl_files
cache_directory = _bindings_scripts_output_dir
component_info = _component_info_pickle
interfaces_info = _interfaces_info_combined_pickle
output_directory = _generated_source_output_dir
# TODO(b/211055528): Missing deps from generated sources.
deps = [
":cached_jinja_templates",
":cached_lex_yacc_tables",
":global_constructors_idls",
":interfaces_info_individual",
":interfaces_info_overall",
]
public_deps = engine_dependencies
public_configs = [ ":bindings_includes" ]
}
source_set("generated_types_sources") {
sources = get_target_outputs(":generated_types")
public_deps = [ ":generated_types" ]
deps = [
# Ensure that all the files have been generated before trying to compile.
":generated_bindings",
]
}
generate_type_conversion("generated_type_conversion") {
# TODO(b/211055528): Missing deps from generated sources.
deps = [
":cached_jinja_templates",
":cached_lex_yacc_tables",
":global_constructors_idls",
":interfaces_info_overall",
]
# Generated IDL files that define all the constructors that are on the global
# scope objects.
global_names_idl_path = _generated_idls_output_dir
interfaces = _global_constructor_interfaces
inputs = [ _interfaces_info_combined_pickle ]
inputs += source_idl_files
inputs += generated_header_idl_files
cache_directory = _bindings_scripts_output_dir
output_dir = _generated_source_output_dir
interfaces_info = _interfaces_info_combined_pickle
component_info = _component_info_pickle
}
compute_global_objects("global_objects") {
idl_files = source_idl_files + generated_header_idl_files
global_objects_file = _global_objects_pickle
}
compute_global_constructors_idls("global_constructors_idls") {
idl_files = source_idl_files
global_objects_file = _global_objects_pickle
# Generated IDL files that will define all the constructors that should be
# on the global scope objects.
global_names_idl_path = _generated_idls_output_dir
interfaces = _global_constructor_interfaces
deps = [ ":global_objects" ]
}
compute_interfaces_info_individual("interfaces_info_individual") {
idl_files =
source_idl_files + generated_header_idl_files + dependency_idl_files
# Generated IDL files that define all the constructors that are on the global
# scope objects.
global_names_idl_path = _generated_idls_output_dir
interfaces = _global_constructor_interfaces
component_info_file = _component_info_pickle
interfaces_info_file = _interfaces_info_individual_pickle
cache_directory = _bindings_scripts_output_dir
deps = [
":cached_lex_yacc_tables",
":global_constructors_idls",
]
}
generate_interfaces_info_overall("interfaces_info_overall") {
individual_interfaces_file = _interfaces_info_individual_pickle
combined_interfaces_file = _interfaces_info_combined_pickle
deps = [ ":interfaces_info_individual" ]
}
cache_lex_tables("cached_lex_yacc_tables") {
output_dir = _bindings_scripts_output_dir
}
cache_templates("cached_jinja_templates") {
output_dir = _bindings_scripts_output_dir
}