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