From 1a289341a4e8d4fe1a69a5e3881fed9a650f71f6 Mon Sep 17 00:00:00 2001 From: Jan-Tarek Butt Date: Thu, 7 Jul 2016 11:47:56 +0200 Subject: [PATCH] build: add GluonSrcDiet define to package.mk This call takes an input and an output argument and will copy all files from the input to the output, while minifying the Lua files. [Matthias Schiffer: simplified definition, added commit message.] --- include/package.mk | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/package.mk b/include/package.mk index 76e109e2..9d35ad3c 100644 --- a/include/package.mk +++ b/include/package.mk @@ -1,3 +1,6 @@ +# Dependencies for LuaSrcDiet +PKG_BUILD_DEPENDS += luci-base/host lua/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. @@ -33,3 +36,16 @@ define GluonInstallI18N fi; \ done endef + +define GluonSrcDiet + rm -rf $(2) + $(CP) $(1) $(2) + $(FIND) $(2) -type f | while read src; do \ + if $(STAGING_DIR_HOST)/bin/lua $(STAGING_DIR_HOST)/bin/LuaSrcDiet \ + --noopt-binequiv -o "$$$$src.o" "$$$$src"; \ + then \ + chmod $$$$(stat -c%a "$$$$src") "$$$$src.o"; \ + mv "$$$$src.o" "$$$$src"; \ + fi; \ + done +endef