Make dune require a (lang ...) line in dune-workspace files

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
Jeremie Dimino 2018-06-29 22:58:59 +01:00 committed by Rudi Grinberg
parent 7c6ecc821f
commit d5ae6dede0
1 changed files with 19 additions and 2 deletions

View File

@ -1,6 +1,10 @@
open Import open Import
open Stanza.Of_sexp open Stanza.Of_sexp
(* workspace files use the same version numbers as dune-project files
for simplicity *)
let syntax = Stanza.syntax
module Context = struct module Context = struct
module Target = struct module Target = struct
type t = type t =
@ -127,6 +131,9 @@ type t =
; contexts : Context.t list ; contexts : Context.t list
} }
include Versioned_file.Make(struct type t = unit end)
let () = Lang.register syntax ()
let t ?x ?profile:cmdline_profile () = let t ?x ?profile:cmdline_profile () =
let x = Option.map x ~f:(fun s -> Context.Target.Named s) in let x = Option.map x ~f:(fun s -> Context.Target.Named s) in
field "profile" string ~default:Config.default_build_profile field "profile" string ~default:Config.default_build_profile
@ -181,9 +188,19 @@ let t ?x ?profile:cmdline_profile () =
; contexts = List.rev contexts ; contexts = List.rev contexts
} }
let t ?x ?profile () = fields (t ?x ?profile ())
let load ?x ?profile p = let load ?x ?profile p =
parse (enter (fields (t ?x ?profile ()))) match Which_program.t with
Univ_map.empty (Io.Sexp.load p ~mode:Many_as_one) | Dune -> load p ~f:(fun _lang -> t ?x ?profile ())
| Jbuilder ->
let sexp =
Io.Sexp.load p ~mode:Many_as_one ~lexer:Sexp.Lexer.jbuild_token
in
parse
(enter (t ?x ?profile ()))
(Univ_map.singleton (Syntax.key syntax) (0, 0))
sexp
let filename = let filename =
match Which_program.t with match Which_program.t with