You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.6 KiB

  1. #
  2. # Copyright (C) 2015 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NPM_NAME:=node-hid
  9. PKG_NAME:=$(PKG_NPM_NAME)
  10. PKG_VERSION:=2.1.1
  11. PKG_RELEASE:=2
  12. PKG_SOURCE:=$(PKG_NPM_NAME)-$(PKG_VERSION).tgz
  13. PKG_SOURCE_URL:=https://registry.npmjs.org/$(PKG_NPM_NAME)/-/
  14. PKG_HASH:=6c1f05935215feed4e8d2f4aecf31abbad8fa783d252b0bd6041ed2f2e96e9ba
  15. PKG_BUILD_DEPENDS:=node/host
  16. PKG_USE_MIPS16:=0
  17. PKG_MAINTAINER:=Hirokazu MORIKAWA <morikw2@gmail.com>
  18. PKG_LICENSE:=MIT or X11
  19. PKG_LICENSE_FILES:=
  20. include $(INCLUDE_DIR)/package.mk
  21. include $(INCLUDE_DIR)/nls.mk
  22. define Package/node-hid
  23. SUBMENU:=Node.js
  24. SECTION:=lang
  25. CATEGORY:=Languages
  26. TITLE:=Node.js package to access HID devices
  27. URL:=https://www.npmjs.com/package/node-hid
  28. DEPENDS:=+node +node-npm +libusb-1.0 +libudev $(ICONV_DEPENDS)
  29. endef
  30. define Package/node-hid/description
  31. Node.js package to access HID devices
  32. endef
  33. TAR_OPTIONS+= --strip-components 1
  34. TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
  35. NODEJS_CPU:=$(subst powerpc,ppc,$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))))
  36. TMPNPM:=$(shell mktemp -u XXXXXXXXXX)
  37. TARGET_CFLAGS+=$(FPIC) -I$(STAGING_DIR)/usr/include/libusb-1.0
  38. TARGET_LDFLAGS+=$(if $(ICONV_FULL),-liconv)
  39. NPM_FLAGS=$(MAKE_VARS) \
  40. $(MAKE_FLAGS) \
  41. npm_config_arch=$(NODEJS_CPU) \
  42. npm_config_target_arch=$(NODEJS_CPU) \
  43. npm_config_build_from_source=true \
  44. npm_config_nodedir=$(STAGING_DIR)/usr/ \
  45. npm_config_prefix=$(PKG_INSTALL_DIR)/usr/ \
  46. npm_config_cache=$(TMP_DIR)/npm-cache-$(TMPNPM) \
  47. npm_config_tmp=$(TMP_DIR)/npm-tmp-$(TMPNPM)
  48. define Build/Compile
  49. $(NPM_FLAGS) npm i -g --production $(PKG_BUILD_DIR) --ignore-scripts
  50. GYP_DEFINES='driver="hidraw"' \
  51. $(NPM_FLAGS) npm i --production --prefix=$(PKG_BUILD_DIR) --target_arch=$(NODEJS_CPU) --prefer-dedupe
  52. rm -rf $(TMP_DIR)/npm-tmp-$(TMPNPM)
  53. rm -rf $(TMP_DIR)/npm-cache-$(TMPNPM)
  54. endef
  55. define Package/node-hid/install
  56. $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)
  57. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{package.json,*.md,*.js} \
  58. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  59. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/{node_modules,src} \
  60. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  61. $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)/build/Release
  62. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/$(PKG_NPM_NAME)/build/Release/HID*.node \
  63. $(1)/usr/lib/node/$(PKG_NPM_NAME)/build/Release/
  64. $(INSTALL_DIR) $(1)/usr/bin
  65. $(LN) ../lib/node/$(PKG_NPM_NAME)/src/show-devices.js $(1)/usr/bin/hid-showdevices
  66. endef
  67. $(eval $(call BuildPackage,node-hid))