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.

76 lines
2.2 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:=hid
  9. PKG_NAME:=node-$(PKG_NPM_NAME)
  10. PKG_VERSION:=0.7.2
  11. PKG_RELEASE:=2
  12. PKG_SOURCE_PROTO:=git
  13. PKG_SOURCE_URL:=https://github.com/node-hid/node-hid.git
  14. PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
  15. PKG_SOURCE_VERSION:=v0.7.2
  16. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
  17. PKG_MIRROR_HASH:=ede801a26a23290ab76d64ab636c3c3e2788030bb830af7006d37444c2a7b2c4
  18. PKG_BUILD_DEPENDS:=node/host
  19. PKG_NODE_VERSION:=`$(STAGING_DIR_HOSTPKG)/bin/node --version`
  20. PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
  21. PKG_LICENSE:=Custom
  22. PKG_LICENSE_FILES:=
  23. include $(INCLUDE_DIR)/package.mk
  24. define Package/node-hid
  25. SUBMENU:=Node.js
  26. SECTION:=lang
  27. CATEGORY:=Languages
  28. TITLE:=Node.js package to access HID devices
  29. URL:=https://github.com/node-hid/node-hid
  30. DEPENDS:=+node +node-npm +libusb-1.0 +hidapi +libstdcpp +libudev-fbsd
  31. endef
  32. define Package/node-hid/description
  33. Node.js package to access HID devices
  34. endef
  35. CPU:=$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))
  36. EXTRA_CFLAGS+=-I$(STAGING_DIR)/usr/include/libusb-1.0
  37. define Build/Compile
  38. git init $(PKG_BUILD_DIR)
  39. cd $(PKG_BUILD_DIR) ; \
  40. $(MAKE_VARS) \
  41. $(MAKE_FLAGS) \
  42. npm_config_arch=$(CONFIG_ARCH) \
  43. npm_config_nodedir=$(BUILD_DIR)/node-$(PKG_NODE_VERSION)/ \
  44. npm_config_cache=$(BUILD_DIR)/node-$(PKG_NODE_VERSION)/npm-cache \
  45. PREFIX="$(PKG_INSTALL_DIR)/usr/" \
  46. npm install --build-from-source --target_arch=$(CPU) -g \
  47. `npm pack $(PKG_BUILD_DIR) | tail -n 1`
  48. endef
  49. define Package/node-hid/install
  50. mkdir -p $(1)/usr/lib/node/node-hid/
  51. $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/. $(1)/usr/lib/node/
  52. $(RM) -rf $(1)/usr/lib/node/node-hid/patches \
  53. $(1)/usr/lib/node/node-hid/.p* \
  54. $(1)/usr/lib/node/node-hid/.quilt* \
  55. $(1)/usr/lib/node/node-hid/.built* \
  56. $(1)/usr/lib/node/node-hid/.config*
  57. # Strip PKG_BUILD_DIR from useless metadata inserted by npm install
  58. # https://github.com/npm/npm/issues/10393
  59. # https://github.com/npm/npm/issues/12110
  60. find $(1)/usr/lib/node -name package.json -exec sed -i -e 's,$(PKG_BUILD_DIR),,g' {} +
  61. endef
  62. $(eval $(call BuildPackage,node-hid))