Hi,
This patch makes able to minify lua code sequential inside directories.
Here is an example how do can call it in package Makefiles:
First of all you need the host dependencies.
PKG_BUILD_DEPENDS += luci-base/host lua/host
Then you muss have to include the gluon spesific package.mk.
include $(GLUONDIR)/include/package.mk
After the all abouve just call the following command inside the package
compile define.
$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
luasrc can have subdirectorys there will also created inside luadest
including its minifyed files.
As an example how good it will woke. I minifyed the Nordwest Freifunk
hoodselector. This lua file have currently around 680 lines and a size
of 22042 Bytes after minifying it has just 9480 Bytes.
Here is a table of the minifying process:
--------------------------------------------------------------------
Lexical Input Input Input Output Output Output
Elements Count Bytes Average Count Bytes Average
--------------------------------------------------------------------
TK_KEYWORD 526 1958 3.72 526 1958 3.72
TK_NAME 813 5506 6.77 813 1984 2.44
TK_NUMBER 35 36 1.03 35 36 1.03
TK_STRING 246 3379 13.74 246 3379 13.74
TK_LSTRING 0 0 0.00 0 0 0.00
TK_OP 1276 1356 1.06 1276 1356 1.06
TK_EOS 1 0 0.00 1 0 0.00
--------------------------------------------------------------------
TK_COMMENT 137 6982 50.96 1 14 14.00
TK_LCOMMENT 0 0 0.00 0 0 0.00
TK_EOL 676 676 1.00 466 466 1.00
TK_SPACE 1187 2149 1.81 287 287 1.00
--------------------------------------------------------------------
Total Elements 4897 22042 4.50 3651 9480 2.60
--------------------------------------------------------------------
Total Tokens 2897 12235 4.22 2897 8713 3.01
--------------------------------------------------------------------
Patches for preparing all gluon spesific packages that includes lua
code will follow soon.
cheers
Tarek
Jan-Tarek Butt (1):
add luaSrcDiet call define to package.mk
include/package.mk | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
--
2.9.0
---
include/package.mk | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/package.mk b/include/package.mk
index 76e109e..a1eeb2d 100644
--- a/include/package.mk
+++ b/include/package.mk
@@ -1,3 +1,7 @@
+# gluon packages will have this implicid integrated the build depends.
+# This is just collective for community specific packages there use GluonSrcDiet.
+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 +37,19 @@ define GluonInstallI18N
fi; \
done
endef
+
+define GluonSrcDiet
+ cd $(1) && $$(FIND) . | sed 's/.\///' | while read src; do \
+ if [ -d $$$$src ]; then \
+ if [ ! -d $(shell echo "$(2)" | sed 's/\/$$//')/$$$$src ]; then \
+ $$(INSTALL_DIR) -p "$(shell echo "$(2)" | sed 's/\/$$//')/$$$$src"; \
+ fi; \
+ else \
+ if $(STAGING_DIR_HOST)/bin/lua $(STAGING_DIR_HOST)/bin/LuaSrcDiet \
+ --noopt-binequiv -o "$(shell echo "$(2)" | sed 's/\/$$//')/$$$$src" \
+ "$$$$src"; then \
+ chmod +x "$(shell echo "$(2)" | sed 's/\/$$//')/$$$$src"; \
+ fi; \
+ fi; \
+ done
+endef
--
2.9.0
Hey zusammen,
die nächsten Hoods sind nun fertig:
- Budjadingen
- Wittmund
- Lohne / Dinklage
Diese werden nun noch getestet.
Eine entsprechende Testing FW ist unter http://runner02.ffnw.de/1.1-RC1/
zu finden.
Bitte nur testen, wenn ihr wisst was ihr tut :)
Jetzt warten wir noch auf eine weitere Funktion / Fix von Tarek, da wird
er aber was zu schreiben.
Viele Grüße,
Stefan