[PATCH] widl: Add option to not generate RPC includes.

Józef Kucia jkucia at codeweavers.com
Thu Nov 15 08:35:23 CST 2018


This makes it easier to use header files generated by widl without
Windows headers. In particular, headers generated with --no-rpc-includes
do not need rpc.h and rpcndr.h header files.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---

This change is mainly for vkd3d. Currently, we use an ugly hack to strip
RPC includes from the generated header files.

---
 tools/widl/header.c    | 13 ++++++++-----
 tools/widl/widl.c      |  7 +++++++
 tools/widl/widl.h      |  1 +
 tools/widl/widl.man.in |  2 ++
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index defc7f850371..212c20a90148 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -1784,12 +1784,15 @@ void write_header(const statement_list_t *stmts)
   }
   fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n\n", PACKAGE_VERSION, input_name);
 
-  fprintf(header, "#ifndef __REQUIRED_RPCNDR_H_VERSION__\n");
-  fprintf(header, "#define __REQUIRED_RPCNDR_H_VERSION__ 475\n");
-  fprintf(header, "#endif\n\n");
+  if (!no_rpc_includes) {
+    fprintf(header, "#ifndef __REQUIRED_RPCNDR_H_VERSION__\n");
+    fprintf(header, "#define __REQUIRED_RPCNDR_H_VERSION__ 475\n");
+    fprintf(header, "#endif\n\n");
+
+    fprintf(header, "#include <rpc.h>\n" );
+    fprintf(header, "#include <rpcndr.h>\n" );
+  }
 
-  fprintf(header, "#include <rpc.h>\n" );
-  fprintf(header, "#include <rpcndr.h>\n" );
   if (!for_each_serializable(stmts, NULL, serializable_exists))
     fprintf(header, "#include <midles.h>\n" );
   fprintf(header, "\n" );
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index 7e411cfcf007..d9062a21c67d 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -64,6 +64,7 @@ static const char usage[] =
 "   -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"
+"   --no-rpc-includes  Do not generate RPC includes in header files.\n"
 "   -N                 Do not preprocess input\n"
 "   --oldnames         Use old naming conventions\n"
 "   -o, --output=NAME  Set the output file name\n"
@@ -111,6 +112,7 @@ int do_server = 0;
 int do_regscript = 0;
 int do_idfile = 0;
 int do_dlldata = 0;
+int no_rpc_includes = 0;
 static int no_preprocess = 0;
 int old_names = 0;
 int do_win32 = 1;
@@ -162,6 +164,7 @@ enum {
     PREFIX_CLIENT_OPTION,
     PREFIX_SERVER_OPTION,
     PRINT_HELP,
+    NO_RPC_INCLUDES_OPTION,
     RT_NS_PREFIX,
     RT_OPTION,
     ROBUST_OPTION,
@@ -180,6 +183,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 },
+    { "no-rpc-includes", 0, NULL, NO_RPC_INCLUDES_OPTION },
     { "ns_prefix", 0, NULL, RT_NS_PREFIX },
     { "oldnames", 0, NULL, OLDNAMES_OPTION },
     { "output", 0, NULL, 'o' },
@@ -601,6 +605,9 @@ int main(int argc,char *argv[])
     case RT_OPTION:
       winrt_mode = 1;
       break;
+    case NO_RPC_INCLUDES_OPTION:
+      no_rpc_includes = 1;
+      break;
     case RT_NS_PREFIX:
       use_abi_namespace = 1;
       break;
diff --git a/tools/widl/widl.h b/tools/widl/widl.h
index 118e2245c2e2..bea6c0748e56 100644
--- a/tools/widl/widl.h
+++ b/tools/widl/widl.h
@@ -44,6 +44,7 @@ extern int do_server;
 extern int do_regscript;
 extern int do_idfile;
 extern int do_dlldata;
+extern int no_rpc_includes;
 extern int old_names;
 extern int do_win32;
 extern int do_win64;
diff --git a/tools/widl/widl.man.in b/tools/widl/widl.man.in
index 7d89db38faa5..bcf8b4021a8f 100644
--- a/tools/widl/widl.man.in
+++ b/tools/widl/widl.man.in
@@ -45,6 +45,8 @@ specification is in the standard autoconf format as returned by
 Generate header files. The default output filename is \fIinfile\fB.h\fR.
 .IP "\fB--oldnames\fR"
 Use old naming conventions.
+.IP "\fB--no-rpc-headers\fR"
+Do not generate RPC includes.
 .PP
 .B Type library options:
 .IP \fB-t\fR
-- 
2.18.1




More information about the wine-devel mailing list