wrc -hHrs

Dimitrie O. Paun dpaun at rogers.com
Thu Dec 19 17:20:09 CST 2002


Now that we have the windres compatible -O option, we can use
it to cleanup a bit some of wrc's options. In particular,
use it to control the output format, and get rid of the
other ones which were (1) polluting the namespace, and
(2) were confusing anyway because they were not orthogonal.

NOTE: the -r option is ignored for now, to kept the patch at a 
      minimum. When it goes it, I'll remove it and update all 
      the Makefiles that make use of it.

ChangeLog
  Collapse the -hHrs options into the -O option.
  Generate .res files by default.

Index: tools/wrc/wrc.c
===================================================================
RCS file: /var/cvs/wine/tools/wrc/wrc.c,v
retrieving revision 1.22
diff -u -r1.22 wrc.c
--- tools/wrc/wrc.c	19 Dec 2002 04:14:38 -0000	1.22
+++ tools/wrc/wrc.c	19 Dec 2002 23:02:45 -0000
@@ -98,19 +98,15 @@
 	"   -E          Preprocess only\n"
 	"   -F target	Ignored for compatibility with windres\n"
 	"   -g          Add symbols to the global c namespace\n"
-	"   -h          Also generate a .h file\n"
-	"   -H file     Same as -h but written to file\n"
 	"   -i file	The name of the input file.\n"
 	"   -I path     Set include search dir to path (multiple -I allowed)\n"
 	"   -J		Do not search the standard include path\n"
 	"   -l lan      Set default language to lan (default is neutral {0, 0})\n"
 	"   -m          Do not remap numerical resource IDs\n"
-	"   -n          Do not generate .s file\n"
 	"   -N          Do not preprocess input\n"
 	"   -o file     Output to file (default is infile.[res|s|h]\n"
-	"   -O format	The output format to generate. format may be `res' only.\n"
+	"   -O format	The output format: one of `res', 'asm', 'hdr'.\n"
 	"   -p prefix   Give a prefix for the generated names\n"
-	"   -r          Create binary .res file (compile only)\n"
 	"   -s          Add structure with win32/16 (PE/NE) resource directory\n"
 	"   -t          Generate indirect loadable resource tables\n"
 	"   -T          Generate only indirect loadable resources tables\n"
@@ -167,9 +163,9 @@
 int constant = 0;
 
 /*
- * Create a .res file from the source and exit (-r option).
+ * Output type (default res)
  */
-int create_res = 0;
+enum output_t { output_def, output_res, output_asm, output_hdr } output_type = output_def;
 
 /*
  * debuglevel == DEBUGLEVEL_NONE	Don't bother
@@ -194,11 +190,6 @@
 int binary = 0;
 
 /*
- * Set when an additional C-header is to be created in compile (-h option).
- */
-int create_header = 0;
-
-/*
  * Set when the NE/PE resource directory should be dumped into
  * the output file.
  */
@@ -226,11 +217,6 @@
 int alignment_pwr;
 
 /*
- * Cleared when the assembly file must be suppressed (-n option)
- */
-int create_s = 1;
-
-/*
  * Language setting for resources (-l option)
  */
 language_t *currentlanguage = NULL;
@@ -272,7 +258,6 @@
 
 char *output_name;		/* The name given by the -o option */
 char *input_name;		/* The name given on the command-line */
-char *header_name;		/* The name given by the -H option */
 char *temp_name;		/* Temporary file for preprocess pipe */
 
 int line_number = 1;		/* The current line */
@@ -402,12 +387,6 @@
 		case 'g':
 			global = 1;
 			break;
-		case 'H':
-			header_name = strdup(optarg);
-			/* Fall through */
-		case 'h':
-			create_header = 1;
-			break;
 		case 'i':
 			if (!input_name) input_name = strdup(optarg);
 			else error("Too many input files.\n");
@@ -430,9 +409,6 @@
 		case 'm':
 			remap = 0;
 			break;
-		case 'n':
-			create_s = 0;
-			break;
 		case 'N':
 			no_preprocess = 1;
 			break;
@@ -441,14 +417,16 @@
 			else error("Too many output files.\n");
 			break;
 		case 'O':
-			if (strcmp(optarg, "res"))
-				error("Output format %s not supported.", optarg);
+			if (strcmp(optarg, "res") == 0) output_type = output_res;
+			else if (strcmp(optarg, "asm") == 0) output_type = output_asm;
+			else if (strcmp(optarg, "hdr") == 0) output_type = output_hdr;
+			else error("Output format %s not supported.", optarg);
 			break;
 		case 'p':
 			prefix = xstrdup(optarg);
 			break;
 		case 'r':
-			create_res = 1;
+			/* ignored for backward compatibility */
 			break;
 		case 's':
 			create_dir = 1;
@@ -509,12 +487,16 @@
 	}
 
 	/* Try to guess the output format based on output name */
-	if (output_name)
+	if (output_type == output_def)
 	{
-		char *dotstr = strrchr(output_name, '.');
-		if (dotstr && (strcmp(dotstr+1, "res") == 0 ||
-			       strcmp(dotstr+1, "o") == 0))
-			create_res = 1;
+		char *dotstr = output_name ? strrchr(output_name, '.') : 0;
+		
+		output_type = output_res; /* by default generate .res files */
+		if (dotstr)
+		{
+			if (strcmp(dotstr+1, "s") == 0) output_type = output_asm;
+			else if(strcmp(dotstr+1, "h") == 0) output_type = output_hdr;
+		}
 	}
 
 
@@ -528,7 +510,7 @@
 		}
 	}
 
-	if(create_res)
+	if(output_type == output_res)
 	{
 		if(constant)
 		{
@@ -536,12 +518,6 @@
 			constant = 0;
 		}
 
-		if(create_header)
-		{
-			warning("Option -[h|H] ignored with compile to .res\n");
-			create_header = 0;
-		}
-
 		if(indirect)
 		{
 			warning("Option -t ignored with compile to .res\n");
@@ -585,12 +561,6 @@
 			constant = 0;
 		}
 
-		if(create_header)
-		{
-			warning("Option -[h|H] ignored with preprocess only\n");
-			create_header = 0;
-		}
-
 		if(indirect)
 		{
 			warning("Option -t ignored with preprocess only\n");
@@ -689,13 +659,9 @@
 	if(!output_name && !preprocess_only)
 	{
 		output_name = dup_basename(input_name, binary ? ".res" : ".rc");
-		strcat(output_name, create_res ? ".res" : ".s");
-	}
-
-	if(!header_name && !create_res)
-	{
-		header_name = dup_basename(input_name, binary ? ".res" : ".rc");
-		strcat(header_name, ".h");
+		if (output_type == output_res) strcat(output_name, ".res");
+		else if (output_type == output_asm) strcat(output_name, ".s");
+		else if (output_type == output_hdr) strcat(output_name, ".h");
 	}
 
 	/* Run the preprocessor on the input */
@@ -761,23 +727,20 @@
 		/* Convert the internal lists to binary data */
 		resources2res(resource_top);
 
-		if(create_res)
+		if(output_type == output_res)
 		{
 			chat("Writing .res-file");
 			write_resfile(output_name, resource_top);
 		}
-		else
+		else if(output_type == output_asm)
 		{
-			if(create_s)
-			{
-				chat("Writing .s-file");
-				write_s_file(output_name, resource_top);
-			}
-			if(create_header)
-			{
-				chat("Writing .h-file");
-				write_h_file(header_name, resource_top);
-			}
+			chat("Writing .s-file");
+			write_s_file(output_name, resource_top);
+		}
+		else if(output_type == output_hdr)
+		{
+			chat("Writing .h-file");
+			write_h_file(output_name, resource_top);
 		}
 
 	}
@@ -786,15 +749,15 @@
 		/* Go from .res to .s */
 		chat("Reading .res-file");
 		resource_top = read_resfile(input_name);
-		if(create_s)
+		if(output_type == output_asm)
 		{
 			chat("Writing .s-file");
 			write_s_file(output_name, resource_top);
 		}
-		if(create_header)
+		else if(output_type == output_hdr)
 		{
 			chat("Writing .h-file");
-			write_h_file(header_name, resource_top);
+			write_h_file(output_name, resource_top);
 		}
 	}
 


-- 
Dimi.




More information about the wine-patches mailing list