Ignore jbuild_version stanzas

These are no longer necessary as they are super-seeded by (lang
...) stanzas in dune-project files

Signed-off-by: Jeremie Dimino <jdimino@janestreet.com>
This commit is contained in:
Jeremie Dimino 2018-05-24 18:01:02 +01:00 committed by Jérémie Dimino
parent cb6baa6c96
commit d211272d24
2 changed files with 7 additions and 29 deletions

View File

@ -1243,7 +1243,7 @@ module Stanzas = struct
exception Include_loop of Path.t * (Loc.t * Path.t) list
let rec v1 project ~file ~include_stack : Stanza.t list Sexp.Of_sexp.t =
let rec t project ~file ~include_stack : Stanza.t list Sexp.Of_sexp.t =
sum
[ cstr "library" (Library.v1 project @> nil) (fun x -> [Library x])
; cstr "executable" (Executables.v1_single project @> nil) execs
@ -1275,44 +1275,23 @@ module Stanzas = struct
if List.exists include_stack ~f:(fun (_, f) -> f = file) then
raise (Include_loop (file, include_stack));
let sexps = Io.Sexp.load file ~mode:Many in
parse project sexps ~default_version:Jbuild_version.V1 ~file ~include_stack)
parse project sexps ~file ~include_stack)
; cstr "documentation" (Documentation.v1 project @> nil)
(fun d -> [Documentation d])
]
and select
: Jbuild_version.t
-> Dune_project.t
-> file:Path.t
-> include_stack:(Loc.t * Path.t) list
-> Stanza.t list Sexp.Of_sexp.t = function
| V1 -> v1
and parse ~default_version ~file ~include_stack project sexps =
let versions, sexps =
List.partition_map sexps ~f:(function
| List (loc, [Atom (_, A "jbuild_version"); ver]) ->
Left (Jbuild_version.t ver, loc)
| sexp -> Right sexp)
in
let version =
match versions with
| [] -> default_version
| [(v, _)] -> v
| _ :: (_, loc) :: _ ->
Loc.fail loc "jbuild_version specified too many times"
in
and parse ~file ~include_stack project sexps =
let l =
List.concat_map sexps ~f:(select version project ~file ~include_stack)
List.concat_map sexps ~f:(t project ~file ~include_stack)
in
match List.filter_map l ~f:(function Env e -> Some e | _ -> None) with
| _ :: e :: _ ->
Loc.fail e.loc "The 'env' stanza cannot appear more than once"
| _ -> l
let parse ?(default_version=Jbuild_version.latest_stable) ~file project sexps =
let parse ~file project sexps =
try
parse project sexps ~default_version ~include_stack:[] ~file
parse project sexps ~include_stack:[] ~file
with
| Include_loop (_, []) -> assert false
| Include_loop (file, last :: rest) ->

View File

@ -370,8 +370,7 @@ module Stanzas : sig
type syntax = OCaml | Plain
val parse
: ?default_version:Jbuild_version.t
-> file:Path.t
: file:Path.t
-> Dune_project.t
-> Sexp.Ast.t list
-> t