[LEDE-DEV] [PATCH] LuaSrcDiet call define for lua code Minifying

Jan-Tarek Butt tarek at ring0.de
Sun Oct 2 13:37:35 PDT 2016


Hi,

This patch makes able to minify lua code sequential inside directories.
Here is an example how do can call it in package Makefiles:

Just call the following command inside the package
compile define.
$(call LuaSrcDiet,./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[0]. 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
--------------------------------------------------------------------

cheers
Tarek

[0] https://git.nordwest.freifunk.net/ffnw-firmware/packages/raw/master/hoodselector/luasrc/hoodselector

Jan-Tarek Butt (1):
  add luaSrcDiet call define to package.mk

 include/package.mk | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

-- 
2.10.0




More information about the Lede-dev mailing list