Make promoted files a set

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-06-28 15:10:35 +06:30
parent 2a80d034fa
commit 4738b6df89
3 changed files with 9 additions and 10 deletions

View File

@ -804,7 +804,7 @@ let clean =
begin
set_common common ~targets:[];
Build_system.files_in_source_tree_to_delete ()
|> List.iter ~f:Path.unlink_no_err;
|> Path.Set.iter ~f:Path.unlink_no_err;
Path.rm_rf Path.build_dir
end
in

View File

@ -11,25 +11,24 @@ let misc_dir = Path.(relative build_dir) ".misc"
module Promoted_to_delete = struct
module P = Utils.Persistent(struct
type t = Path.t list
type t = Path.Set.t
let name = "PROMOTED-TO-DELETE"
let version = 1
end)
let db = ref []
let db = ref Path.Set.empty
let fn = Path.relative Path.build_dir ".to-delete-in-source-tree"
let add p = db := p :: !db
let add p = db := Path.Set.add !db p
let load () =
Option.value ~default:[] (P.load fn)
Option.value ~default:Path.Set.empty (P.load fn)
let dump () =
if Path.build_dir_exists () then
load ()
|> Path.Set.of_list
|> Path.Set.union (Path.Set.of_list !db)
|> Path.Set.to_list
|> Path.Set.union !db
|> P.dump fn
end

View File

@ -204,11 +204,11 @@ val all_lib_deps_by_context
(** List of all buildable targets *)
val all_targets : t -> Path.t list
(** Return the list of files that were created in the source tree and
(** Return the set of files that were created in the source tree and
needs to be deleted *)
val files_in_source_tree_to_delete
: unit
-> Path.t list
-> Path.Set.t
(** {2 Build rules} *)