2018-05-01 15:55:31 +00:00
|
|
|
(** Dune representation of the source tree *)
|
|
|
|
|
2016-12-31 15:12:39 +00:00
|
|
|
open! Import
|
|
|
|
|
2018-05-12 13:38:22 +00:00
|
|
|
module Dune_file : sig
|
2018-06-01 18:44:50 +00:00
|
|
|
module Kind : sig
|
2018-06-20 18:42:53 +00:00
|
|
|
type t = Usexp.syntax = Jbuild | Dune
|
2018-06-01 18:44:50 +00:00
|
|
|
|
|
|
|
val lexer : t -> Sexp.Lexer.t
|
|
|
|
end
|
|
|
|
|
2018-05-12 13:38:22 +00:00
|
|
|
module Plain : sig
|
|
|
|
(** [sexps] is mutable as we get rid of the S-expressions once
|
|
|
|
they have been parsed, in order to release the memory as soon
|
|
|
|
as we don't need them. *)
|
|
|
|
type t =
|
|
|
|
{ path : Path.t
|
|
|
|
; mutable sexps : Sexp.Ast.t list
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-06-01 18:44:50 +00:00
|
|
|
module Contents : sig
|
|
|
|
type t =
|
|
|
|
| Plain of Plain.t
|
|
|
|
| Ocaml_script of Path.t
|
|
|
|
end
|
|
|
|
|
2018-05-12 13:38:22 +00:00
|
|
|
type t =
|
2018-06-01 18:44:50 +00:00
|
|
|
{ contents : Contents.t
|
|
|
|
; kind : Kind.t
|
|
|
|
}
|
2018-05-12 13:38:22 +00:00
|
|
|
|
|
|
|
val path : t -> Path.t
|
|
|
|
end
|
|
|
|
|
2016-12-31 15:12:39 +00:00
|
|
|
module Dir : sig
|
|
|
|
type t
|
|
|
|
|
|
|
|
val path : t -> Path.t
|
2018-04-23 05:08:09 +00:00
|
|
|
val files : t -> String.Set.t
|
2018-01-19 08:50:06 +00:00
|
|
|
val file_paths : t -> Path.Set.t
|
2018-04-23 05:43:20 +00:00
|
|
|
val sub_dirs : t -> t String.Map.t
|
2018-01-19 08:50:06 +00:00
|
|
|
val sub_dir_paths : t -> Path.Set.t
|
2018-04-23 05:08:09 +00:00
|
|
|
val sub_dir_names : t -> String.Set.t
|
2017-09-29 13:09:41 +00:00
|
|
|
|
2018-05-12 13:38:22 +00:00
|
|
|
(** Whether this directory is ignored by an [ignored_subdirs] stanza
|
|
|
|
or [jbuild-ignore] file in one of its ancestor directories. *)
|
2017-09-29 13:09:41 +00:00
|
|
|
val ignored : t -> bool
|
2017-09-29 15:06:29 +00:00
|
|
|
|
|
|
|
val fold
|
|
|
|
: t
|
|
|
|
-> traverse_ignored_dirs:bool
|
|
|
|
-> init:'a
|
|
|
|
-> f:(t -> 'a -> 'a)
|
|
|
|
-> 'a
|
2018-05-09 08:18:01 +00:00
|
|
|
|
2018-05-12 13:38:22 +00:00
|
|
|
(** Return the contents of the dune (or jbuild) file in this directory *)
|
|
|
|
val dune_file : t -> Dune_file.t option
|
2018-05-15 08:46:07 +00:00
|
|
|
|
|
|
|
(** Return the project this directory is part of *)
|
2018-05-22 16:29:54 +00:00
|
|
|
val project : t -> Dune_project.t
|
2016-12-31 15:12:39 +00:00
|
|
|
end
|
|
|
|
|
2018-05-01 15:55:31 +00:00
|
|
|
(** A [t] value represent a view of the source tree. It is lazily
|
|
|
|
constructed by scanning the file system and interpreting [.dune-fs]
|
|
|
|
files, as well as [jbuild-ignore] files for backward
|
|
|
|
compatibility. *)
|
2016-12-31 15:12:39 +00:00
|
|
|
type t
|
|
|
|
|
2017-09-29 13:27:27 +00:00
|
|
|
val load : ?extra_ignored_subtrees:Path.Set.t -> Path.t -> t
|
2016-12-31 15:12:39 +00:00
|
|
|
|
2018-05-01 15:55:31 +00:00
|
|
|
(** Passing [~traverse_ignored_dirs:true] to this functions causes the
|
|
|
|
whole source tree to be deeply scanned, including ignored
|
2018-05-12 13:38:22 +00:00
|
|
|
sub-trees. *)
|
2017-09-29 13:09:41 +00:00
|
|
|
val fold
|
|
|
|
: t
|
|
|
|
-> traverse_ignored_dirs:bool
|
|
|
|
-> init:'a
|
|
|
|
-> f:(Dir.t -> 'a -> 'a)
|
|
|
|
-> 'a
|
2016-12-31 15:12:39 +00:00
|
|
|
|
|
|
|
val root : t -> Dir.t
|
|
|
|
|
|
|
|
val find_dir : t -> Path.t -> Dir.t option
|
2017-02-23 14:58:18 +00:00
|
|
|
|
2018-01-19 08:50:06 +00:00
|
|
|
val files_of : t -> Path.t -> Path.Set.t
|
|
|
|
|
2018-05-01 15:55:31 +00:00
|
|
|
(** [true] iff the path is either a directory or a file *)
|
2017-02-23 14:58:18 +00:00
|
|
|
val exists : t -> Path.t -> bool
|
2018-05-01 15:55:31 +00:00
|
|
|
|
|
|
|
(** [true] iff the path is a file *)
|
2017-02-23 14:58:18 +00:00
|
|
|
val file_exists : t -> Path.t -> string -> bool
|
2017-03-15 09:10:22 +00:00
|
|
|
|
|
|
|
val files_recursively_in : t -> ?prefix_with:Path.t -> Path.t -> Path.Set.t
|