From patchwork Fri Dec 7 19:27:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Denk X-Patchwork-Id: 1009638 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43BMvj6RK4z9s2P for ; Sat, 8 Dec 2018 06:28:29 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 1DC2FC2205E; Fri, 7 Dec 2018 19:28:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A03ECC21FD9; Fri, 7 Dec 2018 19:28:15 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9DB09C21EF1; Fri, 7 Dec 2018 19:28:14 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by lists.denx.de (Postfix) with ESMTPS id 8A2ECC21EBE for ; Fri, 7 Dec 2018 19:28:13 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43BMvK2PwZz1qxSD for ; Fri, 7 Dec 2018 20:28:13 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43BMvK26ppz1qtfR for ; Fri, 7 Dec 2018 20:28:13 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id XrA8gcNfJkeP for ; Fri, 7 Dec 2018 20:28:12 +0100 (CET) X-Auth-Info: Qjaj6rQ1sHvLqJNO8TveBVik1hQCJTofFkGbzZ0yYw0= Received: from janitor.denx.de (unknown [62.91.23.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Fri, 7 Dec 2018 20:28:12 +0100 (CET) Received: by janitor.denx.de (Postfix, from userid 119) id E67ECFD; Fri, 7 Dec 2018 20:28:11 +0100 (CET) Received: from gemini.denx.de (gemini.denx.de [10.4.0.2]) by janitor.denx.de (Postfix) with ESMTPS id 8EEE7F8; Fri, 7 Dec 2018 20:28:04 +0100 (CET) Received: by gemini.denx.de (Postfix, from userid 500) id B7DB3240409; Fri, 7 Dec 2018 20:28:03 +0100 (CET) From: Wolfgang Denk To: u-boot@lists.denx.de Date: Fri, 7 Dec 2018 20:27:51 +0100 Message-Id: <20181207192751.30422-1-wd@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204154035.16299-1-wd@denx.de> References: <20181204154035.16299-1-wd@denx.de> MIME-Version: 1.0 Cc: Otavio Salvador , Vanessa Maegima , Stefan Roese , John Weber Subject: [U-Boot] [PATCH v2] Enable expression support for CONFIG_BOARD_SIZE_LIMIT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Tested-by: Fabio Estevam Cc: Fabio Estevam Cc: Stefano Babic Cc: Vanessa Maegima Cc: Otavio Salvador Cc: John Weber Cc: Stefan Roese --- 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