From 8fc545102cc3f49374a3f965bd82d6555abb765d Mon Sep 17 00:00:00 2001 From: ygrek Date: Mon, 12 Jun 2017 22:42:15 -0700 Subject: [PATCH] examples: use lwt.ppx insteam of pa_lwt --- Makefile.in | 12 ++++++------ configure | 24 ++++++++++++------------ configure.ac | 8 ++++---- examples/Makefile.in | 16 +++++++++------- examples/test_lwt.ml | 8 +++----- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Makefile.in b/Makefile.in index 1804c1b..9f656a5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 @@ -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 @@ -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 diff --git a/configure b/configure index 2814fb9..f623398 100755 --- a/configure +++ b/configure @@ -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 @@ -4077,17 +4077,17 @@ 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 @@ -4095,23 +4095,23 @@ $as_echo "found" >&6; } 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 @@ -4119,7 +4119,7 @@ $as_echo "found" >&6; } 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 diff --git a/configure.ac b/configure.ac index fec39c3..af77116 100644 --- a/configure.ac +++ b/configure.ac @@ -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 @@ -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], diff --git a/examples/Makefile.in b/examples/Makefile.in index 45da28b..560e285 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -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 $@ diff --git a/examples/test_lwt.ml b/examples/test_lwt.ml index acfb563..1caa607 100644 --- a/examples/test_lwt.ml +++ b/examples/test_lwt.ml @@ -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 = [ -- 2.11.4.GIT