Using the Slice Compilers

Ice provides a separate Slice compiler for each language mapping, as shown below:

Language

Compiler

C++

slice2cpp

C#

slice2cs

Java

slice2java

JavaScript

slice2js

MATLABslice2matlab

Objective-C

slice2objc

PHP

slice2php

Python

slice2py

Ruby

slice2rb

The Slice compilers.

The compilers share a similar command-line syntax:

<compiler-name> [options] file...

Regardless of which compiler you use, a number of command-line options are common to the compilers for any language mapping. (See the appropriate language mapping chapter for options that are specific to a particular language mapping.) The common command-line options are:

  • -h, --help
    Displays a help message.
  • -v, --version
    Displays the compiler version.
  • -DNAME
    Defines the preprocessor symbol NAME.
  • -DNAME=DEF
    Defines the preprocessor symbol NAME with the value DEF.
    Each compiler always predefines the __<compiler name in upper case>__ macro when compiling Slice file. For example, slice2cpp predefines __SLICE2CPP__.
  • -UNAME
    Undefines the preprocessor symbol NAME.
  • -IDIR
    Add the directory DIR to the search path for #include directives.
  • -E
    Print the preprocessor output on stdout.
  • --output-dir DIR
    Place the generated files into directory DIR, which must already exist.
  • -d, --debug
    Print debug information showing the operation of the Slice parser.
  • --depend
    Print dependency information to standard output by default, or to the file specified by the --depend-file option. No code is generated when this option is specified. The output includes the complete list of Slice files that the input Slice files depend on through direct or indirect inclusion; this output may include other files depending on the target programming language.  The Ice for C++ build system uses the script config/makedepend.py to process and include this output in Makefiles.
  • --depend-xml
    Print dependency information in XML format to standard output by default, or to the file specified by the --depend-file option. No code is generated when this option is specified. The output consists of the complete list of Slice files that the input Slice files depend on through direct or indirect inclusion, and is identical will all Slice compilers.
  • --depend-file FILE
    Directs dependency information to the specified file. The output format depends on whether --depend or --depend-xml is also specified.

  • --validate
    Checks the provided command-line options for correctness, and does not generate any code.

The Slice compilers permit you to compile more than a single source file, so you can compile several Slice definitions at once, for example:

slice2cpp -I. file1.ice file2.ice file3.ice

See Also