parent
cdcd7e907f
commit
cb72b1cfca
|
@ -285,8 +285,8 @@ module Gen(P : Params) = struct
|
||||||
List.filter_map (String_map.values modules) ~f:(fun m -> Module.file ~dir m ml_kind)
|
List.filter_map (String_map.values modules) ~f:(fun m -> Module.file ~dir m ml_kind)
|
||||||
|> List.map ~f:(fun fn ->
|
|> List.map ~f:(fun fn ->
|
||||||
match ml_kind, Filename.ext (Path.to_string fn) with
|
match ml_kind, Filename.ext (Path.to_string fn) with
|
||||||
| Impl, Some "ml" -> Arg_spec.Dep fn
|
| Impl, Some ".ml" -> Arg_spec.Dep fn
|
||||||
| Intf, Some "mli" -> Dep fn
|
| Intf, Some ".mli" -> Dep fn
|
||||||
| Impl, _ -> S [A "-impl"; Dep fn]
|
| Impl, _ -> S [A "-impl"; Dep fn]
|
||||||
| Intf, _ -> S [A "-intf"; Dep fn])
|
| Intf, _ -> S [A "-intf"; Dep fn])
|
||||||
in
|
in
|
||||||
|
@ -329,7 +329,7 @@ module Gen(P : Params) = struct
|
||||||
| Some (fn, ext) ->
|
| Some (fn, ext) ->
|
||||||
(* We need to to put the .pp before the .ml so that the compiler realises that
|
(* We need to to put the .pp before the .ml so that the compiler realises that
|
||||||
[foo.pp.mli] is the interface for [foo.pp.ml] *)
|
[foo.pp.mli] is the interface for [foo.pp.ml] *)
|
||||||
fn ^ ".pp." ^ ext
|
fn ^ ".pp" ^ ext
|
||||||
|
|
||||||
let pped_module ~dir (m : Module.t) ~f =
|
let pped_module ~dir (m : Module.t) ~f =
|
||||||
let ml_pp_fname = pp_fname m.ml_fname in
|
let ml_pp_fname = pp_fname m.ml_fname in
|
||||||
|
@ -535,17 +535,27 @@ module Gen(P : Params) = struct
|
||||||
Option.iter (Module.cm_source ~dir m cm_kind) ~f:(fun src ->
|
Option.iter (Module.cm_source ~dir m cm_kind) ~f:(fun src ->
|
||||||
let ml_kind = Cm_kind.source cm_kind in
|
let ml_kind = Cm_kind.source cm_kind in
|
||||||
let dst = Module.cm_file m ~dir cm_kind in
|
let dst = Module.cm_file m ~dir cm_kind in
|
||||||
let extra_deps, extra_targets =
|
let extra_args, extra_deps, extra_targets =
|
||||||
match cm_kind, m.mli_fname with
|
match cm_kind, m.mli_fname with
|
||||||
(* If there is no mli, [ocamlY -c file.ml] produces both the .cmY and .cmi. We
|
(* If there is no mli, [ocamlY -c file.ml] produces both the
|
||||||
choose to use ocamlc to produce the cmi and to produce the cmx we have to wait
|
.cmY and .cmi. We choose to use ocamlc to produce the cmi
|
||||||
for the cmo to avoid race conditions. *)
|
and to produce the cmx we have to wait to avoid race
|
||||||
| Cmo, None -> [], [Module.cm_file m ~dir Cmi]
|
conditions. *)
|
||||||
| Cmx, None -> [Module.cm_file m ~dir Cmo], []
|
| Cmo, None -> [], [], [Module.cm_file m ~dir Cmi]
|
||||||
|
| Cmx, None ->
|
||||||
|
(* Change [-intf-suffix] so that the compiler thinks the
|
||||||
|
cmi exists and reads it instead of re-creating it, which
|
||||||
|
could create a race condition. *)
|
||||||
|
([ "-intf-suffix"
|
||||||
|
; match Filename.ext m.ml_fname with
|
||||||
|
| None -> ""
|
||||||
|
| Some ext -> ext
|
||||||
|
],
|
||||||
|
[Module.cm_file m ~dir Cmi], [])
|
||||||
| Cmi, None -> assert false
|
| Cmi, None -> assert false
|
||||||
| Cmi, Some _ -> [], []
|
| Cmi, Some _ -> [], [], []
|
||||||
(* We need the .cmi to build either the .cmo or .cmx *)
|
(* We need the .cmi to build either the .cmo or .cmx *)
|
||||||
| (Cmo | Cmx), Some _ -> [Module.cm_file m ~dir Cmi], []
|
| (Cmo | Cmx), Some _ -> [], [Module.cm_file m ~dir Cmi], []
|
||||||
in
|
in
|
||||||
let dep_graph = Ml_kind.Dict.get dep_graph ml_kind in
|
let dep_graph = Ml_kind.Dict.get dep_graph ml_kind in
|
||||||
let other_cm_files =
|
let other_cm_files =
|
||||||
|
@ -579,6 +589,7 @@ module Gen(P : Params) = struct
|
||||||
; cmt_args
|
; cmt_args
|
||||||
; Dyn Lib.include_flags
|
; Dyn Lib.include_flags
|
||||||
; flags
|
; flags
|
||||||
|
; As extra_args
|
||||||
; A "-I"; Path dir
|
; A "-I"; Path dir
|
||||||
; (match alias_module with
|
; (match alias_module with
|
||||||
| None -> S []
|
| None -> S []
|
||||||
|
|
|
@ -206,14 +206,14 @@ module Filename = struct
|
||||||
| i ->
|
| i ->
|
||||||
Some
|
Some
|
||||||
(String.sub fn ~pos:0 ~len:i,
|
(String.sub fn ~pos:0 ~len:i,
|
||||||
String.sub fn ~pos:(i + 1) ~len:(String.length fn - i - 1))
|
String.sub fn ~pos:i ~len:(String.length fn - i))
|
||||||
|
|
||||||
let ext fn =
|
let ext fn =
|
||||||
match String.rindex fn '.' with
|
match String.rindex fn '.' with
|
||||||
| exception Not_found -> None
|
| exception Not_found -> None
|
||||||
| i ->
|
| i ->
|
||||||
Some
|
Some
|
||||||
(String.sub fn ~pos:(i + 1) ~len:(String.length fn - i - 1))
|
(String.sub fn ~pos:i ~len:(String.length fn - i))
|
||||||
end
|
end
|
||||||
|
|
||||||
module Option = struct
|
module Option = struct
|
||||||
|
|
Loading…
Reference in New Issue