BUILD.gn 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # Copyright 2015 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//build/config/chromeos/ui_mode.gni")
  5. declare_args() {
  6. invert_fieldtrials = false
  7. }
  8. action("field_trial_testing_config_action") {
  9. visibility = [ ":field_trial_config" ]
  10. script = "//tools/variations/fieldtrial_to_struct.py"
  11. source = "//testing/variations/fieldtrial_testing_config.json"
  12. inputs = [
  13. "//tools/json_to_struct/element_generator.py",
  14. "//tools/json_to_struct/json_to_struct.py",
  15. "//tools/json_to_struct/struct_generator.py",
  16. source,
  17. ]
  18. out_name = "fieldtrial_testing_config"
  19. outputs = [
  20. "$target_gen_dir/$out_name.cc",
  21. "$target_gen_dir/$out_name.h",
  22. ]
  23. if (current_os == "win") {
  24. platform = "windows"
  25. } else if (is_chromeos_lacros) {
  26. platform = "chromeos_lacros"
  27. } else {
  28. platform = current_os
  29. }
  30. args = [
  31. rebase_path(source, root_build_dir),
  32. "--destbase=" + rebase_path(target_gen_dir, root_build_dir),
  33. "--namespace=variations",
  34. "--schema=" +
  35. rebase_path("field_trial_testing_config_schema.json", root_build_dir),
  36. "--platform=" + platform,
  37. "--output=$out_name",
  38. ]
  39. if (invert_fieldtrials) {
  40. args += [ "--invert_fieldtrials" ]
  41. }
  42. # At build-time, Android Chrome and WebView/WebLayer use the platform
  43. # "android", but at run-time, variations has separate platforms "android",
  44. # "android_webview" and "android_weblayer". So if building "android", also
  45. # include WebView/WebLayer.
  46. if (platform == "android") {
  47. args += [
  48. "--platform=android_weblayer",
  49. "--platform=android_webview",
  50. ]
  51. }
  52. }
  53. static_library("field_trial_config") {
  54. sources = [
  55. "field_trial_util.cc",
  56. "field_trial_util.h",
  57. ]
  58. sources += get_target_outputs(":field_trial_testing_config_action")
  59. deps = [
  60. ":field_trial_testing_config_action",
  61. "//base",
  62. "//components/variations",
  63. "//components/variations/proto",
  64. "//net",
  65. ]
  66. public_deps = [ "//third_party/protobuf:protobuf_lite" ]
  67. }
  68. source_set("unit_tests") {
  69. testonly = true
  70. sources = [ "field_trial_util_unittest.cc" ]
  71. deps = [
  72. ":field_trial_config",
  73. "//base",
  74. "//base/test:test_support",
  75. "//components/variations",
  76. "//components/variations/service",
  77. "//components/version_info",
  78. "//services/network/public/cpp",
  79. "//testing/gtest",
  80. ]
  81. }