From 4aff0563aa75f64adc6f6d4ef0965b3a14617d2b Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Tue, 25 Apr 2017 17:36:50 -0400 Subject: [PATCH 1/2] build: reduce one level of spawning in node_gyp `configure` will now call `node_gyp` as a module instead of forking makes it easier to debug PR-URL: https://github.com/nodejs/node/pull/12653 Reviewed-By: Ben Noordhuis Reviewed-By: Gibson Fahnestock --- configure | 5 +++-- tools/gyp_node.py | 18 ++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/configure b/configure index 5a6de084836d98..9d9bc9bc17d411 100755 --- a/configure +++ b/configure @@ -40,6 +40,7 @@ import nodedownload # imports in tools/ sys.path.insert(0, os.path.join(root_dir, 'tools')) import getmoduleversion +from gyp_node import run_gyp # parse our options parser = optparse.OptionParser() @@ -1380,7 +1381,7 @@ config = '\n'.join(map('='.join, config.iteritems())) + '\n' write('config.mk', do_not_edit + config) -gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel'] +gyp_args = ['--no-parallel'] if options.use_xcode: gyp_args += ['-f', 'xcode'] @@ -1399,4 +1400,4 @@ gyp_args += args if warn.warned: warn('warnings were emitted in the configure phase') -sys.exit(subprocess.call(gyp_args)) +run_gyp(gyp_args) diff --git a/tools/gyp_node.py b/tools/gyp_node.py index 8de046aae259f1..b37cc7c5f049c3 100755 --- a/tools/gyp_node.py +++ b/tools/gyp_node.py @@ -13,14 +13,6 @@ output_dir = os.path.join(os.path.abspath(node_root), 'out') def run_gyp(args): - rc = gyp.main(args) - if rc != 0: - print 'Error running GYP' - sys.exit(rc) - -if __name__ == '__main__': - args = sys.argv[1:] - # GYP bug. # On msvs it will crash if it gets an absolute path. # On Mac/make it will crash if it doesn't get an absolute path. @@ -63,5 +55,11 @@ def run_gyp(args): args.append('-Dlinux_use_bundled_gold=0') args.append('-Dlinux_use_gold_flags=0') - gyp_args = list(args) - run_gyp(gyp_args) + rc = gyp.main(args) + if rc != 0: + print 'Error running GYP' + sys.exit(rc) + + +if __name__ == '__main__': + run_gyp(sys.argv[1:]) From 80355271c324d2a5515768c1d58976d4483f650c Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Wed, 26 Apr 2017 09:27:46 -0400 Subject: [PATCH 2/2] build: simplify `if` in setting of arg_paths PR-URL: https://github.com/nodejs/node/pull/12653 Reviewed-By: Ben Noordhuis Reviewed-By: Gibson Fahnestock --- tools/gyp_node.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tools/gyp_node.py b/tools/gyp_node.py index b37cc7c5f049c3..043053c3daa9d9 100755 --- a/tools/gyp_node.py +++ b/tools/gyp_node.py @@ -16,16 +16,11 @@ def run_gyp(args): # GYP bug. # On msvs it will crash if it gets an absolute path. # On Mac/make it will crash if it doesn't get an absolute path. - if sys.platform == 'win32': - args.append(os.path.join(node_root, 'node.gyp')) - common_fn = os.path.join(node_root, 'common.gypi') - options_fn = os.path.join(node_root, 'config.gypi') - options_fips_fn = os.path.join(node_root, 'config_fips.gypi') - else: - args.append(os.path.join(os.path.abspath(node_root), 'node.gyp')) - common_fn = os.path.join(os.path.abspath(node_root), 'common.gypi') - options_fn = os.path.join(os.path.abspath(node_root), 'config.gypi') - options_fips_fn = os.path.join(os.path.abspath(node_root), 'config_fips.gypi') + a_path = node_root if sys.platform == 'win32' else os.path.abspath(node_root) + args.append(os.path.join(a_path, 'node.gyp')) + common_fn = os.path.join(a_path, 'common.gypi') + options_fn = os.path.join(a_path, 'config.gypi') + options_fips_fn = os.path.join(a_path, 'config_fips.gypi') if os.path.exists(common_fn): args.extend(['-I', common_fn])