| 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/config/compiler/compiler.gni") | 5 import("//build/config/compiler/compiler.gni") |
| 6 import("//build/config/sanitizers/sanitizers.gni") | 6 import("//build/config/sanitizers/sanitizers.gni") |
| 7 import("//build/config/win/visual_studio_version.gni") | 7 import("//build/config/win/visual_studio_version.gni") |
| 8 | 8 |
| 9 assert(is_win) | 9 assert(is_win) |
| 10 | 10 |
| 11 declare_args() { |
| 12 # Set this to true to enable static analysis through Visual Studio's |
| 13 # /analyze. This dramatically slows compiles and reports thousands of |
| 14 # warnings, so normally this is done on a build machine and only the new |
| 15 # warnings are examined. |
| 16 use_vs_code_analysis = false |
| 17 } |
| 18 |
| 11 # This is included by reference in the //build/config/compiler config that | 19 # This is included by reference in the //build/config/compiler config that |
| 12 # is applied to all targets. It is here to separate out the logic that is | 20 # is applied to all targets. It is here to separate out the logic that is |
| 13 # Windows-only. | 21 # Windows-only. |
| 14 config("compiler") { | 22 config("compiler") { |
| 15 if (current_cpu == "x86") { | 23 if (current_cpu == "x86") { |
| 16 asmflags = [ | 24 asmflags = [ |
| 17 # When /safeseh is specified, the linker will only produce an image if it | 25 # When /safeseh is specified, the linker will only produce an image if it |
| 18 # can also produce a table of the image's safe exception handlers. This | 26 # can also produce a table of the image's safe exception handlers. This |
| 19 # table specifies for the operating system which exception handlers are | 27 # table specifies for the operating system which exception handlers are |
| 20 # valid for the image. Note that /SAFESEH isn't accepted on the command | 28 # valid for the image. Note that /SAFESEH isn't accepted on the command |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 81 } |
| 74 } | 82 } |
| 75 | 83 |
| 76 if (is_syzyasan) { | 84 if (is_syzyasan) { |
| 77 # SyzyAsan needs /PROFILE turned on to produce appropriate pdbs. | 85 # SyzyAsan needs /PROFILE turned on to produce appropriate pdbs. |
| 78 assert(!is_win_fastlink, "/PROFILE and /DEBUG:FASTLINK are incompatible") | 86 assert(!is_win_fastlink, "/PROFILE and /DEBUG:FASTLINK are incompatible") |
| 79 ldflags = [ "/PROFILE" ] | 87 ldflags = [ "/PROFILE" ] |
| 80 } | 88 } |
| 81 } | 89 } |
| 82 | 90 |
| 91 config("vs_code_analysis") { |
| 92 if (use_vs_code_analysis) { |
| 93 # When use_vs_code_analysis is specified add the /analyze switch to enable |
| 94 # static analysis. Specifying /analyze:WX- says that /analyze warnings |
| 95 # should not be treated as errors. |
| 96 cflags = [ "/analyze:WX-" ] |
| 97 |
| 98 # Also, disable various noisy warnings that have low value. |
| 99 cflags += [ |
| 100 "/wd6011", # Dereferencing NULL pointer |
| 101 |
| 102 # C6285 is ~16% of raw warnings and has low value |
| 103 "/wd6285", # non-zero constant || non-zero constant |
| 104 "/wd6308", # realloc might return null pointer |
| 105 |
| 106 # Possible infinite loop: use of the constant |
| 107 # EXCEPTION_CONTINUE_EXECUTION in the exception-filter |
| 108 "/wd6312", |
| 109 |
| 110 "/wd6322", # Empty _except block |
| 111 "/wd6330", # 'char' used instead of 'unsigned char' for istype() call |
| 112 |
| 113 # C6334 is ~80% of raw warnings and has low value |
| 114 "/wd6334", # sizeof applied to an expression with an operator |
| 115 "/wd6326", # Potential comparison of constant with constant |
| 116 "/wd6340", # Sign mismatch in function parameter |
| 117 "/wd28159", # Consider using 'GetTickCount64' |
| 118 "/wd28196", # The precondition is not satisfied |
| 119 "/wd28204", # Inconsistent SAL annotations |
| 120 "/wd28251", # Inconsistent SAL annotations |
| 121 "/wd28252", # Inconsistent SAL annotations |
| 122 "/wd28253", # Inconsistent SAL annotations |
| 123 "/wd28278", # Function appears with no prototype in scope |
| 124 "/wd28285", # syntax error in SAL annotation (in algorithm) |
| 125 "/wd28301", # Inconsistent SAL annotations |
| 126 "/wd28182", # Dereferencing NULL pointer |
| 127 ] |
| 128 } |
| 129 } |
| 130 |
| 83 # This is included by reference in the //build/config/compiler:runtime_library | 131 # This is included by reference in the //build/config/compiler:runtime_library |
| 84 # config that is applied to all targets. It is here to separate out the logic | 132 # config that is applied to all targets. It is here to separate out the logic |
| 85 # that is Windows-only. Please see that target for advice on what should go in | 133 # that is Windows-only. Please see that target for advice on what should go in |
| 86 # :runtime_library vs. :compiler. | 134 # :runtime_library vs. :compiler. |
| 87 config("runtime_library") { | 135 config("runtime_library") { |
| 88 cflags = [] | 136 cflags = [] |
| 89 | 137 |
| 90 # Defines that set up the CRT. | 138 # Defines that set up the CRT. |
| 91 defines = [ | 139 defines = [ |
| 92 "__STD_C", | 140 "__STD_C", |
| 93 "_CRT_RAND_S", | 141 "_CRT_RAND_S", |
| 94 "_CRT_SECURE_NO_DEPRECATE", | 142 "_CRT_SECURE_NO_DEPRECATE", |
| 95 "_HAS_EXCEPTIONS=0", | 143 "_HAS_EXCEPTIONS=0", |
| 96 "_SCL_SECURE_NO_DEPRECATE", | 144 "_SCL_SECURE_NO_DEPRECATE", |
| 97 ] | 145 ] |
| 98 | 146 |
| 99 # Defines that set up the Windows SDK. | 147 # Defines that set up the Windows SDK. |
| 100 defines += [ | 148 defines += [ |
| 101 "_ATL_NO_OPENGL", | 149 "_ATL_NO_OPENGL", |
| 102 "_WINDOWS", | 150 "_WINDOWS", |
| 103 "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS", | 151 "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS", |
| 104 "NTDDI_VERSION=0x0A000000", | 152 "NTDDI_VERSION=0x0A000000", |
| 105 "PSAPI_VERSION=1", | 153 "PSAPI_VERSION=1", |
| 106 "WIN32", | 154 "WIN32", |
| 107 "_SECURE_ATL", | 155 "_SECURE_ATL", |
| 156 ] |
| 108 | 157 |
| 158 if (!use_vs_code_analysis) { |
| 109 # This is required for ATL to use XP-safe versions of its functions. | 159 # This is required for ATL to use XP-safe versions of its functions. |
| 110 "_USING_V110_SDK71_", | 160 # However it is prohibited when using /analyze |
| 111 ] | 161 defines += [ "_USING_V110_SDK71_" ] |
| 162 } |
| 112 | 163 |
| 113 if (is_component_build) { | 164 if (is_component_build) { |
| 114 # Component mode: dynamic CRT. Since the library is shared, it requires | 165 # Component mode: dynamic CRT. Since the library is shared, it requires |
| 115 # exceptions or will give errors about things not matching, so keep | 166 # exceptions or will give errors about things not matching, so keep |
| 116 # exceptions on. | 167 # exceptions on. |
| 117 if (is_debug) { | 168 if (is_debug) { |
| 118 cflags += [ "/MDd" ] | 169 cflags += [ "/MDd" ] |
| 119 } else { | 170 } else { |
| 120 cflags += [ "/MD" ] | 171 cflags += [ "/MD" ] |
| 121 } | 172 } |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 363 |
| 313 # Internal stuff -------------------------------------------------------------- | 364 # Internal stuff -------------------------------------------------------------- |
| 314 | 365 |
| 315 # Config used by the MIDL template to disable warnings. | 366 # Config used by the MIDL template to disable warnings. |
| 316 config("midl_warnings") { | 367 config("midl_warnings") { |
| 317 if (is_clang) { | 368 if (is_clang) { |
| 318 # MIDL generates code like "#endif !_MIDL_USE_GUIDDEF_". | 369 # MIDL generates code like "#endif !_MIDL_USE_GUIDDEF_". |
| 319 cflags = [ "-Wno-extra-tokens" ] | 370 cflags = [ "-Wno-extra-tokens" ] |
| 320 } | 371 } |
| 321 } | 372 } |
| OLD | NEW |