@@ -573,6 +573,11 @@ options.prefix = os.path.expanduser(options.prefix or '')
573
573
auto_downloads = nodedownload.parse(options.download_list)
574
574
575
575
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
+
576
581
def warn(msg):
577
582
warn.warned = True
578
583
prefix = ' \033[1m\033[93mWARNING\033[0m' if os.isatty(1) else ' WARNING'
@@ -634,13 +639,11 @@ def get_version_helper(cc, regexp):
634
639
proc = subprocess.Popen(shlex.split(cc) + [' -v' ], stdin=subprocess.PIPE,
635
640
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
636
641
except OSError:
637
- print (' ' ' Node.js configure error: No acceptable C compiler found!
642
+ error (' ' ' No acceptable C compiler found!
638
643
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.' ' ' )
644
647
645
648
match = re.search(regexp, proc.communicate ()[1])
646
649
@@ -656,7 +659,7 @@ def get_nasm_version(asm):
656
659
stdout=subprocess.PIPE)
657
660
except OSError:
658
661
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
660
663
and refer BUILDING.md.' ' ' )
661
664
return 0
662
665
@@ -684,13 +687,11 @@ def get_gas_version(cc):
684
687
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
685
688
stdout=subprocess.PIPE)
686
689
except OSError:
687
- print (' ' ' Node.js configure error: No acceptable C compiler found!
690
+ error (' ' ' No acceptable C compiler found!
688
691
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.' ' ' )
694
695
695
696
match = re.match(r" GNU assembler version ([2-9]\.[0-9]+)" ,
696
697
proc.communicate ()[1])
@@ -750,13 +751,11 @@ def cc_macros(cc=None):
750
751
stdout=subprocess.PIPE,
751
752
stderr=subprocess.PIPE)
752
753
except OSError:
753
- print (' ' ' Node.js configure error: No acceptable C compiler found!
754
+ error (' ' ' No acceptable C compiler found!
754
755
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.' ' ' )
760
759
761
760
p.stdin.write(' \n' )
762
761
out = p.communicate ()[0]
@@ -1108,8 +1107,7 @@ def configure_openssl(o):
1108
1107
variables[' openssl_no_asm' ] = 1
1109
1108
1110
1109
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' )
1113
1111
variables[' openssl_fips' ] = ' '
1114
1112
1115
1113
if options.without_ssl:
@@ -1178,9 +1176,8 @@ def configure_intl(o):
1178
1176
def icu_download(path):
1179
1177
# download ICU, if needed
1180
1178
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.' ' ' )
1184
1181
for icu in icus:
1185
1182
url = icu[' url' ]
1186
1183
md5 = icu[' md5' ]
@@ -1219,8 +1216,7 @@ def configure_intl(o):
1219
1216
with_icu_source = options.with_icu_source
1220
1217
have_icu_path = bool(options.with_icu_path)
1221
1218
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' )
1224
1220
elif have_icu_path:
1225
1221
# Chromium .gyp mode: --with-icu-path
1226
1222
o[' variables' ][' v8_enable_i18n_support' ] = 1
@@ -1248,9 +1244,8 @@ def configure_intl(o):
1248
1244
o[' variables' ][' v8_enable_i18n_support' ] = 1
1249
1245
pkgicu = pkg_config(' icu-i18n' )
1250
1246
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.' ' ' )
1254
1249
(libs, cflags, libpath) = pkgicu
1255
1250
# libpath provides linker path which may contain spaces
1256
1251
if libpath:
@@ -1336,10 +1331,9 @@ def configure_intl(o):
1336
1331
os.rename(tmp_icu, icu_full_path)
1337
1332
shutil.rmtree(icu_tmp_path)
1338
1333
else:
1339
- print(' Error: --with-icu-source=%s did not result in an "icu" dir.' % \
1340
- with_icu_source)
1341
1334
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)
1343
1337
1344
1338
# ICU mode. (icu-generic.gyp)
1345
1339
o[' variables' ][' icu_gyp_path' ] = ' tools/icu/icu-generic.gyp'
@@ -1352,17 +1346,15 @@ def configure_intl(o):
1352
1346
if localzip:
1353
1347
nodedownload.unpack(localzip, icu_parent_path)
1354
1348
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)
1358
1351
else:
1359
1352
print(' * Using ICU in %s' % icu_full_path)
1360
1353
# Now, what version of ICU is it? We just need the "major", such as 54.
1361
1354
# uvernum.h contains it as a #define.
1362
1355
uvernum_h = os.path.join(icu_full_path, ' source/common/unicode/uvernum.h' )
1363
1356
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)
1366
1358
icu_ver_major = None
1367
1359
matchVerExp = r' ^\s * # define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
1368
1360
match_version = re.compile(matchVerExp)
@@ -1371,8 +1363,7 @@ def configure_intl(o):
1371
1363
if m:
1372
1364
icu_ver_major = m.group(1)
1373
1365
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)
1376
1367
icu_endianness = sys.byteorder[0];
1377
1368
o[' variables' ][' icu_ver_major' ] = icu_ver_major
1378
1369
o[' variables' ][' icu_endianness' ] = icu_endianness
@@ -1396,10 +1387,9 @@ def configure_intl(o):
1396
1387
# may be little-endian if from a icu-project.org tarball
1397
1388
o[' variables' ][' icu_data_in' ] = icu_data_in
1398
1389
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.' )
1401
1390
# .. 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)
1403
1393
# map from variable name to subdirs
1404
1394
icu_src = {
1405
1395
' stubdata' : ' stubdata' ,
0 commit comments