Skip to content
Snippets Groups Projects
Commit b59aa771 authored by Michele Alberti's avatar Michele Alberti
Browse files

Rework solver version detection, still under some assumptions.

parent 2521a026
No related branches found
No related tags found
No related merge requests found
...@@ -57,7 +57,7 @@ let default_exe_name_of_solver = function ...@@ -57,7 +57,7 @@ let default_exe_name_of_solver = function
| Marabou -> "Marabou" | Marabou -> "Marabou"
let default_option_of_solver = function let default_option_of_solver = function
| Pyrat -> "--version" | Pyrat -> "-v"
| Marabou -> "--version" | Marabou -> "--version"
let exe_path_of_solver solver = let exe_path_of_solver solver =
...@@ -122,6 +122,8 @@ let version_of_solver solver s = ...@@ -122,6 +122,8 @@ let version_of_solver solver s =
in in
let regexp_version = Str.regexp regexp_string in let regexp_version = Str.regexp regexp_string in
try try
(* We suppose that the first occurrence that matches [regexp_string] is
indeed the version of the concercend [solver]. *)
ignore (Str.search_forward regexp_version s 0); ignore (Str.search_forward regexp_version s 0);
Version (Str.matched_string s) Version (Str.matched_string s)
with Stdlib.Not_found -> with Stdlib.Not_found ->
...@@ -204,9 +206,18 @@ let detect_default_solvers () = ...@@ -204,9 +206,18 @@ let detect_default_solvers () =
(fun m -> m "Executing command `%s' to detect `%a'." (fun m -> m "Executing command `%s' to detect `%a'."
cmd pp_solver solver); cmd pp_solver solver);
let retcode = Sys.command cmd in let retcode = Sys.command cmd in
let in_channel = Stdlib.open_in tmp in let cmd_output =
let firstline = Stdlib.input_line in_channel in let in_channel = Stdlib.open_in tmp in
Stdlib.close_in in_channel; let buf = Buffer.create 512 in
try
while true do
Stdlib.Buffer.add_channel buf in_channel 512;
done;
assert false
with End_of_file ->
Stdlib.close_in in_channel;
Buffer.contents buf
in
Sys.remove tmp; Sys.remove tmp;
if retcode <> 0 if retcode <> 0
then begin then begin
...@@ -215,7 +226,7 @@ let detect_default_solvers () = ...@@ -215,7 +226,7 @@ let detect_default_solvers () =
end end
else begin else begin
(* If available, we save a [config] for solver. *) (* If available, we save a [config] for solver. *)
let version = version_of_solver solver firstline in let version = version_of_solver solver cmd_output in
let config = { solver; exe; version; } in let config = { solver; exe; version; } in
Logs.app Logs.app
(fun m -> m "Found solver `%a' `%a' (%s)." (fun m -> m "Found solver `%a' `%a' (%s)."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment