Skip to content

Commit 5e348d9

Browse files
author
Ash Cripps
committed
build: update Makefile to support fat binary
build a binary that is both x86_64 and arm64 on macos
1 parent cda60c5 commit 5e348d9

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Makefile

+24-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ TEST_CI_ARGS ?=
1010
STAGINGSERVER ?= node-www
1111
LOGLEVEL ?= silent
1212
OSTYPE := $(shell uname -s | tr '[:upper:]' '[:lower:]')
13+
ARCHTYPE := $(shell uname -m | tr '[:upper:]' '[:lower:]')
1314
COVTESTS ?= test-cov
1415
COV_SKIP_TESTS ?= core_line_numbers.js,testFinalizer.js,test_function/test.js
1516
GTEST_FILTER ?= "*"
@@ -962,6 +963,14 @@ release-only: check-xz
962963
fi
963964

964965
$(PKG): release-only
966+
ifneq ($(OSTYPE),darwin)
967+
$(warning Invalid OSTYPE)
968+
$(error OSTYPE should be `darwin` currently is $(OSTYPE))
969+
endif
970+
ifneq ($(ARCHTYPE),arm64)
971+
$(warning Invalid ARCHTYPE)
972+
$(error ARCHTYPE should be `arm64` currently is $(ARCHTYPE))
973+
endif
965974
$(RM) -r $(MACOSOUTDIR)
966975
mkdir -p $(MACOSOUTDIR)/installer/productbuild
967976
cat tools/macos-installer/productbuild/distribution.xml.tmpl \
@@ -982,14 +991,28 @@ $(PKG): release-only
982991
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
983992
>$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/conclusion.html ; \
984993
done
994+
CC_host="cc -arch x86_64" CXX_host="c++ -arch x86_64" \
995+
CC_target="cc -arch x86_64" CXX_target="c++ -arch x86_64" \
996+
CC="cc -arch x86_64" CXX="c++ -arch x86_64" $(PYTHON) ./configure \
997+
--dest-cpu=x86_64 \
998+
--tag=$(TAG) \
999+
--release-urlbase=$(RELEASE_URLBASE) \
1000+
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
1001+
arch -x86_64 $(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/x64/node
1002+
SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/x64/node/usr/local" sh \
1003+
tools/osx-codesign.sh
9851004
$(PYTHON) ./configure \
986-
--dest-cpu=x64 \
1005+
--dest-cpu=arm64 \
9871006
--tag=$(TAG) \
9881007
--release-urlbase=$(RELEASE_URLBASE) \
9891008
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
9901009
$(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/node
9911010
SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/node/usr/local" sh \
9921011
tools/osx-codesign.sh
1012+
lipo $(MACOSOUTDIR)/dist/x64/node/usr/local/bin/node \
1013+
$(MACOSOUTDIR)/dist/node/usr/local/bin/node \
1014+
-output $(MACOSOUTDIR)/dist/node/usr/local/bin/node \
1015+
-create
9931016
mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
9941017
mkdir -p $(MACOSOUTDIR)/pkgs
9951018
mv $(MACOSOUTDIR)/dist/node/usr/local/lib/node_modules/npm \

0 commit comments

Comments
 (0)