OCaml Development Tools
Overview Screenshots Installation notes Download Tutorial Next release

3 - Project configuration, OCaml compiler location

[en] [fr]
28 September 2011, by Emmanuel Dieul

PNGAn OCaml project can be configured by the way of several main categories:

  • the locations of the sources and binaries
  • the builder profiles
  • the targets to be produces (executables, libraries)
  • the grammars

Each project has its own configuration, which is stored into the ".preferences.xml" files, placed at the project root.

Each one of these main categories has its impact on the others:

  • the source folders indicate to the builder profiles which files have to be compiles; if a source folder disappears, all the targets and grammars based on these sources also disappear
  • the targets and grammars indicate to the builder profiles the products to be built
  • the binary folders indicate to the builder profiles where the compiled files must be moved to
  • ...

In a more general way and for all the workspace projects, the compiler location can also be configured.


The location of the source folders and the binary folder

PNGThe binary folder is the folder where the following files are stored:

  • all the files generated by ocamllex and ocamlyacc
  • all the files compiled by ocamlc or ocamlopt

Into this binary folder, each builder profile has its own folder, which also makes the separate compilation possible.

Finally, the source folders define the location of the source file to be compiled. These folders can be (directly or not) under the project folder: they will finally be displayed under the project folder. Only the source files contained into the source folders are compiled. If there exist source files outside of the source folders, they will be ignored.

The builder profiles, the separate compilation

The builder profiles define several ways to compile the project files. Every project has its own builder profile. However, it’s possible to define specific builder profiles. So, it’s possible to obtain, from the same sources, two executables produced with different options or libraries:

  • system threads (-thread) v.s. virtual machine threads (-vmthread)
  • a testing executable (-g) and a published executable (-principal)
  • ...

Each builder profile has its own compilation space, which is distinct from the one of the other builder profiles.

PNGThree categories of elements can be configured for each builder profile:

  1. the libraries, which can be standard libraries, project libraries or external libraries
  2. the compilation options
  3. the bytecode or native mode

Some integrity principles are implemented in order to conserve a consistent configuration:

  • the options which are not compatible with the compilation mode (native or bytecode) are not selectable (e.g. -vmthread)
  • the selected liraries are necessarily compatibles with the compilation mode

Finally, by default, the project builder profile is in charge of compiling the source files. However, when a specific builder profile exists (e.g. to build an executable), the project builder profile does not compile the files already compiled with another builder profile, except if they are necessary for a target production (executable, library) attached to the project builder profile.

Executable production

PNGFor each executable creation, several elements must be identified:

  • its location and its name,
  • its main source file
  • its builder profile

These executables will be automatically produced, at the end of the compilation process, when a source file has been modified or when the project has been cleaned.

These executables will then be launched via the execution manager:

PNG

The grammars, Camlp4 and the conditional compilation

PNGGrammars, which extends the OCaml language, are also supported into ODT. They are defined in the same way as the executables.

PNGThe compilation of a grammar can imply the creation of a specific builder profile.

Once the grammar has been compiled, or if a standard grammar is available, this grammar can be used within the builder profiles, via the "-pp" option.

The example here shows a conditional compilation: "-DTAG" imposes to the compiler to take into account only the code conditioned by the "TAG" presence. See the Camlp4 manual for more information.

However, the use of grammars really increases the compilation times under windows/cygwin. Then, the "-pp" option must be used with caution into builder profiles.

The preferences file

For each OCaml project, either it has been configured or not, a ".preferences.xml" file exists at the project root. It contains all the project configuration.

This file must not be removed ; otherwise, a file with a default configuration will replace it at the next project opening.

OCaml compiler location

An option is global to every project: the OCaml compiler location.

By default, this compiler is searched into the PATH environment variable. However, under MacOS, this variable isn’t completely available into Eclipse. So, some standard paths are managed by default: /bin, /usr/local/bin and /usr/bin.

If the compiler is installed into a specific path, it must be configured into ODT, via the "Window > Preferences > OCaml > Compiler" menu.

Once the path is noted, Eclipse must be restarted. The compiler will then be found and used.



breves

November 2013


ODT 3.0 released: code completion and others



January 2013


ODT 2.3 released : OCaml 4.00 support



April 2012


ODT 2.2 released : folding code and full indentation



January 2012


ODT 2.1 released : interface generation, libraries and referenced projects



September 2011


ODT 2.0 released : camlp4 integration, separate compilation and more...



December 2010


ODT 1.3.1 released : OCaml 3.12.0 support



October 2010


ODT 1.3 released : many improvements