From ff30789343c3cbffc909cc296ff29908e2b33399 Mon Sep 17 00:00:00 2001 From: Jonathan Chan Date: Sun, 20 Dec 2015 23:29:10 -0800 Subject: [PATCH 1/3] Patch myocamlbuild.ml to not use internal ocamlbuild function. I was running into the following error: ocamlbuild -no-links -tag debug client_server_test.byte + /usr/local/bin/ocamlopt.opt unix.cmxa -I /usr/local/lib/ocaml/ocamlbuild /usr/local/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/local/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild File "myocamlbuild.ml", line 12, characters 4-76: Error: This expression has type Lexing.lexbuf but an expression was expected of type Ocamlbuild_pack.Loc.source = string The interface of an internal ocamlbuild function that was used to implement [find_packages] must have changed. I replaced it with a simple reimplementation using the standard library. --- samples/myocamlbuild.ml | 23 ++++++++++++++++------- src/myocamlbuild.ml | 21 +++++++++++++++------ test/myocamlbuild.ml | 21 +++++++++++++++------ 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/samples/myocamlbuild.ml b/samples/myocamlbuild.ml index e874f13..584b7bf 100644 --- a/samples/myocamlbuild.ml +++ b/samples/myocamlbuild.ml @@ -2,15 +2,24 @@ open Ocamlbuild_plugin (* ocamlfind integration following http://www.nabble.com/forum/ViewPost.jtp?post=15979274 *) -(* these functions are not really officially exported *) -let run_and_read = Ocamlbuild_pack.My_unix.run_and_read -let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings +let run_command cmd = + let chan = Unix.open_process_in cmd in + let out = + let rec loop xs = + match input_line chan with + | x -> loop (x :: xs) + | exception End_of_file -> List.rev xs + in loop [] + in + match Unix.close_process_in chan with + | Unix.WEXITED 0 -> `Ok out + | x -> `Error x (* this lists all supported packages *) let find_packages () = - blank_sep_strings & - Lexing.from_string & - run_and_read "ocamlfind list | cut -d' ' -f1" + match run_command "ocamlfind list | cut -d' ' -f1" with + | `Ok xs -> xs + | `Error _ -> failwith "Failed to find packages." (* this lists all supported packages *) let find_syntaxes () = ["camlp4o"] @@ -33,7 +42,7 @@ dispatch begin function (* When one link an OCaml library/binary/package, one should use -linkpkg *) flag ["ocaml"; "compile"] (S[A"-dtypes"]); - flag ["ocaml"; "compile"] (S[A"-warn-error"; A"Ay"]); + flag ["ocaml"; "compile"] (S[A"-warn-error"; A"ay"]); flag ["ocaml"; "compile"] (S[A"-ppopt"; A"-lwt-debug"]); flag ["ocaml"; "link"] & A"-linkpkg"; diff --git a/src/myocamlbuild.ml b/src/myocamlbuild.ml index 37c507b..7267154 100644 --- a/src/myocamlbuild.ml +++ b/src/myocamlbuild.ml @@ -2,15 +2,24 @@ open Ocamlbuild_plugin (* ocamlfind integration following http://www.nabble.com/forum/ViewPost.jtp?post=15979274 *) -(* these functions are not really officially exported *) -let run_and_read = Ocamlbuild_pack.My_unix.run_and_read -let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings +let run_command cmd = + let chan = Unix.open_process_in cmd in + let out = + let rec loop xs = + match input_line chan with + | x -> loop (x :: xs) + | exception End_of_file -> List.rev xs + in loop [] + in + match Unix.close_process_in chan with + | Unix.WEXITED 0 -> `Ok out + | x -> `Error x (* this lists all supported packages *) let find_packages () = - blank_sep_strings & - Lexing.from_string & - run_and_read "ocamlfind list | cut -d' ' -f1" + match run_command "ocamlfind list | cut -d' ' -f1" with + | `Ok xs -> xs + | `Error _ -> failwith "Failed to find packages." (* this lists all supported packages *) let find_syntaxes () = ["camlp4o"] diff --git a/test/myocamlbuild.ml b/test/myocamlbuild.ml index e874f13..fca8be7 100644 --- a/test/myocamlbuild.ml +++ b/test/myocamlbuild.ml @@ -2,15 +2,24 @@ open Ocamlbuild_plugin (* ocamlfind integration following http://www.nabble.com/forum/ViewPost.jtp?post=15979274 *) -(* these functions are not really officially exported *) -let run_and_read = Ocamlbuild_pack.My_unix.run_and_read -let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings +let run_command cmd = + let chan = Unix.open_process_in cmd in + let out = + let rec loop xs = + match input_line chan with + | x -> loop (x :: xs) + | exception End_of_file -> List.rev xs + in loop [] + in + match Unix.close_process_in chan with + | Unix.WEXITED 0 -> `Ok out + | x -> `Error x (* this lists all supported packages *) let find_packages () = - blank_sep_strings & - Lexing.from_string & - run_and_read "ocamlfind list | cut -d' ' -f1" + match run_command "ocamlfind list | cut -d' ' -f1" with + | `Ok xs -> xs + | `Error _ -> failwith "Failed to find packages." (* this lists all supported packages *) let find_syntaxes () = ["camlp4o"] From 369be3c5f5b85a7aef3ef38e90e6525b4034263c Mon Sep 17 00:00:00 2001 From: Jonathan Chan Date: Mon, 21 Dec 2015 21:06:22 -0800 Subject: [PATCH 2/3] Revert unintentional change to ocamlbuild. --- samples/myocamlbuild.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/myocamlbuild.ml b/samples/myocamlbuild.ml index 584b7bf..fca8be7 100644 --- a/samples/myocamlbuild.ml +++ b/samples/myocamlbuild.ml @@ -42,7 +42,7 @@ dispatch begin function (* When one link an OCaml library/binary/package, one should use -linkpkg *) flag ["ocaml"; "compile"] (S[A"-dtypes"]); - flag ["ocaml"; "compile"] (S[A"-warn-error"; A"ay"]); + flag ["ocaml"; "compile"] (S[A"-warn-error"; A"Ay"]); flag ["ocaml"; "compile"] (S[A"-ppopt"; A"-lwt-debug"]); flag ["ocaml"; "link"] & A"-linkpkg"; From a1858ca7bfb4d3cf8c3406e4035319aeff4f57fb Mon Sep 17 00:00:00 2001 From: Jonathan Chan Date: Sat, 16 Jul 2016 16:32:51 -0700 Subject: [PATCH 3/3] Install .cmx files as well. See warning 58. --- src/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 4f3a73a..af7d3ad 100644 --- a/src/Makefile +++ b/src/Makefile @@ -23,8 +23,9 @@ MLI = \ client.mli CMAS = $(NAME).cma +CMXS = $(NAME).cmx CMXAS = $(NAME).cmxa -LIBS = $(CMAS) $(CMXAS) +LIBS = $(CMAS) $(CMXS) $(CMXAS) BUILD = \ $(addprefix _build/,$(LIBS)) \ $(addprefix _build/,$(MLI)) \