This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ [RFC] windres' -I option]

Anyone have any problems with this?  I agree that it makes sense to make
-I behave consistently.  Are there scripts which would be fatally impacted
if we made this switch?


----- Forwarded message from "Dimitrie O. Paun" <dpaun at rogers dot com> -----

From: "Dimitrie O. Paun" <dpaun at rogers dot com>
To: binutils at sources dot redhat dot com
Cc: wine-devel at winehq dot com
Subject: [RFC] windres' -I option
Date: Wed, 19 Mar 2003 00:42:55 -0500
Reply-To: dpaun at rogers dot com
Organization: DSSD Software Inc.

Hi folks,

For the past few month, I've been working on having better
interoperability between MinGW, and Wine (
By this I mean the ability to maintain a single build system
capable of building apps for either environment. Needless to say,
this is a worthy goal, as it allows Windows-only apps to seamlessly
build as Linux-native apps. This is a complex problem, but for
the purpose of this email I will only focus on windres.

As you probably already know, the Wine project has it's own
resource compiler (wrc). For obvious reasons, it is quite
desirable to have wrc and windres be command line compatible.
To this end, I've modified wrc to the point where we support
all but *one* of windres' options: -I.

This option is used in windres to specify the input format,
while in wrc it's used to specify include directories. The
wrc semantics has a lot on it's side: it is the de-facto
standard in the Unix world for specifying include dirs, and 
it is even compatible with MS's rc. Given the overwhelming
inclination to use -I as an include dir specifier, I think
it would be better if we could align windres to this standard.

My proposal is simple: rename -I to something else (I suggest -J),
and introduce -I as a synonym for --include-dir.

Now, I realize this is a controversial change -- what about
backwards compatibility? Luckily, the situation is not as bad
as it might seem. Firstly, this option does not seem to be used
all that often in practice. Second, the nature of the option allows
for a simple scheme. That is, with -I now used for include directories,
we can try to match the 3 possible old values (res, rc, coff).
If they match, we consider it a input format specifier, issue a
deprecation warning, and behave in the old fashion. Otherwise, 
consider the input an include directory. But what if one want to
specify 'res' or 'coff' as an include dir? Well, apart from the
fact that this is _very_ unlikely, all they have to do is to
prefix those values with './': that is ./res or ./coff.

But I guess this is already too much talk and too little action.
Here is a patch that implements the above, and updates the 

  Rename the -I option to -J. Introduce -I as synonym for --include-dir.

Index: binutils/windres.c
RCS file: /cvs/src/src/binutils/windres.c,v
retrieving revision 1.13
diff -u -r1.13 windres.c
--- binutils/windres.c	5 May 2002 23:25:27 -0000	1.13
+++ binutils/windres.c	17 Mar 2003 07:14:16 -0000
@@ -110,8 +110,7 @@
 #define OPTION_DEFINE 150
@@ -122,8 +121,8 @@
   {"define", required_argument, 0, OPTION_DEFINE},
   {"help", no_argument, 0, OPTION_HELP},
-  {"include-dir", required_argument, 0, OPTION_INCLUDE_DIR},
-  {"input-format", required_argument, 0, 'I'},
+  {"include-dir", required_argument, 0, 'I'},
+  {"input-format", required_argument, 0, 'J'},
   {"language", required_argument, 0, OPTION_LANGUAGE},
   {"output-format", required_argument, 0, 'O'},
   {"preprocessor", required_argument, 0, OPTION_PREPROCESSOR},
@@ -140,7 +139,7 @@
 static void res_init PARAMS ((void));
 static int extended_menuitems PARAMS ((const struct menuitem *));
-static enum res_format format_from_name PARAMS ((const char *));
+static enum res_format format_from_name PARAMS ((const char *, int));
 static enum res_format format_from_filename PARAMS ((const char *, int));
 static void usage PARAMS ((FILE *, int));
 static int cmp_res_entry PARAMS ((const PTR, const PTR));
@@ -588,7 +587,7 @@
 /* Convert a string to a format type, or exit if it can't be done.  */
 static enum res_format
-format_from_name (name)
+format_from_name (name, int exit_on_error)
      const char *name;
   const struct format_map *m;
@@ -597,7 +596,7 @@
     if (strcasecmp (m->name, name) == 0)
-  if (m->name == NULL)
+  if (m->name == NULL && exit_on_error)
       non_fatal (_("unknown format type `%s'"), name);
       fprintf (stderr, _("%s: supported formats:"), program_name);
@@ -779,6 +778,7 @@
   char *input_filename;
   char *output_filename;
   enum res_format input_format;
+  enum res_format input_format_tmp;
   enum res_format output_format;
   char *target;
   char *preprocessor;
@@ -828,12 +828,12 @@
 	  output_filename = optarg;
-	case 'I':
-	  input_format = format_from_name (optarg);
+	case 'J':
+	  input_format = format_from_name (optarg, 1);
 	case 'O':
-	  output_format = format_from_name (optarg);
+	  output_format = format_from_name (optarg, 1);
 	case 'F':
@@ -868,7 +868,16 @@
 	  verbose ++;
+	case 'I':
+	  /* for backward compatibility, should be removed in the future */
+	  input_format_tmp = format_from_name (optarg, 0);
+	  if (input_format_tmp != RES_FORMAT_UNKNOWN)
+	    {
+	      fprintf (stderr, _("Option -I is deprecated for setting the input format, please use -J instead.\n"));
+	      input_format = input_format_tmp;
+	      break;
+	    }
 	  if (preprocargs == NULL)
 	      quotedarg = quot (optarg);
Index: binutils/doc/binutils.texi
RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
retrieving revision 1.30
diff -u -r1.30 binutils.texi
--- binutils/doc/binutils.texi	24 Feb 2003 16:20:28 -0000	1.30
+++ binutils/doc/binutils.texi	17 Mar 2003 07:14:22 -0000
@@ -2569,7 +2569,7 @@
 non-option argument, then @command{windres} will write to standard output.
 @command{windres} can not write a COFF file to standard output.
- at item -I @var{format}
+ at item -J @var{format}
 @itemx --input-format @var{format}
 The input format to read.  @var{format} may be @samp{res}, @samp{rc}, or
 @samp{coff}.  If no input format is specified, @command{windres} will
@@ -2597,6 +2597,7 @@
 to use, including any leading arguments.  The default preprocessor
 argument is @code{gcc -E -xc-header -DRC_INVOKED}.
+ at item -I @var{directory}
 @item --include-dir @var{directory}
 Specify an include directory to use when reading an @code{rc} file.
 @command{windres} will pass this to the preprocessor as an @option{-I}


----- End forwarded message -----

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]