Commit e6868df0 authored by Pietro Abate's avatar Pietro Abate

[r2005-07-15 13:51:37 by afrisch] Get rid of mlcduce_wrapper

Original author: afrisch
Date: 2005-07-15 13:51:37+00:00
parent da938ce4
version="%VER%"
requires="%REQ% camlp4.gramlib"
description="Runtime support for CDuce"
archive(byte)="cduce_lib.cma"
archive(native)="cduce_lib.cmxa"
archive(byte)="+camlp4/camlp4.cma +camlp4/pr_o.cmo cduce_lib.cma"
archive(native)="+camlp4/camlp4.cmxa +camlp4/pr_o.cmx cduce_lib.cmxa"
......@@ -6,8 +6,7 @@ ALL_TARGET=cduce cduce_lib.cma
INSTALL_BINARIES=cduce$(EXE)
ifneq ($(ML_INTERFACE), false)
ALL_TARGET += mlcduce_wrapper
INSTALL_BINARIES += mlcduce_wrapper$(EXE) cduce_mktop
INSTALL_BINARIES += cduce_mktop
endif
......@@ -67,14 +66,14 @@ ifeq ($(NATIVE), true)
EXTENSION_LIB = cmxa
CAML=ocamlopt
COMPILE = $(CAMLOPT)
LINK = $(CAMLOPT) -linkpkg gramlib.cmxa camlp4.cmxa pr_o.cmx
LINK = $(CAMLOPT) -linkpkg gramlib.cmxa camlp4o.cmxa
SYNTAX += -symbol ocaml_compiler=\"native\"
else
EXTENSION = cmo
EXTENSION_LIB = cma
COMPILE = $(CAMLC)
CAML=ocamlc
LINK = $(CAMLC) -custom -linkpkg gramlib.cma camlp4.cma pr_o.cmo
LINK = $(CAMLC) -custom -linkpkg gramlib.cma camlp4o.cma
SYNTAX += -symbol ocaml_compiler=\"bytecode\"
endif
......@@ -104,8 +103,7 @@ install_lib:
uninstall:
rm -f $(BINDIR)/cduce$(EXE) \
$(BINDIR)/mlcduce_wrapper$(EXE) $(BINDIR)/cduce_mktop
rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/cduce_mktop
rm -f $(MANDIR)/man1/cduce.1
rm -Rf $(DOCDIR)
ocamlfind remove cduce
......@@ -127,7 +125,7 @@ CLEAN_DIRS = $(DIRS) cdo2cmo tools tests
# Objects to build
LIB_OBJECTS = \
OBJECTS = \
driver/config.cmo misc/stats.cmo misc/custom.cmo misc/encodings.cmo \
misc/upool.cmo misc/pretty.cmo misc/ns.cmo misc/imap.cmo misc/html.cmo \
\
......@@ -161,8 +159,6 @@ LIB_OBJECTS = \
\
runtime/system.cmo query/query_aggregates.cmo
OBJECTS=$(LIB_OBJECTS)
schema/schema_types.ml: schema/schema_types.mli
cp $^ $@
compile/auto_pat.ml: compile/auto_pat.mli
......@@ -179,11 +175,11 @@ ifneq ($(ML_INTERFACE), false)
endif
ifneq ($(CURL), false)
LIB_OBJECTS += parser/cduce_curl.cmo
OBJECTS += parser/cduce_curl.cmo
PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
LIB_OBJECTS += parser/cduce_netclient.cmo
OBJECTS += parser/cduce_netclient.cmo
PACKAGES += netclient
endif
......@@ -195,11 +191,11 @@ else
endif
ifeq ($(PXP),true)
LIB_OBJECTS += runtime/cduce_pxp.cmo
OBJECTS += runtime/cduce_pxp.cmo
PACKAGES += $(PXP_PACK)
endif
ifeq ($(EXPAT), true)
LIB_OBJECTS += runtime/cduce_expat.cmo
OBJECTS += runtime/cduce_expat.cmo
PACKAGES += expat
endif
......@@ -233,7 +229,7 @@ cduce_packed: cduce_packed.$(EXTENSION)
$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
cduce_lib.$(EXTENSION_LIB): $(LIB_OBJECTS:.cmo=.$(EXTENSION))
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
@echo "Pack cduce_lib.$(EXTENSION)"
$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) -pack $^
@echo "Build $@"
......@@ -243,10 +239,6 @@ dtd2cduce: tools/dtd2cduce.ml
@echo "Build $@"
$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -ccopt -static -package "$(PXP_PACK) cgi" -linkpkg $^
mlcduce_wrapper: $(OBJECTS) ocamliface/mlcduce_wrapper.ml
@echo "Build $@"
$(HIDE)$(CAMLC) -linkpkg $(INCLUDES) -o $@ odyl.cma camlp4.cma pr_o.cmo $^ $(EXTRA_LINK_OPTS)
.PHONY: compute_depend
compute_depend: $(DEPEND_OCAMLDEP)
@echo "Computing dependencies ..."
......@@ -260,8 +252,7 @@ clean:
rm -f `find . -name "*~"`
rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
rm -f cduce$(EXE) ocamlprof.dump
rm -f dtd2cduce$(EXE) webiface$(EXE) cduce_validate$(EXE) \
mlcduce_wrapper$(EXE) evaluator$(EXE)
rm -f dtd2cduce$(EXE) webiface$(EXE) evaluator$(EXE)
rm -Rf prepro package
rm -f web/www/*.html web/*~
rm -f web/*.cdo
......
VERSION=0.3.9
VERSION=0.3.91
......@@ -50,4 +50,4 @@ fi
echo "Effective flags for CDuce: $FLAGS"
echo "Effective flags for OCaml: $LINK"
exec ocamlfind $CAML -package cduce -o $TARG $FLAGS -linkpkg -pp "mlcduce_wrapper $FLAGS" $LINK -impl $PRIMS
exec ocamlfind $CAML -package cduce -o $TARG $FLAGS -linkpkg -pp "cduce --topstub $FLAGS" $LINK -impl $PRIMS
......@@ -270,3 +270,5 @@ let ocaml_stub stub =
let name d = (from_descr d).name
let run d = run (from_descr d)
let make_wrapper = ref (fun _ ->
failwith "OCaml/CDuce interface not available")
......@@ -30,3 +30,4 @@ val register_static_external: string -> Value.t -> unit
val get_builtins: unit -> string list
val make_wrapper: (string -> unit) ref
......@@ -8,6 +8,7 @@ let compile = ref false
let run = ref false
let script = ref false
let mlstub = ref false
let topstub = ref false
let version () =
Printf.eprintf "CDuce, version %s\n" <:symbol<cduce_version>>;
......@@ -47,6 +48,8 @@ let specs =
"print CDuce version, and list built-in optional features";
"--mlstub", Arg.Set mlstub,
" produce stub ML code from a compiled unit";
"--topstub", Arg.Set topstub,
"produce stub ML code for a toplevel from a primitive file";
]
let ppf = Format.std_formatter
......@@ -62,6 +65,9 @@ let mode () =
if (!mlstub) then (
match !src with [x] -> `Mlstub x | _ ->
err "Please specify one .cdo file"
) else if (!topstub) then (
match !src with [x] -> `Topstub x | _ ->
err "Please specify one primitive file"
) else match (!compile,!out_dir,!run,!src,!args) with
| false, _::_, _, _, _ ->
err "--obj-dir option can be used only with --compile"
......@@ -160,3 +166,6 @@ let main () =
| `Mlstub f ->
Config.init_all ();
Librarian.prepare_stub f
| `Topstub f ->
Config.init_all ();
!Librarian.make_wrapper f
......@@ -624,6 +624,25 @@ let gen_wrapper vals =
wrapper values
with Mltypes.Error s -> raise (Location.Generic s)
let make_wrapper fn =
let ic = open_in fn in
let v = ref [] in
(try while true do
let s = input_line ic in
if s <> "" then
match s.[0] with
| 'A'..'Z' -> v := s :: !v
| '#' -> ()
| _ -> failwith "Error in primitive file: names must start with a capitalized letter"
done
with End_of_file -> ());
let s = gen_wrapper !v in
!Pcaml.print_implem [ s,loc ];
print_endline "let () = Librarian.obj_path := [";
List.iter (fun s -> Printf.printf " %S;\n" s) !Librarian.obj_path;
print_endline " ];;";
print_endline "let () = Run.main ();;"
(* Dynamic coercions *)
......@@ -656,7 +675,8 @@ let register () =
(fun cu -> Mltypes.has_cmi (U.get_str cu));
Librarian.stub_ml := stub_ml;
Externals.register := register;
Externals.ext_info := (fun () -> Obj.magic !exts)
Externals.ext_info := (fun () -> Obj.magic !exts);
Librarian.make_wrapper := make_wrapper
let () =
Config.register
......
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