From d1c5d18ff6fd209e87ad18ea9c8c6fd35989ba82 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Tue, 21 Aug 2018 19:25:26 -0400 Subject: [PATCH 1/3] build: rename configure to configure.py !Should go with next commit! * renaming so that IDEs can properly detect this as python * Add dependency to Makefile PR-URL: https://github.com/nodejs/node/pull/22450 Reviewed-By: Joyee Cheung --- Makefile | 2 +- configure => configure.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename configure => configure.py (100%) diff --git a/Makefile b/Makefile index 7f9a57804b7760..21622a24047f68 100644 --- a/Makefile +++ b/Makefile @@ -129,7 +129,7 @@ out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp \ config.gypi $(PYTHON) tools/gyp_node.py -f make -config.gypi: configure +config.gypi: configure configure.py @if [ -x config.status ]; then \ ./config.status; \ else \ diff --git a/configure b/configure.py similarity index 100% rename from configure rename to configure.py From cc9dd0f36596df9ae27b47ee6864c7d3b08ac04b Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Tue, 21 Aug 2018 19:28:53 -0400 Subject: [PATCH 2/3] build: move meta-shebang back to `configure` PR-URL: https://github.com/nodejs/node/pull/22450 Reviewed-By: Joyee Cheung --- configure | 28 ++++++++++++++++++++++++++++ configure.py | 27 +-------------------------- 2 files changed, 29 insertions(+), 26 deletions(-) create mode 100755 configure diff --git a/configure b/configure new file mode 100755 index 00000000000000..495d0e8848860c --- /dev/null +++ b/configure @@ -0,0 +1,28 @@ +#!/bin/sh + +# Locate python2 interpreter and re-execute the script. Note that the +# mix of single and double quotes is intentional, as is the fact that +# the ] goes on a new line. +_=[ 'exec' '/bin/sh' '-c' ''' +which python2.7 >/dev/null && exec python2.7 "$0" "$@" +which python2 >/dev/null && exec python2 "$0" "$@" +exec python "$0" "$@" +''' "$0" "$@" +] +del _ + +import sys +from distutils.spawn import find_executable as which +if sys.version_info[0] != 2 or sys.version_info[1] not in (6, 7): + sys.stderr.write('Please use either Python 2.6 or 2.7') + + python2 = which('python2') or which('python2.6') or which('python2.7') + + if python2: + sys.stderr.write(':\n\n') + sys.stderr.write(' ' + python2 + ' ' + ' '.join(sys.argv)) + + sys.stderr.write('\n') + sys.exit(1) + +import configure diff --git a/configure.py b/configure.py index c04118e9832b0c..ac1137a3419633 100755 --- a/configure.py +++ b/configure.py @@ -1,30 +1,4 @@ -#!/bin/sh - -# Locate python2 interpreter and re-execute the script. Note that the -# mix of single and double quotes is intentional, as is the fact that -# the ] goes on a new line. -_=[ 'exec' '/bin/sh' '-c' ''' -which python2.7 >/dev/null && exec python2.7 "$0" "$@" -which python2 >/dev/null && exec python2 "$0" "$@" -exec python "$0" "$@" -''' "$0" "$@" -] -del _ - import sys -from distutils.spawn import find_executable as which -if sys.version_info[0] != 2 or sys.version_info[1] not in (6, 7): - sys.stderr.write('Please use either Python 2.6 or 2.7') - - python2 = which('python2') or which('python2.6') or which('python2.7') - - if python2: - sys.stderr.write(':\n\n') - sys.stderr.write(' ' + python2 + ' ' + ' '.join(sys.argv)) - - sys.stderr.write('\n') - sys.exit(1) - import errno import optparse import os @@ -35,6 +9,7 @@ import subprocess import shutil import string +from distutils.spawn import find_executable as which # If not run from node/, cd to node/. os.chdir(os.path.dirname(__file__) or '.') From 62a3f9b029f7ef4af1a2ea1e6362141164e48eab Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Wed, 22 Aug 2018 11:02:27 -0400 Subject: [PATCH 3/3] build: add `--verbose` to `./configure` PR-URL: https://github.com/nodejs/node/pull/22450 Reviewed-By: Joyee Cheung --- configure.py | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/configure.py b/configure.py index ac1137a3419633..da696a92b48c1a 100755 --- a/configure.py +++ b/configure.py @@ -559,6 +559,12 @@ default=False, help='build V8 using GN instead of gyp') +parser.add_option('--verbose', + action='store_true', + dest='verbose', + default=False, + help='get more output from this script') + # Create compile_commands.json in out/Debug and out/Release. parser.add_option('-C', action='store_true', @@ -587,6 +593,14 @@ def warn(msg): # track if warnings occurred warn.warned = False +def print_verbose(x): + if not options.verbose: + return + if type(x) is str: + print x + else: + pprint.pprint(x, indent=2) + def b(value): """Returns the string 'true' if value is truthy, 'false' otherwise.""" if value: @@ -1199,7 +1213,7 @@ def without_ssl_error(option): def configure_static(o): if options.fully_static or options.partly_static: if flavor == 'mac': - print("Generation of static executable will not work on OSX " + warn("Generation of static executable will not work on OSX " "when using the default compilation environment") return @@ -1213,9 +1227,9 @@ def configure_static(o): def write(filename, data): filename = filename - print('creating %s' % filename) - f = open(filename, 'w+') - f.write(data) + print_verbose('creating %s' % filename) + with open(filename, 'w+') as f: + f.write(data) do_not_edit = '# Do not edit. Generated by the configure script.\n' @@ -1233,7 +1247,7 @@ def glob_to_var(dir_base, dir_sub, patch_dir): patchfile = '%s/%s/%s' % (dir_base, patch_dir, file) if os.path.isfile(patchfile): srcfile = '%s/%s' % (patch_dir, file) - print('Using version-specific floating patch %s' % patchfile) + warn('Using floating patch "%s" from "%s"' % (patchfile, dir_base)) list.append(srcfile) break return list @@ -1267,8 +1281,8 @@ def icu_download(path): if (md5 == gotmd5): return targetfile else: - print('Expected: %s *MISMATCH*' % md5) - print('\n ** Corrupted ZIP? Delete %s to retry download.\n' % targetfile) + error('Expected: %s *MISMATCH*' % md5) + error('\n ** Corrupted ZIP? Delete %s to retry download.\n' % targetfile) return None icu_config = { 'variables': {} @@ -1369,7 +1383,7 @@ def write_config(data, name): # --with-icu-source processing # now, check that they didn't pass --with-icu-source=deps/icu elif with_icu_source and os.path.abspath(icu_full_path) == os.path.abspath(with_icu_source): - print('Ignoring redundant --with-icu-source=%s' % with_icu_source) + warn('Ignoring redundant --with-icu-source=%s' % with_icu_source) with_icu_source = None # if with_icu_source is still set, try to use it. if with_icu_source: @@ -1412,7 +1426,7 @@ def write_config(data, name): # ICU source dir relative to tools/icu (for .gyp file) o['variables']['icu_path'] = icu_full_path if not os.path.isdir(icu_full_path): - print('* ECMA-402 (Intl) support didn\'t find ICU in %s..' % icu_full_path) + warn('* ECMA-402 (Intl) support didn\'t find ICU in %s..' % icu_full_path) # can we download (or find) a zipfile? localzip = icu_download(icu_full_path) if localzip: @@ -1421,7 +1435,7 @@ def write_config(data, name): error('''Cannot build Intl without ICU in %s. Fix, or disable with "--with-intl=none"''' % icu_full_path) else: - print('* Using ICU in %s' % icu_full_path) + print_verbose('* Using ICU in %s' % icu_full_path) # Now, what version of ICU is it? We just need the "major", such as 54. # uvernum.h contains it as a #define. uvernum_h = os.path.join(icu_full_path, 'source/common/unicode/uvernum.h') @@ -1584,7 +1598,7 @@ def make_bin_override(): if make_global_settings: output['make_global_settings'] = make_global_settings -pprint.pprint(output, indent=2) +print_verbose(output) write('config.gypi', do_not_edit + pprint.pformat(output, indent=2) + '\n') @@ -1623,9 +1637,11 @@ def make_bin_override(): if options.compile_commands_json: gyp_args += ['-f', 'compile_commands_json'] +# pass the leftover positional arguments to GYP gyp_args += args -if warn.warned: +if warn.warned and not options.verbose: warn('warnings were emitted in the configure phase') +print_verbose("running: \n " + " ".join(['python', 'tools/gyp_node.py'] + gyp_args)) run_gyp(gyp_args)