gluon.mk 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Dependencies for LuaSrcDiet
  2. PKG_BUILD_DEPENDS += luci-base/host lua/host
  3. include $(INCLUDE_DIR)/package.mk
  4. # Annoyingly, make's shell function replaces all newlines with spaces, so we have to do some escaping work. Yuck.
  5. define GluonCheckSite
  6. [ -z "$$IPKG_INSTROOT" ] || sed -e 's/-@/\n/g' -e 's/+@/@/g' <<'END__GLUON__CHECK__SITE' | "${TOPDIR}/staging_dir/hostpkg/bin/lua" -e 'dofile()'
  7. local f = assert(io.open(os.getenv('IPKG_INSTROOT') .. '/lib/gluon/site.json'))
  8. local site_json = f:read('*a')
  9. f:close()
  10. site = require('cjson').decode(site_json)
  11. $(shell cat '$(TOPDIR)/../scripts/check_site_lib.lua' '$(1)' | sed -ne '1h; 1!H; $$ {g; s/@/+@/g; s/\n/-@/g; p}')
  12. END__GLUON__CHECK__SITE
  13. endef
  14. # Languages supported by LuCi
  15. GLUON_SUPPORTED_LANGS := ca cs de el en es fr he hu it ja ms no pl pt-br pt ro ru sk sv tr uk vi zh-cn zh-tw
  16. GLUON_I18N_PACKAGES := $(foreach lang,$(GLUON_SUPPORTED_LANGS),+LUCI_LANG_$(lang):luci-i18n-base-$(lang))
  17. GLUON_I18N_CONFIG := $(foreach lang,$(GLUON_SUPPORTED_LANGS),CONFIG_LUCI_LANG_$(lang))
  18. GLUON_ENABLED_LANGS := $(foreach lang,$(GLUON_SUPPORTED_LANGS),$(if $(CONFIG_LUCI_LANG_$(lang)),$(lang)))
  19. define GluonBuildI18N
  20. mkdir -p $$(PKG_BUILD_DIR)/i18n
  21. for lang in $$(GLUON_ENABLED_LANGS); do \
  22. if [ -e $(2)/$$$$lang.po ]; then \
  23. rm -f $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo; \
  24. po2lmo $(2)/$$$$lang.po $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo; \
  25. fi; \
  26. done
  27. endef
  28. define GluonInstallI18N
  29. $$(INSTALL_DIR) $(2)/usr/lib/lua/luci/i18n
  30. for lang in $$(GLUON_ENABLED_LANGS); do \
  31. if [ -e $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo ]; then \
  32. $$(INSTALL_DATA) $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo $(2)/usr/lib/lua/luci/i18n/$(1).$$$$lang.lmo; \
  33. fi; \
  34. done
  35. endef
  36. define GluonSrcDiet
  37. rm -rf $(2)
  38. $(CP) $(1) $(2)
  39. $(FIND) $(2) -type f | while read src; do \
  40. if LuaSrcDiet --noopt-binequiv -o "$$$$src.o" "$$$$src"; then \
  41. chmod $$$$(stat -c%a "$$$$src") "$$$$src.o"; \
  42. mv "$$$$src.o" "$$$$src"; \
  43. fi; \
  44. done
  45. endef