Skip to content

Commit a7ae7aa

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. PR-URL: #32685 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
1 parent 8698dd9 commit a7ae7aa

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

common.gypi

Lines changed: 9 additions & 1 deletion
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%': 'false',
2930

3031
'openssl_fips%': '',
3132
'openssl_no_asm%': 0,
@@ -218,7 +219,14 @@
218219
# Forcibly disable -Werror. We support a wide range of compilers, it's
219220
# simply not feasible to squelch all warnings, never mind that the
220221
# libraries in deps/ are not under our control.
221-
'cflags!': ['-Werror'],
222+
'conditions': [
223+
[ 'error_on_warn=="false"', {
224+
'cflags!': ['-Werror'],
225+
}, '(_target_name!="<(node_lib_target_name)" or '
226+
'_target_name!="<(node_core_target_name)")', {
227+
'cflags!': ['-Werror'],
228+
}],
229+
],
222230
'msvs_settings': {
223231
'VCCLCompilerTool': {
224232
'BufferSecurityCheck': 'true',

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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@
376376
'msvs_disabled_warnings!': [4244],
377377

378378
'conditions': [
379+
[ 'error_on_warn=="true"', {
380+
'cflags': ['-Werror'],
381+
}],
379382
[ 'node_intermediate_lib_type=="static_library" and '
380383
'node_shared=="true" and OS=="aix"', {
381384
# For AIX, shared lib is linked by static lib and .exp. In the
@@ -750,6 +753,9 @@
750753
'msvs_disabled_warnings!': [4244],
751754

752755
'conditions': [
756+
[ 'error_on_warn=="true"', {
757+
'cflags': ['-Werror'],
758+
}],
753759
[ 'node_builtin_modules_path!=""', {
754760
'defines': [ 'NODE_BUILTIN_MODULES_PATH="<(node_builtin_modules_path)"' ]
755761
}],

0 commit comments

Comments
 (0)