Add jbuild.mli
This commit is contained in:
parent
b74544919a
commit
d8be1aa894
|
@ -292,10 +292,10 @@ Lwt/Async-like monad, implemented in [src/future.mli]().
|
|||
|
||||
#### Code flow
|
||||
|
||||
- [src/jbuild_types.ml]() contains the internal representation of =jbuild=
|
||||
- [src/jbuild.mli]() contains the internal representation of `jbuild`
|
||||
files and the parsing code
|
||||
- [src/jbuild_load.ml]() contains the code to scan a source tree and
|
||||
- [src/jbuild_load.mli]() contains the code to scan a source tree and
|
||||
build the internal database by reading the =jbuild= files
|
||||
- [src/gen_rules.ml]() contains all the build rules of Jbuilder
|
||||
- [src/build_system.ml]() contains a trivial implementation of a Build
|
||||
- [src/gen_rules.mli]() contains all the build rules of Jbuilder
|
||||
- [src/build_system.mli]() contains a trivial implementation of a Build
|
||||
system. This is what Jenga will provide when implementing the bridge
|
||||
|
|
|
@ -133,33 +133,21 @@ module Pkgs = struct
|
|||
end
|
||||
|
||||
|
||||
module Raw_string () : sig
|
||||
type t = private string
|
||||
val to_string : t -> string
|
||||
module Pp : sig
|
||||
type t
|
||||
val of_string : string -> t
|
||||
val t : t Sexp.Of_sexp.t
|
||||
val to_string : t -> string
|
||||
val compare : t -> t -> int
|
||||
end = struct
|
||||
type t = string
|
||||
let to_string t = t
|
||||
let of_string t = t
|
||||
let t = string
|
||||
end
|
||||
|
||||
module Pp = struct
|
||||
include Raw_string ()
|
||||
|
||||
let of_string s =
|
||||
assert (not (String.is_prefix s ~prefix:"-"));
|
||||
of_string s
|
||||
s
|
||||
|
||||
let t sexp =
|
||||
let s = string sexp in
|
||||
if String.is_prefix s ~prefix:"-" then
|
||||
of_sexp_error sexp "flag not allowed here"
|
||||
else
|
||||
of_string s
|
||||
let to_string t = t
|
||||
|
||||
let compare : t -> t -> int = Pervasives.compare
|
||||
let compare = String.compare
|
||||
end
|
||||
|
||||
module Pp_or_flags = struct
|
||||
|
@ -429,7 +417,6 @@ module Buildable = struct
|
|||
; libraries : Lib_dep.t list
|
||||
; preprocess : Preprocess_map.t
|
||||
; preprocessor_deps : Dep_conf.t list
|
||||
; lint : Lint.t Per_file.t option
|
||||
; flags : Ordered_set_lang.t
|
||||
; ocamlc_flags : Ordered_set_lang.t
|
||||
; ocamlopt_flags : Ordered_set_lang.t
|
||||
|
@ -442,7 +429,7 @@ module Buildable = struct
|
|||
field "preprocessor_deps" (list Dep_conf.t) ~default:[]
|
||||
>>= fun preprocessor_deps ->
|
||||
field_o "lint" (Per_file.t Lint.t)
|
||||
>>= fun lint ->
|
||||
>>= fun _lint ->
|
||||
field "modules" (fun s -> Ordered_set_lang.(map (t s)) ~f:String.capitalize_ascii)
|
||||
~default:Ordered_set_lang.standard
|
||||
>>= fun modules ->
|
||||
|
@ -455,7 +442,6 @@ module Buildable = struct
|
|||
return
|
||||
{ preprocess
|
||||
; preprocessor_deps
|
||||
; lint
|
||||
; modules
|
||||
; libraries
|
||||
; flags
|
||||
|
@ -472,9 +458,9 @@ end
|
|||
|
||||
module Public_lib = struct
|
||||
type t =
|
||||
{ name : string (* Full public name *)
|
||||
; package : Package.t (* Package it is part of *)
|
||||
; sub_dir : string option (* Subdirectory inside the installation directory *)
|
||||
{ name : string
|
||||
; package : Package.t
|
||||
; sub_dir : string option
|
||||
}
|
||||
|
||||
let public_name_field pkgs =
|
||||
|
@ -811,7 +797,7 @@ module Provides = struct
|
|||
; file : string
|
||||
}
|
||||
|
||||
let v1 sexp =
|
||||
(* let v1 sexp =
|
||||
match sexp with
|
||||
| Atom (_, s) ->
|
||||
{ name = s
|
||||
|
@ -825,7 +811,7 @@ module Provides = struct
|
|||
; file
|
||||
}
|
||||
| sexp ->
|
||||
of_sexp_error sexp "[<name>] or [<name> (file <file>)] expected"
|
||||
of_sexp_error sexp "[<name>] or [<name> (file <file>)] expected"*)
|
||||
end
|
||||
|
||||
module Alias_conf = struct
|
||||
|
|
|
@ -0,0 +1,222 @@
|
|||
(** Representation and parsing of jbuild files *)
|
||||
|
||||
open Import
|
||||
|
||||
module Jbuild_version : sig
|
||||
type t = V1
|
||||
val t : t Sexp.Of_sexp.t
|
||||
|
||||
val latest_stable : t
|
||||
end
|
||||
|
||||
(** Packages visible in a given directory *)
|
||||
module Pkgs : sig
|
||||
type t =
|
||||
{ visible_packages : Package.t String_map.t
|
||||
; closest_packages : Package.t list
|
||||
}
|
||||
|
||||
val empty : t
|
||||
|
||||
val resolve : t -> string -> (Package.t, string) result
|
||||
end
|
||||
|
||||
(** Ppx preprocessors *)
|
||||
module Pp : sig
|
||||
type t
|
||||
val of_string : string -> t
|
||||
val to_string : t -> string
|
||||
end
|
||||
|
||||
module Preprocess : sig
|
||||
type pps =
|
||||
{ pps : Pp.t list
|
||||
; flags : string list
|
||||
}
|
||||
|
||||
type t =
|
||||
| No_preprocessing
|
||||
| Action of Action.Unexpanded.t
|
||||
| Pps of pps
|
||||
end
|
||||
|
||||
module Preprocess_map : sig
|
||||
type t
|
||||
|
||||
(** [find module_name] find the preprocessing specification for a given module *)
|
||||
val find : string -> t -> Preprocess.t
|
||||
|
||||
val pps : t -> Pp.t list
|
||||
end
|
||||
|
||||
module Js_of_ocaml : sig
|
||||
type t =
|
||||
{ flags : Ordered_set_lang.t
|
||||
; javascript_files : string list
|
||||
}
|
||||
end
|
||||
|
||||
module Lib_dep : sig
|
||||
type choice =
|
||||
{ required : String_set.t
|
||||
; forbidden : String_set.t
|
||||
; file : string
|
||||
}
|
||||
|
||||
type select =
|
||||
{ result_fn : string
|
||||
; choices : choice list
|
||||
; loc : Loc.t
|
||||
}
|
||||
|
||||
type t =
|
||||
| Direct of string
|
||||
| Select of select
|
||||
|
||||
val to_lib_names : t -> string list
|
||||
val direct : string -> t
|
||||
end
|
||||
|
||||
module Lib_deps : sig
|
||||
type t = Lib_dep.t list
|
||||
end
|
||||
|
||||
module Dep_conf : sig
|
||||
type t =
|
||||
| File of String_with_vars.t
|
||||
| Alias of String_with_vars.t
|
||||
| Glob_files of String_with_vars.t
|
||||
| Files_recursively_in of String_with_vars.t
|
||||
|
||||
val sexp_of_t : t -> Sexp.t
|
||||
end
|
||||
|
||||
module Buildable : sig
|
||||
type t =
|
||||
{ modules : Ordered_set_lang.t
|
||||
; libraries : Lib_dep.t list
|
||||
; preprocess : Preprocess_map.t
|
||||
; preprocessor_deps : Dep_conf.t list
|
||||
; flags : Ordered_set_lang.t
|
||||
; ocamlc_flags : Ordered_set_lang.t
|
||||
; ocamlopt_flags : Ordered_set_lang.t
|
||||
; js_of_ocaml : Js_of_ocaml.t
|
||||
}
|
||||
|
||||
(** Preprocessing specification used by all modules or [No_preprocessing] *)
|
||||
val single_preprocess : t -> Preprocess.t
|
||||
end
|
||||
|
||||
module Public_lib : sig
|
||||
type t =
|
||||
{ name : string (** Full public name *)
|
||||
; package : Package.t (** Package it is part of *)
|
||||
; sub_dir : string option (** Subdirectory inside the installation directory *)
|
||||
}
|
||||
end
|
||||
|
||||
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 : string list
|
||||
; modes : Mode.Dict.Set.t
|
||||
; kind : Kind.t
|
||||
; c_flags : Ordered_set_lang.Unexpanded.t
|
||||
; c_names : string list
|
||||
; cxx_flags : Ordered_set_lang.Unexpanded.t
|
||||
; cxx_names : string list
|
||||
; includes : String_with_vars.t list
|
||||
; library_flags : String_with_vars.t list
|
||||
; c_library_flags : Ordered_set_lang.Unexpanded.t
|
||||
; self_build_stubs_archive : string option
|
||||
; virtual_deps : string list
|
||||
; wrapped : bool
|
||||
; optional : bool
|
||||
; buildable : Buildable.t
|
||||
; dynlink : bool
|
||||
}
|
||||
|
||||
val has_stubs : t -> bool
|
||||
val stubs_archive : t -> dir:Path.t -> ext_lib:string -> Path.t
|
||||
val all_lib_deps : t -> Lib_deps.t
|
||||
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
|
||||
type t =
|
||||
{ names : string list
|
||||
; link_executables : bool
|
||||
; link_flags : string list
|
||||
; modes : Mode.Dict.Set.t
|
||||
; buildable : Buildable.t
|
||||
}
|
||||
end
|
||||
|
||||
module Rule : sig
|
||||
module Targets : sig
|
||||
type t =
|
||||
| Static of string list
|
||||
| Infer
|
||||
end
|
||||
|
||||
type t =
|
||||
{ targets : Targets.t
|
||||
; deps : Dep_conf.t list
|
||||
; action : Action.Unexpanded.t
|
||||
}
|
||||
end
|
||||
|
||||
module Provides : sig
|
||||
type t =
|
||||
{ name : string
|
||||
; file : string
|
||||
}
|
||||
end
|
||||
|
||||
module Alias_conf : sig
|
||||
type t =
|
||||
{ name : string
|
||||
; deps : Dep_conf.t list
|
||||
; action : Action.Unexpanded.t option
|
||||
; package : Package.t option
|
||||
}
|
||||
end
|
||||
|
||||
module Stanza : sig
|
||||
type t =
|
||||
| Library of Library.t
|
||||
| Executables of Executables.t
|
||||
| Rule of Rule.t
|
||||
| Provides of Provides.t
|
||||
| Install of Install_conf.t
|
||||
| Alias of Alias_conf.t
|
||||
end
|
||||
|
||||
module Stanzas : sig
|
||||
type t = Stanza.t list
|
||||
|
||||
val parse : Pkgs.t -> Sexp.Ast.t list -> t
|
||||
val lib_names : (_ * _ * t) list -> String_set.t
|
||||
end
|
Loading…
Reference in New Issue