gluon.mk 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Dependencies for LuaSrcDiet
  2. PKG_BUILD_DEPENDS += luci-base/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. shell-escape = $(shell $(1) | sed -ne '1h; 1!H; $$ {g; s/@/@1/g; s/\n/@2/g; p}')
  6. shell-unescape = $(subst @1,@,$(subst @2,$(newline),$(1)))
  7. shell-verbatim = $(call shell-unescape,$(call shell-escape,$(1)))
  8. define GluonCheckSite
  9. [ -z "$$IPKG_INSTROOT" ] || "${TOPDIR}/staging_dir/hostpkg/bin/lua" -e 'dofile()' <<'END__GLUON__CHECK__SITE'
  10. local f = assert(io.open(os.getenv('IPKG_INSTROOT') .. '/lib/gluon/site.json'))
  11. local site_json = f:read('*a')
  12. f:close()
  13. site = require('cjson').decode(site_json)
  14. $(call shell-verbatim,cat '$(TOPDIR)/../scripts/check_site_lib.lua' '$(1)')
  15. END__GLUON__CHECK__SITE
  16. endef
  17. GLUON_SUPPORTED_LANGS := de fr
  18. GLUON_LANG_de := German
  19. GLUON_LANG_fr := French
  20. GLUON_I18N_CONFIG := $(foreach lang,$(GLUON_SUPPORTED_LANGS),CONFIG_GLUON_WEB_LANG_$(lang))
  21. GLUON_ENABLED_LANGS := en $(foreach lang,$(GLUON_SUPPORTED_LANGS),$(if $(CONFIG_GLUON_WEB_LANG_$(lang)),$(lang)))
  22. define GluonBuildI18N
  23. mkdir -p $$(PKG_BUILD_DIR)/i18n
  24. for lang in $$(GLUON_ENABLED_LANGS); do \
  25. if [ -e $(2)/$$$$lang.po ]; then \
  26. rm -f $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo; \
  27. po2lmo $(2)/$$$$lang.po $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo; \
  28. fi; \
  29. done
  30. endef
  31. define GluonInstallI18N
  32. $$(INSTALL_DIR) $(2)/lib/gluon/web/i18n
  33. for lang in $$(GLUON_ENABLED_LANGS); do \
  34. if [ -e $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo ]; then \
  35. $$(INSTALL_DATA) $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo $(2)/lib/gluon/web/i18n/$(1).$$$$lang.lmo; \
  36. fi; \
  37. done
  38. endef
  39. define GluonSrcDiet
  40. rm -rf $(2)
  41. $(CP) $(1) $(2)
  42. $(FIND) $(2) -type f | while read src; do \
  43. if LuaSrcDiet --noopt-binequiv -o "$$$$src.o" "$$$$src"; then \
  44. chmod $$$$(stat -c%a "$$$$src") "$$$$src.o"; \
  45. mv "$$$$src.o" "$$$$src"; \
  46. fi; \
  47. done
  48. endef