Previous Up Next

Chapter 4  Basic Babel Code Generation

This chapter describes the Babel code generator and its command line options.


4.1  Babel is a Compiler

Babel is a compiler. It takes symbols and their interfaces as input and generates either code or a given textual representation. These interfaces may be specified in either Scientific Interface Definition Language (SIDL) or Extensible Markup Language (XML). The form the output takes depends upon the options specified on the command line. Refer to the Section 4.2 for details on command line options. More information on the supported bindings can be found in Part II of this document.

4.2  Command Line Options

The entire Babel code generator is written in Java and compiled into a jar file. For convenience, a small script called babel is provided that should set the appropriate environment variables and invoke the Java Virtual Machine on the jar file. To test that the script and jar file are working together properly, simply type babel --help.

Using Babel

Babel requires exactly one of the following mutually exclusive arguments on the command line unless you use the --multi option.

By far, the three most common uses of Babel will be to generate the Client-side proxies, Server-side implementations, and XML associated with the SIDL file. The last option is essentially used internally when the Babel runtime library is being developed.

The --multi option lets you generate multiple targets for a given set of files in a single run. Put it first on the command line, each --client or --server can have a different set of settings.

Additionally, there are a few supplemental arguments that complete the picture.

Long and Short Forms


Table 4.1: Command Line Arguments.
SHORT FORMLONG FORMNOTES
-h--helpPrint options to stdout.
-v--versionPrint version of Babel.
-tform--text=formGenerate text.
-clang--client=langGenerate client classes.
-slang--server=langGenerate server and client classes.
-p--parse-checkOnly check parsing of the SIDL file.
 --cca-modeNew splicer blocks get CCA-required content.
-i--generate-hooksGenerate pre-/post-method hooks.
 --generate-sidl-stdlibRegenerate the Babel runtime library.
-odir--output-directory=dirRoot directory to contain generated files.
-g--generate-subdirsGenerate sources in directory tree matching
  SIDL packaging.
 --generate-subdirs-offTurn off generate-subdirs.
-m--make-prefix=prefixPrepend prefix to names for babel.make.
 --makefileGenerate a simple GNU Makefile.
 --multiGenerate multiple targets in a single run.
-Rpath--repository-path=pathUse specified XML repository(ies) to resolve
  symbols.
-eregex--exclude=regexDo not generate output for matching symbol(s).
 --no-default-repositoryDo not use the default repository to resolve
  symbols.
 --rename-splicersRename Babel 1.0 splicer blocks to their 1.4 names.
 --suppress-contractsDon’t generate contract checks in IOR files.
 --suppress-iorDon’t generate IOR files.
 --suppress-stubsDon’t generate client-side stub files.
 --suppress-timestampSuppress time-related metadata generation.
 --comment-local-onlyReduce doc comments in C stub header.
-E--exclude-externalDo not generate code for dependencies.
 --include-referencedGenerate code for dependencies.
-u--hide-gluePut glue code in a subdirectory.
 --hide-glue-offTurn off hide-glue.
-l--language-subdirPut code in a language dependent directory.
 --language-subdir-offTurn off language-subdir.
-x--cxx-ior-exceptionInclude Null IOR checks in C++ Stubs.
-V--vpathSet the impl (splicer block) root directory.

So far, we’ve shown described the long forms of command line arguments, starting with two hyphens “--”. There are also short forms for many of the more frequently used commands. See Table 4.1 for details.

Examples

To create a new XML version of a SIDL file, use the following command:

% babel -tXML -omydepot mystuff.sidl

To exclude code generation for types whose name begins with “MPI.”, use the following command:

% babel -sC++ –exclude=’^MPI\.’ mystuff.sidl

Now suppose a developer wants to implement a library in C++ that corresponds to these types in the SIDL file.

% babel -E -sC++ mystuff.sidl

Alternatively, the developer could also create C++ implementation files based on the XML repository. In this case, a list of symbols to be implemented would need to be specified. Assuming that all of the types are in a package called “mystuff”, the following command can be issued:

% babel -E -sC++ -Rmydepot mystuff

Now suppose a second developer wants to extend this software. A second SIDL file is created then the implementation files in Fortran 90/95 are generated with the following command:

% babel -E -sf90 -Rmydepot newstuff.sidl

A user now can download both SIDL files and create their Python bindings to use both libraries with the following command:

% babel -cPython -Rhttp://localhost/mystuff/mydepot;
http://www.otherhost.com/newstuff mystuff newstuff

Finally, to generate SIDL files for each package based on the XML stored in the repository, the following command is used:

% babel -tSIDL -Rhttp://localhost/mystuff/mydepot;
http://www.otherhost.com/newstuff mystuff newstuff


1
URLs have colons in them, so this path has to be semi-colon separated, even though UNIX paths are traditionally colon separated.

Previous Up Next