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

Józef Kucia jkucia at codeweavers.com
Thu Nov 15 09:36:53 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.

Version 2: Rebased.

---
 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 8fe8e4c62584..96b9d79b94b9 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -59,6 +59,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 target architecture (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"
@@ -119,6 +120,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 win32_packing = 8;
@@ -167,6 +169,7 @@ enum {
     PREFIX_CLIENT_OPTION,
     PREFIX_SERVER_OPTION,
     PRINT_HELP,
+    NO_RPC_INCLUDES_OPTION,
     RT_NS_PREFIX,
     RT_OPTION,
     ROBUST_OPTION,
@@ -185,6 +188,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' },
@@ -611,6 +615,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 4f4252e3ea3a..4767602231ca 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 win32_packing;
 extern int win64_packing;
diff --git a/tools/widl/widl.man.in b/tools/widl/widl.man.in
index ec81488a0e8d..402d9ebfc22b 100644
--- a/tools/widl/widl.man.in
+++ b/tools/widl/widl.man.in
@@ -47,6 +47,8 @@ Force the target architecture to 32-bit or 64-bit.
 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