build: delegate building from Makefile to ninja
PR-URL: https://github.com/nodejs/node/pull/27504 Refs: https://mobile.twitter.com/refack/status/1118484079077482498 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
This commit is contained in:
parent
50364d98d9
commit
46eb532a2a
25
Makefile
25
Makefile
@ -16,6 +16,7 @@ GTEST_FILTER ?= "*"
|
|||||||
GNUMAKEFLAGS += --no-print-directory
|
GNUMAKEFLAGS += --no-print-directory
|
||||||
GCOV ?= gcov
|
GCOV ?= gcov
|
||||||
PWD = $(CURDIR)
|
PWD = $(CURDIR)
|
||||||
|
BUILD_WITH ?= make
|
||||||
|
|
||||||
ifdef JOBS
|
ifdef JOBS
|
||||||
PARALLEL_ARGS = -j $(JOBS)
|
PARALLEL_ARGS = -j $(JOBS)
|
||||||
@ -95,6 +96,7 @@ help: ## Print help for targets with comments.
|
|||||||
# Without the check there is a race condition between the link being deleted
|
# Without the check there is a race condition between the link being deleted
|
||||||
# and recreated which can break the addons build when running test-ci
|
# and recreated which can break the addons build when running test-ci
|
||||||
# See comments on the build-addons target for some more info
|
# See comments on the build-addons target for some more info
|
||||||
|
ifeq ($(BUILD_WITH), make)
|
||||||
$(NODE_EXE): config.gypi out/Makefile
|
$(NODE_EXE): config.gypi out/Makefile
|
||||||
$(MAKE) -C out BUILDTYPE=Release V=$(V)
|
$(MAKE) -C out BUILDTYPE=Release V=$(V)
|
||||||
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Release/$(NODE_EXE) $@; fi
|
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Release/$(NODE_EXE) $@; fi
|
||||||
@ -102,6 +104,29 @@ $(NODE_EXE): config.gypi out/Makefile
|
|||||||
$(NODE_G_EXE): config.gypi out/Makefile
|
$(NODE_G_EXE): config.gypi out/Makefile
|
||||||
$(MAKE) -C out BUILDTYPE=Debug V=$(V)
|
$(MAKE) -C out BUILDTYPE=Debug V=$(V)
|
||||||
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi
|
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi
|
||||||
|
else
|
||||||
|
ifeq ($(BUILD_WITH), ninja)
|
||||||
|
ifeq ($(V),1)
|
||||||
|
NINJA_ARGS := $(NINJA_ARGS) -v
|
||||||
|
endif
|
||||||
|
ifdef JOBS
|
||||||
|
NINJA_ARGS := $(NINJA_ARGS) -j$(JOBS)
|
||||||
|
else
|
||||||
|
NINJA_ARGS := $(NINJA_ARGS) $(filter -j%,$(MAKEFLAGS))
|
||||||
|
endif
|
||||||
|
$(NODE_EXE): config.gypi out/Release/build.ninja
|
||||||
|
ninja -C out/Release $(NINJA_ARGS)
|
||||||
|
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Release/$(NODE_EXE) $@; fi
|
||||||
|
|
||||||
|
$(NODE_G_EXE): config.gypi out/Debug/build.ninja
|
||||||
|
ninja -C out/Debug $(NINJA_ARGS)
|
||||||
|
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi
|
||||||
|
else
|
||||||
|
$(NODE_EXE) $(NODE_G_EXE):
|
||||||
|
echo This Makefile currently only supports building with 'make' or 'ninja'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(BUILDTYPE),Debug)
|
ifeq ($(BUILDTYPE),Debug)
|
||||||
CONFIG_FLAGS += --debug
|
CONFIG_FLAGS += --debug
|
||||||
|
20
configure.py
20
configure.py
@ -1627,23 +1627,35 @@ write('config.status', '#!/bin/sh\nset -x\nexec ./configure ' +
|
|||||||
' '.join([pipes.quote(arg) for arg in original_argv]) + '\n')
|
' '.join([pipes.quote(arg) for arg in original_argv]) + '\n')
|
||||||
os.chmod('config.status', 0o775)
|
os.chmod('config.status', 0o775)
|
||||||
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
'BUILDTYPE': 'Debug' if options.debug else 'Release',
|
'BUILDTYPE': 'Debug' if options.debug else 'Release',
|
||||||
'PYTHON': sys.executable,
|
|
||||||
'NODE_TARGET_TYPE': variables['node_target_type'],
|
'NODE_TARGET_TYPE': variables['node_target_type'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Not needed for trivial case. Useless when it's a win32 path.
|
||||||
|
if sys.executable != 'python' and ':\\' not in sys.executable:
|
||||||
|
config['PYTHON'] = sys.executable
|
||||||
|
|
||||||
if options.prefix:
|
if options.prefix:
|
||||||
config['PREFIX'] = options.prefix
|
config['PREFIX'] = options.prefix
|
||||||
|
|
||||||
config = '\n'.join(['='.join(item) for item in config.items()]) + '\n'
|
if options.use_ninja:
|
||||||
|
config['BUILD_WITH'] = 'ninja'
|
||||||
|
|
||||||
|
config_lines = ['='.join((k,v)) for k,v in config.items()]
|
||||||
|
# Add a blank string to get a blank line at the end.
|
||||||
|
config_lines += ['']
|
||||||
|
config_str = '\n'.join(config_lines)
|
||||||
|
|
||||||
# On Windows there's no reason to search for a different python binary.
|
# On Windows there's no reason to search for a different python binary.
|
||||||
bin_override = None if sys.platform == 'win32' else make_bin_override()
|
bin_override = None if sys.platform == 'win32' else make_bin_override()
|
||||||
if bin_override:
|
if bin_override:
|
||||||
config = 'export PATH:=' + bin_override + ':$(PATH)\n' + config
|
config_str = 'export PATH:=' + bin_override + ':$(PATH)\n' + config_str
|
||||||
|
|
||||||
|
write('config.mk', do_not_edit + config_str)
|
||||||
|
|
||||||
|
|
||||||
write('config.mk', do_not_edit + config)
|
|
||||||
|
|
||||||
gyp_args = ['--no-parallel', '-Dconfiguring_node=1']
|
gyp_args = ['--no-parallel', '-Dconfiguring_node=1']
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user