[patch binutils]: Add --preprocessor-arg option to windres tool

Kai Tietz ktietz70@googlemail.com
Mon Apr 11 11:52:00 GMT 2011


2011/4/11 Nick Clifton <nickc@redhat.com>:
> Hi Kai,
>
>> This patch adds feature to windres tool, so that user can pass via
>> --preprocessor-arg additional options to the preprocessor.
>
>> 2011-04-08  Kai Tietz
>>
>>        * windres.c (usage): Add new --preprocessor-arg option.
>>        (option_values): Add new OPTION_PREPROCESSOR_ARG enumerator.
>>        (option long_options): Add preprocessor-arg option.
>>        (main): Handle it.
>
> The patch itself is OK, but you need to extend it.  In particular:
>
>  * Document the new option in binutils/binutils.texi.
>
>  * Mention the new feature in binutils/NEWS.
>
>  * Optional, but very helpful: Add a test to
> binutils/testsuite/binutils-all/windres to check that the new feature works.
>
> Cheers
>  Nick

Ok, added documentation and NEWS entry for this new option.

Ok for apply?

Regards,
Kai
-------------- next part --------------
Index: src/binutils/windres.c
===================================================================
--- src.orig/binutils/windres.c	2011-04-09 18:01:32.861135500 +0200
+++ src/binutils/windres.c	2011-04-11 13:38:57.699191700 +0200
@@ -665,6 +665,7 @@ usage (FILE *stream, int status)
   -O --output-format=<format>  Specify output format\n\
   -F --target=<target>         Specify COFF target\n\
      --preprocessor=<program>  Program to use to preprocess rc file\n\
+     --preprocessor-arg=<arg>  Additional preprocessor argument\n\
   -I --include-dir=<dir>       Include directory when preprocessing rc file\n\
   -D --define <sym>[=<val>]    Define SYM when preprocessing rc file\n\
   -U --undefine <sym>          Undefine SYM when preprocessing rc file\n\
@@ -734,7 +735,8 @@ enum option_values
   OPTION_USE_TEMP_FILE,
   OPTION_NO_USE_TEMP_FILE,
   OPTION_YYDEBUG,
-  OPTION_INCLUDE_DIR
+  OPTION_INCLUDE_DIR,
+  OPTION_PREPROCESSOR_ARG
 };
 
 static const struct option long_options[] =
@@ -745,6 +747,7 @@ static const struct option long_options[
   {"output-format", required_argument, 0, 'O'},
   {"target", required_argument, 0, 'F'},
   {"preprocessor", required_argument, 0, OPTION_PREPROCESSOR},
+  {"preprocessor-arg", required_argument, 0, OPTION_PREPROCESSOR_ARG},
   {"include-dir", required_argument, 0, OPTION_INCLUDE_DIR},
   {"define", required_argument, 0, 'D'},
   {"undefine", required_argument, 0, 'U'},
@@ -888,6 +891,23 @@ main (int argc, char **argv)
 	case OPTION_PREPROCESSOR:
 	  preprocessor = optarg;
 	  break;
+	case OPTION_PREPROCESSOR_ARG:
+	  if (preprocargs == NULL)
+	    {
+	      quotedarg = quot (optarg);
+	      preprocargs = xstrdup (quotedarg);
+	    }
+	  else
+	    {
+	      char *n;
+
+	      quotedarg = quot (optarg);
+	      n = xmalloc (strlen (preprocargs) + strlen (quotedarg) + 2);
+	      sprintf (n, "%s %s", preprocargs, quotedarg);
+	      free (preprocargs);
+	      preprocargs = n;
+	    }
+	  break;
 
 	case 'D':
 	case 'U':
Index: src/binutils/NEWS
===================================================================
--- src.orig/binutils/NEWS	2010-11-11 18:04:30.000000000 +0100
+++ src/binutils/NEWS	2011-04-11 13:47:24.878595300 +0200
@@ -1,5 +1,8 @@
 -*- text -*-
 
+* Add --preprocessor-arg option to windres to specify additional options
+  passed to preprocessor.
+
 Changes in 2.21:
 
 
Index: src/binutils/doc/binutils.texi
===================================================================
--- src.orig/binutils/doc/binutils.texi	2010-12-18 12:26:24.000000000 +0100
+++ src/binutils/doc/binutils.texi	2011-04-11 13:44:43.793640100 +0200
@@ -3450,6 +3450,11 @@ preprocessor first.  This option may be
 to use, including any leading arguments.  The default preprocessor
 argument is @code{gcc -E -xc-header -DRC_INVOKED}.
 
+@item --preprocessor-arg @var{option}
+When @command{windres} reads an @code{rc} file, it runs it through the C
+preprocessor first.  This option may be used to specify additional
+option to be passed to preprocessor.
+
 @item -I @var{directory}
 @itemx --include-dir @var{directory}
 Specify an include directory to use when reading an @code{rc} file.


More information about the Binutils mailing list