Web lists-archives.com

Re: [MPlayer-dev-eng] [PATCH 1/3] configure: Drastically speed up generation of config.h/.asm/.mak




Hi,

On 2015-11-14 22:19 +0100, Alexander Strasser wrote:
> From: Reimar Döffinger <Reimar.Doeffinger@xxxxxx>
>
> Avoid spawning grep for every item in the list.

seems this was mainly a problem because some antivirus soft
greatly amplified the effect by slowing down file access.

  FWIW I have attached new patches that avoid the grep but
do not generate outputs with multiple definitions for the
same item. It is a little faster on my linux system and
halves configure time on my windows box. It is not tested
very much and with only a few AWK implementations.

  I am fine with dropping it completely, though the first
patch could be applied either way if anyone is in favor.

  Alexander

> Signed-off-by: Alexander Strasser <eclipse7@xxxxxxx>
> ---
>  configure | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/configure b/configure
> index 0e37441..57e9cb7 100755
> --- a/configure
> +++ b/configure
> @@ -8310,11 +8310,10 @@ list=$(echo $1 | toupper)
>  item=$(echo $2 | toupper)
>  nprefix=$3;
>  for part in $list; do
> -  if $(echo $item | grep -q -E "(^| )$part($| )"); then
> -    echo "${nprefix}_$part = yes"
> -  else
> -    echo "${nprefix}_$part = no"
> -  fi
> +  echo "${nprefix}_$part = no"
> +done
> +for part in $item; do
> +  echo "${nprefix}_$part = yes"
>  done
>  }
>  
> @@ -8731,11 +8730,11 @@ _defineprefix=$3;
>  _postfix=$5;
>  test -z "$_nprefix" && _nprefix='CONFIG'
>  for part in $list; do
> -  if $(echo $item | grep -q -E "(^| )$part($| )"); then
> -    echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 1"
> -  else
> -    echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 0"
> -  fi
> +  echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 0"
> +done
> +for part in $item; do
> +  echo "${_defineprefix}undef ${_nprefix}_${part}${_postfix}"
> +  echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 1"
>  done
>  }
>  
> -- 
>From 16f1de0c1a1558b6294ed5429d45f0c60ab5ef75 Mon Sep 17 00:00:00 2001
Message-Id: <16f1de0c1a1558b6294ed5429d45f0c60ab5ef75.1450212994.git.eclipse7@xxxxxxx>
In-Reply-To: <9abc4a2d16cbc23d68b94ef3f19e6fb3f31bdbc5.1450212994.git.eclipse7@xxxxxxx>
References: <9abc4a2d16cbc23d68b94ef3f19e6fb3f31bdbc5.1450212994.git.eclipse7@xxxxxxx>
From: Alexander Strasser <eclipse7@xxxxxxx>
Date: Fri, 11 Dec 2015 02:16:26 +0100
Subject: [PATCH 3/4] configure: ff_config_enable: Remove empty prefix special
 case
To: mpdev

The special casing does not save anything in terms of source
lines or otherwise.

Also make ff_config_enable behave more like ff_mak_enable.

Signed-off-by: Alexander Strasser <eclipse7@xxxxxxx>
---
 configure | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index 08ead0e..ae703bd 100755
--- a/configure
+++ b/configure
@@ -8755,7 +8755,6 @@ item=$(echo $2 | toupper)
 _nprefix=$4;
 _defineprefix=$3;
 _postfix=$5;
-test -z "$_nprefix" && _nprefix='CONFIG'
 for part in $list; do
   if $(echo $item | grep -q -E "(^| )$part($| )"); then
     echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 1"
@@ -9371,15 +9370,15 @@ $def_schannel
 #define LIBAV_CONFIGURATION FFMPEG_CONFIGURATION
 #define LIBAV_LICENSE FFMPEG_LICENSE
 
-$(ff_config_enable "$libavdecoders_all"  "$libavdecoders" "#")
-$(ff_config_enable "$libavencoders_all"  "$libavencoders" "#")
-$(ff_config_enable "$libavparsers_all"   "$libavparsers" "#")
-$(ff_config_enable "$libavdemuxers_all"  "$libavdemuxers" "#")
-$(ff_config_enable "$libavmuxers_all"    "$libavmuxers" "#")
-$(ff_config_enable "$libavprotocols_all" "$libavprotocols" "#")
-$(ff_config_enable "$libavbsfs_all"      "$libavbsfs" "#")
-$(ff_config_enable "$libavhwaccels_all"  "$libavhwaccels" "#")
-$(ff_config_enable "$libavfilters_all"   "$libavfilters" "#")
+$(ff_config_enable "$libavdecoders_all"  "$libavdecoders"  "#" "CONFIG")
+$(ff_config_enable "$libavencoders_all"  "$libavencoders"  "#" "CONFIG")
+$(ff_config_enable "$libavparsers_all"   "$libavparsers"   "#" "CONFIG")
+$(ff_config_enable "$libavdemuxers_all"  "$libavdemuxers"  "#" "CONFIG")
+$(ff_config_enable "$libavmuxers_all"    "$libavmuxers"    "#" "CONFIG")
+$(ff_config_enable "$libavprotocols_all" "$libavprotocols" "#" "CONFIG")
+$(ff_config_enable "$libavbsfs_all"      "$libavbsfs"      "#" "CONFIG")
+$(ff_config_enable "$libavhwaccels_all"  "$libavhwaccels"  "#" "CONFIG")
+$(ff_config_enable "$libavfilters_all"   "$libavfilters"   "#" "CONFIG")
 
 #endif /* MPLAYER_CONFIG_H */
 EOF
-- 
>From cf8a031fbd76108b48d64f2ef65a367036651da0 Mon Sep 17 00:00:00 2001
Message-Id: <cf8a031fbd76108b48d64f2ef65a367036651da0.1450212994.git.eclipse7@xxxxxxx>
In-Reply-To: <9abc4a2d16cbc23d68b94ef3f19e6fb3f31bdbc5.1450212994.git.eclipse7@xxxxxxx>
References: <9abc4a2d16cbc23d68b94ef3f19e6fb3f31bdbc5.1450212994.git.eclipse7@xxxxxxx>
From: Alexander Strasser <eclipse7@xxxxxxx>
Date: Thu, 3 Dec 2015 01:06:33 +0100
Subject: [PATCH 4/4] configure: Speed up generating config.h/.asm/.mak
To: mpdev

Avoid spawning grep for every item in the list.

Signed-off-by: Alexander Strasser <eclipse7@xxxxxxx>
---
 configure | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/configure b/configure
index ae703bd..a3ab6c2 100755
--- a/configure
+++ b/configure
@@ -8330,17 +8330,26 @@ fi
 
 #############################################################################
 
+print_definitions () {
+_yes=$1
+_no=$2
+_list=$(echo $3 | toupper)
+_list_yes=$(echo $4 | toupper)
+_define=$5
+_nprefix=$6
+_npostfix=$7
+echo "$_list" | awk -vRS=' ' "
+  {
+    gsub(/\\n/, \"\")
+    if (match(\"${_list_yes}\", \"(^| )\" \$0 \"($| )\"))
+      print \"${_define}${_nprefix}_\" \$0 \"${_npostfix} ${_yes}\"
+    else
+      print \"${_define}${_nprefix}_\" \$0 \"${_npostfix} ${_no}\"
+  }"
+}
+
 mak_enable () {
-list=$(echo $1 | toupper)
-item=$(echo $2 | toupper)
-nprefix=$3;
-for part in $list; do
-  if $(echo $item | grep -q -E "(^| )$part($| )"); then
-    echo "${nprefix}_$part = yes"
-  else
-    echo "${nprefix}_$part = no"
-  fi
-done
+print_definitions "= yes" "= no" "$1" "$2" "" "$3" ""
 }
 
 #############################################################################
@@ -8750,18 +8759,7 @@ EOF
 #############################################################################
 
 ff_config_enable () {
-list=$(echo $1 | toupper)
-item=$(echo $2 | toupper)
-_nprefix=$4;
-_defineprefix=$3;
-_postfix=$5;
-for part in $list; do
-  if $(echo $item | grep -q -E "(^| )$part($| )"); then
-    echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 1"
-  else
-    echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 0"
-  fi
-done
+print_definitions 1 0 "$1" "$2" "${3}define " "$4" "$5"
 }
 
 echo "Creating config.h"
-- 
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng