cc.gni 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Copyright 2016 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("//testing/test.gni")
  5. cc_remove_configs = []
  6. cc_add_configs = [
  7. "//build/config:precompiled_headers",
  8. "//build/config/compiler:wexit_time_destructors",
  9. ]
  10. if (!is_debug) {
  11. cc_remove_configs += [ "//build/config/compiler:default_optimization" ]
  12. cc_add_configs += [ "//build/config/compiler:optimize_max" ]
  13. }
  14. template("cc_component") {
  15. component(target_name) {
  16. forward_variables_from(invoker, "*", [ "configs" ])
  17. if (defined(invoker.configs)) {
  18. configs += invoker.configs
  19. }
  20. configs -= cc_remove_configs
  21. configs += cc_add_configs
  22. # TODO(crbug.com/1292951): Remove this line.
  23. configs -= [ "//build/config/compiler:prevent_unsafe_narrowing" ]
  24. }
  25. }
  26. template("cc_test_static_library") {
  27. static_library(target_name) {
  28. forward_variables_from(invoker, "*", [ "configs" ])
  29. if (defined(invoker.configs)) {
  30. configs += invoker.configs
  31. }
  32. configs -= cc_remove_configs
  33. configs += cc_add_configs
  34. # Not needed in test code.
  35. configs -= [ "//build/config/compiler:wexit_time_destructors" ]
  36. # TODO(crbug.com/1292951): Remove this line.
  37. configs -= [ "//build/config/compiler:prevent_unsafe_narrowing" ]
  38. }
  39. }
  40. template("cc_test") {
  41. test(target_name) {
  42. forward_variables_from(invoker, "*", [ "configs" ])
  43. if (defined(invoker.configs)) {
  44. configs += invoker.configs
  45. }
  46. configs -= cc_remove_configs
  47. configs += cc_add_configs
  48. # Not needed in test code.
  49. configs -= [ "//build/config/compiler:wexit_time_destructors" ]
  50. # TODO(crbug.com/1292951): Remove this line.
  51. configs -= [ "//build/config/compiler:prevent_unsafe_narrowing" ]
  52. }
  53. }