1# Copyright (c) 2012 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
5{
6  'includes': [
7    'gtest.gypi',
8  ],
9  'targets': [
10    {
11      'target_name': 'gtest',
12      'toolsets': ['host', 'target'],
13      'type': 'static_library',
14      'sources': [
15        '<@(gtest_sources)',
16      ],
17      'include_dirs': [
18        'gtest',
19        'gtest/include',
20      ],
21      'dependencies': [
22        'gtest_prod',
23      ],
24      'defines': [
25        # In order to allow regex matches in gtest to be shared between Windows
26        # and other systems, we tell gtest to always use it's internal engine.
27        'GTEST_HAS_POSIX_RE=0',
28        # Chrome doesn't support / require C++11, yet.
29        'GTEST_LANG_CXX11=0',
30      ],
31      'all_dependent_settings': {
32        'defines': [
33          'GTEST_HAS_POSIX_RE=0',
34          'GTEST_LANG_CXX11=0',
35        ],
36      },
37      'conditions': [
38        ['OS == "mac" or OS == "ios"', {
39          'sources': [
40            'gtest_mac.h',
41            'gtest_mac.mm',
42          ],
43          'link_settings': {
44            'libraries': [
45              '$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
46            ],
47          },
48        }],
49        ['OS == "mac"', {
50          'sources': [
51            'platform_test_mac.mm',
52          ],
53        }],
54        ['OS == "ios"', {
55          'dependencies' : [
56            '<(DEPTH)/testing/iossim/iossim.gyp:iossim#host',
57          ],
58          'direct_dependent_settings': {
59            'target_conditions': [
60              # Turn all tests into bundles on iOS because that's the only
61              # type of executable supported for iOS.
62              ['_type=="executable"', {
63                'variables': {
64                  # Use a variable so the path gets fixed up so it is always
65                  # correct when INFOPLIST_FILE finally gets set.
66                  'ios_unittest_info_plist_path':
67                    '<(DEPTH)/testing/gtest_ios/unittest-Info.plist',
68                },
69                'mac_bundle': 1,
70                'xcode_settings': {
71                  'BUNDLE_ID_TEST_NAME':
72                    '>!(echo ">(_target_name)" | sed -e "s/_//g")',
73                  'INFOPLIST_FILE': '>(ios_unittest_info_plist_path)',
74                },
75                'mac_bundle_resources': [
76                  '<(ios_unittest_info_plist_path)',
77                  '<(DEPTH)/testing/gtest_ios/Default-568h@2x.png',
78                ],
79                'mac_bundle_resources!': [
80                  '<(ios_unittest_info_plist_path)',
81                ],
82              }],
83            ],
84          },
85          'sources': [
86            'coverage_util_ios.cc',
87            'coverage_util_ios.h',
88            'platform_test_ios.mm',
89          ],
90        }],
91        ['OS=="ios" and asan==1', {
92          'direct_dependent_settings': {
93            'target_conditions': [
94              # Package the ASan runtime dylib into the test app bundles.
95              ['_type=="executable"', {
96                'postbuilds': [
97                  {
98                    'variables': {
99                      # Define copy_asan_dylib_path in a variable ending in
100                      # _path so that gyp understands it's a path and
101                      # performs proper relativization during dict merging.
102                      'copy_asan_dylib_path':
103                        '<(DEPTH)/build/mac/copy_asan_runtime_dylib.sh',
104                    },
105                    'postbuild_name': 'Copy ASan runtime dylib',
106                    'action': [
107                      '>(copy_asan_dylib_path)',
108                    ],
109                  },
110                ],
111              }],
112            ],
113          },
114        }],
115        ['os_posix == 1', {
116          'defines': [
117            # gtest isn't able to figure out when RTTI is disabled for gcc
118            # versions older than 4.3.2, and assumes it's enabled.  Our Mac
119            # and Linux builds disable RTTI, and cannot guarantee that the
120            # compiler will be 4.3.2. or newer.  The Mac, for example, uses
121            # 4.2.1 as that is the latest available on that platform.  gtest
122            # must be instructed that RTTI is disabled here, and for any
123            # direct dependents that might include gtest headers.
124            'GTEST_HAS_RTTI=0',
125          ],
126          'direct_dependent_settings': {
127            'defines': [
128              'GTEST_HAS_RTTI=0',
129            ],
130          },
131        }],
132        ['OS=="android" and android_app_abi=="x86"', {
133          'defines': [
134            'GTEST_HAS_CLONE=0',
135          ],
136          'direct_dependent_settings': {
137            'defines': [
138              'GTEST_HAS_CLONE=0',
139            ],
140          },
141        }],
142        ['OS=="android"', {
143          # We want gtest features that use tr1::tuple, but we currently
144          # don't support the variadic templates used by libstdc++'s
145          # implementation. gtest supports this scenario by providing its
146          # own implementation but we must opt in to it.
147          'defines': [
148            'GTEST_USE_OWN_TR1_TUPLE=1',
149            # GTEST_USE_OWN_TR1_TUPLE only works if GTEST_HAS_TR1_TUPLE is set.
150            # gtest r625 made it so that GTEST_HAS_TR1_TUPLE is set to 0
151            # automatically on android, so it has to be set explicitly here.
152            'GTEST_HAS_TR1_TUPLE=1',
153          ],
154          'direct_dependent_settings': {
155            'defines': [
156              'GTEST_USE_OWN_TR1_TUPLE=1',
157              'GTEST_HAS_TR1_TUPLE=1',
158            ],
159          },
160        }],
161      ],
162      'direct_dependent_settings': {
163        'defines': [
164          'UNIT_TEST',
165        ],
166        'include_dirs': [
167          'gtest/include',  # So that gtest headers can find themselves.
168        ],
169        'target_conditions': [
170          ['_type=="executable"', {
171            'test': 1,
172            'conditions': [
173              ['OS=="mac"', {
174                'run_as': {
175                  'action????': ['${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}'],
176                },
177              }],
178              ['OS=="ios"', {
179                'variables': {
180                  # Use a variable so the path gets fixed up so it is always
181                  # correct when the action finally gets used.
182                  'ios_run_unittest_script_path':
183                    '<(DEPTH)/testing/gtest_ios/run-unittest.sh',
184                },
185                'run_as': {
186                  'action????': ['>(ios_run_unittest_script_path)'],
187                },
188              }],
189              ['OS=="win"', {
190                'run_as': {
191                  'action????': ['$(TargetPath)', '--gtest_print_time'],
192                },
193              }],
194            ],
195          }],
196        ],
197        'msvs_disabled_warnings': [4800],
198      },
199    },
200    {
201      'target_name': 'gtest_main',
202      'type': 'static_library',
203      'dependencies': [
204        'gtest',
205      ],
206      'sources': [
207        'gtest/src/gtest_main.cc',
208      ],
209    },
210    {
211      'target_name': 'gtest_prod',
212      'toolsets': ['host', 'target'],
213      'type': 'none',
214      'sources': [
215        'gtest/include/gtest/gtest_prod.h',
216      ],
217    },
218  ],
219}
220