]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* windres.c (usage): Add new --preprocessor-arg option.
authorNick Clifton <nickc@redhat.com>
Wed, 13 Apr 2011 07:50:15 +0000 (07:50 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 13 Apr 2011 07:50:15 +0000 (07:50 +0000)
(option_values): Add new OPTION_PREPROCESSOR_ARG enumerator.
(option long_options): Add preprocessor-arg option.
(main): Handle it.
* doc/binutils.texi: Add documentation for --preprocessor-arg
option.
* NEWS: Add line about new --preprocessor-arg option for windres.

* binutils-all/windres/windres.exp: Add '// cpparg <option>' command
to rc file interpretation to specify addition pre-processor commands
as script option.
* binutils-all/windres/strtab3.rc: New.
* binutils-all/windres/strtab3.rsd: New.
* binutils-all/windres/README: Add note about cpparg script option.
argument

binutils/ChangeLog
binutils/NEWS
binutils/doc/binutils.texi
binutils/testsuite/ChangeLog
binutils/testsuite/binutils-all/windres/README
binutils/testsuite/binutils-all/windres/strtab3.rc [new file with mode: 0644]
binutils/testsuite/binutils-all/windres/strtab3.rsd [new file with mode: 0644]
binutils/testsuite/binutils-all/windres/windres.exp
binutils/windres.c

index 4d3f46b0455dde9a3584b2f3bbceb287eea3eac9..44dab32b980bb1947e33d648d8855bdddeaf07e7 100644 (file)
@@ -1,3 +1,13 @@
+2011-04-11  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.
+       * doc/binutils.texi: Add documentation for --preprocessor-arg
+       option.
+       * NEWS: Add line about new --preprocessor-arg option for windres.
+
 2011-04-08  John Marino  <binutils@marino.st>
 
        * arlex.l: Prevent redefinition of YY_NO_UNPUT.
index a30f655ff2d3e8d92ee5481f060bb2afca68cbd6..d1b2a51203b23d78310a744779408a8e9ed8ba6d 100644 (file)
@@ -1,7 +1,9 @@
 -*- text -*-
 
-Changes in 2.21:
+* Add --preprocessor-arg option to windres to specify additional options
+  passed to preprocessor.
 
+Changes in 2.21:
 
 * Add --interleave-width option to objcopy to allowing copying a range of
   bytes from the input to the output with the --interleave option.
index 4cba11161c592c9a12b534eb23926967c8be3f56..45a7ff76946763aca2208d4d6830d96115c89656 100644 (file)
@@ -11,7 +11,7 @@
 @copying
 @c man begin COPYRIGHT
 Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
@@ -3450,6 +3450,13 @@ preprocessor first.  This option may be used to specify the preprocessor
 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
+text to be passed to preprocessor on its command line.
+This option can be used multiple times to add multiple options to the
+preprocessor command line.
+
 @item -I @var{directory}
 @itemx --include-dir @var{directory}
 Specify an include directory to use when reading an @code{rc} file.
index 9537660af58790ce014771aabef9016bd70bb442..fb9ad826a3bec2a7440a2c19b2f75a6f70462b1e 100644 (file)
@@ -1,3 +1,13 @@
+011-04-11  Kai Tietz
+
+       * binutils-all/windres/windres.exp: Add '// cpparg <option>' command
+       to rc file interpretation to specify addition pre-processor commands
+       as script option.
+       * binutils-all/windres/strtab3.rc: New.
+       * binutils-all/windres/strtab3.rsd: New.
+       * binutils-all/windres/README: Add note about cpparg script option.
+       argument
+
 2011-04-11  Nick Clifton  <nickc@redhat.com>
 
        * binutils-all/arm/simple.s: Fix assembly problems for COFF based
index f99034949956d09c68b577e7243dc69e1541ea76..66864881e427e54394d5dfed4c7101e8f3d074d5 100644 (file)
@@ -12,6 +12,7 @@ contains one command:
 
        // parse-only
        // xfail *-*-*
+       // cpparg <preprocessor options passed via --preprocessor-arg>
 
 parse-only must preceed any xfail commands, and indicates that a
 comparison with the *.rsd file will not happen.  xfail indicates when
diff --git a/binutils/testsuite/binutils-all/windres/strtab3.rc b/binutils/testsuite/binutils-all/windres/strtab3.rc
new file mode 100644 (file)
index 0000000..542e9dc
--- /dev/null
@@ -0,0 +1,14 @@
+// cpparg -DTEST=1
+
+#include "windows.h"
+
+LANGUAGE 0, 0
+
+STRINGTABLE MOVEABLE PURE DISCARDABLE
+BEGIN
+#ifdef TEST
+  1 "hello, world"
+#else
+  1 "fail"
+#endif
+END
diff --git a/binutils/testsuite/binutils-all/windres/strtab3.rsd b/binutils/testsuite/binutils-all/windres/strtab3.rsd
new file mode 100644 (file)
index 0000000..4d61073
--- /dev/null
@@ -0,0 +1,8 @@
+ 0000 00000000 20000000 ffff0000 ffff0000  .... ...........
+ 0010 00000000 00000000 00000000 00000000  ................
+ 0020 38000000 20000000 ffff0600 ffff0100  8... ...........
+ 0030 00000000 30100000 00000000 00000000  ....0...........
+ 0040 00000c00 68006500 6c006c00 6f002c00  ....h.e.l.l.o.,.
+ 0050 20007700 6f007200 6c006400 00000000   .w.o.r.l.d.....
+ 0060 00000000 00000000 00000000 00000000  ................
+ 0070 00000000 00000000                    ........        
index 5b0c4afc8990ef8fe1b89633bbd2e62022c3e872..2ef73ffeba9ca01260f73e0e26ddf3e7c8a011a2 100644 (file)
@@ -56,6 +56,7 @@ foreach res $res_list {
     set sroot [file rootname $res]
     set broot [file tail $sroot]
     set done 0
+    set cpp_opts ""
 
     set rc [open $res]
     while { [gets $rc line] != -1 } {
@@ -66,10 +67,14 @@ foreach res $res_list {
            setup_xfail $sys
            continue
        }
+       if [regexp "cpparg *(\[^ \]*)" $line junk cppopt] {
+           set cpp_opts "--preprocessor-arg \"$cppopt\""
+           continue
+       }
     }
 
     verbose "$wr -J rc -O res $res tmpdir/$broot.res" 1
-    catch "exec $wr -J rc -O res $res tmpdir/$broot.res" err
+    catch "exec $wr $cpp_opts -J rc -O res $res tmpdir/$broot.res" err
 
     if ![string match "" $err] then {
        send_log "$err\n"
index 05b7559f7447a4fc8fa36b277bd32391c87007b0..4b40c97183c29c5f45bb32bff4ec5dfdedd2a96c 100644 (file)
@@ -1,6 +1,6 @@
 /* windres.c -- a program to manipulate Windows resources
    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
-   2009 Free Software Foundation, Inc.
+   2009, 2011 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
    Rewritten by Kai Tietz, Onevision.
 
@@ -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'},
@@ -889,6 +892,24 @@ main (int argc, char **argv)
          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':
          if (preprocargs == NULL)