blob: a1c5e2c9d084c4037c9e5b3d6e57dc0c87b4a8af [file] [log] [blame]
# Copyright 2022 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/script/v8c/v8c_variables.gni")
##########################################################
# Configuration variables for bindings generation scripts.
##########################################################
_bindings_output_dir = "$root_gen_dir/bindings/testing"
_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"
###################################################
# IDL files to be compiled to bindings source code.
###################################################
# Testing IDL files.
_source_idl_files = [
"anonymous_indexed_getter_interface.idl",
"anonymous_named_getter_interface.idl",
"anonymous_named_indexed_getter_interface.idl",
"arbitrary_interface.idl",
"base_interface.idl",
"boolean_type_test_interface.idl",
"bytestring_type_test_interface.idl",
"callback_function_interface.idl",
"callback_interface_interface.idl",
"conditional_interface.idl",
"constants_interface.idl",
"constructor_interface.idl",
"constructor_with_arguments_interface.idl",
"convert_simple_object_interface.idl",
"derived_getter_setter_interface.idl",
"derived_interface.idl",
"dictionary_interface.idl",
"disabled_interface.idl",
"dom_string_test_interface.idl",
"enumeration_interface.idl",
"exception_object_interface.idl",
"exceptions_interface.idl",
"extended_idl_attributes_interface.idl",
"garbage_collection_test_interface.idl",
"global_interface_parent.idl",
"implemented_as_interface.idl",
"indexed_getter_interface.idl",
"interface_with_any.idl",
"interface_with_any_dictionary.idl",
"interface_with_date.idl",
"interface_with_unsupported_properties.idl",
"named_constructor_interface.idl",
"named_getter_interface.idl",
"named_indexed_getter_interface.idl",
"nested_put_forwards_interface.idl",
"no_constructor_interface.idl",
"no_interface_object_interface.idl",
"nullable_types_test_interface.idl",
"numeric_types_test_interface.idl",
"object_type_bindings_interface.idl",
"operations_test_interface.idl",
"promise_interface.idl",
"put_forwards_interface.idl",
"sequence_user.idl",
"single_operation_interface.idl",
"static_properties_interface.idl",
"stringifier_anonymous_operation_interface.idl",
"stringifier_attribute_interface.idl",
"stringifier_operation_interface.idl",
"target_interface.idl",
"union_types_interface.idl",
"window.idl",
]
_generated_header_idl_files = [
"derived_dictionary.idl",
"dictionary_with_dictionary_member.idl",
"test_dictionary.idl",
"test_enum.idl",
]
# Partial interfaces and the right-side of "implements"
# Code will not get generated for these interfaces; they are used to add
# functionality to other interfaces.
_dependency_idl_files = [
"implemented_interface.idl",
"partial_interface.idl",
"interface_with_unsupported_properties_partial.idl",
]
_unsupported_interface_idl_files = [ "unsupported_interface.idl" ]
#########################
# Bindings tests targets.
#########################
static_library("bindings_test_implementation") {
testonly = true
sources = [
"constants_interface.cc",
"constructor_interface.cc",
"exceptions_interface.cc",
"garbage_collection_test_interface.cc",
"named_constructor_interface.cc",
"operations_test_interface.cc",
"put_forwards_interface.cc",
"static_properties_interface.cc",
]
deps = [
":generated_types_test_support",
"//cobalt/base",
"//testing/gmock",
"//testing/gtest",
]
}
target(gtest_target_type, "bindings_test") {
testonly = true
sources = [
"any_bindings_test.cc",
"any_dictionary_bindings_test.cc",
"array_buffers_test.cc",
"boolean_type_bindings_test.cc",
"bytestring_type_bindings_test.cc",
"callback_function_test.cc",
"callback_interface_test.cc",
"conditional_attribute_test.cc",
"constants_bindings_test.cc",
"constructor_bindings_test.cc",
"convert_simple_object_test.cc",
"date_bindings_test.cc",
"dependent_interface_test.cc",
"dictionary_test.cc",
"dom_string_bindings_test.cc",
"enumeration_bindings_test.cc",
"evaluate_script_test.cc",
"exceptions_bindings_test.cc",
"extended_attributes_test.cc",
"garbage_collection_test.cc",
"get_own_property_descriptor.cc",
"getter_setter_test.cc",
"global_interface_bindings_test.cc",
"implemented_as_interface_test.cc",
"interface_object_test.cc",
"nullable_types_bindings_test.cc",
"numeric_type_bindings_test.cc",
"object_type_bindings_test.cc",
"operations_bindings_test.cc",
"optional_arguments_bindings_test.cc",
"promise_test.cc",
"put_forwards_test.cc",
"sequence_bindings_test.cc",
"stack_trace_test.cc",
"static_properties_bindings_test.cc",
"stringifier_bindings_test.cc",
"union_type_bindings_test.cc",
"unsupported_test.cc",
"variadic_arguments_bindings_test.cc",
]
configs += [ ":enable_conditional_interface" ]
deps = [
":bindings_test_implementation",
":bindings_test_support",
"//cobalt/base",
"//cobalt/script",
"//cobalt/script/v8c:engine",
"//cobalt/test:run_all_unittests",
"//testing/gmock",
"//testing/gtest",
]
}
###################
# Bindings sandbox.
###################
target(final_executable_type, "bindings_sandbox") {
testonly = true
sources = [ "bindings_sandbox_main.cc" ]
deps = [
":bindings_test_implementation",
":bindings_test_support",
"//cobalt/base",
"//cobalt/script:engine",
"//cobalt/script:standalone_javascript_runner",
]
}
##############################
# Bindings generation targets.
##############################
group("bindings_test_support") {
testonly = true
public_deps = [
":generated_bindings_sources_test_support",
":generated_types_sources_test_support",
]
}
config("enable_conditional_interface") {
defines = [
"ENABLE_CONDITIONAL_INTERFACE",
"ENABLE_CONDITIONAL_PROPERTY",
]
}
config("generated_test_support_sources_includes") {
include_dirs = [ _generated_source_output_dir ]
}
idl_compile("generated_bindings_test_support") {
testonly = true
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_test_support",
":cached_lex_yacc_tables_test_support",
":generated_type_conversion_test_support",
":generated_types_test_support",
":global_constructors_idls_test_support",
":interfaces_info_individual_test_support",
":interfaces_info_overall_test_support",
"//cobalt/script:engine",
]
public_deps = engine_dependencies + [ "//testing/gmock" ]
public_configs = [ ":generated_test_support_sources_includes" ]
}
source_set("generated_bindings_sources_test_support") {
testonly = true
sources = get_target_outputs(":generated_bindings_test_support")
configs += [ ":enable_conditional_interface" ]
public_deps = [ ":generated_bindings_test_support" ]
deps = [
# Ensure that all the files have been generated before trying to compile.
":generated_types_test_support",
]
}
idl_compile("generated_types_test_support") {
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_test_support",
":cached_lex_yacc_tables_test_support",
":global_constructors_idls_test_support",
":interfaces_info_individual_test_support",
":interfaces_info_overall_test_support",
]
public_deps = engine_dependencies
public_configs = [ ":generated_test_support_sources_includes" ]
}
source_set("generated_types_sources_test_support") {
testonly = true
sources = get_target_outputs(":generated_types_test_support")
public_deps = [ ":generated_types_test_support" ]
deps = [
# Ensure that all the files have been generated before trying to compile.
":generated_bindings_test_support",
]
}
generate_type_conversion("generated_type_conversion_test_support") {
# TODO(b/211055528): Missing deps from generated sources.
deps = [
":cached_jinja_templates_test_support",
":cached_lex_yacc_tables_test_support",
":global_constructors_idls_test_support",
":interfaces_info_overall_test_support",
]
# Generated IDL file that will define all the constructors that should be
# on the Window object.
global_names_idl_file =
"$_generated_idls_output_dir/testing/window_constructors.idl"
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_test_support") {
idl_files = _source_idl_files + _generated_header_idl_files
global_objects_file = _global_objects_pickle
}
compute_global_constructors_idls("global_constructors_idls_test_support") {
idl_files = _source_idl_files + _unsupported_interface_idl_files
global_objects_file = _global_objects_pickle
# Generated IDL file that will define all the constructors that should be
# on the Window object.
global_names_idl_file =
"$_generated_idls_output_dir/testing/window_constructors.idl"
# Dummy header file which is generated because the idl compiler assumes
# there is a header for each IDL.
global_constructors_generated_header_file =
"$_generated_idls_output_dir/testing/window_constructors.h"
deps = [ ":global_objects_test_support" ]
}
compute_interfaces_info_individual("interfaces_info_individual_test_support") {
idl_files = _source_idl_files + _generated_header_idl_files +
_dependency_idl_files + _unsupported_interface_idl_files
# Generated IDL file that will define all the constructors that should be
# on the Window object.
generated_idl_files =
"$_generated_idls_output_dir/testing/window_constructors.idl"
component_info_file = _component_info_pickle
interfaces_info_file = _interfaces_info_individual_pickle
cache_directory = _bindings_scripts_output_dir
dependency_idl_files = _dependency_idl_files
deps = [
":cached_lex_yacc_tables_test_support",
":global_constructors_idls_test_support",
]
}
generate_interfaces_info_overall("interfaces_info_overall_test_support") {
individual_interfaces_file = _interfaces_info_individual_pickle
combined_interfaces_file = _interfaces_info_combined_pickle
deps = [ ":interfaces_info_individual_test_support" ]
}
cache_lex_tables("cached_lex_yacc_tables_test_support") {
output_dir = _bindings_scripts_output_dir
}
cache_templates("cached_jinja_templates_test_support") {
output_dir = _bindings_scripts_output_dir
}