All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] Enable expression support for CONFIG_BOARD_SIZE_LIMIT
Date: Fri,  7 Dec 2018 20:27:51 +0100	[thread overview]
Message-ID: <20181207192751.30422-1-wd@denx.de> (raw)
In-Reply-To: <20181204154035.16299-1-wd@denx.de>

So far, the use of CONFIG_BOARD_SIZE_LIMIT would only work with
plain numeric constants.  Extend it to allow for expressions, so one
can for example use

	#define CONFIG_BOARD_SIZE_LIMIT	(768 << 10)

in the board configuration.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Tested-by: Fabio Estevam <festevam@gmail.com>

Cc: Fabio Estevam <festevam@gmail.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Vanessa Maegima <vanessa.maegima@nxp.com>
Cc: Otavio Salvador <otavio@ossystems.com.br>
Cc: John Weber <john.weber@technexion.com>
Cc: Stefan Roese <sr@denx.de>
---
v2: replace bashism for evaluating expressions in CONFIG_BOARD_SIZE_LIMIT
    by another call to awk.

Note 1: As gawk lacks an eval function and we don't want to rely on
 bash being used as shell, we use another call to awk to evaluate the
 expression. This has the disadvantage that we cannot use expressions
 like "<<" which awk does not understand. OK, one could replace awk
 by something better...

Note 2: This patch focusses on enabling this new feature.  It does
 not addres another issue that should be solved in a later
 commit: the duplication of the same code in Makefile and
 arch/arm/mach-imx/Makefile

---
 Makefile                   | 17 ++++++++---------
 arch/arm/mach-imx/Makefile | 17 ++++++++---------
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/Makefile b/Makefile
index 0d11ff9797..87eb0fd2b1 100644
--- a/Makefile
+++ b/Makefile
@@ -774,15 +774,14 @@ LDPPFLAGS += \
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \
-	@actual=`wc -c $@ | awk '{print $$1}'`; \
-	limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-	if test $$actual -gt $$limit; then \
-		echo "$@ exceeds file size limit:" >&2 ; \
-		echo "  limit:  $$limit bytes" >&2 ; \
-		echo "  actual: $$actual bytes" >&2 ; \
-		echo "  excess: $$((actual - limit)) bytes" >&2; \
-		exit 1; \
-	fi
+	@(awk "END{print $$(echo $(CONFIG_BOARD_SIZE_LIMIT))}" /dev/null; wc -c $@ ) | \
+	awk 'BEGIN { getline limit } \
+	{ if ($$1 > limit) { \
+		printf "%s exceeds file size limit:\n", $$2; \
+		printf "  limit:  %d bytes\n", limit; \
+		printf "  actual: %d bytes\n", $$1; \
+		printf "  excess: %d bytes\n", $$1 - limit; \
+		exit 1; } }'
 else
 BOARD_SIZE_CHECK =
 endif
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 53d9e5f42b..36d1ecc732 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -60,15 +60,14 @@ endif
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \
-        @actual=`wc -c $@ | awk '{print $$1}'`; \
-        limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-        if test $$actual -gt $$limit; then \
-                echo "$@ exceeds file size limit:" >&2 ; \
-                echo "  limit:  $$limit bytes" >&2 ; \
-                echo "  actual: $$actual bytes" >&2 ; \
-                echo "  excess: $$((actual - limit)) bytes" >&2; \
-                exit 1; \
-        fi
+	@(awk "END{print $$(echo $(CONFIG_BOARD_SIZE_LIMIT))}" /dev/null; wc -c $@ ) | \
+	awk 'BEGIN { getline limit } \
+	{ if ($$1 > limit) { \
+		printf "%s exceeds file size limit:\n", $$2; \
+		printf "  limit:  %d bytes\n", limit; \
+		printf "  actual: %d bytes\n", $$1; \
+		printf "  excess: %d bytes\n", $$1 - limit; \
+		exit 1; } }'
 else
 BOARD_SIZE_CHECK =
 endif
-- 
2.19.2

  parent reply	other threads:[~2018-12-07 19:27 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-30 14:52 [U-Boot] [PATCH v4] pico-imx7d: Increase the CONFIG_ENV_OFFSET size Fabio Estevam
2018-11-30 15:17 ` Otavio Salvador
2018-11-30 15:33 ` Wolfgang Denk
2018-11-30 16:28   ` Fabio Estevam
2018-12-03 15:52     ` Wolfgang Denk
2018-12-03 16:53       ` Fabio Estevam
2018-12-03 17:39         ` Otavio Salvador
2018-12-04  9:40           ` Wolfgang Denk
2018-12-04  9:37         ` Wolfgang Denk
2018-12-04 10:41           ` Fabio Estevam
2018-12-04 13:03             ` Wolfgang Denk
2018-12-04 13:18               ` Fabio Estevam
2018-12-04 13:35                 ` Wolfgang Denk
2018-12-04 14:15                   ` Fabio Estevam
2018-12-04 15:40                     ` [U-Boot] [PATCH] Enable expression support for CONFIG_BOARD_SIZE_LIMIT Wolfgang Denk
2018-12-04 15:42                       ` Otavio Salvador
2018-12-04 16:15                       ` Fabio Estevam
2018-12-05  9:52                         ` Wolfgang Denk
2018-12-06 13:04                           ` Fabio Estevam
2018-12-06 14:23                             ` Wolfgang Denk
2018-12-06 14:41                               ` Fabio Estevam
2018-12-06 14:44                                 ` Andy Pont
2018-12-06 14:58                                   ` Fabio Estevam
2018-12-06 15:01                                     ` Fabio Estevam
2018-12-06 14:50                                 ` Philipp Tomsich
2018-12-06 15:06                                   ` Fabio Estevam
2018-12-06 15:17                                 ` Fabio Estevam
2018-12-07 15:21                                   ` Wolfgang Denk
2018-12-07 15:37                                     ` Fabio Estevam
2018-12-07 19:28                                       ` Wolfgang Denk
2018-12-07 19:27                       ` Wolfgang Denk [this message]
2018-12-14 19:16                         ` [U-Boot] [U-Boot, v2] " Tom Rini
2019-03-06 20:54                           ` Simon Goldschmidt
2019-03-08 17:17                             ` Tom Rini
2019-03-08 17:28                               ` Martin Husemann
2019-03-08 17:53                                 ` Philipp Tomsich
2019-03-08 18:16                                   ` Simon Goldschmidt
2019-03-08 19:55                                   ` Tom Rini
2019-03-15 10:13                                 ` Ismael Luceno Cortes
2018-12-17 14:13 ` [U-Boot] [PATCH v4] pico-imx7d: Increase the CONFIG_ENV_OFFSET size Fabio Estevam
2018-12-17 14:47   ` Stefano Babic
2018-12-17 14:50     ` Fabio Estevam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181207192751.30422-1-wd@denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.