From 86ef92ea068a9c49d8d0638737b56b606362c260 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Fri, 21 Oct 2016 13:38:06 +0200 Subject: [PATCH] make: strip *.lua as intended since dcd89700 This saves a few kilobytes in the executable. Also, the name XXD seemed no longer suitable, as it does lua-specific cleaning. --- config.mk | 2 +- daemon/daemon.mk | 2 +- scripts/embed-lua.sh | 10 ++++++++++ scripts/embed.sh | 9 --------- 4 files changed, 12 insertions(+), 11 deletions(-) create mode 100755 scripts/embed-lua.sh delete mode 100755 scripts/embed.sh diff --git a/config.mk b/config.mk index fbed46eaa..9054705f6 100644 --- a/config.mk +++ b/config.mk @@ -23,7 +23,7 @@ ETCDIR ?= $(PREFIX)/etc/kresd CC ?= cc RM := rm -f LN := ln -s -XXD := ./scripts/embed.sh +XXD_LUA := ./scripts/embed-lua.sh INSTALL := install # Flags diff --git a/daemon/daemon.mk b/daemon/daemon.mk index ff00fb108..fcdbde5ba 100644 --- a/daemon/daemon.mk +++ b/daemon/daemon.mk @@ -12,7 +12,7 @@ kresd_DIST := daemon/lua/kres.lua daemon/lua/trust_anchors.lua # Embedded resources %.inc: %.lua - @$(call quiet,XXD,$<) $< > $@ + @$(call quiet,XXD_LUA,$<) $< > $@ ifeq ($(AMALG), yes) kresd.amalg.c: daemon/lua/sandbox.inc daemon/lua/config.inc else diff --git a/scripts/embed-lua.sh b/scripts/embed-lua.sh new file mode 100755 index 000000000..403dfa2d0 --- /dev/null +++ b/scripts/embed-lua.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +# clean unnecessary stuff from the lua file +alias strip="sed -e 's/^[\t ]*//g; s/ */ /g; /^--/d; /^$/d'" +if command -v xxd > /dev/null 2>&1; then + strip < "$1" | xxd -i - +else + strip < "$1" | hexdump -v -e '/1 "0x%02X, " " "' +fi +exit $? diff --git a/scripts/embed.sh b/scripts/embed.sh deleted file mode 100755 index 043e74afd..000000000 --- a/scripts/embed.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -e -alias strip="sed -e 's/^[ ]*//g; s/[ ][ ]*/ /g; /^--/d; /^$/d'" -if command -v xxd > /dev/null 2>&1; then - xxd -i - < $1 | strip -else - hexdump -v -e '/1 "0x%02X, " " "' < $1 | strip -fi -exit $? -- 2.47.3