Skip to content

build: extract common code from NODE_EXE/_G_EXE #22310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,20 @@ help: ## Print help for targets with comments.
# to check for changes.
.PHONY: $(NODE_EXE) $(NODE_G_EXE)

define build_node_exe
$(MAKE) -C out BUILDTYPE=$1 V=$(V)
# The -r/-L check stops it recreating the link if it is already in place,
# otherwise $(NODE_EXE) being a .PHONY target means it is always re-run.
# 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
# See comments on the build-addons target for some more info
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/$1/$(NODE_EXE) $@; fi
endef
$(NODE_EXE): config.gypi out/Makefile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT $BUILDTYPE is already defined.

node/Makefile

Lines 64 to 68 in db723a1

ifeq ($(BUILDTYPE),Release)
all: out/Makefile $(NODE_EXE) ## Default target, builds node in out/Release/node.
else
all: out/Makefile $(NODE_EXE) $(NODE_G_EXE)
endif

so this could be:

$(NODE_EXE) $(NODE_G_EXE): config.gypi out/Makefile
  $(MAKE) -C out
  if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/$(BUILDTYPE)/$(NODE_EXE) $@; fi

removing
BUILDTYPE is defined so no need to pass is explicitly
V=$(V) this is just 🤷‍♂️
and putting $(BUILDTYPE) in the link target

$(MAKE) -C out BUILDTYPE=Release V=$(V)
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Release/$(NODE_EXE) $@; fi
@$(call build_node_exe,"Release")

$(NODE_G_EXE): config.gypi out/Makefile
$(MAKE) -C out BUILDTYPE=Debug V=$(V)
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi
@$(call build_node_exe,"Debug")

CODE_CACHE_DIR ?= out/$(BUILDTYPE)/obj/gen
CODE_CACHE_FILE ?= $(CODE_CACHE_DIR)/node_code_cache.cc
Expand Down