dune/src/dune_file.mli

397 lines
9.4 KiB
OCaml
Raw Normal View History

2017-06-02 14:00:15 +00:00
(** Representation and parsing of jbuild files *)
open Import
(** Ppx preprocessors *)
module Pp : sig
Refactor library management (#516) Lib module ---------- We have a new module Lib that replaces Lib, parts of Lib_db and parts of Findlib. It is used to manage all libraries (internal and extrernal). Lib.t represent a completely resolved library, i.e. where all the dependencies have been resolved. Lib.Compile is used to provide what is necessary to build the library itself. Lib.Meta provides what is necessary to generate the META file for the library. We also have library databases represented as Lib.DB.t. A library database is simply a mapping from names to Lib.t values and and created from a resolve function that looks up a name and return a Lib.Info.t. A Lib.Info.t is the same as a Lib.t except that dependencies are not resolved. A library database can have a parent database that is used to lookup names that are not found in the current database. In practice we have the following hierarchy: 1. For every scope, we have a library database that holds all the libraries of this scope. In this DB, a library can be referred by either it's name or public name 2. the parent of each of these databases is a database that holds all the public libraries of the workspace. In this DB libraries must be referred by their public name 3. the parent of this DB is for installed libraries (1) databases are accessible via Scope.libs (Super_context.find_scope_by_{name,dir} sctx xxx) (2) is accessible via Super_context.public_libs sctx (3) is accessible via Super_context.installed_libs sctx The dependencies of a library are always resolved inside the DB it is part of. When we compute a transitive closure, we check that we don't have two libraries from two different DB with the same name. So for instance linting Base should now supported. Jbuild.Scope_info ----------------- Jbuild.Scope was renamed Jbuild.Scope_info Scope module ------------ This replaces Lib_db. A Scope.t is now just a pair of a Jbuild.Scope_info.t and a Lib.DB.t. Scope.DB.t is an object used to lookup scopes by either name or directory. We no longer have an external scope or special anonymous scope. Instead one should use Super_context.installed_libs or Super_context.public_libs depending on the context.
2018-02-20 11:46:10 +00:00
type t = private string
2017-06-02 14:00:15 +00:00
val of_string : string -> t
val to_string : t -> string
2018-03-27 20:59:18 +00:00
val compare : t -> t -> Ordering.t
2017-06-02 14:00:15 +00:00
end
module Preprocess : sig
type pps =
{ loc : Loc.t
; pps : (Loc.t * Pp.t) list
2017-06-02 14:00:15 +00:00
; flags : string list
; staged : bool
2017-06-02 14:00:15 +00:00
}
type t =
| No_preprocessing
| Action of Loc.t * Action.Unexpanded.t
2017-06-02 14:00:15 +00:00
| Pps of pps
end
2018-03-03 18:03:37 +00:00
module Per_module : Per_item.S with type key = Module.Name.t
2017-06-02 14:00:15 +00:00
module Preprocess_map : sig
type t = Preprocess.t Per_module.t
2017-06-02 14:00:15 +00:00
val no_preprocessing : t
val default : t
(** [find module_name] find the preprocessing specification for a
given module *)
2018-03-03 18:03:37 +00:00
val find : Module.Name.t -> t -> Preprocess.t
2017-06-02 14:00:15 +00:00
val pps : t -> (Loc.t * Pp.t) list
2017-06-02 14:00:15 +00:00
end
module Lint : sig
type t = Preprocess_map.t
val no_lint : t
end
2017-06-02 14:00:15 +00:00
module Js_of_ocaml : sig
type t =
{ flags : Ordered_set_lang.Unexpanded.t
2017-06-02 14:00:15 +00:00
; javascript_files : string list
}
val default : t
2017-06-02 14:00:15 +00:00
end
module Lib_dep : sig
type choice =
2018-04-23 05:08:09 +00:00
{ required : String.Set.t
; forbidden : String.Set.t
2017-06-02 14:00:15 +00:00
; file : string
}
type select =
{ result_fn : string
; choices : choice list
; loc : Loc.t
}
type t =
| Direct of (Loc.t * string)
2017-06-02 14:00:15 +00:00
| Select of select
val to_lib_names : t -> string list
val direct : Loc.t * string -> t
val of_pp : Loc.t * Pp.t -> t
2017-06-02 14:00:15 +00:00
end
module Lib_deps : sig
type t = Lib_dep.t list
2018-03-01 20:16:29 +00:00
val of_pps : Pp.t list -> t
val info : t -> kind:Lib_deps_info.Kind.t -> Lib_deps_info.t
2017-06-02 14:00:15 +00:00
end
module Bindings : sig
type 'a one =
| Unnamed of 'a
| Named of string * 'a list
type 'a t = 'a one list
val find : 'a t -> string -> 'a list option
val fold : 'a t -> f:('a one -> 'acc -> 'acc) -> init:'acc -> 'acc
val empty : 'a t
val to_list : 'a t -> 'a list
val singleton : 'a -> 'a t
val sexp_of_t : ('a -> Usexp.t) -> 'a t -> Usexp.t
end
2017-06-02 14:00:15 +00:00
module Dep_conf : sig
type t =
2017-06-02 14:00:15 +00:00
| File of String_with_vars.t
| Alias of String_with_vars.t
| Alias_rec of String_with_vars.t
2017-06-02 14:00:15 +00:00
| Glob_files of String_with_vars.t
| Source_tree of String_with_vars.t
| Package of String_with_vars.t
| Universe
val t : t Sexp.Of_sexp.t
2017-06-02 14:00:15 +00:00
val sexp_of_t : t -> Sexp.t
end
module Buildable : sig
type t =
{ loc : Loc.t
; modules : Ordered_set_lang.t
; modules_without_implementation : Ordered_set_lang.t
2017-06-02 14:00:15 +00:00
; libraries : Lib_dep.t list
; preprocess : Preprocess_map.t
; preprocessor_deps : Dep_conf.t list
; lint : Lint.t
; flags : Ordered_set_lang.Unexpanded.t
; ocamlc_flags : Ordered_set_lang.Unexpanded.t
; ocamlopt_flags : Ordered_set_lang.Unexpanded.t
2017-06-02 14:00:15 +00:00
; js_of_ocaml : Js_of_ocaml.t
; allow_overlapping_dependencies : bool
2017-06-02 14:00:15 +00:00
}
(** Preprocessing specification used by all modules or [No_preprocessing] *)
val single_preprocess : t -> Preprocess.t
end
module Public_lib : sig
type t =
{ name : Loc.t * string (** Full public name *)
; package : Package.t (** Package it is part of *)
; sub_dir : string option (** Subdirectory inside the installation
directory *)
}
val name : t -> string
end
module Sub_system_info : sig
(** The type of all kind of sub-system information.
This type is what we get just after parsing a [jbuild] file. *)
type t = ..
type sub_system = t = ..
(** What the user must provide in order to define the parsing part
of a sub-system. *)
module type S = sig
type t
type sub_system += T of t
(** Name of the sub-system *)
val name : Sub_system_name.t
(** Location of the parameters in the jbuild/dune file. *)
val loc : t -> Loc.t
(** Syntax for jbuild/dune files *)
val syntax : Syntax.t
(** Parse parameters written by the user in jbuid/dune files *)
val parse : t Sexp.Of_sexp.t
end
module Register(M : S) : sig end
val get : Sub_system_name.t -> (module S)
2017-06-02 14:00:15 +00:00
end
module Mode_conf : sig
type t =
| Byte
| Native
| Best (** [Native] if available and [Byte] if not *)
val t : t Sexp.Of_sexp.t
val compare : t -> t -> Ordering.t
val pp : Format.formatter -> t -> unit
module Set : sig
include Set.S with type elt = t
val t : t Sexp.Of_sexp.t
(** Both Byte and Native *)
val default : t
val eval : t -> has_native:bool -> Mode.Dict.Set.t
end
end
2017-06-02 14:00:15 +00:00
module Library : sig
module Kind : sig
type t =
| Normal
| Ppx_deriver
| Ppx_rewriter
end
type t =
{ name : string
; public : Public_lib.t option
; synopsis : string option
; install_c_headers : string list
; ppx_runtime_libraries : (Loc.t * string) list
; modes : Mode_conf.Set.t
2017-06-02 14:00:15 +00:00
; kind : Kind.t
; c_flags : Ordered_set_lang.Unexpanded.t
; c_names : (Loc.t * string) list
2017-06-02 14:00:15 +00:00
; cxx_flags : Ordered_set_lang.Unexpanded.t
; cxx_names : (Loc.t * string) list
; library_flags : Ordered_set_lang.Unexpanded.t
2017-06-02 14:00:15 +00:00
; c_library_flags : Ordered_set_lang.Unexpanded.t
; self_build_stubs_archive : string option
; virtual_deps : (Loc.t * string) list
2017-06-02 14:00:15 +00:00
; wrapped : bool
; optional : bool
; buildable : Buildable.t
; dynlink : bool
; project : Dune_project.t
; sub_systems : Sub_system_info.t Sub_system_name.Map.t
; no_keep_locs : bool
; dune_version : Syntax.Version.t
2017-06-02 14:00:15 +00:00
}
val has_stubs : t -> bool
val stubs_archive : t -> dir:Path.t -> ext_lib:string -> Path.t
val dll : t -> dir:Path.t -> ext_dll:string -> Path.t
val archive : t -> dir:Path.t -> ext:string -> Path.t
val best_name : t -> string
2017-06-02 14:00:15 +00:00
end
module Install_conf : sig
type file =
{ src : string
; dst : string option
}
type t =
{ section : Install.Section.t
; files : file list
; package : Package.t
}
end
module Executables : sig
module Link_mode : sig
type t =
{ mode : Mode_conf.t
; kind : Binary_kind.t
}
val t : t Sexp.Of_sexp.t
val sexp_of_t : t Sexp.To_sexp.t
val exe : t
val object_ : t
val shared_object : t
val byte : t
val native : t
val compare : t -> t -> Ordering.t
module Set : Set.S with type elt = t
end
2017-06-02 14:00:15 +00:00
type t =
{ names : (Loc.t * string) list
; link_flags : Ordered_set_lang.Unexpanded.t
; link_deps : Dep_conf.t list
; modes : Link_mode.Set.t
; buildable : Buildable.t
2017-06-02 14:00:15 +00:00
}
end
module Rule : sig
module Targets : sig
type t =
| Static of string list
| Infer
end
module Mode : sig
type t =
| Standard
(** Only use this rule if the source files don't exist. *)
| Fallback
(** Silently promote the targets to the source tree. *)
| Promote
(** Same as [Promote] but [jbuilder clean] must delete the file *)
| Promote_but_delete_on_clean
(** Same as [Standard] however this is not a rule stanza, so it
is not possible to add a [(fallback)] field to the rule. *)
| Not_a_rule_stanza
(** Just ignore the source files entirely. This is for cases
where the targets are promoted only in a specific context,
such as for .install files. *)
2018-01-25 10:13:18 +00:00
| Ignore_source_files
end
2017-06-02 14:00:15 +00:00
type t =
{ targets : Targets.t
; deps : Dep_conf.t Bindings.t
; action : Loc.t * Action.Unexpanded.t
; mode : Mode.t
; locks : String_with_vars.t list
; loc : Loc.t
2017-06-02 14:00:15 +00:00
}
end
2018-03-03 16:12:55 +00:00
module Menhir : sig
type t =
{ merge_into : string option
; flags : Ordered_set_lang.Unexpanded.t
2018-03-03 16:12:55 +00:00
; modules : string list
; mode : Rule.Mode.t
; loc : Loc.t
}
type Stanza.t += T of t
2018-03-03 16:12:55 +00:00
end
2017-06-02 14:00:15 +00:00
module Alias_conf : sig
type t =
{ name : string
; deps : Dep_conf.t Bindings.t
; action : (Loc.t * Action.Unexpanded.t) option
; locks : String_with_vars.t list
2017-06-02 14:00:15 +00:00
; package : Package.t option
; enabled_if : String_with_vars.t Blang.t option
; loc : Loc.t
2017-06-02 14:00:15 +00:00
}
end
module Copy_files : sig
type t =
{ add_line_directive : bool
; glob : String_with_vars.t
}
end
2018-03-01 06:03:06 +00:00
module Documentation : sig
type t =
{ loc : Loc.t
; package : Package.t
2018-03-01 06:03:06 +00:00
; mld_files : Ordered_set_lang.t
}
end
module Tests : sig
type t =
{ exes : Executables.t
; locks : String_with_vars.t list
; package : Package.t option
; deps : Dep_conf.t Bindings.t
; enabled_if : String_with_vars.t Blang.t option
}
end
module Include_subdirs : sig
type t = No | Unqualified
end
type Stanza.t +=
| Library of Library.t
| Executables of Executables.t
| Rule of Rule.t
| Install of Install_conf.t
| Alias of Alias_conf.t
| Copy_files of Copy_files.t
| Documentation of Documentation.t
| Tests of Tests.t
| Include_subdirs of Loc.t * Include_subdirs.t
2017-06-02 14:00:15 +00:00
module Stanzas : sig
type t = Stanza.t list
type syntax = OCaml | Plain
val parse
: file:Path.t
-> kind:File_tree.Dune_file.Kind.t
-> Dune_project.t
-> Sexp.Ast.t list
-> t
2017-06-02 14:00:15 +00:00
end