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