The grpc-compile command provides a simple command-line interface to the XDR/RPC language compiler (see Compiler). It reads a RPC definitions written in the XDR/RPC language on the standard input and, depending on the options, write Scheme code containing client, server, data type or constant definitions on the standard output.
rpcgen. These extensions include:
%line comments; these are actually treated as special directives by
rpcgenbut they are simply ignored by
chartype, equivalent to
unsignedtype, equivalent to
structin type specifiers.
Also note that some XDR/RPC definition files (.x files)
originally designed to be used in C programs with
C preprocessor directives. Unlike
rpcgen, which automatically
cpp, such input files need to be piped through
cpp -P before being fed to
Code generation options can be combined. For instance, the command line below writes data type and constant definitions as well as client stubs in a single file:
$ grpc-compile --xdr --constants --client < input.x > client-stubs.scm
The various pieces of generated code can also be stored in separate files. The following example shows how to create one file containing constant and type definitions, another one containing client stubs, and a third one containing server stubs. Since the two last files depend on the first one, care must be taken to load them beforehand.
$ grpc-compile --xdr --constants < input.x > types+constants.scm $ echo '(load "types+constants.scm")' > client-stubs.scm $ grpc-compile --client < input.x >> client-stubs.scm $ echo '(load "types+constants.scm")' > server-stubs.scm $ grpc-compile --server < input.x >> server-stubs.scm
In the future, there may be additional
--define-module options to make it easier to use Guile's module
system in generated code.