wrc: Add support for target options, and define _WIN64 for 64-bit builds.
This commit is contained in:
parent
c6e1a0c81e
commit
e6340f1652
102
tools/wrc/wrc.c
102
tools/wrc/wrc.c
|
@ -52,41 +52,32 @@
|
||||||
|
|
||||||
static const char usage[] =
|
static const char usage[] =
|
||||||
"Usage: wrc [options...] [infile[.rc|.res]]\n"
|
"Usage: wrc [options...] [infile[.rc|.res]]\n"
|
||||||
" -D id[=val] Define preprocessor identifier id=val\n"
|
" -b, --target=TARGET Specify target CPU and platform when cross-compiling\n"
|
||||||
" -E Preprocess only\n"
|
" -D, --define id[=val] Define preprocessor identifier id=val\n"
|
||||||
" -F target Ignored for compatibility with windres\n"
|
" --debug=nn Set debug level to 'nn'\n"
|
||||||
" -h Prints this summary\n"
|
" -E Preprocess only\n"
|
||||||
" -i file The name of the input file\n"
|
" --endianess=e Set output byte-order e={n[ative], l[ittle], b[ig]}\n"
|
||||||
" -I path Set include search dir to path (multiple -I allowed)\n"
|
" (win32 only; default is " ENDIAN "-endian)\n"
|
||||||
" -J format The input format (either `rc' or `rc16')\n"
|
" -F TARGET Synonym for -b for compatibility with windres\n"
|
||||||
" -l lan Set default language to lan (default is neutral {0, 0})\n"
|
" -fo FILE Synonym for -o for compatibility with windres\n"
|
||||||
" -o file Output to file (default is infile.res)\n"
|
" -h, --help Prints this summary\n"
|
||||||
" -O format The output format (either `res' or `res16`)\n"
|
" -i, --input=FILE The name of the input file\n"
|
||||||
" -r Ignored for compatibility with rc\n"
|
" -I, --include-dir=PATH Set include search dir to path (multiple -I allowed)\n"
|
||||||
" -U id Undefine preprocessor identifier id\n"
|
" -J, --input-format=FORMAT The input format (either `rc' or `rc16')\n"
|
||||||
" -v Enable verbose mode\n"
|
" -l, --language=LANG Set default language to LANG (default is neutral {0, 0})\n"
|
||||||
"The following long options are supported:\n"
|
" -m16, -m32, -m64 Build for 16-bit, 32-bit resp. 64-bit platforms\n"
|
||||||
" --debug=nn Set debug level to 'nn'\n"
|
" --no-use-temp-file Ignored for compatibility with windres\n"
|
||||||
" --define Synonym for -D\n"
|
" --nostdinc Disables searching the standard include path\n"
|
||||||
" --endianess=e Set output byte-order e={n[ative], l[ittle], b[ig]}\n"
|
" -o, --output=FILE Output to file (default is infile.res)\n"
|
||||||
" (win32 only; default is " ENDIAN "-endian)\n"
|
" -O, --output-format=FORMAT The output format (either `res' or `res16`)\n"
|
||||||
" --help Synonym for -h\n"
|
" --pedantic Enable pedantic warnings\n"
|
||||||
" --include-dir Synonym for -I\n"
|
" --preprocessor Specifies the preprocessor to use, including arguments\n"
|
||||||
" --input Synonym for -i\n"
|
" -r Ignored for compatibility with rc\n"
|
||||||
" --input-format Synonym for -J\n"
|
" -U, --undefine id Undefine preprocessor identifier id\n"
|
||||||
" --language Synonym for -l\n"
|
" --use-temp-file Ignored for compatibility with windres\n"
|
||||||
" --no-use-temp-file Ignored for compatibility with windres\n"
|
" -v, --verbose Enable verbose mode\n"
|
||||||
" --nostdinc Disables searching the standard include path\n"
|
" --verify-translations Check the status of the various translations\n"
|
||||||
" --output -fo Synonym for -o\n"
|
" --version Print version and exit\n"
|
||||||
" --output-format Synonym for -O\n"
|
|
||||||
" --pedantic Enable pedantic warnings\n"
|
|
||||||
" --preprocessor Specifies the preprocessor to use, including arguments\n"
|
|
||||||
" --target Synonym for -F\n"
|
|
||||||
" --undefine Synonym for -U\n"
|
|
||||||
" --use-temp-file Ignored for compatibility with windres\n"
|
|
||||||
" --verbose Synonym for -v\n"
|
|
||||||
" --verify-translations Check the status of the various translations\n"
|
|
||||||
" --version Print version and exit\n"
|
|
||||||
"Input is taken from stdin if no sourcefile specified.\n"
|
"Input is taken from stdin if no sourcefile specified.\n"
|
||||||
"Debug level 'n' is a bitmask with following meaning:\n"
|
"Debug level 'n' is a bitmask with following meaning:\n"
|
||||||
" * 0x01 Tell which resource is parsed (verbose mode)\n"
|
" * 0x01 Tell which resource is parsed (verbose mode)\n"
|
||||||
|
@ -153,6 +144,8 @@ int no_preprocess = 0;
|
||||||
|
|
||||||
int check_utf8 = 1; /* whether to check for valid utf8 */
|
int check_utf8 = 1; /* whether to check for valid utf8 */
|
||||||
|
|
||||||
|
static int pointer_size = sizeof(void *);
|
||||||
|
|
||||||
static int verify_translations_mode;
|
static int verify_translations_mode;
|
||||||
|
|
||||||
char *output_name = NULL; /* The name given by the -o option */
|
char *output_name = NULL; /* The name given by the -o option */
|
||||||
|
@ -187,7 +180,7 @@ enum long_options_values
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char short_options[] =
|
static const char short_options[] =
|
||||||
"D:Ef:F:hi:I:J:l:o:O:rU:v";
|
"b:D:Ef:F:hi:I:J:l:m:o:O:rU:v";
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
{ "debug", 1, NULL, LONG_OPT_DEBUG },
|
{ "debug", 1, NULL, LONG_OPT_DEBUG },
|
||||||
{ "define", 1, NULL, 'D' },
|
{ "define", 1, NULL, 'D' },
|
||||||
|
@ -320,6 +313,19 @@ static int load_file( const char *input_name, const char *output_name )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_target( const char *target )
|
||||||
|
{
|
||||||
|
char *p, *cpu = xstrdup( target );
|
||||||
|
|
||||||
|
/* target specification is in the form CPU-MANUFACTURER-OS or CPU-MANUFACTURER-KERNEL-OS */
|
||||||
|
if (!(p = strchr( cpu, '-' ))) error( "Invalid target specification '%s'\n", target );
|
||||||
|
*p = 0;
|
||||||
|
if (!strcmp( cpu, "amd64" ) || !strcmp( cpu, "x86_64" ) || !strcmp( cpu, "ia64" ))
|
||||||
|
pointer_size = 8;
|
||||||
|
else
|
||||||
|
pointer_size = 4;
|
||||||
|
free( cpu );
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -346,8 +352,6 @@ int main(int argc,char *argv[])
|
||||||
/* Set the default defined stuff */
|
/* Set the default defined stuff */
|
||||||
set_version_defines();
|
set_version_defines();
|
||||||
wpp_add_cmdline_define("RC_INVOKED=1");
|
wpp_add_cmdline_define("RC_INVOKED=1");
|
||||||
wpp_add_cmdline_define("__WIN32__=1");
|
|
||||||
wpp_add_cmdline_define("__FLAT__=1");
|
|
||||||
/* Microsoft RC always searches current directory */
|
/* Microsoft RC always searches current directory */
|
||||||
wpp_add_include_path(".");
|
wpp_add_include_path(".");
|
||||||
|
|
||||||
|
@ -422,8 +426,9 @@ int main(int argc,char *argv[])
|
||||||
case 'E':
|
case 'E':
|
||||||
preprocess_only = 1;
|
preprocess_only = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'b':
|
||||||
case 'F':
|
case 'F':
|
||||||
/* ignored for compatibility with windres */
|
set_target( optarg );
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
printf(usage);
|
printf(usage);
|
||||||
|
@ -447,6 +452,12 @@ int main(int argc,char *argv[])
|
||||||
defaultlanguage = new_language(PRIMARYLANGID(lan), SUBLANGID(lan));
|
defaultlanguage = new_language(PRIMARYLANGID(lan), SUBLANGID(lan));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
if (!strcmp( optarg, "16" )) win32 = 0;
|
||||||
|
else if (!strcmp( optarg, "32" )) { win32 = 1; pointer_size = 4; }
|
||||||
|
else if (!strcmp( optarg, "64" )) { win32 = 1; pointer_size = 8; }
|
||||||
|
else error( "Invalid option: -m%s\n", optarg );
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
if (*optarg != 'o') error("Unknown option: -f%s\n", optarg);
|
if (*optarg != 'o') error("Unknown option: -f%s\n", optarg);
|
||||||
optarg++;
|
optarg++;
|
||||||
|
@ -456,12 +467,7 @@ int main(int argc,char *argv[])
|
||||||
else error("Too many output files.\n");
|
else error("Too many output files.\n");
|
||||||
break;
|
break;
|
||||||
case 'O':
|
case 'O':
|
||||||
if (strcmp(optarg, "res16") == 0)
|
if (strcmp(optarg, "res16") == 0) win32 = 0;
|
||||||
{
|
|
||||||
win32 = 0;
|
|
||||||
wpp_del_define("__WIN32__");
|
|
||||||
wpp_del_define("__FLAT__");
|
|
||||||
}
|
|
||||||
else if (strcmp(optarg, "res")) warning("Output format %s not supported.\n", optarg);
|
else if (strcmp(optarg, "res")) warning("Output format %s not supported.\n", optarg);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
|
@ -485,6 +491,12 @@ int main(int argc,char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (win32)
|
||||||
|
{
|
||||||
|
wpp_add_cmdline_define("_WIN32=1");
|
||||||
|
if (pointer_size == 8) wpp_add_cmdline_define("_WIN64=1");
|
||||||
|
}
|
||||||
|
|
||||||
/* If we do need to search standard includes, add them to the path */
|
/* If we do need to search standard includes, add them to the path */
|
||||||
if (stdinc)
|
if (stdinc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,17 @@ specified with \fI-o\fR, then \fBwrc\fR will write the output to
|
||||||
no inputfile was given.
|
no inputfile was given.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
|
.BI \-b,\ --target= cpu-manufacturer[-kernel]-os
|
||||||
|
Specify the target CPU and platform on which the generated code will
|
||||||
|
be built. The target specification is in the standard autoconf format
|
||||||
|
as returned by config.sub.
|
||||||
|
.TP
|
||||||
|
.I \fB\-D\fR, \fB\-\-define\fR=\fIid[=val]\fR
|
||||||
|
Define preprocessor identifier \fIid\fR to (optionally) value \fIval\fR.
|
||||||
|
See also
|
||||||
|
.B PREPROCESSOR
|
||||||
|
below.
|
||||||
|
.TP
|
||||||
.I \fB\-\-debug\fR=\fInn\fR
|
.I \fB\-\-debug\fR=\fInn\fR
|
||||||
Set debug level to \fInn\fR. The value is a bitmask consisting of
|
Set debug level to \fInn\fR. The value is a bitmask consisting of
|
||||||
1=verbose, 2=dump internals, 4=resource parser trace, 8=preprocessor
|
1=verbose, 2=dump internals, 4=resource parser trace, 8=preprocessor
|
||||||
|
@ -32,20 +43,11 @@ l[ittle] or b[ig]. Only resources in source-form can be reorderd. Native
|
||||||
ordering depends on the system on which \fBwrc\fR was built. You can see
|
ordering depends on the system on which \fBwrc\fR was built. You can see
|
||||||
the native ordering by typing \fIwrc \-h\fR.
|
the native ordering by typing \fIwrc \-h\fR.
|
||||||
.TP
|
.TP
|
||||||
.I \fB\-D\fR, \fB\-\-define\fR=\fIid[=val]\fR
|
|
||||||
Define preprocessor identifier \fIid\fR to (optionally) value \fIval\fR.
|
|
||||||
See also
|
|
||||||
.B PREPROCESSOR
|
|
||||||
below.
|
|
||||||
.TP
|
|
||||||
.I \fB\-E\fR
|
.I \fB\-E\fR
|
||||||
Preprocess only. The output is written to standard output if no
|
Preprocess only. The output is written to standard output if no
|
||||||
outputfile was selected. The output is compatible with what gcc would
|
outputfile was selected. The output is compatible with what gcc would
|
||||||
generate.
|
generate.
|
||||||
.TP
|
.TP
|
||||||
.I \fB\-F\fR, \fB\-\-target\fR
|
|
||||||
Ignored for compatibility with \fIwindres\fR.
|
|
||||||
.TP
|
|
||||||
.I \fB\-h\fR, \fB\-\-help\fR
|
.I \fB\-h\fR, \fB\-\-help\fR
|
||||||
Prints a summary message and exits.
|
Prints a summary message and exits.
|
||||||
.TP
|
.TP
|
||||||
|
@ -73,6 +75,11 @@ input to 'rc16' disables the recognition of win32 keywords.
|
||||||
Set default language to \fIlan\fR. Default is the neutral language 0
|
Set default language to \fIlan\fR. Default is the neutral language 0
|
||||||
(i.e. "LANGUAGE 0, 0").
|
(i.e. "LANGUAGE 0, 0").
|
||||||
.TP
|
.TP
|
||||||
|
.B \-m16, -m32, -m64
|
||||||
|
Generate resources for 16-bit, 32-bit, respectively 64-bit
|
||||||
|
platforms. The only difference between 32-bit and 64-bit is whether
|
||||||
|
the _WIN64 preprocessor symbol is defined.
|
||||||
|
.TP
|
||||||
.I \fB\-\-nostdinc\fR
|
.I \fB\-\-nostdinc\fR
|
||||||
Do not search the standard include path, look for include files only
|
Do not search the standard include path, look for include files only
|
||||||
in the directories explicitly specified with the \fI\-I\fR option.
|
in the directories explicitly specified with the \fI\-I\fR option.
|
||||||
|
@ -136,7 +143,7 @@ __WRC_MINOR__ Minor version of wrc
|
||||||
.br
|
.br
|
||||||
__WRC_PATCHLEVEL__ Patch level
|
__WRC_PATCHLEVEL__ Patch level
|
||||||
.PP
|
.PP
|
||||||
Win32 compilation mode also sets __WIN32__ to 1 and __FLAT__ to 1.
|
Win32 compilation mode also sets _WIN32 to 1.
|
||||||
.PP
|
.PP
|
||||||
Special macros __FILE__, __LINE__, __TIME__ and __DATE__ are also
|
Special macros __FILE__, __LINE__, __TIME__ and __DATE__ are also
|
||||||
recognized and expand to their respective equivalent.
|
recognized and expand to their respective equivalent.
|
||||||
|
|
Loading…
Reference in New Issue