123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- # 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/buildflag_header.gni")
- import("//build/config/chromecast_build.gni")
- import("//mojo/public/tools/bindings/mojom.gni")
- import("//testing/libfuzzer/fuzzer_test.gni")
- import("//testing/test.gni")
- mojom("variations_mojom") {
- sources = [ "variations.mojom" ]
- }
- if (is_android) {
- import("//build/config/android/rules.gni")
- }
- large_variation_key_size_enabled =
- is_castos || is_cast_android || is_chromeos_lacros
- buildflag_header("buildflags") {
- header = "buildflags.h"
- flags = [ "LARGE_VARIATION_KEY_SIZE=$large_variation_key_size_enabled" ]
- }
- component("variations_features") {
- output_name = "variations_features"
- defines = [ "IS_VARIATIONS_FEATURES_IMPL" ]
- sources = [
- "variations_features.cc",
- "variations_features.h",
- ]
- deps = [ "//base" ]
- }
- component("variations") {
- sources = [
- "active_field_trials.cc",
- "active_field_trials.h",
- "child_process_field_trial_syncer.cc",
- "child_process_field_trial_syncer.h",
- "client_filterable_state.cc",
- "client_filterable_state.h",
- "entropy_provider.cc",
- "entropy_provider.h",
- "fake_crash.cc",
- "fake_crash.h",
- "hashing.cc",
- "hashing.h",
- "metrics.cc",
- "metrics.h",
- "platform_field_trials.h",
- "pref_names.cc",
- "pref_names.h",
- "processed_study.cc",
- "processed_study.h",
- "seed_response.cc",
- "seed_response.h",
- "study_filtering.cc",
- "study_filtering.h",
- "synthetic_trial_registry.cc",
- "synthetic_trial_registry.h",
- "synthetic_trials.cc",
- "synthetic_trials.h",
- "synthetic_trials_active_group_id_provider.cc",
- "synthetic_trials_active_group_id_provider.h",
- "variations_associated_data.cc",
- "variations_associated_data.h",
- "variations_client.h",
- "variations_crash_keys.cc",
- "variations_crash_keys.h",
- "variations_ids_provider.cc",
- "variations_ids_provider.h",
- "variations_layers.cc",
- "variations_layers.h",
- "variations_murmur_hash.cc",
- "variations_murmur_hash.h",
- "variations_request_scheduler.cc",
- "variations_request_scheduler.h",
- "variations_seed_processor.cc",
- "variations_seed_processor.h",
- "variations_seed_simulator.cc",
- "variations_seed_simulator.h",
- "variations_seed_store.cc",
- "variations_seed_store.h",
- "variations_switches.cc",
- "variations_switches.h",
- "variations_url_constants.cc",
- "variations_url_constants.h",
- ]
- # Needed for exporting functions (because the target type is a component).
- defines = [ "IS_VARIATIONS_IMPL" ]
- if (is_android || is_ios) {
- sources += [
- "variations_request_scheduler_mobile.cc",
- "variations_request_scheduler_mobile.h",
- ]
- }
- if (is_android) {
- sources += [
- "android/variations_associated_data_android.cc",
- "android/variations_seed_bridge.cc",
- "android/variations_seed_bridge.h",
- ]
- }
- if (is_chromeos_ash) {
- sources += [
- "variations_crash_keys_chromeos.cc",
- "variations_crash_keys_chromeos.h",
- ]
- }
- public_deps = [
- ":variations_features",
- "proto",
- "//base",
- ]
- deps = [
- ":buildflags",
- ":variations_mojom",
- "proto",
- "//build:chromeos_buildflags",
- "//components/crash/core/common:crash_key",
- "//components/prefs",
- "//components/version_info",
- "//crypto",
- "//third_party/protobuf:protobuf_lite",
- "//third_party/zlib/google:compression_utils",
- ]
- if (is_android) {
- deps += [ ":jni" ]
- }
- }
- if (is_android) {
- generate_jni("jni") {
- sources = [
- "android/java/src/org/chromium/components/variations/VariationsAssociatedData.java",
- "android/java/src/org/chromium/components/variations/firstrun/VariationsSeedBridge.java",
- ]
- }
- java_cpp_strings("java_switches_srcjar") {
- # External code should depend on ":variations_java" instead.
- visibility = [ ":*" ]
- sources = [ "variations_switches.cc" ]
- template = "//components/variations/android/java_templates/VariationsSwitches.java.tmpl"
- }
- android_library("variations_java") {
- srcjar_deps = [
- ":java_switches_srcjar",
- ":variations_enum_srcjar",
- ]
- deps = [ "//third_party/androidx:androidx_annotation_annotation_java" ]
- }
- java_cpp_enum("variations_enum_srcjar") {
- # External code should depend on ":variations_java" instead.
- visibility = [ ":*" ]
- sources = [
- "metrics.h",
- "synthetic_trials.h",
- ]
- }
- }
- static_library("test_support") {
- testonly = true
- sources = [
- "scoped_variations_ids_provider.cc",
- "scoped_variations_ids_provider.h",
- "variations_params_manager.cc",
- "variations_params_manager.h",
- "variations_test_utils.cc",
- "variations_test_utils.h",
- ]
- public_deps = [
- ":variations",
- ":variations_mojom",
- ]
- deps = [
- "field_trial_config:field_trial_config",
- "proto",
- "//base/test:test_support",
- "//components/metrics",
- "//components/prefs:prefs",
- "//third_party/zlib/google:compression_utils",
- ]
- }
- source_set("unit_tests") {
- testonly = true
- sources = [
- "active_field_trials_unittest.cc",
- "child_process_field_trial_syncer_unittest.cc",
- "client_filterable_state_unittest.cc",
- "entropy_provider_unittest.cc",
- "hashing_unittest.cc",
- "net/variations_command_line_unittest.cc",
- "net/variations_http_headers_unittest.cc",
- "processed_study_unittest.cc",
- "simulate_for_crosstalk_unittest.cc",
- "study_filtering_unittest.cc",
- "synthetic_trial_registry_unittest.cc",
- "variations_associated_data_unittest.cc",
- "variations_ids_provider_unittest.cc",
- "variations_murmur_hash_unittest.cc",
- "variations_request_scheduler_unittest.cc",
- "variations_seed_processor_unittest.cc",
- "variations_seed_simulator_unittest.cc",
- "variations_seed_store_unittest.cc",
- "variations_test_utils_unittest.cc",
- ]
- if (is_android || is_ios) {
- sources += [ "variations_request_scheduler_mobile_unittest.cc" ]
- }
- if (is_chromeos_ash) {
- sources += [ "variations_crash_keys_chromeos_unittest.cc" ]
- }
- # This test uses crash_reporter::GetCrashKeyValue(), which in a component
- # build returns the crash keys in the unit-test, not the "variations"
- # target. The test verifies the keys in the "variations" target, not the
- # test. As such, it fails in component builds.
- # TODO(crbug.com/1186718): Enable this unittest for is_fuchsia when crash keys
- # are supported on Fuchsia.
- if (!is_component_build && !is_fuchsia) {
- sources += [ "variations_crash_keys_unittest.cc" ]
- }
- deps = [
- ":test_support",
- ":variations",
- ":variations_features",
- ":variations_mojom",
- "net",
- "proto",
- "//base/test:test_support",
- "//components/crash/core/common:crash_key",
- "//components/prefs:test_support",
- "//components/variations/field_trial_config:field_trial_config",
- "//services/network/public/cpp:cpp_base",
- "//testing/gmock",
- "//testing/gtest",
- "//third_party/smhasher:murmurhash3",
- "//third_party/zlib/google:compression_utils",
- "//url",
- ]
- }
- # Convenience testing target
- test("variations_unittests") {
- sources = [ "//components/test/run_all_unittests.cc" ]
- deps = [
- ":unit_tests",
- "//components/test:test_support",
- "//components/variations/field_trial_config:unit_tests",
- "//components/variations/service:unit_tests",
- ]
- }
- if (use_libfuzzer) {
- fuzzer_test("create_trial_from_study_fuzzer") {
- sources = [ "fuzzers/create_trial_from_study_fuzzer.cc" ]
- deps = [
- ":variations",
- "proto",
- "//base/test:test_support",
- "//third_party/libprotobuf-mutator",
- ]
- }
- }
|