Alexandre Julliard : widl: Add --sysroot and --nostdinc options.
Alexandre Julliard
julliard at winehq.org
Mon Nov 4 16:40:24 CST 2019
Module: wine
Branch: master
Commit: 5f39d36a6c134bab77cea8f2e91c313e066eeffe
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5f39d36a6c134bab77cea8f2e91c313e066eeffe
Author: Alexandre Julliard <julliard at winehq.org>
Date: Sat Nov 2 13:34:27 2019 +0100
widl: Add --sysroot and --nostdinc options.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tools/widl/Makefile.in | 2 +-
tools/widl/widl.c | 34 ++++++++++++++++++++++++++++------
tools/widl/widl.man.in | 5 +++++
3 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/tools/widl/Makefile.in b/tools/widl/Makefile.in
index e06d6cc5b3..80a12601de 100644
--- a/tools/widl/Makefile.in
+++ b/tools/widl/Makefile.in
@@ -19,7 +19,7 @@ C_SRCS = \
LEX_SRCS = parser.l
BISON_SRCS = parser.y
-widl_EXTRADEFS = -DDEFAULT_INCLUDE_DIR=\"${includedir}/wine/windows/\"
+widl_EXTRADEFS = -DINCLUDEDIR=\"${includedir}\"
EXTRALIBS = -lwpp
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index f5fa20c884..aa6697135b 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -60,6 +60,8 @@ static const char usage[] =
" --local-stubs=file Write empty stubs for call_as/local methods to file\n"
" -m32, -m64 Set the target architecture (Win32 or Win64)\n"
" -N Do not preprocess input\n"
+" --nostdinc Do not search the standard include path\n"
+" --ns_prefix Prefix namespaces with ABI namespace\n"
" --oldnames Use old naming conventions\n"
" -o, --output=NAME Set the output file name\n"
" -Otype Type of stubs to generate (-Os, -Oi, -Oif)\n"
@@ -69,8 +71,7 @@ static const char usage[] =
" --prefix-server=p Prefix names of server functions with 'p'\n"
" -r Generate registration script\n"
" -robust Ignored, present for midl compatibility\n"
-" --winrt Enable Windows Runtime mode\n"
-" --ns_prefix Prefix namespaces with ABI namespace\n"
+" --sysroot=DIR Prefix include paths with DIR\n"
" -s Generate server stub\n"
" -t Generate typelib\n"
" -u Generate interface identifiers file\n"
@@ -79,6 +80,7 @@ static const char usage[] =
" --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"
+" --winrt Enable Windows Runtime mode\n"
"Debug level 'n' is a bitmask with following meaning:\n"
" * 0x01 Tell which resource is parsed (verbose mode)\n"
" * 0x02 Dump internal structures\n"
@@ -125,6 +127,7 @@ int win32_packing = 8;
int win64_packing = 8;
int winrt_mode = 0;
int use_abi_namespace = 0;
+static int stdinc = 1;
static enum stub_mode stub_mode = MODE_Os;
char *input_name;
@@ -163,6 +166,7 @@ enum {
DLLDATA_OPTION,
DLLDATA_ONLY_OPTION,
LOCAL_STUBS_OPTION,
+ NOSTDINC_OPTION,
PREFIX_ALL_OPTION,
PREFIX_CLIENT_OPTION,
PREFIX_SERVER_OPTION,
@@ -170,6 +174,7 @@ enum {
RT_NS_PREFIX,
RT_OPTION,
ROBUST_OPTION,
+ SYSROOT_OPTION,
WIN32_OPTION,
WIN64_OPTION,
WIN32_ALIGN_OPTION,
@@ -185,6 +190,7 @@ static const struct option long_options[] = {
{ "dlldata-only", 0, NULL, DLLDATA_ONLY_OPTION },
{ "help", 0, NULL, PRINT_HELP },
{ "local-stubs", 1, NULL, LOCAL_STUBS_OPTION },
+ { "nostdinc", 0, NULL, NOSTDINC_OPTION },
{ "ns_prefix", 0, NULL, RT_NS_PREFIX },
{ "oldnames", 0, NULL, OLDNAMES_OPTION },
{ "output", 0, NULL, 'o' },
@@ -192,6 +198,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 },
+ { "sysroot", 1, NULL, SYSROOT_OPTION },
{ "target", 0, NULL, 'b' },
{ "winrt", 0, NULL, RT_OPTION },
{ "win32", 0, NULL, WIN32_OPTION },
@@ -567,10 +574,11 @@ void write_id_data(const statement_list_t *stmts)
int main(int argc,char *argv[])
{
- int optc;
+ int i, optc;
int ret = 0;
int opti = 0;
char *output_name = NULL;
+ const char *sysroot = "";
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
@@ -593,6 +601,9 @@ int main(int argc,char *argv[])
do_everything = 0;
local_stubs_name = xstrdup(optarg);
break;
+ case NOSTDINC_OPTION:
+ stdinc = 0;
+ break;
case OLDNAMES_OPTION:
old_names = 1;
break;
@@ -615,6 +626,9 @@ int main(int argc,char *argv[])
case RT_NS_PREFIX:
use_abi_namespace = 1;
break;
+ case SYSROOT_OPTION:
+ sysroot = xstrdup(optarg);
+ break;
case WIN32_OPTION:
pointer_size = 4;
break;
@@ -733,9 +747,17 @@ int main(int argc,char *argv[])
}
}
-#ifdef DEFAULT_INCLUDE_DIR
- wpp_add_include_path(DEFAULT_INCLUDE_DIR);
-#endif
+ if (stdinc)
+ {
+ static const char *incl_dirs[] = { INCLUDEDIR, "/usr/include", "/usr/local/include" };
+
+ for (i = 0; i < ARRAY_SIZE(incl_dirs); i++)
+ {
+ if (i && !strcmp( incl_dirs[i], incl_dirs[0] )) continue;
+ wpp_add_include_path( strmake( "%s%s/wine/msvcrt", sysroot, incl_dirs[i] ));
+ wpp_add_include_path( strmake( "%s%s/wine/windows", sysroot, incl_dirs[i] ));
+ }
+ }
switch (target_cpu)
{
diff --git a/tools/widl/widl.man.in b/tools/widl/widl.man.in
index ec81488a0e..010b7f04e2 100644
--- a/tools/widl/widl.man.in
+++ b/tools/widl/widl.man.in
@@ -41,6 +41,11 @@ 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.
+.IP \fB\-\-sysroot=\fIdir\fR
+Prefix the standard include paths with \fIdir\fR.
+.IP \fB\-\-nostdinc\fR
+Do not search standard include paths like /usr/include and
+/usr/local/include.
.PP
.B Header options:
.IP "\fB-h\fR"
More information about the wine-cvs
mailing list