mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-12-01 01:36:09 +03:00
413 lines
13 KiB
Plaintext
413 lines
13 KiB
Plaintext
# Copyright 2015 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.
|
|
|
|
# ==============================================================================
|
|
# TEST SETUP
|
|
# ==============================================================================
|
|
|
|
if (is_android) {
|
|
import("//build/config/android/config.gni")
|
|
import("//build/config/android/rules.gni")
|
|
import("//build/config/sanitizers/sanitizers.gni")
|
|
import("//build/config/android/extract_unwind_tables.gni")
|
|
}
|
|
|
|
if (is_fuchsia) {
|
|
import("//build/config/chromecast_build.gni")
|
|
import("//build/config/fuchsia/rules.gni")
|
|
import("//build/config/fuchsia/package.gni")
|
|
}
|
|
|
|
if (is_chromeos) {
|
|
import("//build/config/chromeos/rules.gni")
|
|
}
|
|
|
|
# Define a test as an executable (or apk on Android) with the "testonly" flag
|
|
# set.
|
|
# Variable:
|
|
# use_raw_android_executable: Use executable() rather than android_apk().
|
|
# use_native_activity: Test implements ANativeActivity_onCreate().
|
|
template("test") {
|
|
if (is_android) {
|
|
_use_raw_android_executable = defined(invoker.use_raw_android_executable) &&
|
|
invoker.use_raw_android_executable
|
|
|
|
# output_name is used to allow targets with the same name but in different
|
|
# packages to still produce unique runner scripts.
|
|
_output_name = invoker.target_name
|
|
if (defined(invoker.output_name)) {
|
|
_output_name = invoker.output_name
|
|
}
|
|
|
|
_test_runner_target = "${_output_name}__test_runner_script"
|
|
_wrapper_script_vars = [
|
|
"ignore_all_data_deps",
|
|
"shard_timeout",
|
|
]
|
|
|
|
assert(_use_raw_android_executable || enable_java_templates)
|
|
|
|
_incremental_apk_only =
|
|
incremental_apk_by_default && !_use_raw_android_executable
|
|
|
|
if (_use_raw_android_executable) {
|
|
_exec_target = "${target_name}__exec"
|
|
_dist_target = "${target_name}__dist"
|
|
_exec_output =
|
|
"$target_out_dir/${invoker.target_name}/${invoker.target_name}"
|
|
|
|
executable(_exec_target) {
|
|
# Configs will always be defined since we set_defaults in BUILDCONFIG.gn.
|
|
configs = []
|
|
data_deps = []
|
|
forward_variables_from(invoker,
|
|
"*",
|
|
_wrapper_script_vars + [ "extra_dist_files" ])
|
|
testonly = true
|
|
|
|
# Thanks to the set_defaults() for test(), configs are initialized with
|
|
# the default shared_library configs rather than executable configs.
|
|
configs -= [
|
|
"//build/config:shared_library_config",
|
|
"//build/config/android:hide_all_but_jni",
|
|
]
|
|
configs += [ "//build/config:executable_config" ]
|
|
|
|
# Don't output to the root or else conflict with the group() below.
|
|
output_name = rebase_path(_exec_output, root_out_dir)
|
|
if (is_component_build || is_asan) {
|
|
data_deps += [ "//build/android:cpplib_stripped" ]
|
|
}
|
|
}
|
|
|
|
create_native_executable_dist(_dist_target) {
|
|
testonly = true
|
|
dist_dir = "$root_out_dir/$target_name"
|
|
binary = _exec_output
|
|
deps = [
|
|
":$_exec_target",
|
|
]
|
|
if (defined(invoker.extra_dist_files)) {
|
|
extra_files = invoker.extra_dist_files
|
|
}
|
|
}
|
|
} else {
|
|
_library_target = "_${target_name}__library"
|
|
_apk_target = "${target_name}_apk"
|
|
_apk_specific_vars = [
|
|
"android_manifest",
|
|
"android_manifest_dep",
|
|
"enable_multidex",
|
|
"proguard_configs",
|
|
"proguard_enabled",
|
|
"use_default_launcher",
|
|
"write_asset_list",
|
|
"use_native_activity",
|
|
]
|
|
|
|
# Adds the unwind tables from unstripped binary as an asset file in the
|
|
# apk, if |add_unwind_tables_in_apk| is specified by the test.
|
|
if (defined(invoker.add_unwind_tables_in_apk) &&
|
|
invoker.add_unwind_tables_in_apk) {
|
|
_unwind_table_asset_name = "${target_name}_unwind_assets"
|
|
unwind_table_asset(_unwind_table_asset_name) {
|
|
testonly = true
|
|
library_target = _library_target
|
|
deps = [
|
|
":$_library_target",
|
|
]
|
|
}
|
|
}
|
|
|
|
shared_library(_library_target) {
|
|
# Configs will always be defined since we set_defaults in BUILDCONFIG.gn.
|
|
configs = [] # Prevent list overwriting warning.
|
|
configs = invoker.configs
|
|
testonly = true
|
|
|
|
deps = []
|
|
forward_variables_from(
|
|
invoker,
|
|
"*",
|
|
_apk_specific_vars + _wrapper_script_vars + [ "visibility" ])
|
|
|
|
if (!defined(invoker.use_default_launcher) ||
|
|
invoker.use_default_launcher) {
|
|
deps += [
|
|
"//build/config:exe_and_shlib_deps",
|
|
"//testing/android/native_test:native_test_native_code",
|
|
]
|
|
}
|
|
}
|
|
unittest_apk(_apk_target) {
|
|
forward_variables_from(invoker, _apk_specific_vars + [ "deps" ])
|
|
shared_library = ":$_library_target"
|
|
apk_name = invoker.target_name
|
|
if (defined(invoker.output_name)) {
|
|
apk_name = invoker.output_name
|
|
install_script_name = "install_${invoker.output_name}"
|
|
}
|
|
|
|
# Add the Java classes so that each target does not have to do it.
|
|
deps += [ "//base/test:test_support_java" ]
|
|
|
|
if (defined(_unwind_table_asset_name)) {
|
|
deps += [ ":${_unwind_table_asset_name}" ]
|
|
}
|
|
|
|
# TODO(agrieve): Remove this data_dep once bots don't build the _apk
|
|
# target (post-GYP).
|
|
# It's a bit backwards for the apk to depend on the runner script, since
|
|
# the apk is conceptually a runtime_dep of the script. However, it is
|
|
# currently necessary because the bots build this _apk target directly
|
|
# rather than the group() below.
|
|
data_deps = [
|
|
":$_test_runner_target",
|
|
]
|
|
}
|
|
|
|
_test_runner_target = "${_output_name}__test_runner_script"
|
|
_incremental_test_name = "${_output_name}_incremental"
|
|
_incremental_test_runner_target =
|
|
"${_output_name}_incremental__test_runner_script"
|
|
if (_incremental_apk_only) {
|
|
_incremental_test_name = _output_name
|
|
_incremental_test_runner_target = _test_runner_target
|
|
}
|
|
|
|
# Incremental test targets work only for .apks.
|
|
test_runner_script(_incremental_test_runner_target) {
|
|
forward_variables_from(invoker,
|
|
_wrapper_script_vars + [
|
|
"data",
|
|
"data_deps",
|
|
"deps",
|
|
"public_deps",
|
|
])
|
|
apk_target = ":$_apk_target"
|
|
test_name = _incremental_test_name
|
|
test_type = "gtest"
|
|
test_suite = _output_name
|
|
incremental_install = true
|
|
}
|
|
group("${target_name}_incremental") {
|
|
testonly = true
|
|
data_deps = [
|
|
":$_incremental_test_runner_target",
|
|
]
|
|
deps = [
|
|
":${_apk_target}_incremental",
|
|
]
|
|
}
|
|
}
|
|
|
|
if (!_incremental_apk_only) {
|
|
test_runner_script(_test_runner_target) {
|
|
forward_variables_from(invoker,
|
|
_wrapper_script_vars + [
|
|
"data",
|
|
"data_deps",
|
|
"deps",
|
|
"public_deps",
|
|
])
|
|
|
|
if (_use_raw_android_executable) {
|
|
executable_dist_dir = "$root_out_dir/$_dist_target"
|
|
} else {
|
|
apk_target = ":$_apk_target"
|
|
}
|
|
test_name = _output_name
|
|
test_type = "gtest"
|
|
test_suite = _output_name
|
|
}
|
|
}
|
|
|
|
test_runner_script(target_name) {
|
|
forward_variables_from(invoker,
|
|
_wrapper_script_vars + [
|
|
"data",
|
|
"data_deps",
|
|
"deps",
|
|
"public_deps",
|
|
])
|
|
|
|
if (_use_raw_android_executable) {
|
|
executable_dist_dir = "$root_out_dir/$_dist_target"
|
|
deps += [
|
|
":$_dist_target",
|
|
":$_test_runner_target",
|
|
]
|
|
} else {
|
|
apk_target = ":$_apk_target"
|
|
deps += [ ":$_apk_target" ]
|
|
if (_incremental_apk_only) {
|
|
deps += [ ":${target_name}_incremental" ]
|
|
} else {
|
|
deps += [ ":$_test_runner_target" ]
|
|
}
|
|
}
|
|
generated_script = "$root_build_dir/$_output_name"
|
|
incremental_install = _incremental_apk_only
|
|
test_name = _output_name
|
|
test_suite = _output_name
|
|
test_type = "gtest"
|
|
}
|
|
} else if (is_fuchsia) {
|
|
_output_name = invoker.target_name
|
|
_pkg_target = "${_output_name}_pkg"
|
|
_gen_runner_target = "${_output_name}_runner"
|
|
_exec_target = "${_output_name}__exec"
|
|
|
|
group(target_name) {
|
|
testonly = true
|
|
deps = [
|
|
":$_gen_runner_target",
|
|
":$_pkg_target",
|
|
]
|
|
|
|
# Disable packaging for Chromecast builds. (https://crbug.com/810069)
|
|
if (is_chromecast) {
|
|
deps -= [ ":${_pkg_target}" ]
|
|
}
|
|
}
|
|
|
|
# Makes the script which invokes the executable.
|
|
test_runner_script(_gen_runner_target) {
|
|
forward_variables_from(invoker, [ "use_test_server" ])
|
|
test_name = _output_name
|
|
package_name = _output_name
|
|
}
|
|
|
|
executable(_exec_target) {
|
|
testonly = true
|
|
forward_variables_from(invoker, "*")
|
|
output_name = _exec_target
|
|
deps += [ "//build/config:exe_and_shlib_deps" ]
|
|
}
|
|
|
|
package(_pkg_target) {
|
|
testonly = true
|
|
package_name = _output_name
|
|
sandbox_policy = "//build/config/fuchsia/testing_sandbox_policy"
|
|
binary = get_label_info(_exec_target, "name")
|
|
deps = [
|
|
":$_exec_target",
|
|
]
|
|
}
|
|
} else if (is_ios) {
|
|
import("//build/config/ios/ios_sdk.gni")
|
|
import("//build/config/ios/rules.gni")
|
|
|
|
_test_target = target_name
|
|
_resources_bundle_data = target_name + "_resources_bundle_data"
|
|
|
|
bundle_data(_resources_bundle_data) {
|
|
visibility = [ ":$_test_target" ]
|
|
sources = [
|
|
"//testing/gtest_ios/Default.png",
|
|
]
|
|
outputs = [
|
|
"{{bundle_resources_dir}}/{{source_file_part}}",
|
|
]
|
|
}
|
|
|
|
ios_app_bundle(_test_target) {
|
|
testonly = true
|
|
|
|
# See above call.
|
|
set_sources_assignment_filter([])
|
|
forward_variables_from(invoker, "*", [ "testonly" ])
|
|
|
|
# Provide sensible defaults in case invoker did not define any of those
|
|
# required variables.
|
|
if (!defined(info_plist) && !defined(info_plist_target)) {
|
|
info_plist = "//testing/gtest_ios/unittest-Info.plist"
|
|
}
|
|
|
|
_bundle_id_suffix = ios_generic_test_bundle_id_suffix
|
|
if (!ios_automatically_manage_certs) {
|
|
_bundle_id_suffix = "${target_name}"
|
|
}
|
|
if (!defined(extra_substitutions)) {
|
|
extra_substitutions = []
|
|
}
|
|
extra_substitutions += [ "GTEST_BUNDLE_ID_SUFFIX=$_bundle_id_suffix" ]
|
|
|
|
if (!defined(deps)) {
|
|
deps = []
|
|
}
|
|
deps += [
|
|
# All shared libraries must have the sanitizer deps to properly link in
|
|
# asan mode (this target will be empty in other cases).
|
|
"//build/config:exe_and_shlib_deps",
|
|
]
|
|
if (!defined(bundle_deps)) {
|
|
bundle_deps = []
|
|
}
|
|
bundle_deps += [ ":$_resources_bundle_data" ]
|
|
}
|
|
} else if (is_chromeos && cros_board != "") {
|
|
# When the arg cros_board is set, assume we're in the cros chrome-sdk
|
|
# building simplechrome.
|
|
|
|
_gen_runner_target = "${target_name}__runner"
|
|
_runtime_deps_file =
|
|
"$root_out_dir/gen.runtime/" + get_label_info(target_name, "dir") +
|
|
"/" + get_label_info(target_name, "name") + ".runtime_deps"
|
|
|
|
generate_vm_runner_script(_gen_runner_target) {
|
|
testonly = true
|
|
generated_script = "$root_build_dir/bin/run_" + invoker.target_name
|
|
test_exe = "$root_out_dir/" + get_label_info(invoker.target_name, "name")
|
|
runtime_deps_file = _runtime_deps_file
|
|
}
|
|
|
|
executable(target_name) {
|
|
forward_variables_from(invoker, "*")
|
|
if (!defined(deps)) {
|
|
deps = []
|
|
}
|
|
if (!defined(data)) {
|
|
data = []
|
|
}
|
|
|
|
testonly = true
|
|
output_name = target_name
|
|
write_runtime_deps = _runtime_deps_file
|
|
data += [ _runtime_deps_file ]
|
|
deps += [
|
|
":$_gen_runner_target",
|
|
"//build/config:exe_and_shlib_deps",
|
|
]
|
|
}
|
|
} else {
|
|
executable(target_name) {
|
|
deps = []
|
|
|
|
forward_variables_from(invoker, "*")
|
|
|
|
testonly = true
|
|
deps += [
|
|
# All shared libraries must have the sanitizer deps to properly link in
|
|
# asan mode (this target will be empty in other cases).
|
|
"//build/config:exe_and_shlib_deps",
|
|
|
|
# Give tests the default manifest on Windows (a no-op elsewhere).
|
|
"//build/win:default_exe_manifest",
|
|
]
|
|
}
|
|
}
|
|
}
|
|
|
|
# Test defaults.
|
|
set_defaults("test") {
|
|
if (is_android) {
|
|
configs = default_shared_library_configs
|
|
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
|
|
configs += [ "//build/config/android:hide_all_but_jni" ]
|
|
} else {
|
|
configs = default_executable_configs
|
|
}
|
|
}
|