Commit 112e66df authored by Pietro Abate's avatar Pietro Abate
Browse files

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