diff --git a/samples/myocamlbuild.ml b/samples/myocamlbuild.ml index e874f13..fca8be7 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"] 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)) \ 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"]