Skip to content

Commit b9fa8f3

Browse files
committed
build: add --error-on-warn configure flag
This commit adds a configuration time flag named error-on-warn: $ ./configure --help | grep -A1 error-on-warn --error-on-warn Turn compiler warnings into errors for node core sources. The motivation for this is that CI jobs can use this flag to turn warnings into errors.
1 parent 2379516 commit b9fa8f3

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

common.gypi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
'uv_library%': 'static_library',
2727

2828
'clang%': 0,
29+
'error_on_warn%': '0',
2930

3031
'openssl_fips%': '',
3132
'openssl_no_asm%': 0,
@@ -219,8 +220,9 @@
219220
# simply not feasible to squelch all warnings, never mind that the
220221
# libraries in deps/ are not under our control.
221222
'conditions': [
222-
['_target_name!="<(node_lib_target_name)" or '
223-
'_target_name!="<(node_core_target_name)"', {
223+
[ 'error_on_warn=="true" and '
224+
'(_target_name!="<(node_lib_target_name)" or '
225+
'_target_name!="<(node_core_target_name)")', {
224226
'cflags!': ['-Werror'],
225227
}],
226228
],

configure.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@
117117
choices=valid_os,
118118
help='operating system to build for ({0})'.format(', '.join(valid_os)))
119119

120+
parser.add_option('--error-on-warn',
121+
action='store_true',
122+
dest='error_on_warn',
123+
help='Turn compiler warnings into errors for node core sources.')
124+
120125
parser.add_option('--gdb',
121126
action='store_true',
122127
dest='gdb',
@@ -1018,6 +1023,7 @@ def configure_node(o):
10181023
o['variables']['node_install_npm'] = b(not options.without_npm)
10191024
o['variables']['debug_node'] = b(options.debug_node)
10201025
o['default_configuration'] = 'Debug' if options.debug else 'Release'
1026+
o['variables']['error_on_warn'] = b(options.error_on_warn)
10211027

10221028
host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
10231029
target_arch = options.dest_cpu or host_arch

node.gyp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@
346346
'node.gypi'
347347
],
348348

349-
'cflags': [ '-Werror', ],
350-
351349
'include_dirs': [
352350
'src',
353351
'deps/v8/include'
@@ -377,6 +375,9 @@
377375
'msvs_disabled_warnings!': [4244],
378376

379377
'conditions': [
378+
[ 'error_on_warn=="true"', {
379+
'cflags': ['-Werror'],
380+
}],
380381
[ 'node_intermediate_lib_type=="static_library" and '
381382
'node_shared=="true" and OS=="aix"', {
382383
# For AIX, shared lib is linked by static lib and .exp. In the
@@ -530,8 +531,6 @@
530531
'node.gypi',
531532
],
532533

533-
'cflags': [ '-Werror', ],
534-
535534
'include_dirs': [
536535
'src',
537536
'<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
@@ -753,6 +752,9 @@
753752
'msvs_disabled_warnings!': [4244],
754753

755754
'conditions': [
755+
[ 'error_on_warn=="true"', {
756+
'cflags': ['-Werror'],
757+
}],
756758
[ 'node_builtin_modules_path!=""', {
757759
'defines': [ 'NODE_BUILTIN_MODULES_PATH="<(node_builtin_modules_path)"' ]
758760
}],

0 commit comments

Comments
 (0)