@@ -573,6 +573,11 @@ options.prefix = os.path.expanduser(options.prefix or '')
573573auto_downloads = nodedownload.parse(options.download_list)
574574
575575
576+ def error(msg):
577+ prefix = ' \033[1m\033[31mERROR\033[0m' if os.isatty(1) else ' ERROR'
578+ print(' %s: %s' % (prefix, msg))
579+ sys.exit(1)
580+
576581def warn(msg):
577582 warn.warned = True
578583 prefix = ' \033[1m\033[93mWARNING\033[0m' if os.isatty(1) else ' WARNING'
@@ -634,13 +639,11 @@ def get_version_helper(cc, regexp):
634639 proc = subprocess.Popen(shlex.split(cc) + [' -v' ], stdin=subprocess.PIPE,
635640 stderr=subprocess.PIPE, stdout=subprocess.PIPE)
636641 except OSError:
637- print (' ' ' Node.js configure error: No acceptable C compiler found!
642+ error (' ' ' No acceptable C compiler found!
638643
639- Please make sure you have a C compiler installed on your system and/or
640- consider adjusting the CC environment variable if you installed
641- it in a non-standard prefix.
642- ' ' ' )
643- sys.exit ()
644+ Please make sure you have a C compiler installed on your system and/or
645+ consider adjusting the CC environment variable if you installed
646+ it in a non-standard prefix.' ' ' )
644647
645648 match = re.search(regexp, proc.communicate ()[1])
646649
@@ -656,7 +659,7 @@ def get_nasm_version(asm):
656659 stdout=subprocess.PIPE)
657660 except OSError:
658661 warn(' ' ' No acceptable ASM compiler found!
659- Please make sure you have installed nasm from http://www.nasm.us
662+ Please make sure you have installed NASM from http://www.nasm.us
660663 and refer BUILDING.md.' ' ' )
661664 return 0
662665
@@ -684,13 +687,11 @@ def get_gas_version(cc):
684687 stdin=subprocess.PIPE, stderr=subprocess.PIPE,
685688 stdout=subprocess.PIPE)
686689 except OSError:
687- print (' ' ' Node.js configure error: No acceptable C compiler found!
690+ error (' ' ' No acceptable C compiler found!
688691
689- Please make sure you have a C compiler installed on your system and/or
690- consider adjusting the CC environment variable if you installed
691- it in a non-standard prefix.
692- ' ' ' )
693- sys.exit ()
692+ Please make sure you have a C compiler installed on your system and/or
693+ consider adjusting the CC environment variable if you installed
694+ it in a non-standard prefix.' ' ' )
694695
695696 match = re.match(r" GNU assembler version ([2-9]\.[0-9]+)" ,
696697 proc.communicate ()[1])
@@ -750,13 +751,11 @@ def cc_macros(cc=None):
750751 stdout=subprocess.PIPE,
751752 stderr=subprocess.PIPE)
752753 except OSError:
753- print (' ' ' Node.js configure error: No acceptable C compiler found!
754+ error (' ' ' No acceptable C compiler found!
754755
755- Please make sure you have a C compiler installed on your system and/or
756- consider adjusting the CC environment variable if you installed
757- it in a non-standard prefix.
758- ' ' ' )
759- sys.exit ()
756+ Please make sure you have a C compiler installed on your system and/or
757+ consider adjusting the CC environment variable if you installed
758+ it in a non-standard prefix.' ' ' )
760759
761760 p.stdin.write(' \n' )
762761 out = p.communicate ()[0]
@@ -1108,8 +1107,7 @@ def configure_openssl(o):
11081107 variables[' openssl_no_asm' ] = 1
11091108
11101109 if options.openssl_fips:
1111- print(' Error: FIPS is not supported yet in this version' )
1112- exit(1)
1110+ error(' FIPS is not supported in this version' )
11131111 variables[' openssl_fips' ] = ' '
11141112
11151113 if options.without_ssl:
@@ -1178,9 +1176,8 @@ def configure_intl(o):
11781176 def icu_download(path):
11791177 # download ICU, if needed
11801178 if not os.access(options.download_path, os.W_OK):
1181- print(' Error: cannot write to desired download path. ' \
1182- ' Either create it or verify permissions.' )
1183- sys.exit(1)
1179+ error(' ' ' Cannot write to desired download path.
1180+ Either create it or verify permissions.' ' ' )
11841181 for icu in icus:
11851182 url = icu[' url' ]
11861183 md5 = icu[' md5' ]
@@ -1219,8 +1216,7 @@ def configure_intl(o):
12191216 with_icu_source = options.with_icu_source
12201217 have_icu_path = bool(options.with_icu_path)
12211218 if have_icu_path and with_intl ! = ' none' :
1222- print(' Error: Cannot specify both --with-icu-path and --with-intl' )
1223- sys.exit(1)
1219+ error(' Cannot specify both --with-icu-path and --with-intl' )
12241220 elif have_icu_path:
12251221 # Chromium .gyp mode: --with-icu-path
12261222 o[' variables' ][' v8_enable_i18n_support' ] = 1
@@ -1248,9 +1244,8 @@ def configure_intl(o):
12481244 o[' variables' ][' v8_enable_i18n_support' ] = 1
12491245 pkgicu = pkg_config(' icu-i18n' )
12501246 if pkgicu[0] is None:
1251- print(' Error: could not load pkg-config data for "icu-i18n".' )
1252- print(' See above errors or the README.md.' )
1253- sys.exit(1)
1247+ error(' ' ' Could not load pkg-config data for "icu-i18n".
1248+ See above errors or the README.md.' ' ' )
12541249 (libs, cflags, libpath) = pkgicu
12551250 # libpath provides linker path which may contain spaces
12561251 if libpath:
@@ -1336,10 +1331,9 @@ def configure_intl(o):
13361331 os.rename(tmp_icu, icu_full_path)
13371332 shutil.rmtree(icu_tmp_path)
13381333 else:
1339- print(' Error: --with-icu-source=%s did not result in an "icu" dir.' % \
1340- with_icu_source)
13411334 shutil.rmtree(icu_tmp_path)
1342- sys.exit(1)
1335+ error(' --with-icu-source=%s did not result in an "icu" dir.' % \
1336+ with_icu_source)
13431337
13441338 # ICU mode. (icu-generic.gyp)
13451339 o[' variables' ][' icu_gyp_path' ] = ' tools/icu/icu-generic.gyp'
@@ -1352,17 +1346,15 @@ def configure_intl(o):
13521346 if localzip:
13531347 nodedownload.unpack(localzip, icu_parent_path)
13541348 if not os.path.isdir(icu_full_path):
1355- print(' Cannot build Intl without ICU in %s.' % icu_full_path)
1356- print(' (Fix, or disable with " --with-intl=none" )' )
1357- sys.exit(1)
1349+ error(' ' ' Cannot build Intl without ICU in %s.
1350+ Fix, or disable with " --with-intl=none" ' ' ' % icu_full_path)
13581351 else:
13591352 print(' * Using ICU in %s' % icu_full_path)
13601353 # Now, what version of ICU is it? We just need the "major", such as 54.
13611354 # uvernum.h contains it as a #define.
13621355 uvernum_h = os.path.join(icu_full_path, ' source/common/unicode/uvernum.h' )
13631356 if not os.path.isfile(uvernum_h):
1364- print(' Error: could not load %s - is ICU installed? ' % uvernum_h)
1365- sys.exit(1)
1357+ error(' Could not load %s - is ICU installed? ' % uvernum_h)
13661358 icu_ver_major = None
13671359 matchVerExp = r' ^\s * # define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
13681360 match_version = re.compile(matchVerExp)
@@ -1371,8 +1363,7 @@ def configure_intl(o):
13711363 if m:
13721364 icu_ver_major = m.group(1)
13731365 if not icu_ver_major:
1374- print(' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h)
1375- sys.exit(1)
1366+ error(' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h)
13761367 icu_endianness = sys.byteorder[0];
13771368 o[' variables' ][' icu_ver_major' ] = icu_ver_major
13781369 o[' variables' ][' icu_endianness' ] = icu_endianness
@@ -1396,10 +1387,9 @@ def configure_intl(o):
13961387 # may be little-endian if from a icu-project.org tarball
13971388 o[' variables' ][' icu_data_in' ] = icu_data_in
13981389 if not os.path.isfile(icu_data_path):
1399- print(' Error: ICU prebuilt data file %s does not exist.' % icu_data_path)
1400- print(' See the README.md.' )
14011390 # .. and we're not about to build it from .gyp!
1402- sys.exit(1)
1391+ error(' ' ' ICU prebuilt data file %s does not exist.
1392+ See the README.md.' ' ' % icu_data_path)
14031393 # map from variable name to subdirs
14041394 icu_src = {
14051395 ' stubdata' : ' stubdata' ,
0 commit comments