Commit deaf02a5 authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Remove assembly generation from wrc.

parent f498d4b8
......@@ -65,7 +65,6 @@
#include "wrc.h"
#include "utils.h"
#include "writeres.h"
#include "readres.h"
#include "dumpres.h"
#include "genres.h"
......@@ -86,7 +85,6 @@
static char usage[] =
"Usage: wrc [options...] [infile[.rc|.res]] [outfile]\n"
" -a n Alignment of resource (win16 only, default is 4)\n"
" -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 cp Set the resource's codepage to cp (default is 0)\n"
......@@ -95,18 +93,15 @@ static char usage[] =
" -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"
" -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"
" -o file Output to file (default is infile.[res|s]\n"
" -O format The output format: one of `res', 'asm'.\n"
" -p prefix Give a prefix for the generated names\n"
" -o file Output to file (default is infile.res)\n"
" -O format The output format (must be `res').\n"
" -P program Specifies the preprocessor to use, including arguments.\n"
" -s Add structure with win32/16 (PE/NE) resource directory\n"
" -v Enable verbose mode.\n"
" -V Print version and exit\n"
" -w 16|32 Select win16 or win32 output (default is win32)\n"
......@@ -136,7 +131,7 @@ static char usage[] =
" * 0x10 Preprocessor lex messages\n"
" * 0x20 Preprocessor yacc trace\n"
"If no input filename is given and the output name is not overridden\n"
"with -o, then the output is written to \"wrc.tab.{s,res}\"\n"
"with -o, then the output is written to \"wrc.tab.res\"\n"
;
char version_string[] = "Wine Resource Compiler Version " WRC_FULLVERSION "\n"
......@@ -144,10 +139,9 @@ char version_string[] = "Wine Resource Compiler Version " WRC_FULLVERSION "\n"
" 1994 Martin von Loewis\n";
/*
* Default prefix for resource names used in the C array.
* Option '-p name' sets it to 'name'
* External functions
*/
char *prefix = __ASM_NAME("_Resource");
void write_resfile(char *outname, resource_t *top);
/*
* Set if compiling in 32bit mode (default).
......@@ -155,11 +149,6 @@ char *prefix = __ASM_NAME("_Resource");
int win32 = 1;
/*
* Output type (default res)
*/
enum output_t { output_def, output_res, output_asm } output_type = output_def;
/*
* debuglevel == DEBUGLEVEL_NONE Don't bother
* debuglevel & DEBUGLEVEL_CHAT Say whats done
* debuglevel & DEBUGLEVEL_DUMP Dump internal structures
......@@ -177,22 +166,6 @@ int debuglevel = DEBUGLEVEL_NONE;
int extensions = 1;
/*
* Set when creating C array from .res file (-b option).
*/
int binary = 0;
/*
* Set when the NE/PE resource directory should be dumped into
* the output file.
*/
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;
......@@ -250,7 +223,7 @@ static void rm_tempfile(void);
static void segvhandler(int sig);
static const char* short_options =
"a:AbB:cC:d:D:eEF:ghH:i:I:Jl:LmnNo:O:p:P:rstTvVw:W";
"a:AB:cC:d:D:eEF:hH:i:I:Jl:LmnNo:O:P:rtTvVw:W";
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] = {
{ "input", 1, 0, 'i' },
......@@ -320,9 +293,6 @@ int main(int argc,char *argv[])
case 'a':
alignment = atoi(optarg);
break;
case 'b':
binary = 1;
break;
case 'B':
switch(optarg[0])
{
......@@ -361,9 +331,6 @@ int main(int argc,char *argv[])
case 'F':
/* ignored for compatibility with windres */
break;
case 'g':
global = 1;
break;
case 'h':
printf(usage);
exit(0);
......@@ -394,20 +361,13 @@ int main(int argc,char *argv[])
else error("Too many output files.\n");
break;
case 'O':
if (strcmp(optarg, "res") == 0) output_type = output_res;
else if (strcmp(optarg, "asm") == 0) output_type = output_asm;
else error("Output format %s not supported.", optarg);
break;
case 'p':
prefix = xstrdup(optarg);
if (strcmp(optarg, "res"))
error("Output format %s not supported.", optarg);
break;
case 'P':
if (strcmp(optarg, "cat") == 0) no_preprocess = 1;
else fprintf(stderr, "-P option not yet supported, ignored.\n");
break;
case 's':
create_dir = 1;
break;
case 'v':
debuglevel = DEBUGLEVEL_CHAT;
break;
......@@ -460,19 +420,6 @@ int main(int argc,char *argv[])
else error("Too many output files.\n");
}
/* Try to guess the output format based on output name */
if (output_type == output_def)
{
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;
}
}
/* Check the command line options for invalid combinations */
if(win32)
{
......@@ -483,51 +430,6 @@ int main(int argc,char *argv[])
}
}
if(output_type == output_res)
{
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");
}
if(binary)
{
error("Option -r and -b cannot be used together\n");
}
}
if(byteorder != WRC_BO_NATIVE)
{
if(binary)
error("Forced byteordering not supported for binary resources\n");
}
if(preprocess_only)
{
if(global)
{
warning("Option -g ignored with preprocess only\n");
global = 0;
}
if(create_dir)
{
warning("Option -s ignored with preprocess only\n");
create_dir = 0;
}
if(binary)
{
error("Option -E and -b cannot be used together\n");
}
}
/* Set alignment power */
a = alignment;
for(alignment_pwr = 0; alignment_pwr < 10 && a > 1; alignment_pwr++)
......@@ -575,21 +477,15 @@ int main(int argc,char *argv[])
if(!currentlanguage)
currentlanguage = new_language(0, 0);
if(binary && !input_name)
{
error("Binary mode requires .res file as input\n");
}
/* Generate appropriate outfile names */
if(!output_name && !preprocess_only)
{
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");
output_name = dup_basename(input_name, ".rc");
strcat(output_name, ".res");
}
/* Run the preprocessor on the input */
if(!no_preprocess && !binary)
if(!no_preprocess)
{
/*
* Preprocess the input to a temp-file, or stdout if
......@@ -626,54 +522,26 @@ int main(int argc,char *argv[])
input_name = temp_name;
}
if(!binary)
{
/* Go from .rc to .res or .s */
chat("Starting parse");
if(!(yyin = fopen(input_name, "rb")))
error("Could not open %s for input\n", input_name);
/* Go from .rc to .res */
chat("Starting parse");
ret = yyparse();
if(!(yyin = fopen(input_name, "rb")))
error("Could not open %s for input\n", input_name);
if(input_name)
fclose(yyin);
ret = yyparse();
if(ret)
{
/* Error during parse */
exit(1);
}
if(input_name) fclose(yyin);
if(debuglevel & DEBUGLEVEL_DUMP)
dump_resources(resource_top);
if(ret) exit(1); /* Error during parse */
/* Convert the internal lists to binary data */
resources2res(resource_top);
if(debuglevel & DEBUGLEVEL_DUMP)
dump_resources(resource_top);
if(output_type == output_res)
{
chat("Writing .res-file");
write_resfile(output_name, resource_top);
}
else if(output_type == output_asm)
{
chat("Writing .s-file");
write_s_file(output_name, resource_top);
}
/* Convert the internal lists to binary data */
resources2res(resource_top);
}
else
{
/* Go from .res to .s */
chat("Reading .res-file");
resource_top = read_resfile(input_name);
if(output_type == output_asm)
{
chat("Writing .s-file");
write_s_file(output_name, resource_top);
}
}
chat("Writing .res-file");
write_resfile(output_name, resource_top);
return 0;
}
......
......@@ -51,9 +51,6 @@ extern int debuglevel;
extern int win32;
extern int create_res;
extern int extensions;
extern int binary;
extern int create_dir;
extern int global;
extern int alignment;
extern int alignment_pwr;
extern int create_s;
......@@ -64,7 +61,6 @@ extern int preprocess_only;
extern int no_preprocess;
extern int remap;
extern char *prefix;
extern char *output_name;
extern char *input_name;
extern char *cmdline;
......
......@@ -5,39 +5,25 @@ wrc \- Wine Resource Compiler
.BI "wrc " "[options] " "[inputfile]"
.SH DESCRIPTION
.B wrc
compiles resources from
.I inputfile
into win16 and win32 compatible
binary format.
.B wrc
outputs the binary data either in a standard \fB.res\fR formatted binary
file, or an assembly file.
.B wrc
is also capable of reading \fB.res\fR formatted files and convert them
into an assembly file.
compiles resources from \fBinputfile\fR
into win16 and win32 compatible binary format.
.PP
The source\-file is preprocessed with a builtin ANSI\-C compatible
preprocessor before the resources are compiled. See \fBPREPROCESSOR\fR
below.
.PP
.B wrc
takes only one \fBinputfile\fR as argument. The \fBinputfile\fR has
extension \fB.rc\fR for resources in source form and \fB.res\fR for
binary resources. The resources are read from standard input if no
inputfile is given. If the outputfile is not specified with \fI-o\fR,
then \fBwrc\fR will write the output to \fBinputfile.{s,res}\fR
with \fB.rc\fR stripped, depending on the mode of compilation.
The outputfile is named \fBwrc.tab.{s,res}\fR if no inputfile was
given.
takes only one \fBinputfile\fR as argument. The resources are read from
standard input if no inputfile is given. If the output file is not
specified with \fI-o\fR, then \fBwrc\fR will write the output to
\fBinputfile.res\fR with \fB.rc\fR stripped, or to \fBwrc.tab.res\fR if
no inputfile was given.
.SH OPTIONS
.TP
.I \-a n
Win16 only; set the alignment between resources n. The alignment must
be a power of 2. The default is 4.
.TP
.I \-b
Create an assembly file from a binary \fB.res\fR file.
.TP
.I \-B x
Win32 only; set output byte\-ordering, where \fIx\fR is one of n[ative],
l[ittle] or b[ig]. Only resources in source-form can be reorderd. Native
......@@ -68,10 +54,6 @@ Preprocess only. The output is written to standard output if no
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
......@@ -106,29 +88,20 @@ source\-files that contain overlapping type\-IDs, or when the format of the
resource is not 100% compliant.
.TP
.I \-o file
Write output to \fIfile\fR. Default is \fBinputfile.{res,s,h}\fR
with \fB.rc\fR stripped or \fBwrc.tab.{s,h,res}\fR, depending on the
compilation mode.
Write output to \fIfile\fR. Default is \fBinputfile.res\fR
with \fB.rc\fR stripped or \fBwrc.tab.res\fR if input is read
from standard input.
.TP
.I \-O format
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
Prefix all generated names with \fIprefix\fR. This is only relevant for
names in the assembly code and header file. Resource names are not
affected.
Sets the output format. The only supported \fformat\fR is 'res', which
is also the default format if this option is not specified. The option
exists mainly for compatibility with \fBwindres\fR.
.TP
.I \-P program
This option may be used to specify the preprocessor to use, including any
leading arguments. If not specified, \fBwrc\fR uses its builtin processor.
To disable preprocessing, use \fB-P cat\fR.
.TP
.I \-s
Add structure with win32/16 (PE/NE) resource directory to outputfile.
This directory is always in native byteorder.
.TP
.I \-v
Turns on verbose mode (equivalent to -d 1).
.TP
......
/*
* Write resource prototypes
*
* Copyright 1998 Bertho A. Stultiens (BS)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WRC_WRITERES_H
#define __WRC_WRITERES_H
#ifndef __WRC_WRCTYPES_H
#include "wrctypes.h"
#endif
void write_resfile(char *outname, resource_t *top);
void write_s_file(char *outname, resource_t *top);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment