[dpdk-dev] scripts: fix symbol overriding in configuration files

Message ID 1417087745-9004-1-git-send-email-david.marchand@6wind.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

David Marchand Nov. 27, 2014, 11:29 a.m. UTC
  When redefining the same symbol in configuration (basically after an inclusion),
we need to undefine the previous symbol to avoid "redefined" errors.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 scripts/gen-config-h.sh |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Comments

Thomas Monjalon Nov. 27, 2014, 6:17 p.m. UTC | #1
> When redefining the same symbol in configuration (basically after an inclusion),
> we need to undefine the previous symbol to avoid "redefined" errors.
> 
> Signed-off-by: David Marchand <david.marchand@6wind.com>

Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>

Applied

Thanks
  
Bruce Richardson Nov. 28, 2014, 11:35 a.m. UTC | #2
On Thu, Nov 27, 2014 at 12:29:05PM +0100, David Marchand wrote:
> When redefining the same symbol in configuration (basically after an inclusion),
> we need to undefine the previous symbol to avoid "redefined" errors.
> 
> Signed-off-by: David Marchand <david.marchand@6wind.com>

Though I see this patch is already replied, my comment on the below is that
it may be best as two separate patches, since you are doing two things there
that makes the actual change hard to see. One patch should move the "|" from the
start of the next line to end of the previous, and the second patch should then
add the undef statements. As it is, I had to stare at this for a while to work
out why the grep lines were changing to undefine previously defined values. :-)

/Bruce

> ---
>  scripts/gen-config-h.sh |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/gen-config-h.sh b/scripts/gen-config-h.sh
> index efd7667..2fac08c 100755
> --- a/scripts/gen-config-h.sh
> +++ b/scripts/gen-config-h.sh
> @@ -33,11 +33,11 @@
>  
>  echo "#ifndef __RTE_CONFIG_H"
>  echo "#define __RTE_CONFIG_H"
> -grep CONFIG_ $1							 \
> -| grep -v '^[ \t]*#'							 \
> -| sed 's,CONFIG_\(.*\)=y.*$,#define \1 1,'			 \
> -| sed 's,CONFIG_\(.*\)=n.*$,#undef \1,'				 \
> -| sed 's,CONFIG_\(.*\)=\(.*\)$,#define \1 \2,'			 \
> -| sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,'
> +grep CONFIG_ $1 |
> +grep -v '^[ \t]*#' |
> +sed 's,CONFIG_\(.*\)=y.*$,#undef \1\n#define \1 1,' |
> +sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' |
> +sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\n#define \1 \2,' |
> +sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,'
>  echo "#endif /* __RTE_CONFIG_H */"
>  
> -- 
> 1.7.10.4
>
  
Bruce Richardson Nov. 28, 2014, 1:56 p.m. UTC | #3
On Thu, Nov 27, 2014 at 10:17:22AM -0800, Thomas Monjalon wrote:
> > When redefining the same symbol in configuration (basically after an inclusion),
> > we need to undefine the previous symbol to avoid "redefined" errors.
> > 
> > Signed-off-by: David Marchand <david.marchand@6wind.com>
> 
> Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> 
> Applied
>
This patch doesn't seem to work on FreeBSD. I'm still investigating how to fix
it but right now compilation with gcc/clang on FreeBSD is broken due to the
config.h file having lines like the below in it :-(

/usr/home/bruce/dpdk.org/x86_64-native-bsdapp-clang/include/rte_config.h:3:21: fatal error: extra tokens at end of #undef directive [-Wextra-tokens]
#undef RTE_EXEC_ENVn#define RTE_EXEC_ENV "bsdapp"

I'll send on a fix as soon as I can.

Regards,
/Bruce
  

Patch

diff --git a/scripts/gen-config-h.sh b/scripts/gen-config-h.sh
index efd7667..2fac08c 100755
--- a/scripts/gen-config-h.sh
+++ b/scripts/gen-config-h.sh
@@ -33,11 +33,11 @@ 
 
 echo "#ifndef __RTE_CONFIG_H"
 echo "#define __RTE_CONFIG_H"
-grep CONFIG_ $1							 \
-| grep -v '^[ \t]*#'							 \
-| sed 's,CONFIG_\(.*\)=y.*$,#define \1 1,'			 \
-| sed 's,CONFIG_\(.*\)=n.*$,#undef \1,'				 \
-| sed 's,CONFIG_\(.*\)=\(.*\)$,#define \1 \2,'			 \
-| sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,'
+grep CONFIG_ $1 |
+grep -v '^[ \t]*#' |
+sed 's,CONFIG_\(.*\)=y.*$,#undef \1\n#define \1 1,' |
+sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' |
+sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\n#define \1 \2,' |
+sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,'
 echo "#endif /* __RTE_CONFIG_H */"