From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCVgI-0001ni-OH for qemu-devel@nongnu.org; Wed, 30 Jul 2014 11:20:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCVgD-00017V-ON for qemu-devel@nongnu.org; Wed, 30 Jul 2014 11:20:42 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:44795 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCVgD-000170-Az for qemu-devel@nongnu.org; Wed, 30 Jul 2014 11:20:37 -0400 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Wed, 30 Jul 2014 16:20:26 +0100 Message-Id: <1406733627-24255-5-git-send-email-alex.bennee@linaro.org> In-Reply-To: <1406733627-24255-1-git-send-email-alex.bennee@linaro.org> References: <1406733627-24255-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v2 4/5] scripts/make_device_config.sh: inline includes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Previously we processed all the includes at first and then just concatenated them to the end of the eventual file. This meant if you wanted to include a set of configs but only turn off some you couldn't. Now you can do (for example): # We support most of the 32 bit boards so need all their config include arm-softmmu.mak # we explicitly disable ones that require old ARMv5 support CONFIG_ARMV5_BOARDS=n Signed-off-by: Alex Bennée diff --git a/scripts/make_device_config.sh b/scripts/make_device_config.sh index 7242707..b0d0b51 100644 --- a/scripts/make_device_config.sh +++ b/scripts/make_device_config.sh @@ -1,6 +1,8 @@ #! /bin/sh # Construct a target device config file from a default, pulling in any -# files from include directives. +# files from include directives. The include files are inlined in the order +# they are found in the source file so you can reverse a sub-set of +# settings afterwards. dest=$1.tmp dep=`dirname $1`-`basename $1`.d @@ -8,21 +10,26 @@ src=$2 src_dir=`dirname $src` all_includes= -process_includes () { - cat $1 | grep '^include' | \ - while read include file ; do - all_includes="$all_includes $src_dir/$file" - process_includes $src_dir/$file - done +process_file () { + local in=$1 + local out=$2 + while read first second; do + if [ "$first" = "include" ]; then + local inc="$src_dir/$second" + all_includes="$all_includes $inc" + echo "# include file: $inc" >> $out + process_file $inc $out + echo "# end of include: $inc" >> $out + else + if [ "x$second" = "x" ]; then + echo $first >> $out + else + echo "$first $second" >> $out + fi + fi + done < $in } -f=$src -while [ -n "$f" ] ; do - f=`cat $f | tr -d '\r' | awk '/^include / {printf "'$src_dir'/%s ", $2}'` - [ $? = 0 ] || exit 1 - all_includes="$all_includes $f" -done -process_includes $src > $dest - -cat $src $all_includes | grep -v '^include' > $dest +echo "# This file is auto-generated by make_device_config.sh" > $dest +process_file $src $dest echo "$1: $all_includes" > $dep -- 2.0.3