Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Side by Side Diff: build/config/compiler/BUILD.gn

Issue 1422463013: Allow disabling warnings as errors in GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: windows Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/android/config.gni") 5 import("//build/config/android/config.gni")
6 import("//build/config/chrome_build.gni") 6 import("//build/config/chrome_build.gni")
7 import("//build/config/compiler/compiler.gni") 7 import("//build/config/compiler/compiler.gni")
8 import("//build/config/nacl/config.gni") 8 import("//build/config/nacl/config.gni")
9 import("//build/toolchain/ccache.gni") 9 import("//build/toolchain/ccache.gni")
10 10
11 if (current_cpu == "arm") { 11 if (current_cpu == "arm") {
12 import("//build/config/arm.gni") 12 import("//build/config/arm.gni")
13 } 13 }
14 if (current_cpu == "mipsel" || current_cpu == "mips64el") { 14 if (current_cpu == "mipsel" || current_cpu == "mips64el") {
15 import("//build/config/mips.gni") 15 import("//build/config/mips.gni")
16 } 16 }
17 if (is_posix) { 17 if (is_posix) {
18 import("//build/config/gcc/gcc_version.gni") 18 import("//build/config/gcc/gcc_version.gni")
19 } 19 }
20 if (is_win) { 20 if (is_win) {
21 import("//build/config/win/visual_studio_version.gni") 21 import("//build/config/win/visual_studio_version.gni")
22 } 22 }
23 23
24 declare_args() { 24 declare_args() {
25 # Default to warnings as errors for default workflow, where we catch
26 # warnings with known toolchains. Allow overriding this e.g. for Chromium
27 # builds on Linux that could use a different version of the compiler.
28 treat_warnings_as_errors = true
29
25 # Normally, Android builds are lightly optimized, even for debug builds, to 30 # Normally, Android builds are lightly optimized, even for debug builds, to
26 # keep binary size down. Setting this flag to true disables such optimization 31 # keep binary size down. Setting this flag to true disables such optimization
27 android_full_debug = false 32 android_full_debug = false
28 33
29 # Whether to use the binary binutils checked into third_party/binutils. 34 # Whether to use the binary binutils checked into third_party/binutils.
30 # These are not multi-arch so cannot be used except on x86 and x86-64 (the 35 # These are not multi-arch so cannot be used except on x86 and x86-64 (the
31 # only two architectures that are currently checked in). Turn this off when 36 # only two architectures that are currently checked in). Turn this off when
32 # you are using a custom toolchain and need to control -B in cflags. 37 # you are using a custom toolchain and need to control -B in cflags.
33 linux_use_bundled_binutils = is_linux && current_cpu == "x64" 38 linux_use_bundled_binutils = is_linux && current_cpu == "x64"
34 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", 39 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin",
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 # default_warnings ------------------------------------------------------------ 599 # default_warnings ------------------------------------------------------------
595 # 600 #
596 # Collects all warning flags that are used by default. This is used as a 601 # Collects all warning flags that are used by default. This is used as a
597 # subconfig of both chromium_code and no_chromium_code. This way these 602 # subconfig of both chromium_code and no_chromium_code. This way these
598 # flags are guaranteed to appear on the compile command line after -Wall. 603 # flags are guaranteed to appear on the compile command line after -Wall.
599 config("default_warnings") { 604 config("default_warnings") {
600 cflags = [] 605 cflags = []
601 cflags_cc = [] 606 cflags_cc = []
602 607
603 if (is_win) { 608 if (is_win) {
609 if (treat_warnings_as_errors) {
610 cflags += [ "/WX" ]
611 }
612
604 cflags += [ 613 cflags += [
605 # Treat warnings as errors.
606 "/WX",
607
608 # Warnings permanently disabled: 614 # Warnings permanently disabled:
609 615
610 # C4127: conditional expression is constant 616 # C4127: conditional expression is constant
611 # This warning can in theory catch dead code and other problems, but 617 # This warning can in theory catch dead code and other problems, but
612 # triggers in far too many desirable cases where the conditional 618 # triggers in far too many desirable cases where the conditional
613 # expression is either set by macros or corresponds some legitimate 619 # expression is either set by macros or corresponds some legitimate
614 # compile-time constant expression (due to constant template args, 620 # compile-time constant expression (due to constant template args,
615 # conditionals comparing the sizes of different types, etc.). Some of 621 # conditionals comparing the sizes of different types, etc.). Some of
616 # these can be worked around, but it's not worth it. 622 # these can be worked around, but it's not worth it.
617 "/wd4127", 623 "/wd4127",
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 # Disable unused-value (crbug.com/505318) except -Wunused-result. 703 # Disable unused-value (crbug.com/505318) except -Wunused-result.
698 "-Wno-unused-value", 704 "-Wno-unused-value",
699 "-Wunused-result", 705 "-Wunused-result",
700 ] 706 ]
701 } 707 }
702 } else { 708 } else {
703 # Common GCC warning setup. 709 # Common GCC warning setup.
704 cflags += [ 710 cflags += [
705 # Enables. 711 # Enables.
706 "-Wendif-labels", # Weird old-style text after an #endif. 712 "-Wendif-labels", # Weird old-style text after an #endif.
707 "-Werror", # Warnings as errors.
708 713
709 # Disables. 714 # Disables.
710 "-Wno-missing-field-initializers", # "struct foo f = {0};" 715 "-Wno-missing-field-initializers", # "struct foo f = {0};"
711 "-Wno-unused-parameter", # Unused function parameters. 716 "-Wno-unused-parameter", # Unused function parameters.
712 ] 717 ]
713 718
719 if (treat_warnings_as_errors) {
720 cflags += [ "-Werror" ]
721 }
722
714 if (is_mac) { 723 if (is_mac) {
715 cflags += [ "-Wnewline-eof" ] 724 cflags += [ "-Wnewline-eof" ]
716 if (!is_nacl) { 725 if (!is_nacl) {
717 # When compiling Objective-C, warns if a method is used whose 726 # When compiling Objective-C, warns if a method is used whose
718 # availability is newer than the deployment target. This is not 727 # availability is newer than the deployment target. This is not
719 # required when compiling Chrome for iOS. 728 # required when compiling Chrome for iOS.
720 cflags += [ "-Wpartial-availability" ] 729 cflags += [ "-Wpartial-availability" ]
721 } 730 }
722 } 731 }
723 732
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 if (symbol_level == 0) { 1236 if (symbol_level == 0) {
1228 configs = [ ":no_symbols" ] 1237 configs = [ ":no_symbols" ]
1229 } else if (symbol_level == 1) { 1238 } else if (symbol_level == 1) {
1230 configs = [ ":minimal_symbols" ] 1239 configs = [ ":minimal_symbols" ]
1231 } else if (symbol_level == 2) { 1240 } else if (symbol_level == 2) {
1232 configs = [ ":symbols" ] 1241 configs = [ ":symbols" ]
1233 } else { 1242 } else {
1234 assert(false) 1243 assert(false)
1235 } 1244 }
1236 } 1245 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698