Commit ab1f78b5 authored by Pietro Abate's avatar Pietro Abate

[r2004-06-29 23:06:06 by afrisch] Cleanup. Remove options --pxp and --expat

Original author: afrisch
Date: 2004-06-29 23:06:08+00:00
parent 6efbf17d
include Makefile.conf
VERSION = 0.2.0-rc1
all: cduce dtd2cduce validate cdo2ml cduce_lib.cma
ifeq ($(NATIVE),true)
all: cduce_lib.cmxa
endif
PACKAGES = pxp-engine pxp-lex-iso88591 ulex camlp4 num cgi pcre netstring
ifeq ($(PXP_WLEX), true)
PACKAGES += pxp-wlex-utf8
......@@ -8,6 +13,17 @@ else
PACKAGES += pxp-lex-utf8
endif
# Call make with VERBOSE=true to get a trace of commands
VERBOSE=false
ifneq ($(VERBOSE), true)
HIDE=@
else
HIDE=
endif
# webiface can be made static to be able to move it more easily
# (to compile it on a machine which is not the web server)
# Seems to be some problems with statically linking curl
......@@ -18,27 +34,6 @@ SYNTAX = -I misc/ q_symbol.cmo \
-symbol build_date=\"$(shell date +%Y-%m-%d)\" \
-symbol session_dir=\"$(SESSION_DIR)\"
ifeq ($(NATIVE), true)
SYNTAX += -symbol ocaml_compiler=\"native\"
else
SYNTAX += -symbol ocaml_compiler=\"bytecode\"
endif
ifeq ($(EXPAT), true)
PACKAGES += expat
SYNTAX += -symbol EXPAT=
endif
ifeq ($(CURL), true)
PACKAGES += curl
SYNTAX += -symbol CURL=
endif
ifeq ($(NETCLIENT), true)
PACKAGES += netclient
SYNTAX += -symbol NETCLIENT=
endif
SYNTAX_PARSER = -syntax camlp4o $(SYNTAX:%=-ppopt %)
CAMLC_P = ocamlc -g
......@@ -72,33 +67,22 @@ ifeq ($(NATIVE), true)
EXTENSION_LIB = cmxa
COMPILE = $(CAMLOPT)
LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
SYNTAX += -symbol ocaml_compiler=\"bytecode\"
else
EXTENSION = cmo
EXTENSION_LIB = cma
COMPILE = $(CAMLC)
LINK = $(CAMLC) -custom -linkpkg gramlib.cma
SYNTAX += -symbol ocaml_compiler=\"native\"
endif
ifneq ($(ML_INTERFACE), false)
SYNTAX += -symbol ML_INTERFACE=
ML_LIB = oCaml_all.$(EXTENSION_LIB)
ML_INTERFACE_OBJ = ocamliface/mltypes.cmo ocamliface/mlstub.cmo
else
ML_INTERFACE_OBJ =
endif
INSTALL := $(shell which install)
all: cduce dtd2cduce validate cdo2ml
ifneq ($(ML_INTERFACE), false)
all: cDuce_all.cma
endif
ifeq ($(NATIVE),true)
all: cDuce_all.cmxa
cDuce_all.cma:
$(MAKE) NATIVE=false $@
cduce_lib.cma:
$(HIDE)$(MAKE) NATIVE=false $@
endif
install: all install_lib
......@@ -111,18 +95,16 @@ install: all install_lib
$(INSTALL) -m644 doc/validate.1 $(MANDIR)/man1/
install_lib:
ifneq ($(ML_INTERFACE), false)
@echo "--> Build META"
@echo 'version="$(VERSION)"' > META
@echo 'requires="$(PACKAGES) camlp4.gramlib"' >> META
@echo 'description="Runtime support for CDuce"' >> META
@echo 'archive(byte)="oCaml_all.cma,cDuce_all.cma"' >> META
@echo 'archive(native)="oCaml_all.cmxa,cDuce_all.cmxa"' >> META
@echo "Build META"
$(HIDE)echo 'version="$(VERSION)"' > META
$(HIDE)echo 'requires="$(PACKAGES) camlp4.gramlib"' >> META
$(HIDE)echo 'description="Runtime support for CDuce"' >> META
$(HIDE)echo 'archive(byte)="cduce_lib.cma"' >> META
$(HIDE)echo 'archive(native)="cduce_lib.cmxa"' >> META
-$(OCAMLFIND) remove cduce
-$(OCAMLFIND) install cduce META \
cDuce_all.cmi oCaml_all.cmi \
cduce_lib.cmi cduce_lib.cmi \
$(wildcard *.cma) $(wildcard *.cmxa) $(wildcard *.a)
endif
uninstall:
rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/dtd2cduce$(EXE) \
......@@ -153,6 +135,7 @@ CLEAN_DIRS = $(DIRS) cdo2cmo tools tests
# Objects to build
OBJECTS = \
driver/config.cmo \
misc/stats.cmo \
misc/serialize.cmo misc/custom.cmo \
misc/state.cmo misc/pool.cmo misc/encodings.cmo misc/bool.cmo \
......@@ -186,9 +169,32 @@ OBJECTS = \
compile/operators.cmo \
\
types/builtin.cmo \
driver/librarian.cmo
driver/librarian.cmo \
driver/cduce.cmo
ML_INTERFACE_OBJS = \
ocamliface/caml_cduce.cmo ocamliface/mltypes.cmo ocamliface/mlstub.cmo
ifneq ($(ML_INTERFACE), false)
OBJECTS += $(ML_INTERFACE_OBJS)
endif
ifneq ($(CURL), false)
OBJECTS += parser/cduce_curl.cmo
PACKAGES += curl
endif
ifneq ($(NETCLIENT), false)
OBJECTS += parser/cduce_netclient.cmo
PACKAGES += netclient
endif
ifeq ($(EXPAT), true)
OBJECTS += runtime/cduce_expat.cmo
PACKAGES += expat
else
OBJECTS += runtime/cduce_pxp.cmo
endif
OBJECTS += $(ML_INTERFACE_OBJ) driver/cduce.cmo
CQL_OBJECTS= query/query.cmo query/query_parse.cmo
CQL_OBJECTS_RUN = query/query_run.cmo
......@@ -205,45 +211,43 @@ ALL_OBJECTS = $(OBJECTS) $(CQL_OBJECTS) \
$(CQL_OBJECTS_RUN)
ALL_INTERFACES = schema/schema_types.mli
ifneq ($(ML_INTERFACE), false)
ALL_INTERFACES += ocamliface/mltypes.mli ocamliface/mlstub.mli
endif
DEPEND = $(ALL_OBJECTS:.cmo=.ml) $(ALL_OBJECTS:.cmo=.mli) $(ALL_INTERFACES)
INCLUDES = $(DIRS:%=-I %)
cduce: $(CDUCE:.cmo=.$(EXTENSION))
$(LINK) $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_LINK_OPTS)
@echo "Build $@"
$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
cduce_packed.ml: $(CDUCE:.cmo=.ml)
rm -f cduce_packed.ml
ocaml tools/pack.ml $^ > cduce_packed.ml
cduce_packed: cduce_packed.$(EXTENSION)
$(LINK) $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_LINK_OPTS)
$(LINK) $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
cDuce_all.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
@echo "--> Build $@"
@$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
@$(COMPILE) -a -o $@ cDuce_all.$(EXTENSION)
cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
@echo "Build $@"
$(HIDE)$(COMPILE) -o cduce_lib.$(EXTENSION) -pack $^
$(HIDE)$(COMPILE) -a -o $@ cduce_lib.$(EXTENSION)
oCaml_all.$(EXTENSION_LIB):
cd cdo2cmo; $(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) $@
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
$(LINK) -verbose $(INCLUDES) -o $@ $(ML_LIB) $^ $(EXTRA_OPTS_WEBIFACE)
@echo "Build $@"
$(HIDE)$(LINK) -verbose $(INCLUDES) -o $@ $^ $(EXTRA_OPTS_WEBIFACE)
dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION))
$(LINK) $(INCLUDES) -o $@ $^
@echo "Build $@"
$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
$(LINK) $(INCLUDES) -o $@ $^
@echo "Build $@"
$(HIDE)$(LINK) $(INCLUDES) -o $@ $^
cdo2ml: ocamliface/cdo2ml.ml
ocamlc -o $@ -pp camlp4o -I +camlp4 camlp4.cma pr_o.cmo $^
@echo "Build $@"
$(HIDE)ocamlc -o $@ -pp camlp4o -I +camlp4 camlp4.cma pr_o.cmo $^
.PHONY: compute_depend
compute_depend: $(DEPEND_OCAMLDEP)
......@@ -255,7 +259,7 @@ clean:
for i in $(CLEAN_DIRS); do \
(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
done
(cd expat; $(MAKE) clean)
rm -f ocamliface/cmi2ml ocamliface/asttypes.ml
rm -f `find . -name "*~"`
rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
rm -f cduce$(EXE) ocamlprof.dump
......@@ -267,7 +271,7 @@ clean:
distclean: clean
rm -f Makefile.conf
$(ML_INTERFACE_OBJ:.cmo=.$(EXTENSION)): oCaml_all.$(EXTENSION_LIB)
ocamliface/mltypes.$(EXTENSION)): ocamliface/caml_cduce.$(EXTENSION)
$(ALL_OBJECTS:.cmo=.$(EXTENSION)): misc/q_symbol.cmo
$(ALL_INTERFACES): misc/q_symbol.cmo
......@@ -275,16 +279,20 @@ $(ALL_INTERFACES): misc/q_symbol.cmo
.SUFFIXES: .ml .mli .cmo .cmi .cmx
misc/q_symbol.cmo: misc/q_symbol.ml
$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
@echo "Build $@"
$(HIDE)$(CAMLC) -c -pp 'camlp4o pa_extend.cmo q_MLast.cmo' $<
.ml.cmo:
$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
@echo "Build $@"
$(HIDE)$(CAMLC) -c $(INCLUDES) $(SYNTAX_PARSER) $<
.ml.cmx:
$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
@echo "Build $@"
$(HIDE)$(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
.mli.cmi:
$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
@echo "Build $@"
$(HIDE)$(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
include depend
......@@ -313,3 +321,16 @@ install_web: website
fi;
cp web/img/*.* $(HTML_DIR)/img
### Pack OCaml modules for the CDuce/OCaml interface
ocamliface/caml_cduce.cmo:
@cd ocamliface; \
$(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) \
HIDE=$(HIDE) caml_cduce.cmo
ocamliface/caml_cduce.cmx:
@cd ocamliface; \
$(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) \
HIDE=$(HIDE) caml_cduce.cmx
# This Makefile generates oCaml_all.cma/.cmxa and put it in ..
# This Makefile generates oCaml_cduce.cmo/.cmx and put it in ..
#
# We need the units such that typing/types.cmo (.cmx)
# - If OCaml has been compiler in a directory DIR,
# you can do:
# make MODEL=tree PREFIX=DIR
# e.g.: make oCaml_all.cma MODEL=tree PREFIX=$HOME/ocaml-3.07
# e.g.: make oCaml_cduce.cmo MODEL=tree PREFIX=$HOME/ocaml-3.07
#
# - If you have a (flat) directory DIR will all the compiled units
# from utils/ parsing/ and typing/, you can do:
# make MODEL=flat PREFIX=DIR
# e.g.: make oCaml_all.cma MODEL=fal PREFIX=$HOME/godi/lib/ocaml/compiler-lib
# e.g.: make oCaml_cduce.cmo MODEL=fal PREFIX=$HOME/godi/lib/ocaml/compiler-lib
OBJECTS=asttypes.ml $(patsubst %,$(PREFIX)/%, $(UNITS))
......@@ -29,39 +29,49 @@ else
endif
endif
oCaml_all.cma:
ocamlc -pack -o oCaml_all.cmo $(INCLUDES) $(OBJECTS)
ocamlc -a -o oCaml_all.cma oCaml_all.cmo
mv oCaml_all.cma oCaml_all.cmi ..
rm -f oCaml_all.*
oCaml_cduce.cma:
ocamlc -pack -o oCaml_cduce.cmo $(INCLUDES) $(OBJECTS)
mv oCaml_cduce.cmo oCaml_cduce.cmi ..
oCaml_all.cmxa:
ocamlopt -pack -o oCaml_all.cmx $(INCLUDES) $(XOBJECTS)
ocamlopt -a -o oCaml_all.cmxa oCaml_all.cmx
mv oCaml_all.cmxa oCaml_all.a oCaml_all.cmi ..
rm -f oCaml_all.*
oCaml_cduce.cmxa:
ocamlopt -pack -o oCaml_cduce.cmx $(INCLUDES) $(XOBJECTS)
mv oCaml_cduce.cmx oCaml_cduce.o oCaml_cduce.cmi ..
clean:
rm -f oCaml_all.* *~
rm -f oCaml_cduce.* *~
UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \
utils/clflags.cmo utils/terminfo.cmo utils/ccomp.cmo utils/warnings.cmo \
utils/consistbl.cmo
utils/clflags.cmo utils/consistbl.cmo
PARSING=parsing/linenum.cmo parsing/location.cmo parsing/longident.cmo \
parsing/syntaxerr.cmo parsing/parser.cmo \
parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo
PARSING=parsing/longident.cmo
TYPING=typing/ident.cmo typing/path.cmo \
typing/primitive.cmo typing/types.cmo \
typing/btype.cmo typing/oprint.cmo \
typing/subst.cmo typing/predef.cmo \
typing/datarepr.cmo typing/env.cmo \
typing/typedtree.cmo typing/ctype.cmo \
typing/printtyp.cmo typing/includeclass.cmo \
typing/mtype.cmo typing/includecore.cmo \
typing/includemod.cmo typing/parmatch.cmo \
typing/typetexp.cmo typing/stypes.cmo typing/typecore.cmo \
typing/typedecl.cmo typing/typeclass.cmo \
typing/typemod.cmo
typing/ctype.cmo typing/printtyp.cmo
#UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \
# utils/clflags.cmo utils/terminfo.cmo utils/ccomp.cmo utils/warnings.cmo \
# utils/consistbl.cmo
#
#PARSING=parsing/linenum.cmo parsing/location.cmo parsing/longident.cmo \
# parsing/syntaxerr.cmo parsing/parser.cmo \
# parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo
#
#TYPING=typing/ident.cmo typing/path.cmo \
# typing/primitive.cmo typing/types.cmo \
# typing/btype.cmo typing/oprint.cmo \
# typing/subst.cmo typing/predef.cmo \
# typing/datarepr.cmo typing/env.cmo \
# typing/typedtree.cmo typing/ctype.cmo \
# typing/printtyp.cmo typing/includeclass.cmo \
# typing/mtype.cmo typing/includecore.cmo \
# typing/includemod.cmo typing/parmatch.cmo \
# typing/typetexp.cmo typing/stypes.cmo typing/typecore.cmo \
# typing/typedecl.cmo typing/typeclass.cmo \
# typing/typemod.cmo
This diff is collapsed.
let ocaml_iface = ref false
let curl_support = ref false
let netclient_support = ref false
let expat_support = ref false
let pxp_support = ref false
......@@ -12,19 +12,15 @@ 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" (Url.curl_support);
Printf.eprintf "support for netclient: %b\n" (Url.netclient_support);
Printf.eprintf "support for ocaml interfacing: %b\n" !Config.ocaml_iface;
Printf.eprintf "support for pxp: %b\n" !Config.pxp_support;
Printf.eprintf "support for expat: %b\n" !Config.expat_support;
Printf.eprintf "support for curl: %b\n" !Config.curl_support;
Printf.eprintf "support for netclient: %b\n" !Config.netclient_support;
exit 0
let license () =
......@@ -70,23 +66,6 @@ let specs = ref
let ppf = Format.std_formatter
let ppf_err = Format.err_formatter
let () =
if Load_xml.expat_support then
specs :=
("--expat", Arg.Unit (fun () -> Load_xml.use_parser := `Expat),
" use expat parser (default)") ::
("--pxp", Arg.Unit (fun () -> Load_xml.use_parser := `Pxp),
" use PXP parser") ::
!specs
else
specs :=
("--expat", Arg.Unit (fun () -> (Format.fprintf ppf "WARNING: --expat unused option. CDuce compiled without expat support\n\n")),
" option not available: CDuce was compiled without expat support") ::
("--pxp", Arg.Unit (fun () -> (Format.fprintf ppf "WARNING: --pxp useless option. CDuce compiled without expat support\n\n")),
" useless option: CDuce was compiled without expat support") ::
!specs
let err s =
prerr_endline s;
exit 1
......
# This Makefile generates caml_cduce.cmo/.cmx
#
# We need the units such that typing/types.cmo (.cmx)
#
# - If OCaml has been compiled in a directory DIR,
# you can do:
# make MODEL=tree PREFIX=DIR
# e.g.: make caml_cduce.cmo MODEL=tree PREFIX=$HOME/ocaml-3.07
#
# - If you have a (flat) directory DIR will all the compiled units
# from utils/ parsing/ and typing/, you can do:
# make MODEL=flat PREFIX=DIR
# e.g.: make caml_cduce.cmo MODEL=flat PREFIX=$HOME/godi/lib/ocaml/compiler-lib
OCAML_OBJECTS=$(patsubst %,$(PREFIX)/%, $(UNITS))
OBJECTS=asttypes.ml $(OCAML_OBJECTS)
XOBJECTS=$(OBJECTS:.cmo=.cmx)
ifeq ($(MODEL),flat)
UNITS= $(subst utils/,,$(UTILS)) \
$(subst parsing/,,$(PARSING)) \
$(subst typing/,,$(TYPING))
INCLUDES = -I $(PREFIX)
ASTTYPES = $(PREFIX)/asttypes.cmi
else
ifeq ($(MODEL),tree)
UNITS= $(UTILS) $(PARSING) $(TYPING)
INCLUDES = -I $(PREFIX)/utils -I $(PREFIX)/parsing -I $(PREFIX)/typing
ASTTYPES = $(PREFIX)/parsing/asttypes.cmi
else
$(error Set MODEL=flat or MODEL=tree)
endif
endif
caml_cduce.cmo: asttypes.ml
@echo "Build $@"
$(HIDE)ocamlc -pack -o $@ $(INCLUDES) $(OBJECTS)
caml_cduce.cmx: asttypes.ml
@echo "Build $@"
$(HIDE)ocamlopt -pack -o $@ $(INCLUDES) $(XOBJECTS)
## Hack to rebuild asttypes.ml from asttypes.cmi
## (because -pack needs .cmo in 3.07)
.PHONY: asttypes.ml
asttypes.ml: cmi2ml
@echo "Create $@"
$(HIDE)./cmi2ml Asttypes $(ASTTYPES) > asttypes.ml
cmi2ml: cmi2ml.ml
@echo "Build $@"
$(HIDE)ocamlc -o $@ $(INCLUDES) $(OCAML_OBJECTS) $<
UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \
utils/clflags.cmo utils/consistbl.cmo
PARSING=parsing/longident.cmo
TYPING=typing/ident.cmo typing/path.cmo \
typing/primitive.cmo typing/types.cmo \
typing/btype.cmo typing/oprint.cmo \
typing/subst.cmo typing/predef.cmo \
typing/datarepr.cmo typing/env.cmo \
typing/ctype.cmo typing/printtyp.cmo
#UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \
# utils/clflags.cmo utils/terminfo.cmo utils/ccomp.cmo utils/warnings.cmo \
# utils/consistbl.cmo
#
#PARSING=parsing/linenum.cmo parsing/location.cmo parsing/longident.cmo \
# parsing/syntaxerr.cmo parsing/parser.cmo \
# parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo
#
#TYPING=typing/ident.cmo typing/path.cmo \
# typing/primitive.cmo typing/types.cmo \
# typing/btype.cmo typing/oprint.cmo \
# typing/subst.cmo typing/predef.cmo \
# typing/datarepr.cmo typing/env.cmo \
# typing/typedtree.cmo typing/ctype.cmo \
# typing/printtyp.cmo typing/includeclass.cmo \
# typing/mtype.cmo typing/includecore.cmo \
# typing/includemod.cmo typing/parmatch.cmo \
# typing/typetexp.cmo typing/stypes.cmo typing/typecore.cmo \
# typing/typedecl.cmo typing/typeclass.cmo \
# typing/typemod.cmo
let () =
let sg = Env.read_signature Sys.argv.(1) Sys.argv.(2) in
Printtyp.signature Format.std_formatter sg
......@@ -534,4 +534,6 @@ let () =
let cdt = Types.descr (typ t) in
vars := [| |];
cdt
)
);
Config.ocaml_iface := true
exception Error of string
open OCaml_all
open Caml_cduce
open Asttypes
open Types
......
open OCaml_all
open Caml_cduce
open Asttypes
open Types
......
let load_url s =
let buff = Buffer.create 4096 in
let conn = Curl.init () in
Curl.set_url conn s;
Curl.set_writefunction conn (Buffer.add_string buff);
Curl.perform conn;
Buffer.contents buff
let () =
Url.load_url := load_url;
Config.curl_support := true
let load_url s =
match Neturl.extract_url_scheme s with
| "http" ->
(try Http_client.Convenience.http_get s
with
| Http_client.Bad_message s ->
let msg = Printf.sprintf "Netclient. Bad http answer: %s" s in
raise (Location.Generic msg)
| Http_client.Http_error (n,s) ->
let msg = Printf.sprintf "Netclient. Http error %i: %s" n s in
raise (Location.Generic msg)
| Http_client.No_reply ->
raise (Location.Generic "Netclient. No reply")
| Http_client.Http_protocol exn ->
let msg = Printf.sprintf "Netclient. %s"
(Printexc.to_string exn) in
raise (Location.Generic msg)
)
| "file" ->
raise (Location.Generic
"FIXME: write in url.ml the code so that netclient \
handle file:// protocol")
| sc ->
let msg =
Printf.sprintf "Error: netclient does not handle the %s protocol" sc
in
raise (Location.Generic msg)
let () =
Url.load_url := load_url;
Config.netclient_support := true
type url = Filename of string | Url of string
ifdef CURL then
let curl_support = true
else
let curl_support = false
ifdef NETCLIENT then
let netclient_support = true
else
let netclient_support = false
let is_url s =
try let _ = Neturl.extract_url_scheme s in true
with Neturl.Malformed_URL -> false
ifdef CURL then
let load_url s =
let buff = Buffer.create 4096 in
let conn = Curl.init () in
Curl.set_url conn s;
Curl.set_writefunction conn (Buffer.add_string buff);
Curl.perform conn;
Buffer.contents buff
else
ifdef NETCLIENT then
let load_url s =
match Neturl.extract_url_scheme s with
| "http" ->
(try Http_client.Convenience.http_get s
with
| Http_client.Bad_message s ->
let msg = Printf.sprintf "Netclient. Bad http answer: %s" s in
raise (Location.Generic msg)
| Http_client.Http_error (n,s) ->
let msg = Printf.sprintf "Netclient. Http error %i: %s" n s in
raise (Location.Generic msg)
| Http_client.No_reply ->
raise (Location.Generic "Netclient. No reply")
| Http_client.Http_protocol exn ->
let msg = Printf.sprintf "Netclient. %s"
(Printexc.to_string exn) in
raise (Location.Generic msg)
)
| "file" ->
raise (Location.Generic
"FIXME: write in url.ml the code so that netclient \
handle file:// protocol")
| sc ->
let msg =
Printf.sprintf "Error: netclient does not handle the %s protocol" sc
in
raise (Location.Generic msg)
else
let load_url s =
let msg =
Printf.sprintf
"Error \"%s\": \nTo fetch external URLs, you need to compile CDuce with curl and/or netclient" s
in
raise (Location.Generic msg)
let no_load_url s =
let msg =
Printf.sprintf
"Error \"%s\": \nTo fetch external URLs, you need to compile CDuce with curl and/or netclient" s
in
raise (Location.Generic msg)
let load_url = ref no_load_url