Skip to content
Snippets Groups Projects
gluon.mk 1.91 KiB
Newer Older
# Dependencies for LuaSrcDiet
PKG_BUILD_DEPENDS += luci-base/host
include $(INCLUDE_DIR)/package.mk

# Annoyingly, make's shell function replaces all newlines with spaces, so we have to do some escaping work. Yuck.
shell-escape = $(shell $(1) | sed -ne '1h; 1!H; $$ {g; s/@/@1/g; s/\n/@2/g; p}')
shell-unescape = $(subst @1,@,$(subst @2,$(newline),$(1)))
shell-verbatim = $(call shell-unescape,$(call shell-escape,$(1)))


[ -z "$$IPKG_INSTROOT" ] || "${TOPDIR}/staging_dir/hostpkg/bin/lua" -e 'dofile()' <<'END__GLUON__CHECK__SITE'
local f = assert(io.open(os.getenv('IPKG_INSTROOT') .. '/lib/gluon/site.json'))
local site_json = f:read('*a')
f:close()

site = require('cjson').decode(site_json)
$(call shell-verbatim,cat '$(TOPDIR)/../scripts/check_site_lib.lua' '$(1)')
Matthias Schiffer's avatar
Matthias Schiffer committed

GLUON_SUPPORTED_LANGS := de fr
GLUON_LANG_de := German
GLUON_LANG_fr := French
Matthias Schiffer's avatar
Matthias Schiffer committed

GLUON_I18N_CONFIG := $(foreach lang,$(GLUON_SUPPORTED_LANGS),CONFIG_GLUON_WEB_LANG_$(lang))
GLUON_ENABLED_LANGS := en $(foreach lang,$(GLUON_SUPPORTED_LANGS),$(if $(CONFIG_GLUON_WEB_LANG_$(lang)),$(lang)))
Matthias Schiffer's avatar
Matthias Schiffer committed


define GluonBuildI18N
	mkdir -p $$(PKG_BUILD_DIR)/i18n
	for lang in $$(GLUON_ENABLED_LANGS); do \
		if [ -e $(2)/$$$$lang.po ]; then \
Matthias Schiffer's avatar
Matthias Schiffer committed
			rm -f $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo; \
			po2lmo $(2)/$$$$lang.po $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo; \
Matthias Schiffer's avatar
Matthias Schiffer committed
		fi; \
	done
endef

define GluonInstallI18N
	$$(INSTALL_DIR) $(2)/lib/gluon/web/i18n
Matthias Schiffer's avatar
Matthias Schiffer committed
	for lang in $$(GLUON_ENABLED_LANGS); do \
		if [ -e $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo ]; then \
			$$(INSTALL_DATA) $$(PKG_BUILD_DIR)/i18n/$(1).$$$$lang.lmo $(2)/lib/gluon/web/i18n/$(1).$$$$lang.lmo; \
Matthias Schiffer's avatar
Matthias Schiffer committed
		fi; \
	done
endef

define GluonSrcDiet
	rm -rf $(2)
	$(CP) $(1) $(2)
	$(FIND) $(2) -type f | while read src; do \
		if LuaSrcDiet --noopt-binequiv -o "$$$$src.o" "$$$$src"; then \
			chmod $$$$(stat -c%a "$$$$src") "$$$$src.o"; \
			mv "$$$$src.o" "$$$$src"; \
		fi; \