cleanup
This commit is contained in:
parent
372efc86a7
commit
6b4e7b31d8
|
@ -56,7 +56,8 @@ end
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
{ (* File specification by targets *)
|
{ (* 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 =
|
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
|
create_file_specs t target_specs rule ~allow_override
|
||||||
|
|
||||||
let setup_copy_rules t ~all_non_target_source_files ~all_targets_by_dir =
|
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
|
let ctx_dir = ctx.build_dir in
|
||||||
Pset.iter all_non_target_source_files ~f:(fun path ->
|
Pset.iter all_non_target_source_files ~f:(fun path ->
|
||||||
let ctx_path = Path.append ctx_dir path in
|
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
|
~all_targets_by_dir
|
||||||
~allow_override:true))
|
~allow_override:true))
|
||||||
|
|
||||||
let create ~file_tree ~rules =
|
let create ~contexts ~file_tree ~rules =
|
||||||
let all_source_files =
|
let all_source_files =
|
||||||
File_tree.fold file_tree ~init:Pset.empty ~f:(fun dir acc ->
|
File_tree.fold file_tree ~init:Pset.empty ~f:(fun dir acc ->
|
||||||
let path = File_tree.Dir.path dir in
|
let path = File_tree.Dir.path dir in
|
||||||
|
@ -288,10 +289,10 @@ let create ~file_tree ~rules =
|
||||||
|> Pset.of_list))
|
|> Pset.of_list))
|
||||||
in
|
in
|
||||||
let all_copy_targets =
|
let all_copy_targets =
|
||||||
String_map.fold (Context.all ()) ~init:Pset.empty ~f:(fun ~key:_ ~data:(ctx : Context.t) acc ->
|
List.fold_left contexts ~init:Pset.empty ~f:(fun acc (ctx : Context.t) ->
|
||||||
Pset.union acc (Pset.elements all_source_files
|
Pset.union acc (Pset.elements all_source_files
|
||||||
|> List.map ~f:(Path.append ctx.build_dir)
|
|> List.map ~f:(Path.append ctx.build_dir)
|
||||||
|> Pset.of_list))
|
|> Pset.of_list))
|
||||||
in
|
in
|
||||||
let all_other_targets =
|
let all_other_targets =
|
||||||
List.fold_left rules ~init:Pset.empty ~f:(fun acc { Pre_rule.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.of_alist_multi
|
||||||
|> Pmap.map ~f:Pset.of_list
|
|> Pmap.map ~f:Pset.of_list
|
||||||
) in
|
) 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);
|
List.iter rules ~f:(compile_rule t ~all_targets_by_dir ~allow_override:false);
|
||||||
setup_copy_rules t ~all_targets_by_dir
|
setup_copy_rules t ~all_targets_by_dir
|
||||||
~all_non_target_source_files:
|
~all_non_target_source_files:
|
||||||
|
@ -335,7 +336,7 @@ let remove_old_artifacts t =
|
||||||
if not keep then Path.rmdir dir;
|
if not keep then Path.rmdir dir;
|
||||||
keep
|
keep
|
||||||
in
|
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
|
if Path.exists ctx.build_dir then
|
||||||
ignore (walk ctx.build_dir : bool))
|
ignore (walk ctx.build_dir : bool))
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,11 @@ open! Import
|
||||||
|
|
||||||
type t
|
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
|
val is_target : t -> Path.t -> bool
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,6 @@ type t =
|
||||||
|
|
||||||
let compare a b = compare a.name b.name
|
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 get_arch_sixtyfour stdlib_dir =
|
||||||
let config_h = Path.relative stdlib_dir "caml/config.h" in
|
let config_h = Path.relative stdlib_dir "caml/config.h" in
|
||||||
List.exists (lines_of_file (Path.to_string config_h)) ~f:(fun line ->
|
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
|
in
|
||||||
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 =
|
return
|
||||||
{ name
|
{ name
|
||||||
; kind
|
; kind
|
||||||
; merlin
|
; merlin
|
||||||
|
@ -232,11 +229,6 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin =
|
||||||
; cmxs_magic_number = get "cmxs_magic_number"
|
; cmxs_magic_number = get "cmxs_magic_number"
|
||||||
; cmt_magic_number = get "cmt_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
|
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
|
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 which : t -> string -> Path.t option
|
||||||
|
|
||||||
val extend_env : vars:string String_map.t -> env:string array -> string array
|
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
|
Gen_rules.gen conf ~contexts
|
||||||
?filter_out_optional_stanzas_with_missing_deps
|
?filter_out_optional_stanzas_with_missing_deps
|
||||||
>>= fun rules ->
|
>>= 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
|
return { build_system
|
||||||
; jbuilds = conf.jbuilds
|
; jbuilds = conf.jbuilds
|
||||||
; contexts
|
; contexts
|
||||||
|
|
Loading…
Reference in New Issue