English version
Accueil propos Tlchargement Ressources Contactez-nous

Ce site est rarement mis jour. Pour les informations les plus rcentes, rendez-vous sur le nouveau site OCaml l'adresse ocaml.org.

Browse thread
ocamlbuild: add source files on the fly
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-12-12 (21:38)
From: Mikkel_Fahnøe_Jørgensen <mikkel@d...>
Subject: Re: [Caml-list] ocamlbuild: add source files on the fly
2008/12/11 Anastasia Gornostaeva <ermine@ermine.pp.ru>:
> Hello.
> How can I add additional source files for a program on fly? For instance, in
> usual Makefile I can do:
> SOURCES = file1.ml file2.ml file3.ml
> SOURCES += file4.ml

ocamlbuild scans dependencies automatically, so if the other files are
needed by the main program, you only have to build that single file.

For example,

  ocamlbuild file4.native

will depend of file4.ml and if the file has a statement like

  open File3
  open File2

then these are included in the build. This also works for ocamlyacc
and lex parser files.

If you build libraries, ocamlbuild has a .mllib file you can add files to.

If you also need C files, you need something more.
Here I developed ocamlbuild-ctools, where you can add c files to a
.cprog file and a .clib file. Ocamlbuild also has some C support, but
it is more limited and has no dependency scanning.