Allow to redefine the default context
This commit is contained in:
parent
677b9e1e06
commit
7538fd8263
|
@ -6,7 +6,8 @@ module Kind = struct
|
||||||
end
|
end
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
{ kind : Kind.t
|
{ name : string
|
||||||
|
; kind : Kind.t
|
||||||
; for_host : t option
|
; for_host : t option
|
||||||
; build_dir : Path.t
|
; build_dir : Path.t
|
||||||
; path : Path.t list
|
; 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 get_path var = Path.absolute (get var) in
|
||||||
let stdlib_dir = get_path "standard_library" in
|
let stdlib_dir = get_path "standard_library" in
|
||||||
let t =
|
let t =
|
||||||
{ kind
|
{ name
|
||||||
|
; kind
|
||||||
; for_host = None
|
; for_host = None
|
||||||
; build_dir
|
; build_dir
|
||||||
; path
|
; path
|
||||||
|
|
|
@ -25,7 +25,8 @@ module Kind : sig
|
||||||
end
|
end
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
{ kind : Kind.t
|
{ name : string
|
||||||
|
; kind : Kind.t
|
||||||
|
|
||||||
; (** If this context is a cross-compilation context, you need another context for
|
; (** If this context is a cross-compilation context, you need another context for
|
||||||
building tools used for the compilation that run on the host. *)
|
building tools used for the compilation that run on the host. *)
|
||||||
|
|
15
src/main.ml
15
src/main.ml
|
@ -15,26 +15,27 @@ let package_install_file { packages; _ } pkg =
|
||||||
|
|
||||||
let setup ?filter_out_optional_stanzas_with_missing_deps () =
|
let setup ?filter_out_optional_stanzas_with_missing_deps () =
|
||||||
let { Jbuild_load. file_tree; tree; stanzas; packages } = Jbuild_load.load () in
|
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
|
(if Sys.file_exists "jbuild-workspace" then
|
||||||
Future.all
|
Future.all
|
||||||
(List.map (Workspace.load "jbuild-workspace")
|
(List.map (Workspace.load "jbuild-workspace")
|
||||||
~f:(fun { Workspace.Context. name; switch; root } ->
|
~f:(fun { Workspace.Context. name; switch; root } ->
|
||||||
Context.create_for_opam ~name ~switch ?root ()))
|
Context.create_for_opam ~name ~switch ?root ()))
|
||||||
>>= fun other_contexts ->
|
|
||||||
return (context :: other_contexts)
|
|
||||||
else
|
else
|
||||||
return [context])
|
return [])
|
||||||
>>= fun all_contexts ->
|
>>= 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 =
|
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
|
Gen_rules.gen ~context ~file_tree ~tree ~stanzas ~packages
|
||||||
?filter_out_optional_stanzas_with_missing_deps ())
|
?filter_out_optional_stanzas_with_missing_deps ())
|
||||||
in
|
in
|
||||||
let build_system = Build_system.create ~file_tree ~rules in
|
let build_system = Build_system.create ~file_tree ~rules in
|
||||||
return { build_system
|
return { build_system
|
||||||
; stanzas
|
; stanzas
|
||||||
; context
|
; context = default_context
|
||||||
; packages
|
; packages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ let t sexps =
|
||||||
sexp
|
sexp
|
||||||
in
|
in
|
||||||
begin match ctx.name with
|
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
|
of_sexp_errorf sexp "%S is not allowed as a build context name" s
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue