Skip to content
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

build: update Makefile to support fat binary on macos #37861

Closed
wants to merge 3 commits 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
27 changes: 26 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ TEST_CI_ARGS ?=
STAGINGSERVER ?= node-www
LOGLEVEL ?= silent
OSTYPE := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCHTYPE := $(shell uname -m | tr '[:upper:]' '[:lower:]')
COVTESTS ?= test-cov
COV_SKIP_TESTS ?= core_line_numbers.js,testFinalizer.js,test_function/test.js
GTEST_FILTER ?= "*"
Expand Down Expand Up @@ -962,6 +963,16 @@ release-only: check-xz
fi

$(PKG): release-only
# pkg building is currently only supported on an ARM64 macOS host for
# ease of compiling fat-binaries for both macOS architectures.
ifneq ($(OSTYPE),darwin)
AshCripps marked this conversation as resolved.
Show resolved Hide resolved
$(warning Invalid OSTYPE)
$(error OSTYPE should be `darwin` currently is $(OSTYPE))
endif
ifneq ($(ARCHTYPE),arm64)
$(warning Invalid ARCHTYPE)
$(error ARCHTYPE should be `arm64` currently is $(ARCHTYPE))
endif
$(RM) -r $(MACOSOUTDIR)
mkdir -p $(MACOSOUTDIR)/installer/productbuild
cat tools/macos-installer/productbuild/distribution.xml.tmpl \
Expand All @@ -982,14 +993,28 @@ $(PKG): release-only
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
>$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/conclusion.html ; \
done
CC_host="cc -arch x86_64" CXX_host="c++ -arch x86_64" \
CC_target="cc -arch x86_64" CXX_target="c++ -arch x86_64" \
CC="cc -arch x86_64" CXX="c++ -arch x86_64" $(PYTHON) ./configure \
--dest-cpu=x86_64 \
--tag=$(TAG) \
--release-urlbase=$(RELEASE_URLBASE) \
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
arch -x86_64 $(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/x64/node
SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/x64/node/usr/local" sh \
tools/osx-codesign.sh
$(PYTHON) ./configure \
--dest-cpu=x64 \
--dest-cpu=arm64 \
--tag=$(TAG) \
--release-urlbase=$(RELEASE_URLBASE) \
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
$(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/node
SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/node/usr/local" sh \
tools/osx-codesign.sh
lipo $(MACOSOUTDIR)/dist/x64/node/usr/local/bin/node \
$(MACOSOUTDIR)/dist/node/usr/local/bin/node \
-output $(MACOSOUTDIR)/dist/node/usr/local/bin/node \
-create
mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
mkdir -p $(MACOSOUTDIR)/pkgs
mv $(MACOSOUTDIR)/dist/node/usr/local/lib/node_modules/npm \
Expand Down