547547 default = False ,
548548 help = 'build V8 using GN instead of gyp' )
549549
550+ parser .add_option ('--verbose' ,
551+ action = 'store_true' ,
552+ dest = 'verbose' ,
553+ default = False ,
554+ help = 'get more output from this script' )
555+
550556# Create compile_commands.json in out/Debug and out/Release.
551557parser .add_option ('-C' ,
552558 action = 'store_true' ,
@@ -575,6 +581,14 @@ def warn(msg):
575581# track if warnings occurred
576582warn .warned = False
577583
584+ def print_verbose (x ):
585+ if not options .verbose :
586+ return
587+ if type (x ) is str :
588+ print x
589+ else :
590+ pprint .pprint (x , indent = 2 )
591+
578592def b (value ):
579593 """Returns the string 'true' if value is truthy, 'false' otherwise."""
580594 if value :
@@ -1158,7 +1172,7 @@ def without_ssl_error(option):
11581172def configure_static (o ):
11591173 if options .fully_static or options .partly_static :
11601174 if flavor == 'mac' :
1161- print ("Generation of static executable will not work on OSX "
1175+ warn ("Generation of static executable will not work on OSX "
11621176 "when using the default compilation environment" )
11631177 return
11641178
@@ -1172,9 +1186,9 @@ def configure_static(o):
11721186
11731187def write (filename , data ):
11741188 filename = filename
1175- print ('creating %s' % filename )
1176- f = open (filename , 'w+' )
1177- f .write (data )
1189+ print_verbose ('creating %s' % filename )
1190+ with open (filename , 'w+' ) as f :
1191+ f .write (data )
11781192
11791193do_not_edit = '# Do not edit. Generated by the configure script.\n '
11801194
@@ -1192,7 +1206,7 @@ def glob_to_var(dir_base, dir_sub, patch_dir):
11921206 patchfile = '%s/%s/%s' % (dir_base , patch_dir , file )
11931207 if os .path .isfile (patchfile ):
11941208 srcfile = '%s/%s' % (patch_dir , file )
1195- print ('Using version-specific floating patch %s ' % patchfile )
1209+ warn ('Using floating patch "%s" from "%s" ' % ( patchfile , dir_base ) )
11961210 list .append (srcfile )
11971211 break
11981212 return list
@@ -1226,8 +1240,8 @@ def icu_download(path):
12261240 if (md5 == gotmd5 ):
12271241 return targetfile
12281242 else :
1229- print ('Expected: %s *MISMATCH*' % md5 )
1230- print ('\n ** Corrupted ZIP? Delete %s to retry download.\n ' % targetfile )
1243+ error ('Expected: %s *MISMATCH*' % md5 )
1244+ error ('\n ** Corrupted ZIP? Delete %s to retry download.\n ' % targetfile )
12311245 return None
12321246 icu_config = {
12331247 'variables' : {}
@@ -1328,7 +1342,7 @@ def write_config(data, name):
13281342 # --with-icu-source processing
13291343 # now, check that they didn't pass --with-icu-source=deps/icu
13301344 elif with_icu_source and os .path .abspath (icu_full_path ) == os .path .abspath (with_icu_source ):
1331- print ('Ignoring redundant --with-icu-source=%s' % with_icu_source )
1345+ warn ('Ignoring redundant --with-icu-source=%s' % with_icu_source )
13321346 with_icu_source = None
13331347 # if with_icu_source is still set, try to use it.
13341348 if with_icu_source :
@@ -1371,7 +1385,7 @@ def write_config(data, name):
13711385 # ICU source dir relative to tools/icu (for .gyp file)
13721386 o ['variables' ]['icu_path' ] = icu_full_path
13731387 if not os .path .isdir (icu_full_path ):
1374- print ('* ECMA-402 (Intl) support didn\' t find ICU in %s..' % icu_full_path )
1388+ warn ('* ECMA-402 (Intl) support didn\' t find ICU in %s..' % icu_full_path )
13751389 # can we download (or find) a zipfile?
13761390 localzip = icu_download (icu_full_path )
13771391 if localzip :
@@ -1380,7 +1394,7 @@ def write_config(data, name):
13801394 error ('''Cannot build Intl without ICU in %s.
13811395 Fix, or disable with "--with-intl=none"''' % icu_full_path )
13821396 else :
1383- print ('* Using ICU in %s' % icu_full_path )
1397+ print_verbose ('* Using ICU in %s' % icu_full_path )
13841398 # Now, what version of ICU is it? We just need the "major", such as 54.
13851399 # uvernum.h contains it as a #define.
13861400 uvernum_h = os .path .join (icu_full_path , 'source/common/unicode/uvernum.h' )
@@ -1543,7 +1557,7 @@ def make_bin_override():
15431557if make_global_settings :
15441558 output ['make_global_settings' ] = make_global_settings
15451559
1546- pprint . pprint (output , indent = 2 )
1560+ print_verbose (output )
15471561
15481562write ('config.gypi' , do_not_edit +
15491563 pprint .pformat (output , indent = 2 ) + '\n ' )
@@ -1582,9 +1596,11 @@ def make_bin_override():
15821596if options .compile_commands_json :
15831597 gyp_args += ['-f' , 'compile_commands_json' ]
15841598
1599+ # pass the leftover positional arguments to GYP
15851600gyp_args += args
15861601
1587- if warn .warned :
1602+ if warn .warned and not options . verbose :
15881603 warn ('warnings were emitted in the configure phase' )
15891604
1605+ print_verbose ("running: \n " + " " .join (['python' , 'tools/gyp_node.py' ] + gyp_args ))
15901606run_gyp (gyp_args )
0 commit comments