widl: Always generate files for the target platform only.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2018-11-14 18:18:17 +01:00
parent 2cba0ed944
commit f67301e9ec
10 changed files with 75 additions and 109 deletions

View File

@ -627,26 +627,6 @@ void write_client(const statement_list_t *stmts)
if (!client)
return;
if (do_win32 && do_win64)
{
fprintf(client, "#ifndef _WIN64\n\n");
pointer_size = 4;
write_client_routines( stmts );
fprintf(client, "\n#else /* _WIN64 */\n\n");
pointer_size = 8;
write_client_routines( stmts );
fprintf(client, "\n#endif /* _WIN64 */\n");
}
else if (do_win32)
{
pointer_size = 4;
write_client_routines( stmts );
}
else if (do_win64)
{
pointer_size = 8;
write_client_routines( stmts );
}
fclose(client);
}

View File

@ -942,7 +942,7 @@ static void write_proxy_routines(const statement_list_t *stmts)
write_stubdesc(expr_eval_routines);
print_proxy( "#if !defined(__RPC_WIN%u__)\n", pointer_size == 8 ? 64 : 32);
print_proxy( "#error Currently only Wine and WIN32 are supported.\n");
print_proxy( "#error Invalid build platform for this proxy.\n");
print_proxy( "#endif\n");
print_proxy( "\n");
write_procformatstring(proxy, stmts, need_proxy);
@ -1053,26 +1053,6 @@ void write_proxies(const statement_list_t *stmts)
init_proxy(stmts);
if(!proxy) return;
if (do_win32 && do_win64)
{
fprintf(proxy, "\n#ifndef _WIN64\n\n");
pointer_size = 4;
write_proxy_routines( stmts );
fprintf(proxy, "\n#else /* _WIN64 */\n\n");
pointer_size = 8;
write_proxy_routines( stmts );
fprintf(proxy, "\n#endif /* _WIN64 */\n");
}
else if (do_win32)
{
pointer_size = 4;
write_proxy_routines( stmts );
}
else if (do_win64)
{
pointer_size = 8;
write_proxy_routines( stmts );
}
fclose(proxy);
}

View File

@ -325,7 +325,7 @@ void output_typelib_regscript( const typelib_t *typelib )
sprintf(resname, "%s\\%d", typelib_name, expr->cval);
}
put_str( indent, "'%x' { %s = s '%%MODULE%%%s' }\n",
lcid_expr ? lcid_expr->cval : 0, typelib_kind == SYS_WIN64 ? "win64" : "win32", id_part );
lcid_expr ? lcid_expr->cval : 0, pointer_size == 8 ? "win64" : "win32", id_part );
put_str( indent, "FLAGS = s '%u'\n", flags );
put_str( --indent, "}\n" );
put_str( --indent, "}\n" );

View File

@ -544,26 +544,6 @@ void write_server(const statement_list_t *stmts)
if (!server)
return;
if (do_win32 && do_win64)
{
fprintf(server, "#ifndef _WIN64\n\n");
pointer_size = 4;
write_server_routines( stmts );
fprintf(server, "\n#else /* _WIN64 */\n\n");
pointer_size = 8;
write_server_routines( stmts );
fprintf(server, "\n#endif /* _WIN64 */\n");
}
else if (do_win32)
{
pointer_size = 4;
write_server_routines( stmts );
}
else if (do_win64)
{
pointer_size = 8;
write_server_routines( stmts );
}
fclose(server);
}

View File

@ -169,7 +169,7 @@ unsigned short get_type_vt(type_t *t)
else
return VT_I8;
case TYPE_BASIC_INT3264:
if (typelib_kind == SYS_WIN64)
if (pointer_size == 8)
{
if (type_basic_get_sign(t) > 0)
return VT_UI8;

View File

@ -43,11 +43,6 @@
#include "wine/wpp.h"
#include "header.h"
/* future options to reserve characters for: */
/* A = ACF input filename */
/* J = do not search standard include path */
/* w = select win16/win32 output (?) */
static const char usage[] =
"Usage: widl [options...] infile.idl\n"
" or: widl [options...] --dlldata-only name1 [name2...]\n"
@ -63,7 +58,7 @@ static const char usage[] =
" -H file Name of header file (default is infile.h)\n"
" -I path Set include search dir to path (multiple -I allowed)\n"
" --local-stubs=file Write empty stubs for call_as/local methods to file\n"
" -m32, -m64 Set the kind of typelib to build (Win32 or Win64)\n"
" -m32, -m64 Set the target architecture (Win32 or Win64)\n"
" -N Do not preprocess input\n"
" --oldnames Use old naming conventions\n"
" -o, --output=NAME Set the output file name\n"
@ -81,8 +76,7 @@ static const char usage[] =
" -u Generate interface identifiers file\n"
" -V Print version and exit\n"
" -W Enable pedantic warnings\n"
" --win32 Only generate 32-bit code\n"
" --win64 Only generate 64-bit code\n"
" --win32, --win64 Set the target architecture (Win32 or Win64)\n"
" --win32-align n Set win32 structure alignment to 'n'\n"
" --win64-align n Set win64 structure alignment to 'n'\n"
"Debug level 'n' is a bitmask with following meaning:\n"
@ -97,6 +91,20 @@ static const char usage[] =
static const char version_string[] = "Wine IDL Compiler version " PACKAGE_VERSION "\n"
"Copyright 2002 Ove Kaaven\n";
#ifdef __i386__
enum target_cpu target_cpu = CPU_x86;
#elif defined(__x86_64__)
enum target_cpu target_cpu = CPU_x86_64;
#elif defined(__powerpc__)
enum target_cpu target_cpu = CPU_POWERPC;
#elif defined(__arm__)
enum target_cpu target_cpu = CPU_ARM;
#elif defined(__aarch64__)
enum target_cpu target_cpu = CPU_ARM64;
#else
#error Unsupported CPU
#endif
int debuglevel = DEBUGLEVEL_NONE;
int parser_debug, yy_flex_debug;
@ -113,8 +121,6 @@ int do_idfile = 0;
int do_dlldata = 0;
static int no_preprocess = 0;
int old_names = 0;
int do_win32 = 1;
int do_win64 = 1;
int win32_packing = 8;
int win64_packing = 8;
int winrt_mode = 0;
@ -147,7 +153,6 @@ int line_number = 1;
static FILE *idfile;
unsigned int pointer_size = 0;
syskind_t typelib_kind = sizeof(void*) == 8 ? SYS_WIN64 : SYS_WIN32;
time_t now;
@ -187,6 +192,7 @@ static const struct option long_options[] = {
{ "prefix-client", 1, NULL, PREFIX_CLIENT_OPTION },
{ "prefix-server", 1, NULL, PREFIX_SERVER_OPTION },
{ "robust", 0, NULL, ROBUST_OPTION },
{ "target", 0, NULL, 'b' },
{ "winrt", 0, NULL, RT_OPTION },
{ "win32", 0, NULL, WIN32_OPTION },
{ "win64", 0, NULL, WIN64_OPTION },
@ -269,19 +275,23 @@ static void set_target( const char *target )
static const struct
{
const char *name;
syskind_t kind;
enum target_cpu cpu;
} cpu_names[] =
{
{ "i386", SYS_WIN32 },
{ "i486", SYS_WIN32 },
{ "i586", SYS_WIN32 },
{ "i686", SYS_WIN32 },
{ "i786", SYS_WIN32 },
{ "amd64", SYS_WIN64 },
{ "x86_64", SYS_WIN64 },
{ "powerpc", SYS_WIN32 },
{ "arm", SYS_WIN32 },
{ "aarch64", SYS_WIN64 }
{ "i386", CPU_x86 },
{ "i486", CPU_x86 },
{ "i586", CPU_x86 },
{ "i686", CPU_x86 },
{ "i786", CPU_x86 },
{ "amd64", CPU_x86_64 },
{ "x86_64", CPU_x86_64 },
{ "powerpc", CPU_POWERPC },
{ "arm", CPU_ARM },
{ "armv5", CPU_ARM },
{ "armv6", CPU_ARM },
{ "armv7", CPU_ARM },
{ "arm64", CPU_ARM64 },
{ "aarch64", CPU_ARM64 },
};
unsigned int i;
@ -295,7 +305,7 @@ static void set_target( const char *target )
{
if (!strcmp( cpu_names[i].name, spec ))
{
typelib_kind = cpu_names[i].kind;
target_cpu = cpu_names[i].cpu;
free( spec );
return;
}
@ -605,12 +615,10 @@ int main(int argc,char *argv[])
use_abi_namespace = 1;
break;
case WIN32_OPTION:
do_win32 = 1;
do_win64 = 0;
pointer_size = 4;
break;
case WIN64_OPTION:
do_win32 = 0;
do_win64 = 1;
pointer_size = 8;
break;
case WIN32_ALIGN_OPTION:
win32_packing = strtol(optarg, NULL, 0);
@ -663,8 +671,8 @@ int main(int argc,char *argv[])
wpp_add_include_path(optarg);
break;
case 'm':
if (!strcmp( optarg, "32" )) typelib_kind = SYS_WIN32;
else if (!strcmp( optarg, "64" )) typelib_kind = SYS_WIN64;
if (!strcmp( optarg, "32" )) pointer_size = 4;
else if (!strcmp( optarg, "64" )) pointer_size = 8;
break;
case 'N':
no_preprocess = 1;
@ -728,6 +736,26 @@ int main(int argc,char *argv[])
wpp_add_include_path(DEFAULT_INCLUDE_DIR);
#endif
switch (target_cpu)
{
case CPU_x86:
if (pointer_size == 8) target_cpu = CPU_x86_64;
else pointer_size = 4;
break;
case CPU_x86_64:
if (pointer_size == 4) target_cpu = CPU_x86;
else pointer_size = 8;
break;
case CPU_ARM64:
if (pointer_size == 4) error( "Cannot build 32-bit code for this CPU\n" );
pointer_size = 8;
break;
default:
if (pointer_size == 8) error( "Cannot build 64-bit code for this CPU\n" );
pointer_size = 4;
break;
}
/* if nothing specified, try to guess output type from the output file name */
if (output_name && do_everything && !do_header && !do_typelib && !do_proxies &&
!do_client && !do_server && !do_regscript && !do_idfile && !do_dlldata)

View File

@ -45,8 +45,6 @@ extern int do_regscript;
extern int do_idfile;
extern int do_dlldata;
extern int old_names;
extern int do_win32;
extern int do_win64;
extern int win32_packing;
extern int win64_packing;
extern int winrt_mode;
@ -76,6 +74,13 @@ extern time_t now;
extern int line_number;
extern int char_number;
enum target_cpu
{
CPU_x86, CPU_x86_64, CPU_POWERPC, CPU_ARM, CPU_ARM64, CPU_LAST = CPU_ARM64
};
extern enum target_cpu target_cpu;
enum stub_mode
{
MODE_Os, /* inline stubs */

View File

@ -35,10 +35,12 @@ Set the name of the output file. When generating multiple output
files, this sets only the base name of the file; the respective output
files are then named \fIname\fR.h, \fIname\fR_p.c, etc. If a full
file name with extension is specified, only that file is generated.
.IP "\fB-b \fIcpu-manufacturer\fR[\fB-\fIkernel\fR]\fB-\fIos\fR"
.IP "\fB-b, --target=\fIcpu-manufacturer\fR[\fI-kernel\fR]\fI-os\fR"
Set the target architecture when cross-compiling. The target
specification is in the standard autoconf format as returned by
\fBconfig.sub\fR.
.IP "\fB-m32, -m64, --win32, --win64\fR"
Force the target architecture to 32-bit or 64-bit.
.PP
.B Header options:
.IP "\fB-h\fR"
@ -51,8 +53,6 @@ Use old naming conventions.
Generate a type library. The default output filename is
\fIinfile\fB.tlb\fR. If the output file name ends in \fB.res\fR, a
binary resource file containing the type library is generated instead.
.IP "\fB-m32, -m64\fR"
Generate a Win32 or Win64 type library respectively.
.PP
.B UUID file options:
.IP "\fB-u\fR"
@ -78,10 +78,6 @@ Prefix to put on the name of server stubs.
.IP "\fB-s\fR"
Generate a server stub file. The default output filename is
\fIinfile\fB_s.c\fR.
.IP "\fB--win32\fR, \fB--win64\fR"
Only generate 32-bit or 64-bit code respectively (the default is to
generate both 32-bit and 64-bit versions into the same destination
file).
.PP
.IP "\fB--winrt\fR"
Enable Windows Runtime mode.

View File

@ -553,7 +553,6 @@ typedef enum {
SYS_WIN64
} syskind_t;
extern syskind_t typelib_kind;
extern user_type_list_t user_type_list;
extern context_handle_list_t context_handle_list;
extern generic_handle_list_t generic_handle_list;

View File

@ -2653,8 +2653,6 @@ int create_msft_typelib(typelib_t *typelib)
GUID midl_info_guid = {0xde77ba65,0x517c,0x11d1,{0xa2,0xda,0x00,0x00,0xf8,0x77,0x3c,0xe9}};
char info_string[128];
pointer_size = (typelib_kind == SYS_WIN64) ? 8 : 4;
msft = xmalloc(sizeof(*msft));
memset(msft, 0, sizeof(*msft));
msft->typelib = typelib;
@ -2662,7 +2660,7 @@ int create_msft_typelib(typelib_t *typelib)
ctl2_init_header(msft);
ctl2_init_segdir(msft);
msft->typelib_header.varflags |= typelib_kind;
msft->typelib_header.varflags |= (pointer_size == 8) ? SYS_WIN64 : SYS_WIN32;
/*
* The following two calls return an offset or -1 if out of memory. We