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.

112 lines
3.7 KiB

  1. # This is free software, licensed under the GNU General Public License v2.
  2. # See /LICENSE for more information.
  3. #
  4. include $(TOPDIR)/rules.mk
  5. PKG_NPM_NAME:=javascript-obfuscator
  6. PKG_NAME:=node-$(PKG_NPM_NAME)
  7. PKG_VERSION:=2.19.0
  8. PKG_RELEASE:=$(AUTORELEASE)
  9. PKG_SOURCE:=$(PKG_NPM_NAME)-$(PKG_VERSION).tgz
  10. PKG_SOURCE_URL:=https://registry.npmjs.org/$(PKG_NPM_NAME)/-/
  11. PKG_HASH:=9bc89b04c78277130bc6f699563871d211f6fc85803c874f6114a632d9456f7b
  12. PKG_BUILD_DEPENDS:=node/host
  13. HOST_BUILD_PARALLEL:=1
  14. HOST_BUILD_DEPENDS:=node/host
  15. PKG_BUILD_PARALLEL:=1
  16. PKG_USE_MIPS16:=0
  17. PKG_MAINTAINER:=Zbynek Kocur <zbynek.kocur@fel.cvut.cz>
  18. PKG_LICENSE:=BSD-2-Clause
  19. PKG_LICENSE_FILES:=LICENSE.BSD
  20. include $(INCLUDE_DIR)/host-build.mk
  21. include $(INCLUDE_DIR)/package.mk
  22. define Package/node-javascript-obfuscator
  23. SUBMENU:=Node.js
  24. SECTION:=lang
  25. CATEGORY:=Languages
  26. TITLE:=JavaScript obfuscator
  27. URL:=https://www.npmjs.org/package/javascript-obfuscator
  28. DEPENDS:=+node
  29. endef
  30. define Package/node-javascript-obfuscator/description
  31. JavaScript obfuscator is a powerful free obfuscator for JavaScript with a wide number of features which provides protection for your source code.
  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. HOSTTMPNPM:=$(shell mktemp -u XXXXXXXXXX)
  38. TARGET_CFLAGS+=$(FPIC)
  39. TARGET_CPPFLAGS+=$(FPIC)
  40. NPM_FLAGS=$(MAKE_VARS) \
  41. $(MAKE_FLAGS) \
  42. npm_config_arch=$(NODEJS_CPU) \
  43. npm_config_target_arch=$(NODEJS_CPU) \
  44. npm_config_build_from_source=true \
  45. npm_config_nodedir=$(STAGING_DIR)/usr/ \
  46. npm_config_prefix=$(PKG_INSTALL_DIR)/usr/ \
  47. npm_config_cache=$(TMP_DIR)/npm-cache-$(TMPNPM) \
  48. npm_config_tmp=$(TMP_DIR)/npm-tmp-$(TMPNPM)
  49. define Build/Compile
  50. cd $(PKG_BUILD_DIR); \
  51. $(NPM_FLAGS) npm install --production --global-style --no-save --omit=dev --no-package-lock --ignore-scripts --legacy-peer-deps
  52. rm -rf $(TMP_DIR)/npm-tmp-$(TMPNPM)
  53. rm -rf $(TMP_DIR)/npm-cache-$(TMPNPM)
  54. endef
  55. define Package/node-javascript-obfuscator/install
  56. $(INSTALL_DIR) $(1)/usr/lib/node/$(PKG_NPM_NAME)
  57. $(CP) $(PKG_BUILD_DIR)/{package.json,LICENSE.BSD} \
  58. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  59. $(CP) $(PKG_BUILD_DIR)/README.md \
  60. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  61. $(CP) $(PKG_BUILD_DIR)/{node_modules,bin,dist} \
  62. $(1)/usr/lib/node/$(PKG_NPM_NAME)/
  63. $(INSTALL_DIR) $(1)/usr/bin
  64. $(LN) ../lib/node/javascript-obfuscator/bin/javascript-obfuscator $(1)/usr/bin/javascript-obfuscator
  65. endef
  66. HOST_NPM_FLAGS=$(HOST_MAKE_VARS) \
  67. $(HOST_MAKE_FLAGS) \
  68. npm_config_arch=$(NODEJS_CPU) \
  69. npm_config_target_arch=$(NODEJS_CPU) \
  70. npm_config_build_from_source=true \
  71. npm_config_nodedir=$(STAGING_DIR)/usr/ \
  72. npm_config_prefix=$(HOST_INSTALL_DIR)/usr/ \
  73. npm_config_cache=$(TMP_DIR)/npm-cache-$(HOSTTMPNPM) \
  74. npm_config_tmp=$(TMP_DIR)/npm-tmp-$(HOSTTMPNPM)
  75. define Host/Compile
  76. cd $(HOST_BUILD_DIR); \
  77. $(HOST_NPM_FLAGS) npm install --production --global-style --no-save --omit=dev --no-package-lock --ignore-scripts --legacy-peer-deps
  78. rm -rf $(TMP_DIR)/npm-tmp-$(HOSTTMPNPM)
  79. rm -rf $(TMP_DIR)/npm-cache-$(HOSTTMPNPM)
  80. endef
  81. define Host/Install
  82. $(INSTALL_DIR) $(1)/lib/node_modules/$(PKG_NPM_NAME)
  83. $(CP) $(HOST_BUILD_DIR)/{package.json,LICENSE.BSD} \
  84. $(1)/lib/node_modules/$(PKG_NPM_NAME)/
  85. $(CP) $(HOST_BUILD_DIR)/README.md \
  86. $(1)/lib/node_modules/$(PKG_NPM_NAME)/
  87. $(CP) $(HOST_BUILD_DIR)/{node_modules,bin,dist} \
  88. $(1)/lib/node_modules/$(PKG_NPM_NAME)/
  89. $(INSTALL_DIR) $(1)/bin
  90. $(LN) ../lib/node_modules/javascript-obfuscator/bin/javascript-obfuscator $(1)/bin/javascript-obfuscator
  91. endef
  92. $(eval $(call HostBuild))
  93. $(eval $(call BuildPackage,node-javascript-obfuscator))