cleanup
This commit is contained in:
parent
372efc86a7
commit
6b4e7b31d8
|
@ -56,7 +56,8 @@ end
|
|||
|
||||
type t =
|
||||
{ (* File specification by targets *)
|
||||
files : (Path.t, File_spec.packed) Hashtbl.t
|
||||
files : (Path.t, File_spec.packed) Hashtbl.t
|
||||
; contexts : Context.t list
|
||||
}
|
||||
|
||||
let find_file_exn t file =
|
||||
|
@ -257,7 +258,7 @@ let compile_rule t ~all_targets_by_dir ?(allow_override=false) pre_rule =
|
|||
create_file_specs t target_specs rule ~allow_override
|
||||
|
||||
let setup_copy_rules t ~all_non_target_source_files ~all_targets_by_dir =
|
||||
String_map.iter (Context.all ()) ~f:(fun ~key:_ ~data:(ctx : Context.t) ->
|
||||
List.iter t.contexts ~f:(fun (ctx : Context.t) ->
|
||||
let ctx_dir = ctx.build_dir in
|
||||
Pset.iter all_non_target_source_files ~f:(fun path ->
|
||||
let ctx_path = Path.append ctx_dir path in
|
||||
|
@ -277,7 +278,7 @@ let setup_copy_rules t ~all_non_target_source_files ~all_targets_by_dir =
|
|||
~all_targets_by_dir
|
||||
~allow_override:true))
|
||||
|
||||
let create ~file_tree ~rules =
|
||||
let create ~contexts ~file_tree ~rules =
|
||||
let all_source_files =
|
||||
File_tree.fold file_tree ~init:Pset.empty ~f:(fun dir acc ->
|
||||
let path = File_tree.Dir.path dir in
|
||||
|
@ -288,10 +289,10 @@ let create ~file_tree ~rules =
|
|||
|> Pset.of_list))
|
||||
in
|
||||
let all_copy_targets =
|
||||
String_map.fold (Context.all ()) ~init:Pset.empty ~f:(fun ~key:_ ~data:(ctx : Context.t) acc ->
|
||||
Pset.union acc (Pset.elements all_source_files
|
||||
|> List.map ~f:(Path.append ctx.build_dir)
|
||||
|> Pset.of_list))
|
||||
List.fold_left contexts ~init:Pset.empty ~f:(fun acc (ctx : Context.t) ->
|
||||
Pset.union acc (Pset.elements all_source_files
|
||||
|> List.map ~f:(Path.append ctx.build_dir)
|
||||
|> Pset.of_list))
|
||||
in
|
||||
let all_other_targets =
|
||||
List.fold_left rules ~init:Pset.empty ~f:(fun acc { Pre_rule.targets; _ } ->
|
||||
|
@ -308,7 +309,7 @@ let create ~file_tree ~rules =
|
|||
|> Pmap.of_alist_multi
|
||||
|> Pmap.map ~f:Pset.of_list
|
||||
) in
|
||||
let t = { files = Hashtbl.create 1024 } in
|
||||
let t = { files = Hashtbl.create 1024; contexts } in
|
||||
List.iter rules ~f:(compile_rule t ~all_targets_by_dir ~allow_override:false);
|
||||
setup_copy_rules t ~all_targets_by_dir
|
||||
~all_non_target_source_files:
|
||||
|
@ -335,7 +336,7 @@ let remove_old_artifacts t =
|
|||
if not keep then Path.rmdir dir;
|
||||
keep
|
||||
in
|
||||
String_map.iter (Context.all ()) ~f:(fun ~key:_ ~data:(ctx : Context.t) ->
|
||||
List.iter t.contexts ~f:(fun (ctx : Context.t) ->
|
||||
if Path.exists ctx.build_dir then
|
||||
ignore (walk ctx.build_dir : bool))
|
||||
|
||||
|
|
|
@ -4,7 +4,11 @@ open! Import
|
|||
|
||||
type t
|
||||
|
||||
val create : file_tree:File_tree.t -> rules:Build_interpret.Rule.t list -> t
|
||||
val create
|
||||
: contexts:Context.t list
|
||||
-> file_tree:File_tree.t
|
||||
-> rules:Build_interpret.Rule.t list
|
||||
-> t
|
||||
|
||||
val is_target : t -> Path.t -> bool
|
||||
|
||||
|
|
|
@ -66,9 +66,6 @@ type t =
|
|||
|
||||
let compare a b = compare a.name b.name
|
||||
|
||||
let all_known = ref String_map.empty
|
||||
let all () = !all_known
|
||||
|
||||
let get_arch_sixtyfour stdlib_dir =
|
||||
let config_h = Path.relative stdlib_dir "caml/config.h" in
|
||||
List.exists (lines_of_file (Path.to_string config_h)) ~f:(fun line ->
|
||||
|
@ -176,7 +173,7 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin =
|
|||
in
|
||||
let get_path var = Path.absolute (get var) in
|
||||
let stdlib_dir = get_path "standard_library" in
|
||||
let t =
|
||||
return
|
||||
{ name
|
||||
; kind
|
||||
; merlin
|
||||
|
@ -232,11 +229,6 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin =
|
|||
; cmxs_magic_number = get "cmxs_magic_number"
|
||||
; cmt_magic_number = get "cmt_magic_number"
|
||||
}
|
||||
in
|
||||
if String_map.mem name !all_known then
|
||||
die "context %s already exists" name;
|
||||
all_known := String_map.add !all_known ~key:name ~data:t;
|
||||
return t
|
||||
|
||||
let opam_config_var t var = opam_config_var ~env:t.env ~cache:t.opam_var_cache var
|
||||
|
||||
|
|
|
@ -116,9 +116,6 @@ val create_for_opam
|
|||
|
||||
val default : ?merlin:bool -> unit -> t Future.t
|
||||
|
||||
(** All contexts in use, by name *)
|
||||
val all : unit -> t String_map.t
|
||||
|
||||
val which : t -> string -> Path.t option
|
||||
|
||||
val extend_env : vars:string String_map.t -> env:string array -> string array
|
||||
|
|
|
@ -34,7 +34,7 @@ let setup ?filter_out_optional_stanzas_with_missing_deps ?workspace () =
|
|||
Gen_rules.gen conf ~contexts
|
||||
?filter_out_optional_stanzas_with_missing_deps
|
||||
>>= fun rules ->
|
||||
let build_system = Build_system.create ~file_tree:conf.file_tree ~rules in
|
||||
let build_system = Build_system.create ~contexts ~file_tree:conf.file_tree ~rules in
|
||||
return { build_system
|
||||
; jbuilds = conf.jbuilds
|
||||
; contexts
|
||||
|
|
Loading…
Reference in New Issue