Allow to redefine the default context

This commit is contained in:
Jérémie Dimino 2017-02-25 00:28:10 +00:00
parent 677b9e1e06
commit 7538fd8263
4 changed files with 15 additions and 11 deletions

View File

@ -6,7 +6,8 @@ module Kind = struct
end
type t =
{ kind : Kind.t
{ name : string
; kind : Kind.t
; for_host : t option
; build_dir : Path.t
; path : Path.t list
@ -162,7 +163,8 @@ let create ~(kind : Kind.t) ~path ~env ~name =
let get_path var = Path.absolute (get var) in
let stdlib_dir = get_path "standard_library" in
let t =
{ kind
{ name
; kind
; for_host = None
; build_dir
; path

View File

@ -25,7 +25,8 @@ module Kind : sig
end
type t =
{ kind : Kind.t
{ name : string
; kind : Kind.t
; (** If this context is a cross-compilation context, you need another context for
building tools used for the compilation that run on the host. *)

View File

@ -15,26 +15,27 @@ let package_install_file { packages; _ } pkg =
let setup ?filter_out_optional_stanzas_with_missing_deps () =
let { Jbuild_load. file_tree; tree; stanzas; packages } = Jbuild_load.load () in
Lazy.force Context.default >>= fun context ->
(if Sys.file_exists "jbuild-workspace" then
Future.all
(List.map (Workspace.load "jbuild-workspace")
~f:(fun { Workspace.Context. name; switch; root } ->
Context.create_for_opam ~name ~switch ?root ()))
>>= fun other_contexts ->
return (context :: other_contexts)
else
return [context])
>>= fun all_contexts ->
return [])
>>= fun contexts ->
(match List.find contexts ~f:(fun c -> c.name = "default") with
| None -> Lazy.force Context.default
| Some c -> return c)
>>= fun default_context ->
let rules =
List.concat_map all_contexts ~f:(fun context ->
List.concat_map contexts ~f:(fun context ->
Gen_rules.gen ~context ~file_tree ~tree ~stanzas ~packages
?filter_out_optional_stanzas_with_missing_deps ())
in
let build_system = Build_system.create ~file_tree ~rules in
return { build_system
; stanzas
; context
; context = default_context
; packages
}

View File

@ -33,7 +33,7 @@ let t sexps =
sexp
in
begin match ctx.name with
| "default" | ".aliases" | "log" as s ->
| ".aliases" | "log" as s ->
of_sexp_errorf sexp "%S is not allowed as a build context name" s
| _ -> ()
end;