wrc: drop header file generation

Dimitrie O. Paun dpaun at rogers.com
Tue Jan 28 04:58:38 CST 2003


Since I haven't sent a patch in a while now...

I've never really looked into what wrc was doing when
generating a header file -- I always asummed it was creating
the defines needed by the .c code to reference the resources.

Not so. Looking at the header file generated by wrc, 
it occured to me that it is exporting symbols that it
shouldn't be exporting in the first place. I think the
options where added long ago for compatibility with the
old resource compiler.

Anyway, there seems to be no reason to keep this around.
It's an unwaranted extension that exports stuff it shouldn't,
and that opens a big and ugly can of worms. We're better
off without it.

ChangeLog
  Remove header file generation, and related options.


Index: tools/wrc/wrc.c
===================================================================
RCS file: /var/cvs/wine/tools/wrc/wrc.c,v
retrieving revision 1.26
diff -u -r1.26 wrc.c
--- tools/wrc/wrc.c	23 Jan 2003 21:21:50 -0000	1.26
+++ tools/wrc/wrc.c	27 Jan 2003 20:38:00 -0000
@@ -89,14 +89,12 @@
 	"   -b          Create an assembly array from a binary .res file\n"
 	"   -B x        Set output byte-order x={n[ative], l[ittle], b[ig]}\n"
 	"               (win32 only; default is " ENDIAN "-endian)\n"
-	"   -c          Add 'const' prefix to C constants\n"
 	"   -C cp       Set the resource's codepage to cp (default is 0)\n"
 	"   -d n        Set debug level to 'n'\n"
 	"   -D id[=val] Define preprocessor identifier id=val\n"
 	"   -e          Disable recognition of win32 keywords in 16bit compile\n"
 	"   -E          Preprocess only\n"
 	"   -F target	Ignored for compatibility with windres\n"
-	"   -g          Add symbols to the global c namespace\n"
 	"   -h		Prints this summary.\n"
 	"   -i file	The name of the input file.\n"
 	"   -I path     Set include search dir to path (multiple -I allowed)\n"
@@ -105,7 +103,7 @@
 	"   -m          Do not remap numerical resource IDs\n"
 	"   -N          Do not preprocess input\n"
 	"   -o file     Output to file (default is infile.[res|s|h]\n"
-	"   -O format	The output format: one of `res', 'asm', 'hdr'.\n"
+	"   -O format	The output format: one of `res', 'asm'.\n"
 	"   -p prefix   Give a prefix for the generated names\n"
 	"   -s          Add structure with win32/16 (PE/NE) resource directory\n"
 	"   -v          Enable verbose mode.\n"
@@ -156,14 +154,9 @@
 int win32 = 1;
 
 /*
- * Set when generated C variables should be prefixed with 'const'
- */
-int constant = 0;
-
-/*
  * Output type (default res)
  */
-enum output_t { output_def, output_res, output_asm, output_hdr } output_type = output_def;
+enum output_t { output_def, output_res, output_asm } output_type = output_def;
 
 /*
  * debuglevel == DEBUGLEVEL_NONE	Don't bother
@@ -194,11 +187,6 @@
 int create_dir = 0;
 
 /*
- * Set when all symbols should be added to the global namespace (-g option)
- */
-int global = 0;
-
-/*
  * NE segment resource aligment (-a option)
  */
 int alignment = 4;
@@ -352,9 +340,6 @@
 				lose++;
 			}
 			break;
-		case 'c':
-			constant = 1;
-			break;
 		case 'C':
 			codepage = strtol(optarg, NULL, 0);
 			break;
@@ -373,9 +358,6 @@
 		case 'F':
 			/* ignored for compatibility with windres */
 			break;
-		case 'g':
-			global = 1;
-			break;
 		case 'h':
 			printf(usage);
 			exit(0);
@@ -411,7 +393,6 @@
 		case 'O':
 			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':
@@ -481,7 +462,6 @@
 		if (dotstr)
 		{
 			if (strcmp(dotstr+1, "s") == 0) output_type = output_asm;
-			else if(strcmp(dotstr+1, "h") == 0) output_type = output_hdr;
 		}
 	}
 
@@ -498,18 +478,6 @@
 
 	if(output_type == output_res)
 	{
-		if(constant)
-		{
-			warning("Option -c ignored with compile to .res\n");
-			constant = 0;
-		}
-
-		if(global)
-		{
-			warning("Option -g ignored with compile to .res\n");
-			global = 0;
-		}
-
 		if(create_dir)
 		{
 			error("Option -r and -s cannot be used together\n");
@@ -529,18 +497,6 @@
 
 	if(preprocess_only)
 	{
-		if(constant)
-		{
-			warning("Option -c ignored with preprocess only\n");
-			constant = 0;
-		}
-
-		if(global)
-		{
-			warning("Option -g ignored with preprocess only\n");access 
-			global = 0;
-		}
-
 		if(create_dir)
 		{
 			warning("Option -s ignored with preprocess only\n");
@@ -616,7 +572,6 @@
 		output_name = dup_basename(input_name, binary ? ".res" : ".rc");
 		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 */
@@ -692,11 +647,6 @@
 			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);
-		}
 
 	}
 	else
@@ -708,11 +658,6 @@
 		{
 			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);
 		}
 	}
 
Index: tools/wrc/wrc.h
===================================================================
RCS file: /var/cvs/wine/tools/wrc/wrc.h,v
retrieving revision 1.26
diff -u -r1.26 wrc.h
--- tools/wrc/wrc.h	20 Jan 2003 23:29:27 -0000	1.26
+++ tools/wrc/wrc.h	27 Jan 2003 20:34:54 -0000
@@ -49,13 +49,10 @@
 #define DEBUGLEVEL_PPTRACE	0x0020
 
 extern int win32;
-extern int constant;
 extern int create_res;
 extern int extensions;
 extern int binary;
-extern int create_header;
 extern int create_dir;
-extern int global;
 extern int alignment;
 extern int alignment_pwr;
 extern int create_s;
@@ -69,7 +66,6 @@
 extern char *prefix;
 extern char *output_name;
 extern char *input_name;
-extern char *header_name;
 extern char *cmdline;
 extern time_t now;
 
Index: tools/wrc/wrc.man
===================================================================
RCS file: /var/cvs/wine/tools/wrc/wrc.man,v
retrieving revision 1.11
diff -u -r1.11 wrc.man
--- tools/wrc/wrc.man	20 Jan 2003 23:29:27 -0000	1.11
+++ tools/wrc/wrc.man	27 Jan 2003 20:41:58 -0000
@@ -44,9 +44,6 @@
 ordering depends on the system on which \fBwrc\fR was built. You can see
 the native ordering by typing \fIwrc \-?\fR.
 .TP
-.I \-c
-Add 'const' prefix to C constants when writing header files.
-.TP
 .I \-C cp
 Set the resource's codepage to \fIcp\fR. Default codepage is 0.
 .TP
@@ -71,10 +68,6 @@
 outputfile was selected. The output is compatible with what gcc would
 generate.
 .TP
-.I \-g
-Add symbols to the global C namespace. This makes all symbols available
-for linking by other modules.
-.TP
 .I \-h
 Prints a summary message and exits.
 .TP
@@ -119,8 +112,8 @@
 compilation mode.
 .TP
 .I \-O format
-Sets the output format. \fformat\fR can one of 'res', 'asm', and 'hdr'
-to generate a \fB.res\fR, \fB.s\fR, or \fB.h\fR file respectively.
+Sets the output format. \fformat\fR can one either 'res' or 'asm'
+to generate a \fB.res\fR or \fB.s\fR file respectively.
 If not specified, \fBwrc\fR assumes 'res'.
 .TP
 .I \-p prefix
@@ -213,6 +206,6 @@
 WineHQ, the
 .B wine
 development headquarters, at
-.I http://www.winehq.com/.
+.I http://www.winehq.org/.
 .SH "SEE ALSO"
 .BR wine (1),
Index: tools/wrc/writeres.c
===================================================================
RCS file: /var/cvs/wine/tools/wrc/writeres.c,v
retrieving revision 1.25
diff -u -r1.25 writeres.c
--- tools/wrc/writeres.c	20 Jan 2003 23:29:27 -0000	1.25
+++ tools/wrc/writeres.c	27 Jan 2003 20:33:46 -0000
@@ -48,26 +48,6 @@
         "\n"
 	;
 
-static char h_file_head_str[] =
-	"/*\n"
-	" * This file is generated with wrc version " WRC_FULLVERSION ". Do not edit!\n"
-	" * Source : %s\n"
-	" * Cmdline: %s\n"
-	" * Date   : %s"
-	" */\n"
-        "\n"
-	"#ifndef __%08lx_H\n"	/* This becomes the date of compile */
-	"#define __%08lx_H\n"
-	"\n"
-	"#include <wrc_rsc.h>\n"
-	"\n"
-	;
-
-static char h_file_tail_str[] =
-	"#endif\n"
-	"/* <eof> */\n\n"
-	;
-
 char _NEResTab[] = "_NEResTab";
 char _PEResTab[] = "_PEResTab";
 char _ResTable[] = "_ResTable";
@@ -914,8 +894,6 @@
 
 		fprintf(fo, "\t.align\t%d\n", win32 ? 4 : alignment);
 		fprintf(fo, __ASM_NAME("%s%s_data") ":\n", prefix, rsc->c_name);
-		if(global)
-			fprintf(fo, "\t.globl\t" __ASM_NAME("%s%s_data") "\n", prefix, rsc->c_name);
 
 		write_s_res(fo, rsc->binres);
 
@@ -929,77 +907,18 @@
 		fprintf(fo, __ASM_NAME("%s_ResourceDescriptor") ":\n", prefix);
 		fprintf(fo, "\t.globl\t" __ASM_NAME("%s_ResourceDescriptor") "\n", prefix);
 		fprintf(fo, __ASM_NAME("%s_ResourceTable") ":\n", prefix);
-		if(global)
-			fprintf(fo, "\t.globl\t" __ASM_NAME("%s_ResourceTable") "\n", prefix);
 		fprintf(fo, "\t.long\t" __ASM_NAME("%s%s") "\n", prefix, win32 ? _PEResTab : _NEResTab);
 		fprintf(fo, __ASM_NAME("%s_NumberOfResources") ":\n", prefix);
-		if(global)
-			fprintf(fo, "\t.globl\t" __ASM_NAME("%s_NumberOfResources") "\n", prefix);
 		fprintf(fo, "\t.long\t%d\n", direntries);
 		fprintf(fo, __ASM_NAME("%s_ResourceSectionSize") ":\n", prefix);
-		if(global)
-			fprintf(fo, "\t.globl\t" __ASM_NAME("%s_ResourceSectionSize") "\n", prefix);
 		fprintf(fo, "\t.long\t.LResTabEnd - " __ASM_NAME("%s%s") "\n", prefix, win32 ? _PEResTab : _NEResTab);
 		if(win32)
 		{
 			fprintf(fo, __ASM_NAME("%s_ResourcesEntries") ":\n", prefix);
-			if(global)
-				fprintf(fo, "\t.globl\t" __ASM_NAME("%s_ResourcesEntries") "\n", prefix);
 			fprintf(fo, "\t.long\t" __ASM_NAME("%s_ResourceDirectory") "\n", prefix);
 		}
 	}
 
 	fprintf(fo, s_file_tail_str);
-	fclose(fo);
-}
-
-/*
- *****************************************************************************
- * Function	: write_h_file
- * Syntax	: void write_h_file(char *outname, resource_t *top)
- * Input	:
- *	outname	- Filename to write to
- *	top	- The resource-tree to convert
- * Output	:
- * Description	:
- * Remarks	:
- *****************************************************************************
-*/
-void write_h_file(char *outname, resource_t *top)
-{
-	FILE *fo;
-	resource_t *rsc;
-
-	fo = fopen(outname, "wt");
-	if(!fo)
-	{
-		error("Could not open %s\n", outname);
-	}
-
-	fprintf(fo, h_file_head_str, input_name ? input_name : "stdin",
-                cmdline, ctime(&now), (long)now, (long)now);
-
-	/* First write the segment tables reference */
-	if(create_dir)
-	{
-		fprintf(fo, "extern %schar %s%s[];\n\n",
-			constant ? "const " : "",
-			prefix,
-			win32 ? _PEResTab : _NEResTab);
-	}
-
-	/* Write the resource data */
-	for(rsc = top; global && rsc; rsc = rsc->next)
-	{
-		if(!rsc->binres)
-			continue;
-
-		fprintf(fo, "extern %schar %s%s_data[];\n",
-			constant ? "const " : "",
-			prefix,
-			rsc->c_name);
-	}
-
-	fprintf(fo, h_file_tail_str);
 	fclose(fo);
 }
Index: tools/wrc/writeres.h
===================================================================
RCS file: /var/cvs/wine/tools/wrc/writeres.h,v
retrieving revision 1.2
diff -u -r1.2 writeres.h
--- tools/wrc/writeres.h	10 Mar 2002 00:24:24 -0000	1.2
+++ tools/wrc/writeres.h	27 Jan 2003 20:34:11 -0000
@@ -27,6 +27,5 @@
 
 void write_resfile(char *outname, resource_t *top);
 void write_s_file(char *outname, resource_t *top);
-void write_h_file(char *outname, resource_t *top);
 
 #endif


-- 
Dimi.




More information about the wine-patches mailing list