|
|
@ -29,10 +29,9 @@ type t =
|
|
|
|
let equal = [%compare.equal : t]
|
|
|
|
let equal = [%compare.equal : t]
|
|
|
|
|
|
|
|
|
|
|
|
module OrderedSourceFile = struct
|
|
|
|
module OrderedSourceFile = struct
|
|
|
|
(* Don't use nonrec due to https://github.com/janestreet/ppx_compare/issues/2 *)
|
|
|
|
type nonrec t = t
|
|
|
|
type t_ = t [@@deriving compare]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type t = t_ [@@deriving compare]
|
|
|
|
let compare = compare
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
module Map = Caml.Map.Make (OrderedSourceFile)
|
|
|
|
module Map = Caml.Map.Make (OrderedSourceFile)
|
|
|
@ -53,11 +52,10 @@ let from_abs_path ?(warn_on_error= true) fname =
|
|
|
|
| Some path ->
|
|
|
|
| Some path ->
|
|
|
|
RelativeInferModel path
|
|
|
|
RelativeInferModel path
|
|
|
|
| None ->
|
|
|
|
| None ->
|
|
|
|
|
|
|
|
(* fname_real is absolute already *)
|
|
|
|
Absolute fname_real
|
|
|
|
Absolute fname_real
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(* fname_real is absolute already *)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let to_string fname =
|
|
|
|
let to_string fname =
|
|
|
|
match fname with
|
|
|
|
match fname with
|
|
|
|
| Invalid origin ->
|
|
|
|
| Invalid origin ->
|
|
|
@ -70,7 +68,6 @@ let to_string fname =
|
|
|
|
|
|
|
|
|
|
|
|
let pp fmt fname = Format.fprintf fmt "%s" (to_string fname)
|
|
|
|
let pp fmt fname = Format.fprintf fmt "%s" (to_string fname)
|
|
|
|
|
|
|
|
|
|
|
|
(* Checking if the path exists may be needed only in some cases, hence the flag check_exists *)
|
|
|
|
|
|
|
|
let to_abs_path fname =
|
|
|
|
let to_abs_path fname =
|
|
|
|
match fname with
|
|
|
|
match fname with
|
|
|
|
| Invalid origin ->
|
|
|
|
| Invalid origin ->
|
|
|
@ -137,16 +134,14 @@ let of_header ?(warn_on_error= true) header_file =
|
|
|
|
let abs_path = to_abs_path header_file in
|
|
|
|
let abs_path = to_abs_path header_file in
|
|
|
|
let source_exts = ["c"; "cc"; "cpp"; "cxx"; "m"; "mm"] in
|
|
|
|
let source_exts = ["c"; "cc"; "cpp"; "cxx"; "m"; "mm"] in
|
|
|
|
let header_exts = ["h"; "hh"; "hpp"; "hxx"] in
|
|
|
|
let header_exts = ["h"; "hh"; "hpp"; "hxx"] in
|
|
|
|
let file_no_ext, ext_opt = Filename.split_extension abs_path in
|
|
|
|
match Filename.split_extension abs_path with
|
|
|
|
let file_opt =
|
|
|
|
| file_no_ext, Some ext when List.mem ~equal:String.equal header_exts ext ->
|
|
|
|
match ext_opt with
|
|
|
|
List.find_map source_exts ~f:(fun ext ->
|
|
|
|
| Some ext when List.mem ~equal:String.equal header_exts ext ->
|
|
|
|
let possible_file = file_no_ext ^ "." ^ ext in
|
|
|
|
let possible_files = List.map ~f:(fun ext -> file_no_ext ^ "." ^ ext) source_exts in
|
|
|
|
if path_exists possible_file then Some (from_abs_path ~warn_on_error possible_file)
|
|
|
|
List.find ~f:path_exists possible_files
|
|
|
|
else None )
|
|
|
|
| _ ->
|
|
|
|
| _ ->
|
|
|
|
None
|
|
|
|
None
|
|
|
|
in
|
|
|
|
|
|
|
|
Option.map ~f:(from_abs_path ~warn_on_error) file_opt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let create ?(warn_on_error= true) path =
|
|
|
|
let create ?(warn_on_error= true) path =
|
|
|
@ -167,7 +162,3 @@ let changed_sources_from_changed_files changed_files =
|
|
|
|
| None ->
|
|
|
|
| None ->
|
|
|
|
changed_files' )
|
|
|
|
changed_files' )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module UNSAFE = struct
|
|
|
|
|
|
|
|
let from_string str = if Filename.is_relative str then RelativeProjectRoot str else Absolute str
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|