node-arduino-firmata: Support for npm@8
authorHirokazu MORIKAWA <morikw2@gmail.com>
Wed, 6 Apr 2022 01:01:20 +0000 (10:01 +0900)
committerRosen Penev <rosenp@gmail.com>
Sun, 22 May 2022 20:39:01 +0000 (13:39 -0700)
With the upgrade of node.js to version 16, the npm version will also change to version 8.
This fix is to support npm@8. npm@6 can also build without problems.

Signed-off-by: Hirokazu MORIKAWA <morikw2@gmail.com>
(cherry picked from commit 005e114ddd0d9a6b3bf63cac1d39b5a27ef7460d)

lang/node-arduino-firmata/Makefile

index fd2b3f4c1884c0d2b1621437e7fa04ed9392d1a2..c915afb543166c00024247370c662b341063b0a5 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NPM_NAME:=arduino-firmata
 PKG_NAME:=node-$(PKG_NPM_NAME)
 PKG_VERSION:=0.3.4
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE:=$(PKG_NPM_NAME)-$(PKG_VERSION).tgz
 PKG_SOURCE_URL:=https://registry.npmjs.org/$(PKG_NPM_NAME)/-/
@@ -42,8 +42,12 @@ TAR_OPTIONS+= --strip-components 1
 TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
 
 NODEJS_CPU:=$(subst powerpc,ppc,$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))))
+TMPNPM:=$(shell mktemp -u XXXXXXXXXX)
 
-define Build/Compile
+TARGET_CFLAGS+=$(FPIC)
+TARGET_CPPFLAGS+=$(FPIC)
+
+NPM_FLAGS:= \
        $(MAKE_VARS) \
        $(MAKE_FLAGS) \
        npm_config_arch=$(NODEJS_CPU) \
@@ -51,11 +55,14 @@ define Build/Compile
        npm_config_build_from_source=true \
        npm_config_nodedir=$(STAGING_DIR)/usr/ \
        npm_config_prefix=$(PKG_INSTALL_DIR)/usr/ \
-       npm_config_cache=$(TMP_DIR)/npm-cache \
-       npm_config_tmp=$(TMP_DIR)/npm-tmp \
-       npm install -g $(PKG_BUILD_DIR)
-       rm -rf $(TMP_DIR)/npm-tmp
-       rm -rf $(TMP_DIR)/npm-cache
+       npm_config_cache=$(TMP_DIR)/npm-cache-$(TMPNPM) \
+       npm_config_tmp=$(TMP_DIR)/npm-tmp-$(TMPNPM)
+
+define Build/Compile
+       $(NPM_FLAGS) npm i -g --production $(PKG_BUILD_DIR)
+       $(NPM_FLAGS) npm i --production --prefix=$(PKG_BUILD_DIR) --target_arch=$(NODEJS_CPU) --prefer-dedupe
+       rm -rf $(TMP_DIR)/npm-tmp-$(TMPNPM)
+       rm -rf $(TMP_DIR)/npm-cache-$(TMPNPM)
 endef
 
 define Package/node-arduino-firmata/install