Using the Slice Compilers

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

Language

Compiler

Freeze Compiler

C++

slice2cpp

slice2freeze

Java

slice2java

slice2freezej

JavaScript

slice2js

 

C#

slice2cs

 

Objective-C

slice2objc

 

Python

slice2py

 

Ruby

slice2rb

 

PHP

slice2php

 

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.
  • -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.
  • -d, --debug
    Print debug information showing the operation of the Slice parser.
  • --ice
    Permit use of the reserved Ice prefix in Slice identifiers. This is useful when building Ice itself, or when compiling a Slice file that includes another Slice file with Ice-prefixed identifiers, such as Ice/BuiltinSequences.ice.
  • --underscore
    Permit use of underscores in Slice identifiers.

  • --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