Skip to content

Commit

Permalink
examples: use lwt.ppx insteam of pa_lwt
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrek committed Jun 13, 2017
1 parent d1967b6 commit 8fc5451
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
12 changes: 6 additions & 6 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ CURLBCOBJS = $(CURLOBJS:.cmx=.cmo)
CLIBS = @CURLLIBS@

TARGETS := curl.cma libcurl-helper$(EXT_LIB) dllcurl-helper$(EXT_DLL)
ifneq (@OCAML_PKG_lwt@,no)
ifneq (@OCAML_PKG_lwt_unix@,no)
TARGETS += curl_lwt.cmo
endif
ifeq (@OCAMLBEST@,opt)
TARGETS += curl.cmxa curl.cmx
ifneq (@OCAML_PKG_lwt@,no)
ifneq (@OCAML_PKG_lwt_unix@,no)
TARGETS += curl_lwt.cmx
endif
endif
Expand All @@ -49,7 +49,7 @@ INSTALL_TARGETS = curl$(EXT_LIB) curl.cmi curl.mli $(TARGETS)
ifeq (@OCAML_HAS_BIN_ANNOT@,yes)
INSTALL_TARGETS += curl.cmt curl.cmti
endif
ifneq (@OCAML_PKG_lwt@,no)
ifneq (@OCAML_PKG_lwt_unix@,no)
INSTALL_TARGETS += curl_lwt.cmi curl_lwt.mli curl_lwt$(EXT_OBJ)
ifeq (@OCAML_HAS_BIN_ANNOT@,yes)
INSTALL_TARGETS += curl_lwt.cmt curl_lwt.cmti
Expand All @@ -65,20 +65,20 @@ build: all
test: examples
examples/test_cb_exn
examples/test_memory_leaks
ifneq (@OCAML_PKG_lwt@,no)
ifneq (@OCAML_PKG_lwt_unix@,no)
examples/test_lwt_unit
endif
ifeq (@OCAMLBEST@,opt)
examples/test_cb_exn.opt
examples/test_memory_leaks.opt
ifneq (@OCAML_PKG_lwt@,no)
ifneq (@OCAML_PKG_lwt_unix@,no)
examples/test_lwt_unit.opt
endif
endif

doc:
mkdir -p doc
ifneq (@OCAML_PKG_lwt@,no)
ifneq (@OCAML_PKG_lwt_unix@,no)
ocamlfind ocamldoc -html -d doc -package lwt curl.mli curl_lwt.mli
else
ocamldoc -html -d doc curl.mli
Expand Down
24 changes: 12 additions & 12 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ OCAML_HAS_BIN_ANNOT
INSTALLDIR
CURLLIBS
ac_prefix_program
OCAML_PKG_camlp4
OCAML_PKG_lwt
OCAML_PKG_lwt_ppx
OCAML_PKG_lwt_unix
OCAMLFIND
OCAMLBUILD
OCAMLDOC
Expand Down Expand Up @@ -4077,49 +4077,49 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package lwt" >&5
$as_echo_n "checking for OCaml findlib package lwt... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package lwt.unix" >&5
$as_echo_n "checking for OCaml findlib package lwt.unix... " >&6; }
unset found
unset pkg
found=no
for pkg in lwt ; do
for pkg in lwt.unix ; do
if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
OCAML_PKG_lwt=$pkg
OCAML_PKG_lwt_unix=$pkg
found=yes
break
fi
done
if test "$found" = "no" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
OCAML_PKG_lwt=no
OCAML_PKG_lwt_unix=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package camlp4" >&5
$as_echo_n "checking for OCaml findlib package camlp4... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package lwt.ppx" >&5
$as_echo_n "checking for OCaml findlib package lwt.ppx... " >&6; }
unset found
unset pkg
found=no
for pkg in camlp4 ; do
for pkg in lwt.ppx ; do
if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
OCAML_PKG_camlp4=$pkg
OCAML_PKG_lwt_ppx=$pkg
found=yes
break
fi
done
if test "$found" = "no" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
OCAML_PKG_camlp4=no
OCAML_PKG_lwt_ppx=no
fi
Expand Down
8 changes: 4 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ AC_PROG_INSTALL()
AC_PROG_OCAML()
AC_PROG_FINDLIB()

AC_CHECK_OCAML_PKG([lwt])
AC_CHECK_OCAML_PKG([camlp4])
AC_CHECK_OCAML_PKG([lwt.unix])
AC_CHECK_OCAML_PKG([lwt.ppx])

INSTALLDIR=$OCAMLLIB/curl

Expand All @@ -31,8 +31,8 @@ AC_SUBST(CURLLIBS)
AC_SUBST(OCAMLLIB)
AC_SUBST(INSTALLDIR)
AC_SUBST(OCAMLFIND)
AC_SUBST(OCAML_PKG_lwt)
AC_SUBST(OCAML_PKG_camlp4)
AC_SUBST(OCAML_PKG_lwt_unix)
AC_SUBST(OCAML_PKG_lwt_ppx)

AS_IF([test "$OCAMLFIND" == "no"],
[$OCAMLC -I +compiler-libs ocamlcommon.cma print_ext.ml -o print_ext],
Expand Down
16 changes: 9 additions & 7 deletions examples/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@ OCURLLIB = curl.cma unix.cma threads.cma
OCURLOPTLIB = curl.cmxa unix.cmxa threads.cmxa

TARGETS = ocurl oput ominimal ossl ocurl_test_threads opar test_cb_exn test_memory_leaks
ifneq (@OCAML_PKG_lwt@,no)
ifneq (@OCAML_PKG_camlp4@,no)
TARGETS += test_lwt test_lwt_unit
ifneq (@OCAML_PKG_lwt_unix@,no)
TARGETS += test_lwt_unit
ifneq (@OCAML_PKG_lwt_ppx@,no)
TARGETS += test_lwt
endif
endif

ifeq (@OCAMLBEST@,opt)
TARGETS += ocurl.opt oput.opt ominimal.opt ossl.opt ocurl_test_threads.opt opar.opt test_cb_exn.opt test_memory_leaks.opt
ifneq (@OCAML_PKG_lwt@,no)
ifneq (@OCAML_PKG_camlp4@,no)
TARGETS += test_lwt.opt test_lwt_unit.opt
ifneq (@OCAML_PKG_lwt_unix@,no)
TARGETS += test_lwt_unit.opt
ifneq (@OCAML_PKG_lwt_ppx@,no)
TARGETS += test_lwt.opt
endif
endif
endif

all: $(TARGETS)

FINDLIB_LWT_FLAGS=-linkpkg -syntax camlp4o -package lwt.unix,lwt.syntax
FINDLIB_LWT_FLAGS=-linkpkg -package lwt.unix,lwt.ppx

test_lwt: ../curl.cma ../curl_lwt.cmo test_lwt.ml
$(FINDLIB) c -custom $(FINDLIB_LWT_FLAGS) $(LFLAGS) $^ -o $@
Expand Down
8 changes: 3 additions & 5 deletions examples/test_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ let get url =
let h = Curl.init () in
Curl.set_url h url;
curl_setup_simple h;
try_lwt (* e.g. Canceled *)
lwt (code,_body) = download h in
begin try%lwt (* e.g. Canceled *)
let%lwt (code,_body) = download h in
log_curl h code;
Lwt.return ()
(* do something with body *)
with exn ->
printfn "EXN %s URL: %s" (Printexc.to_string exn) url;
Lwt.fail exn
finally
Curl.cleanup h;
Lwt.return ()
end[%lwt.finally Curl.cleanup h; Lwt.return ()]

let urls =
[
Expand Down

0 comments on commit 8fc5451

Please sign in to comment.