Commit 408cd092 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-03-09 20:13:34 by jdemouth] Add ocaml interface to cduce compiler.

Original author: jdemouth
Date: 2004-03-09 20:14:57+00:00
parent cdfd175b
......@@ -57,6 +57,10 @@ Important notes:
<hit enter key when asked for password>
cvs -z3 -d":pserver:anoncvs@camlcvs.inria.fr:/caml" co ocaml
- cduce can be interfaced with OCaml language to be called from it. In order
to be able to use this feature, you will have to patch OCaml Makefile and
build a special library. Everything is explained bellow.
- pcre-ocaml: you may also need to install the PCRE library
from http://www.pcre.org/ (use version >=4.4)
[red-hat users: pcre (rawhide) packages may not work with the
......@@ -92,6 +96,14 @@ Efficiency issues:
Compilation
------------------------------------------------------------------------------
Build OCaml compiler lib (needed to interface CDuce with OCaml):
- Copy ocaml_cdo2cmo_patch (located in cdo2cmo directory of your cduce
archive) in the directory where you extracted OCaml sources.
- Patch OCaml's Makefile with:
patch -Nj0 < ocaml_cdo2cmo_patch
- Build OCaml's special library:
make oCaml_all.cma
THE FAST WAY:
- check local settings in Makefile.conf or do "make help" [optional]
......@@ -147,6 +159,9 @@ NATIVE=true : use the OCaml native code compiler (ocamlopt) to build CDuce
NATIVE=false : use the OCaml bytecode compiler (ocamlc)
default: true (the native code version is much faster)
ML_INTERFACE=true : build CDuce with OCaml interface support
default: false
PXP_WLEX=true : use wlex for parsing UTF-8 XML files
need pxp built with wlex support
PXP_WLEX=false: use ocamllex for parsing UTF-8 XML files
......
open Location
open Ident
ifdef ML_INTERFACE then module ML = Ml_ocaml;;
exception InvalidInputFilename of string
exception InvalidObjectFilename of string
......@@ -276,6 +278,24 @@ let run rule ppf ppf_err input =
let script = run Parser.prog
let topinput = run Parser.top_phrases
ifdef ML_INTERFACE then
let check_ml cu id out_dir out =
try
(* Load Caml .cmi file. *)
let ml_cu = ML.CompUnit.from_bytecode (cu ^ ".cmi")
and cd_cu = Ml_cduce.CompUnit.from_types_cu cu id in
(* Check file interfaces. *)
Ml_checker.run ml_cu cd_cu;
(* Generate interface file. *)
let out = open_out ( Filename.concat out_dir (cu ^ ".ml") ) in
let fmt = Format.formatter_of_out_channel out in
Ml_generator.ML.generate fmt ml_cu cd_cu;
close_out out;
with _ ->
Format.eprintf "Warning: no valid Caml interface found.@."
else
let check_ml cu id out_dir out = ();;
let compile src out_dir =
try
if not (Filename.check_suffix src ".cd")
......@@ -289,6 +309,7 @@ let compile src out_dir =
let id = Types.CompUnit.mk (U.mk_latin1 cu) in
Librarian.compile !verbose id src;
Librarian.save id out;
check_ml cu id out_dir out;
exit 0
with exn -> catch_exn Format.err_formatter exn; exit 1
......
......@@ -12,10 +12,16 @@ let args = ref []
let compile = ref false
let run = ref false
ifdef ML_INTERFACE then
let ocaml_support = true
else
let ocaml_support = false;;
let version () =
Printf.eprintf "CDuce, version %s\n" <:symbol<cduce_version>>;
Printf.eprintf "built on %s\n" <:symbol<build_date>>;
Printf.eprintf "using OCaml %s compiler\n" <:symbol<ocaml_compiler>>;
Printf.eprintf "support for ocaml interfacing: %b\n" ocaml_support;
Printf.eprintf "support for expat: %b\n" (Load_xml.expat_support);
Printf.eprintf "support for curl: %b\n" (Load_xml.curl_support);
exit 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment