OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/buildflag_header.gni") | 5 import("//build/buildflag_header.gni") |
6 import("//build/config/allocator.gni") | 6 import("//build/config/allocator.gni") |
7 import("//build/config/compiler/compiler.gni") | 7 import("//build/config/compiler/compiler.gni") |
8 | 8 |
9 if (is_win) { | |
10 import("//build/config/win/visual_studio_version.gni") | |
11 } | |
12 | |
13 declare_args() { | 9 declare_args() { |
14 # Provide a way to force disable debugallocation in Debug builds, | 10 # Provide a way to force disable debugallocation in Debug builds, |
15 # e.g. for profiling (it's more rare to profile Debug builds, | 11 # e.g. for profiling (it's more rare to profile Debug builds, |
16 # but people sometimes need to do that). | 12 # but people sometimes need to do that). |
17 enable_debugallocation = is_debug | 13 enable_debugallocation = is_debug |
18 } | 14 } |
19 | 15 |
20 # This "allocator" meta-target will forward to the default allocator according | 16 # This "allocator" meta-target will forward to the default allocator according |
21 # to the build settings. | 17 # to the build settings. |
22 group("allocator") { | 18 group("allocator") { |
23 if (!is_nacl) { | 19 public_deps = [] |
24 deps = [] | 20 deps = [] |
25 | 21 |
26 if (use_allocator == "tcmalloc") { | 22 if (use_allocator == "tcmalloc") { |
27 deps += [ ":tcmalloc" ] | 23 deps += [ ":tcmalloc" ] |
28 } | 24 } |
29 | 25 |
30 # This condition expresses the win_use_allocator_shim in the GYP build. | 26 # This condition expresses the win_use_allocator_shim in the GYP build. |
31 if (is_win && !is_component_build && visual_studio_version != "2015") { | 27 if (is_win && !is_component_build && !is_debug) { |
32 deps += [ ":allocator_shim" ] | 28 public_deps += [ ":allocator_shim" ] |
33 all_dependent_configs = [ ":nocmt" ] | 29 } |
34 } | |
35 } # !is_nacl | |
36 } | 30 } |
37 | 31 |
38 # This config defines ALLOCATOR_SHIM in the same conditions that the allocator | 32 # This config defines ALLOCATOR_SHIM in the same conditions that the allocator |
39 # shim will be used by the allocator target. | 33 # shim will be used by the allocator target. |
40 # | 34 # |
41 # TODO(brettw) this is only used in one place and is kind of mess, because it | 35 # TODO(brettw) this is only used in one place and is kind of mess, because it |
42 # assumes that the library using it will eventually be linked with | 36 # assumes that the library using it will eventually be linked with |
43 # //base/allocator in the default way. Clean this up and delete this. | 37 # //base/allocator in the default way. Clean this up and delete this. |
44 config("allocator_shim_define") { | 38 config("allocator_shim_define") { |
45 if (is_win && !is_component_build && visual_studio_version != "2015") { | 39 if (is_win && !is_component_build && !is_debug) { |
46 defines = [ "ALLOCATOR_SHIM" ] | 40 defines = [ "ALLOCATOR_SHIM" ] |
47 } | 41 } |
48 } | 42 } |
49 | 43 |
50 config("tcmalloc_flags") { | 44 config("tcmalloc_flags") { |
51 defines = [] | 45 defines = [] |
52 if (enable_debugallocation) { | 46 if (enable_debugallocation) { |
53 defines += [ | 47 defines += [ |
54 # Use debugallocation for Debug builds to catch problems early | 48 # Use debugallocation for Debug builds to catch problems early |
55 # and cleanly, http://crbug.com/30715 . | 49 # and cleanly, http://crbug.com/30715 . |
(...skipping 15 matching lines...) Expand all Loading... |
71 # typedefs. | 65 # typedefs. |
72 "-Wno-unused-local-typedefs", | 66 "-Wno-unused-local-typedefs", |
73 | 67 |
74 # for magic2_ in debugallocation.cc (only built in Debug builds) | 68 # for magic2_ in debugallocation.cc (only built in Debug builds) |
75 # typedefs. | 69 # typedefs. |
76 "-Wno-unused-private-field", | 70 "-Wno-unused-private-field", |
77 ] | 71 ] |
78 } | 72 } |
79 } | 73 } |
80 | 74 |
81 # This config and libc modification are only used on Windows. | 75 # This config is only used on Windows static release builds for the |
82 if (is_win) { | 76 # allocator shim. |
83 config("nocmt") { | 77 if (is_win && !is_component_build && !is_debug) { |
84 ldflags = [ | 78 source_set("allocator_shim") { |
85 "/NODEFAULTLIB:libcmt", | 79 sources = [ |
86 "/NODEFAULTLIB:libcmtd", | 80 "allocator_shim_win.cc", |
| 81 "allocator_shim_win.h", |
87 ] | 82 ] |
88 libs = [ rebase_path("$target_gen_dir/allocator/libcmt.lib") ] | 83 configs += [ ":allocator_shim_define" ] |
89 } | |
90 | |
91 if (!is_component_build && visual_studio_version != "2015") { | |
92 action("prep_libc") { | |
93 script = "prep_libc.py" | |
94 outputs = [ | |
95 "$target_gen_dir/allocator/libcmt.lib", | |
96 ] | |
97 args = [ | |
98 visual_studio_path + "/vc/lib", | |
99 rebase_path("$target_gen_dir/allocator"), | |
100 current_cpu, | |
101 | |
102 # The environment file in the build directory. This is required because | |
103 # the Windows toolchain setup saves the VC paths and such so that | |
104 # running "mc.exe" will work with the configured toolchain. This file | |
105 # is in the root build dir. | |
106 "environment.$current_cpu", | |
107 ] | |
108 } | |
109 | |
110 source_set("allocator_shim") { | |
111 sources = [ | |
112 "allocator_shim_win.cc", | |
113 ] | |
114 configs -= [ "//build/config/compiler:chromium_code" ] | |
115 configs += [ "//build/config/compiler:no_chromium_code" ] | |
116 | |
117 deps = [ | |
118 ":prep_libc", | |
119 ] | |
120 } | |
121 } | 84 } |
122 } | 85 } |
123 | 86 |
124 if (use_allocator == "tcmalloc") { | 87 if (use_allocator == "tcmalloc") { |
125 # tcmalloc currently won't compile on Android. | 88 # tcmalloc currently won't compile on Android. |
126 source_set("tcmalloc") { | 89 source_set("tcmalloc") { |
127 tcmalloc_dir = "//third_party/tcmalloc/chromium" | 90 tcmalloc_dir = "//third_party/tcmalloc/chromium" |
128 | 91 |
129 # Don't check tcmalloc's includes. These files include various files like | 92 # Don't check tcmalloc's includes. These files include various files like |
130 # base/foo.h and they actually refer to tcmalloc's forked copy of base | 93 # base/foo.h and they actually refer to tcmalloc's forked copy of base |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 "allocator_shim_override_glibc_weak_symbols.h", | 283 "allocator_shim_override_glibc_weak_symbols.h", |
321 ] | 284 ] |
322 deps = [ | 285 deps = [ |
323 ":tcmalloc", | 286 ":tcmalloc", |
324 ] | 287 ] |
325 } else if (is_linux && use_allocator == "none") { | 288 } else if (is_linux && use_allocator == "none") { |
326 sources += [ "allocator_shim_default_dispatch_to_glibc.cc" ] | 289 sources += [ "allocator_shim_default_dispatch_to_glibc.cc" ] |
327 } | 290 } |
328 } | 291 } |
329 } | 292 } |
OLD | NEW |