Fix c_compiler parsing for OCaml >= 4.06.0 (#393)

This commit is contained in:
Rudi Grinberg 2018-01-11 00:54:25 +08:00 committed by David Allsopp
parent 9ed300e5a2
commit 3776acd8d2
1 changed files with 21 additions and 15 deletions

View File

@ -337,11 +337,6 @@ let create ~(kind : Kind.t) ~path ~base_env ~env_extra ~name ~merlin
else
env,env_extra
in
let c_compiler, ocamlc_cflags, ocamlopt_cflags =
match get_opt "c_compiler" with
| Some c_compiler -> (* >= 4.06 *)
(c_compiler, get "ocamlc_cflags", get "ocamlopt_cflags")
| None ->
let split_prog s =
let len = String.length s in
let rec loop i =
@ -356,6 +351,17 @@ let create ~(kind : Kind.t) ~path ~base_env ~env_extra ~name ~merlin
in
loop 0
in
let c_compiler, ocamlc_cflags, ocamlopt_cflags =
match get_opt "c_compiler" with
| Some c_compiler -> (* >= 4.06 *)
let c_compiler, extra_args = split_prog c_compiler in
let args var =
if String.length extra_args > 0 then
sprintf "%s %s" extra_args (get var)
else
get var in
(c_compiler, args "ocamlc_cflags", args "ocamlopt_cflags")
| None ->
let c_compiler, ocamlc_cflags = split_prog (get "bytecomp_c_compiler") in
let _, ocamlopt_cflags = split_prog (get "native_c_compiler") in
(c_compiler, ocamlc_cflags, ocamlopt_cflags)