diff --git a/CHANGES.md b/CHANGES.md index 4e82307263a..9f135b6158d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,8 @@ unreleased - Watch mode: display "Success" in green and "Had errors" in red (#1956, @emillon) +- Fix glob dependencies on installed directories (#1965, @rgrinberg) + 1.8.2 (10/03/2019) ------------------ diff --git a/src/build_system.ml b/src/build_system.ml index 4e4dc694122..68560303e63 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -1087,7 +1087,7 @@ and get_file_spec t path = Errors.fail_opt loc "File unavailable: %s" (Path.to_string_maybe_quoted path) -let stamp_file_for_files_of ~dir ~ext = +let stamp_files_for_files_of ~dir ~exts = let t = t () in let files_of_dir = Path.Table.find_or_add t.files_of dir ~f:(fun dir -> @@ -1102,26 +1102,27 @@ let stamp_file_for_files_of ~dir ~ext = ; stamps = String.Map.empty }) in - match String.Map.find files_of_dir.stamps ext with - | Some fn -> fn - | None -> - let stamp_file = Path.relative misc_dir (files_of_dir.dir_hash ^ ext) in - let files = - Option.value - (String.Map.find files_of_dir.files_by_ext ext) - ~default:[] - in - compile_rule t - (let open Build.O in - Pre_rule.make - ~env:None - ~context:None - (Build.paths files >>> - Build.action ~targets:[stamp_file] - (Action.with_stdout_to stamp_file - (Action.digest_files files)))); - files_of_dir.stamps <- String.Map.add files_of_dir.stamps ext stamp_file; - stamp_file + List.map exts ~f:(fun ext -> + match String.Map.find files_of_dir.stamps ext with + | Some fn -> fn + | None -> + let stamp_file = Path.relative misc_dir (files_of_dir.dir_hash ^ ext) in + let files = + Option.value + (String.Map.find files_of_dir.files_by_ext ext) + ~default:[] + in + compile_rule t + (let open Build.O in + Pre_rule.make + ~env:None + ~context:None + (Build.paths files >>> + Build.action ~targets:[stamp_file] + (Action.with_stdout_to stamp_file + (Action.digest_files files)))); + files_of_dir.stamps <- String.Map.add files_of_dir.stamps ext stamp_file; + stamp_file) let all_targets () = let t = t () in diff --git a/src/build_system.mli b/src/build_system.mli index 44ab1222899..e0772da48ed 100644 --- a/src/build_system.mli +++ b/src/build_system.mli @@ -74,8 +74,8 @@ val targets_of : dir:Path.t -> Path.Set.t (** Load the rules for this directory. *) val load_dir : dir:Path.t -> unit -(** Stamp file that depends on all files of [dir] with extension [ext]. *) -val stamp_file_for_files_of : dir:Path.t -> ext:string -> Path.t +(** Stamp files that depends on all files of [dir] with extensions [exts]. *) +val stamp_files_for_files_of : dir:Path.t -> exts:string list -> Path.t list (** Sets the package this file is part of *) val set_package : Path.t -> Package.Name.t -> unit diff --git a/src/lib_file_deps.ml b/src/lib_file_deps.ml index acaa1f828cb..064d8050a18 100644 --- a/src/lib_file_deps.ml +++ b/src/lib_file_deps.ml @@ -64,16 +64,16 @@ let setup_file_deps = let file_deps_of_lib (lib : Lib.t) ~groups = if Lib.is_local lib then - Alias.stamp_file - (Group.L.alias groups ~dir:(Lib.src_dir lib) ~name:(Lib.name lib)) + [Alias.stamp_file + (Group.L.alias groups ~dir:(Lib.src_dir lib) ~name:(Lib.name lib))] else (* suppose that all the files of an external lib are at the same place *) - Build_system.stamp_file_for_files_of + Build_system.stamp_files_for_files_of ~dir:(Obj_dir.public_cmi_dir (Lib.obj_dir lib)) - ~ext:(Group.L.to_string groups) + ~exts:(List.map ~f:Group.to_string groups) let file_deps_with_exts = - List.rev_map ~f:(fun (lib, groups) -> file_deps_of_lib lib ~groups) + List.concat_map ~f:(fun (lib, groups) -> file_deps_of_lib lib ~groups) let file_deps libs ~groups = - List.rev_map libs ~f:(file_deps_of_lib ~groups) + List.concat_map libs ~f:(file_deps_of_lib ~groups)