Differences between revisions 10 and 11
Revision 10 as of 2007-05-08 15:29:07
Size: 2050
Editor: nly93-1-82-232-72-199
Comment: Add colors in code
Revision 11 as of 2008-03-12 02:47:13
Size: 2050
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

Our project uses RPC protocol and "rpcgen" utility to generate .c and .h sources from RPC protocol source files (.x extension).

The problem with "rpcgen" utility is how it generates the "#include" statements. Namely, "rpcgen" will pick include path from its source file (.x) path. THerefore, i've wrote several actions, which does directory change, .x -> [.c|.h] code generation with "rpcgen" and then change directory back:

   1 def rpc_xdr_action( target, source, env ):
   2         source_dir  = os.path.dirname( str(source[0]) )
   3         source_file = os.path.basename( str(source[0]) )
   4 
   5         target_file = os.path.abspath( str(target[0]) )
   6 
   7         cwd = os.getcwd()
   8 
   9         os.chdir( source_dir )
  10         os.system( "rpcgen -c -o " + target_file + " " + source_file )
  11         os.chdir( cwd )
  12 
  13 def rpc_client_action( target, source, env ):
  14         source_dir  = os.path.dirname( str(source[0]) )
  15         source_file = os.path.basename( str(source[0]) )
  16 
  17         target_file = os.path.abspath( str(target[0]) )
  18 
  19         cwd = os.getcwd()
  20 
  21         os.chdir( source_dir )
  22         os.system( "rpcgen -l -o " + target_file + " " + source_file )
  23         os.chdir( cwd )
  24 
  25 def rpc_header_action( target, source, env ):
  26         source_dir  = os.path.dirname( str(source[0]) )
  27         source_file = os.path.basename( str(source[0]) )
  28 
  29         target_file = os.path.abspath( str(target[0]) )
  30 
  31         cwd = os.getcwd()
  32 
  33         os.chdir( source_dir )
  34         os.system( "rpcgen -h -o " + target_file + " " + source_file )
  35         os.chdir( cwd )
  36 
  37 
  38 rpcxdr = Builder( action = rpc_xdr_action,
  39                   suffix = ".c",
  40                   src_suffix = ".x" )
  41 
  42 env.Append(BUILDERS = {'RPCXDRBuilder' : rpcxdr})
  43 
  44 rpcclnt = Builder( action = rpc_client_action,
  45                    suffix = ".c",
  46                    src_suffix = ".x" )
  47 
  48 env.Append(BUILDERS = {'RPCCLNTBuilder' : rpcclnt})
  49 
  50 rpchdr = Builder( action = rpc_header_action,
  51                   suffix = ".h",
  52                   src_suffix = ".x" )
  53 
  54 env.Append(BUILDERS = {'RPCHDRBuilder' : rpchdr})

Request1: How to actually use the RPC builders.

Request2: Please include an rpcgen tool in the standarc scons distribution.

RpcBuilder (last edited 2008-03-12 02:47:13 by localhost)