diff --git a/src/context.ml b/src/context.ml index f375333d..77e7e048 100644 --- a/src/context.ml +++ b/src/context.ml @@ -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 diff --git a/src/context.mli b/src/context.mli index 0dea1d34..e1422dab 100644 --- a/src/context.mli +++ b/src/context.mli @@ -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. *) diff --git a/src/main.ml b/src/main.ml index cdfb4771..e1f5a8d8 100644 --- a/src/main.ml +++ b/src/main.ml @@ -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 } diff --git a/src/workspace.ml b/src/workspace.ml index 2bf117af..07899d96 100644 --- a/src/workspace.ml +++ b/src/workspace.ml @@ -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;