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  'target_defaults': {
7    'variables': {
8      # This code gets run a lot and debugged rarely, so it should be fast
9      # by default. See http://crbug.com/388949.
10      'debug_optimize': '2',
11      'win_debug_Optimization': '2',
12      # Run time checks are incompatible with any level of optimizations.
13      'win_debug_RuntimeChecks': '0',
14    },
15  },
16  'variables': {
17    'tcmalloc_dir': '../../third_party/tcmalloc/chromium',
18    'use_vtable_verify%': 0,
19  },
20  'targets': [
21    # Only executables and not libraries should depend on the
22    # allocator target; only the application (the final executable)
23    # knows what allocator makes sense.
24    {
25      'target_name': 'allocator',
26      'type': 'static_library',
27      # Make sure the allocation library is optimized to
28      # the hilt in official builds.
29      'variables': {
30        'optimize': 'max',
31      },
32      'include_dirs': [
33        '.',
34        '<(tcmalloc_dir)/src/base',
35        '<(tcmalloc_dir)/src',
36        '../..',
37      ],
38      'direct_dependent_settings': {
39        'configurations': {
40          'Common_Base': {
41            'msvs_settings': {
42              'VCLinkerTool': {
43                'IgnoreDefaultLibraryNames': ['libcmtd.lib', 'libcmt.lib'],
44                'AdditionalDependencies': [
45                  '<(SHARED_INTERMEDIATE_DIR)/allocator/libcmt.lib'
46                ],
47              },
48            },
49          },
50        },
51        'conditions': [
52          ['OS=="win"', {
53            'defines': [
54              'PERFTOOLS_DLL_DECL=',
55            ],
56          }],
57        ],
58      },
59      'sources': [
60        # Generated for our configuration from tcmalloc's build
61        # and checked in.
62        '<(tcmalloc_dir)/src/config.h',
63        '<(tcmalloc_dir)/src/config_android.h',
64        '<(tcmalloc_dir)/src/config_linux.h',
65        '<(tcmalloc_dir)/src/config_win.h',
66
67        # all tcmalloc native and forked files
68        '<(tcmalloc_dir)/src/addressmap-inl.h',
69        '<(tcmalloc_dir)/src/base/abort.cc',
70        '<(tcmalloc_dir)/src/base/abort.h',
71        '<(tcmalloc_dir)/src/base/arm_instruction_set_select.h',
72        '<(tcmalloc_dir)/src/base/atomicops-internals-linuxppc.h',
73        '<(tcmalloc_dir)/src/base/atomicops-internals-arm-generic.h',
74        '<(tcmalloc_dir)/src/base/atomicops-internals-arm-v6plus.h',
75        '<(tcmalloc_dir)/src/base/atomicops-internals-macosx.h',
76        '<(tcmalloc_dir)/src/base/atomicops-internals-windows.h',
77        '<(tcmalloc_dir)/src/base/atomicops-internals-x86.cc',
78        '<(tcmalloc_dir)/src/base/atomicops-internals-x86.h',
79        '<(tcmalloc_dir)/src/base/atomicops.h',
80        '<(tcmalloc_dir)/src/base/basictypes.h',
81        '<(tcmalloc_dir)/src/base/commandlineflags.h',
82        '<(tcmalloc_dir)/src/base/cycleclock.h',
83        # We don't list dynamic_annotations.c since its copy is already
84        # present in the dynamic_annotations target.
85        '<(tcmalloc_dir)/src/base/dynamic_annotations.h',
86        '<(tcmalloc_dir)/src/base/elf_mem_image.cc',
87        '<(tcmalloc_dir)/src/base/elf_mem_image.h',
88        '<(tcmalloc_dir)/src/base/elfcore.h',
89        '<(tcmalloc_dir)/src/base/googleinit.h',
90        '<(tcmalloc_dir)/src/base/linux_syscall_support.h',
91        '<(tcmalloc_dir)/src/base/linuxthreads.cc',
92        '<(tcmalloc_dir)/src/base/linuxthreads.h',
93        '<(tcmalloc_dir)/src/base/logging.cc',
94        '<(tcmalloc_dir)/src/base/logging.h',
95        '<(tcmalloc_dir)/src/base/low_level_alloc.cc',
96        '<(tcmalloc_dir)/src/base/low_level_alloc.h',
97        '<(tcmalloc_dir)/src/base/simple_mutex.h',
98        '<(tcmalloc_dir)/src/base/spinlock.cc',
99        '<(tcmalloc_dir)/src/base/spinlock.h',
100        '<(tcmalloc_dir)/src/base/spinlock_internal.cc',
101        '<(tcmalloc_dir)/src/base/spinlock_internal.h',
102        '<(tcmalloc_dir)/src/base/spinlock_linux-inl.h',
103        '<(tcmalloc_dir)/src/base/spinlock_posix-inl.h',
104        '<(tcmalloc_dir)/src/base/spinlock_win32-inl.h',
105        '<(tcmalloc_dir)/src/base/stl_allocator.h',
106        '<(tcmalloc_dir)/src/base/synchronization_profiling.h',
107        '<(tcmalloc_dir)/src/base/sysinfo.cc',
108        '<(tcmalloc_dir)/src/base/sysinfo.h',
109        '<(tcmalloc_dir)/src/base/thread_annotations.h',
110        '<(tcmalloc_dir)/src/base/thread_lister.c',
111        '<(tcmalloc_dir)/src/base/thread_lister.h',
112        '<(tcmalloc_dir)/src/base/vdso_support.cc',
113        '<(tcmalloc_dir)/src/base/vdso_support.h',
114        '<(tcmalloc_dir)/src/central_freelist.cc',
115        '<(tcmalloc_dir)/src/central_freelist.h',
116        '<(tcmalloc_dir)/src/common.cc',
117        '<(tcmalloc_dir)/src/common.h',
118        '<(tcmalloc_dir)/src/debugallocation.cc',
119        '<(tcmalloc_dir)/src/deep-heap-profile.cc',
120        '<(tcmalloc_dir)/src/deep-heap-profile.h',
121        '<(tcmalloc_dir)/src/free_list.cc',
122        '<(tcmalloc_dir)/src/free_list.h',
123        '<(tcmalloc_dir)/src/getpc.h',
124        '<(tcmalloc_dir)/src/gperftools/heap-checker.h',
125        '<(tcmalloc_dir)/src/gperftools/heap-profiler.h',
126        '<(tcmalloc_dir)/src/gperftools/malloc_extension.h',
127        '<(tcmalloc_dir)/src/gperftools/malloc_extension_c.h',
128        '<(tcmalloc_dir)/src/gperftools/malloc_hook.h',
129        '<(tcmalloc_dir)/src/gperftools/malloc_hook_c.h',
130        '<(tcmalloc_dir)/src/gperftools/profiler.h',
131        '<(tcmalloc_dir)/src/gperftools/stacktrace.h',
132        '<(tcmalloc_dir)/src/gperftools/tcmalloc.h',
133        '<(tcmalloc_dir)/src/heap-checker-bcad.cc',
134        '<(tcmalloc_dir)/src/heap-checker.cc',
135        '<(tcmalloc_dir)/src/heap-profile-table.cc',
136        '<(tcmalloc_dir)/src/heap-profile-table.h',
137        '<(tcmalloc_dir)/src/heap-profiler.cc',
138        '<(tcmalloc_dir)/src/internal_logging.cc',
139        '<(tcmalloc_dir)/src/internal_logging.h',
140        '<(tcmalloc_dir)/src/libc_override.h',
141        '<(tcmalloc_dir)/src/libc_override_gcc_and_weak.h',
142        '<(tcmalloc_dir)/src/libc_override_glibc.h',
143        '<(tcmalloc_dir)/src/libc_override_osx.h',
144        '<(tcmalloc_dir)/src/libc_override_redefine.h',
145        '<(tcmalloc_dir)/src/linked_list.h',
146        '<(tcmalloc_dir)/src/malloc_extension.cc',
147        '<(tcmalloc_dir)/src/malloc_hook-inl.h',
148        '<(tcmalloc_dir)/src/malloc_hook.cc',
149        '<(tcmalloc_dir)/src/malloc_hook_mmap_freebsd.h',
150        '<(tcmalloc_dir)/src/malloc_hook_mmap_linux.h',
151        '<(tcmalloc_dir)/src/maybe_threads.cc',
152        '<(tcmalloc_dir)/src/maybe_threads.h',
153        '<(tcmalloc_dir)/src/memfs_malloc.cc',
154        '<(tcmalloc_dir)/src/memory_region_map.cc',
155        '<(tcmalloc_dir)/src/memory_region_map.h',
156        '<(tcmalloc_dir)/src/packed-cache-inl.h',
157        '<(tcmalloc_dir)/src/page_heap.cc',
158        '<(tcmalloc_dir)/src/page_heap.h',
159        '<(tcmalloc_dir)/src/page_heap_allocator.h',
160        '<(tcmalloc_dir)/src/pagemap.h',
161        '<(tcmalloc_dir)/src/profile-handler.cc',
162        '<(tcmalloc_dir)/src/profile-handler.h',
163        '<(tcmalloc_dir)/src/profiledata.cc',
164        '<(tcmalloc_dir)/src/profiledata.h',
165        '<(tcmalloc_dir)/src/profiler.cc',
166        '<(tcmalloc_dir)/src/raw_printer.cc',
167        '<(tcmalloc_dir)/src/raw_printer.h',
168        '<(tcmalloc_dir)/src/sampler.cc',
169        '<(tcmalloc_dir)/src/sampler.h',
170        '<(tcmalloc_dir)/src/span.cc',
171        '<(tcmalloc_dir)/src/span.h',
172        '<(tcmalloc_dir)/src/stack_trace_table.cc',
173        '<(tcmalloc_dir)/src/stack_trace_table.h',
174        '<(tcmalloc_dir)/src/stacktrace.cc',
175        '<(tcmalloc_dir)/src/stacktrace_arm-inl.h',
176        '<(tcmalloc_dir)/src/stacktrace_config.h',
177        '<(tcmalloc_dir)/src/stacktrace_generic-inl.h',
178        '<(tcmalloc_dir)/src/stacktrace_libunwind-inl.h',
179        '<(tcmalloc_dir)/src/stacktrace_powerpc-inl.h',
180        '<(tcmalloc_dir)/src/stacktrace_win32-inl.h',
181        '<(tcmalloc_dir)/src/stacktrace_with_context.cc',
182        '<(tcmalloc_dir)/src/stacktrace_x86-inl.h',
183        '<(tcmalloc_dir)/src/static_vars.cc',
184        '<(tcmalloc_dir)/src/static_vars.h',
185        '<(tcmalloc_dir)/src/symbolize.cc',
186        '<(tcmalloc_dir)/src/symbolize.h',
187        '<(tcmalloc_dir)/src/system-alloc.cc',
188        '<(tcmalloc_dir)/src/system-alloc.h',
189        '<(tcmalloc_dir)/src/tcmalloc.cc',
190        '<(tcmalloc_dir)/src/tcmalloc_guard.h',
191        '<(tcmalloc_dir)/src/thread_cache.cc',
192        '<(tcmalloc_dir)/src/thread_cache.h',
193        '<(tcmalloc_dir)/src/windows/config.h',
194        '<(tcmalloc_dir)/src/windows/get_mangled_names.cc',
195        '<(tcmalloc_dir)/src/windows/gperftools/tcmalloc.h',
196        '<(tcmalloc_dir)/src/windows/ia32_modrm_map.cc',
197        '<(tcmalloc_dir)/src/windows/ia32_opcode_map.cc',
198        '<(tcmalloc_dir)/src/windows/mingw.h',
199        '<(tcmalloc_dir)/src/windows/mini_disassembler.cc',
200        '<(tcmalloc_dir)/src/windows/mini_disassembler.h',
201        '<(tcmalloc_dir)/src/windows/mini_disassembler_types.h',
202        '<(tcmalloc_dir)/src/windows/override_functions.cc',
203        '<(tcmalloc_dir)/src/windows/patch_functions.cc',
204        '<(tcmalloc_dir)/src/windows/port.cc',
205        '<(tcmalloc_dir)/src/windows/port.h',
206        '<(tcmalloc_dir)/src/windows/preamble_patcher.cc',
207        '<(tcmalloc_dir)/src/windows/preamble_patcher.h',
208        '<(tcmalloc_dir)/src/windows/preamble_patcher_with_stub.cc',
209
210        'allocator_shim.cc',
211        'allocator_shim.h',
212        'debugallocation_shim.cc',
213        'generic_allocators.cc',
214        'win_allocator.cc',
215      ],
216      # sources! means that these are not compiled directly.
217      'sources!': [
218        # Included by allocator_shim.cc for maximal inlining.
219        'generic_allocators.cc',
220        'win_allocator.cc',
221
222        # Included by debugallocation_shim.cc.
223        '<(tcmalloc_dir)/src/debugallocation.cc',
224        '<(tcmalloc_dir)/src/tcmalloc.cc',
225
226        # We simply don't use these, but list them above so that IDE
227        # users can view the full available source for reference, etc.
228        '<(tcmalloc_dir)/src/addressmap-inl.h',
229        '<(tcmalloc_dir)/src/base/atomicops-internals-linuxppc.h',
230        '<(tcmalloc_dir)/src/base/atomicops-internals-macosx.h',
231        '<(tcmalloc_dir)/src/base/atomicops-internals-x86-msvc.h',
232        '<(tcmalloc_dir)/src/base/atomicops-internals-x86.cc',
233        '<(tcmalloc_dir)/src/base/atomicops-internals-x86.h',
234        '<(tcmalloc_dir)/src/base/atomicops.h',
235        '<(tcmalloc_dir)/src/base/basictypes.h',
236        '<(tcmalloc_dir)/src/base/commandlineflags.h',
237        '<(tcmalloc_dir)/src/base/cycleclock.h',
238        '<(tcmalloc_dir)/src/base/elf_mem_image.h',
239        '<(tcmalloc_dir)/src/base/elfcore.h',
240        '<(tcmalloc_dir)/src/base/googleinit.h',
241        '<(tcmalloc_dir)/src/base/linux_syscall_support.h',
242        '<(tcmalloc_dir)/src/base/simple_mutex.h',
243        '<(tcmalloc_dir)/src/base/spinlock_linux-inl.h',
244        '<(tcmalloc_dir)/src/base/spinlock_posix-inl.h',
245        '<(tcmalloc_dir)/src/base/spinlock_win32-inl.h',
246        '<(tcmalloc_dir)/src/base/stl_allocator.h',
247        '<(tcmalloc_dir)/src/base/thread_annotations.h',
248        '<(tcmalloc_dir)/src/getpc.h',
249        '<(tcmalloc_dir)/src/gperftools/heap-checker.h',
250        '<(tcmalloc_dir)/src/gperftools/heap-profiler.h',
251        '<(tcmalloc_dir)/src/gperftools/malloc_extension.h',
252        '<(tcmalloc_dir)/src/gperftools/malloc_extension_c.h',
253        '<(tcmalloc_dir)/src/gperftools/malloc_hook.h',
254        '<(tcmalloc_dir)/src/gperftools/malloc_hook_c.h',
255        '<(tcmalloc_dir)/src/gperftools/profiler.h',
256        '<(tcmalloc_dir)/src/gperftools/stacktrace.h',
257        '<(tcmalloc_dir)/src/gperftools/tcmalloc.h',
258        '<(tcmalloc_dir)/src/heap-checker-bcad.cc',
259        '<(tcmalloc_dir)/src/heap-checker.cc',
260        '<(tcmalloc_dir)/src/libc_override.h',
261        '<(tcmalloc_dir)/src/libc_override_gcc_and_weak.h',
262        '<(tcmalloc_dir)/src/libc_override_glibc.h',
263        '<(tcmalloc_dir)/src/libc_override_osx.h',
264        '<(tcmalloc_dir)/src/libc_override_redefine.h',
265        '<(tcmalloc_dir)/src/malloc_hook_mmap_freebsd.h',
266        '<(tcmalloc_dir)/src/malloc_hook_mmap_linux.h',
267        '<(tcmalloc_dir)/src/memfs_malloc.cc',
268        '<(tcmalloc_dir)/src/packed-cache-inl.h',
269        '<(tcmalloc_dir)/src/page_heap_allocator.h',
270        '<(tcmalloc_dir)/src/pagemap.h',
271        '<(tcmalloc_dir)/src/stacktrace_arm-inl.h',
272        '<(tcmalloc_dir)/src/stacktrace_config.h',
273        '<(tcmalloc_dir)/src/stacktrace_generic-inl.h',
274        '<(tcmalloc_dir)/src/stacktrace_libunwind-inl.h',
275        '<(tcmalloc_dir)/src/stacktrace_powerpc-inl.h',
276        '<(tcmalloc_dir)/src/stacktrace_win32-inl.h',
277        '<(tcmalloc_dir)/src/stacktrace_with_context.cc',
278        '<(tcmalloc_dir)/src/stacktrace_x86-inl.h',
279        '<(tcmalloc_dir)/src/tcmalloc_guard.h',
280        '<(tcmalloc_dir)/src/windows/config.h',
281        '<(tcmalloc_dir)/src/windows/gperftools/tcmalloc.h',
282        '<(tcmalloc_dir)/src/windows/get_mangled_names.cc',
283        '<(tcmalloc_dir)/src/windows/ia32_modrm_map.cc',
284        '<(tcmalloc_dir)/src/windows/ia32_opcode_map.cc',
285        '<(tcmalloc_dir)/src/windows/mingw.h',
286        '<(tcmalloc_dir)/src/windows/mini_disassembler.cc',
287        '<(tcmalloc_dir)/src/windows/mini_disassembler.h',
288        '<(tcmalloc_dir)/src/windows/mini_disassembler_types.h',
289        '<(tcmalloc_dir)/src/windows/override_functions.cc',
290        '<(tcmalloc_dir)/src/windows/patch_functions.cc',
291        '<(tcmalloc_dir)/src/windows/preamble_patcher.cc',
292        '<(tcmalloc_dir)/src/windows/preamble_patcher.h',
293        '<(tcmalloc_dir)/src/windows/preamble_patcher_with_stub.cc',
294      ],
295      'dependencies': [
296        '../third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
297      ],
298      'msvs_settings': {
299        # TODO(sgk):  merge this with build/common.gypi settings
300        'VCLibrarianTool': {
301          'AdditionalOptions': ['/ignore:4006,4221'],
302        },
303        'VCLinkerTool': {
304          'AdditionalOptions': ['/ignore:4006'],
305        },
306      },
307      'configurations': {
308        'Debug_Base': {
309          'msvs_settings': {
310            'VCCLCompilerTool': {
311              'RuntimeLibrary': '0',
312            },
313          },
314          'variables': {
315            # Provide a way to force disable debugallocation in Debug builds,
316            # e.g. for profiling (it's more rare to profile Debug builds,
317            # but people sometimes need to do that).
318            'disable_debugallocation%': 0,
319          },
320          'conditions': [
321            # TODO(phajdan.jr): Also enable on Windows.
322            ['disable_debugallocation==0 and OS!="win"', {
323              'defines': [
324                # Use debugallocation for Debug builds to catch problems early
325                # and cleanly, http://crbug.com/30715 .
326                'TCMALLOC_FOR_DEBUGALLOCATION',
327              ],
328            }],
329          ],
330        },
331      },
332      # Disable the heap checker in tcmalloc.
333      'defines': [
334        'NO_HEAP_CHECK',
335      ],
336      'conditions': [
337        ['OS=="linux" and clang_type_profiler==1', {
338          'dependencies': [
339            'type_profiler_tcmalloc',
340          ],
341          # It is undoing dependencies and cflags_cc for type_profiler which
342          # build/common.gypi injects into all targets.
343          'dependencies!': [
344            'type_profiler',
345          ],
346          'cflags_cc!': [
347            '-fintercept-allocation-functions',
348          ],
349        }],
350        ['OS=="win"', {
351          'defines': [
352            'PERFTOOLS_DLL_DECL=',
353          ],
354          'defines!': [
355            # tcmalloc source files unconditionally define this, remove it from
356            # the list of defines that common.gypi defines globally.
357            'NOMINMAX',
358          ],
359          'dependencies': [
360            'libcmt',
361          ],
362          'include_dirs': [
363            '<(tcmalloc_dir)/src/windows',
364          ],
365          'sources!': [
366            '<(tcmalloc_dir)/src/base/elf_mem_image.cc',
367            '<(tcmalloc_dir)/src/base/elf_mem_image.h',
368            '<(tcmalloc_dir)/src/base/linuxthreads.cc',
369            '<(tcmalloc_dir)/src/base/linuxthreads.h',
370            '<(tcmalloc_dir)/src/base/vdso_support.cc',
371            '<(tcmalloc_dir)/src/base/vdso_support.h',
372            '<(tcmalloc_dir)/src/maybe_threads.cc',
373            '<(tcmalloc_dir)/src/maybe_threads.h',
374            '<(tcmalloc_dir)/src/symbolize.h',
375            '<(tcmalloc_dir)/src/system-alloc.cc',
376            '<(tcmalloc_dir)/src/system-alloc.h',
377
378            # included by allocator_shim.cc
379            'debugallocation_shim.cc',
380          ],
381        }],
382        ['OS=="win" or profiling!=1', {
383          'sources!': [
384            # cpuprofiler
385            '<(tcmalloc_dir)/src/base/thread_lister.c',
386            '<(tcmalloc_dir)/src/base/thread_lister.h',
387            '<(tcmalloc_dir)/src/profiledata.cc',
388            '<(tcmalloc_dir)/src/profiledata.h',
389            '<(tcmalloc_dir)/src/profile-handler.cc',
390            '<(tcmalloc_dir)/src/profile-handler.h',
391            '<(tcmalloc_dir)/src/profiler.cc',
392          ],
393        }],
394        ['OS=="linux" or OS=="freebsd" or OS=="solaris" or OS=="android"', {
395          'sources!': [
396            '<(tcmalloc_dir)/src/system-alloc.h',
397            '<(tcmalloc_dir)/src/windows/port.cc',
398            '<(tcmalloc_dir)/src/windows/port.h',
399
400            # TODO(willchan): Support allocator shim later on.
401            'allocator_shim.cc',
402          ],
403          # We enable all warnings by default, but upstream disables a few.
404          # Keep "-Wno-*" flags in sync with upstream by comparing against:
405          # http://code.google.com/p/google-perftools/source/browse/trunk/Makefile.am
406          'cflags': [
407            '-Wno-sign-compare',
408            '-Wno-unused-result',
409          ],
410          'cflags!': [
411            '-fvisibility=hidden',
412          ],
413          'link_settings': {
414            'ldflags': [
415              # Don't let linker rip this symbol out, otherwise the heap&cpu
416              # profilers will not initialize properly on startup.
417              '-Wl,-uIsHeapProfilerRunning,-uProfilerStart',
418              # Do the same for heap leak checker.
419              '-Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi',
420              '-Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl',
421              '-Wl,-u_ZN15HeapLeakChecker12IgnoreObjectEPKv,-u_ZN15HeapLeakChecker14UnIgnoreObjectEPKv',
422          ]},
423        }],
424        [ 'use_vtable_verify==1', {
425          'cflags': [
426            '-fvtable-verify=preinit',
427          ],
428        }],
429        ['order_profiling != 0', {
430          'target_conditions' : [
431            ['_toolset=="target"', {
432              'cflags!': [ '-finstrument-functions' ],
433            }],
434          ],
435        }],
436      ],
437    },
438    {
439      # This library is linked in to src/base.gypi:base and allocator_unittests
440      # It can't depend on either and nothing else should depend on it - all
441      # other code should use the interfaced provided by base.
442      'target_name': 'allocator_extension_thunks',
443      'type': 'static_library',
444      'sources': [
445        'allocator_extension_thunks.cc',
446        'allocator_extension_thunks.h',
447      ],
448      'toolsets': ['host', 'target'],
449      'include_dirs': [
450        '../../'
451      ],
452      'conditions': [
453        ['OS=="linux" and clang_type_profiler==1', {
454          # It is undoing dependencies and cflags_cc for type_profiler which
455          # build/common.gypi injects into all targets.
456          'dependencies!': [
457            'type_profiler',
458          ],
459          'cflags_cc!': [
460            '-fintercept-allocation-functions',
461          ],
462        }],
463      ],
464    },
465   ],
466  'conditions': [
467    ['OS=="win"', {
468      'targets': [
469        {
470          'target_name': 'libcmt',
471          'type': 'none',
472          'actions': [
473            {
474              'action_name': 'libcmt',
475              'inputs': [
476                'prep_libc.py',
477              ],
478              'outputs': [
479                '<(SHARED_INTERMEDIATE_DIR)/allocator/libcmt.lib',
480              ],
481              'action': [
482                'python',
483                'prep_libc.py',
484                '$(VCInstallDir)lib',
485                '<(SHARED_INTERMEDIATE_DIR)/allocator',
486                '<(target_arch)',
487              ],
488            },
489          ],
490        },
491        {
492          'target_name': 'allocator_unittests',
493          'type': 'executable',
494          'dependencies': [
495            'allocator',
496            'allocator_extension_thunks',
497            '../../testing/gtest.gyp:gtest',
498          ],
499          'include_dirs': [
500            '.',
501            '<(tcmalloc_dir)/src/base',
502            '<(tcmalloc_dir)/src',
503            '../..',
504          ],
505          'sources': [
506            'allocator_unittest.cc',
507            '../profiler/alternate_timer.cc',
508            '../profiler/alternate_timer.h',
509          ],
510        },
511        {
512          'target_name': 'tcmalloc_unittest',
513          'type': 'executable',
514          'sources': [
515            'tcmalloc_unittest.cc',
516          ],
517          'include_dirs': [
518            '../..',
519            # For constants of TCMalloc.
520            '<(tcmalloc_dir)/src',
521          ],
522          'dependencies': [
523            '../../testing/gtest.gyp:gtest',
524            '../base.gyp:base',
525            'allocator',
526          ],
527        },
528      ],
529    }],
530    ['OS=="win" and target_arch=="ia32"', {
531      'targets': [
532        {
533          'target_name': 'allocator_extension_thunks_win64',
534          'type': 'static_library',
535          'sources': [
536            'allocator_extension_thunks.cc',
537            'allocator_extension_thunks.h',
538          ],
539          'toolsets': ['host', 'target'],
540          'include_dirs': [
541            '../../'
542          ],
543          'configurations': {
544            'Common_Base': {
545              'msvs_target_platform': 'x64',
546            },
547          },
548        },
549      ],
550    }],
551    ['OS=="linux" and clang_type_profiler==1', {
552      # Some targets in this section undo dependencies and cflags_cc for
553      # type_profiler which build/common.gypi injects into all targets.
554      'targets': [
555        {
556          'target_name': 'type_profiler',
557          'type': 'static_library',
558          'dependencies!': [
559            'type_profiler',
560          ],
561          'cflags_cc!': [
562            '-fintercept-allocation-functions',
563          ],
564          'include_dirs': [
565            '../..',
566          ],
567          'sources': [
568            'type_profiler.cc',
569            'type_profiler.h',
570            'type_profiler_control.h',
571          ],
572          'toolsets': ['host', 'target'],
573        },
574        {
575          'target_name': 'type_profiler_tcmalloc',
576          'type': 'static_library',
577          'dependencies!': [
578            'type_profiler',
579          ],
580          'cflags_cc!': [
581            '-fintercept-allocation-functions',
582          ],
583          'include_dirs': [
584            '<(tcmalloc_dir)/src',
585            '../..',
586          ],
587          'sources': [
588            'type_profiler_tcmalloc.cc',
589            'type_profiler_tcmalloc.h',
590            '<(tcmalloc_dir)/src/gperftools/type_profiler_map.h',
591            '<(tcmalloc_dir)/src/type_profiler_map.cc',
592          ],
593        },
594        {
595          'target_name': 'type_profiler_unittests',
596          'type': 'executable',
597          'dependencies': [
598            '../../testing/gtest.gyp:gtest',
599            '../base.gyp:base',
600            'allocator',
601            'type_profiler_tcmalloc',
602          ],
603          'include_dirs': [
604            '../..',
605          ],
606          'sources': [
607            'type_profiler_control.cc',
608            'type_profiler_control.h',
609            'type_profiler_unittest.cc',
610          ],
611        },
612        {
613          'target_name': 'type_profiler_map_unittests',
614          'type': 'executable',
615          'dependencies': [
616            '../../testing/gtest.gyp:gtest',
617            '../base.gyp:base',
618            'allocator',
619          ],
620          'dependencies!': [
621            'type_profiler',
622          ],
623          'cflags_cc!': [
624            '-fintercept-allocation-functions',
625          ],
626          'include_dirs': [
627            '<(tcmalloc_dir)/src',
628            '../..',
629          ],
630          'sources': [
631            'type_profiler_map_unittest.cc',
632            '<(tcmalloc_dir)/src/gperftools/type_profiler_map.h',
633            '<(tcmalloc_dir)/src/type_profiler_map.cc',
634          ],
635        },
636      ],
637    }],
638  ],
639}
640