diff --git a/src/dir_contents.ml b/src/dir_contents.ml index 8eb1aa3c..35a42df0 100644 --- a/src/dir_contents.ml +++ b/src/dir_contents.ml @@ -198,7 +198,7 @@ end = struct | Yes_with_transition _ -> ( wrap_modules modules , Module.Name.Map.remove modules main_module_name - |> Module.Name.Map.map ~f:Module.deprecate + |> Module.Name.Map.map ~f:Module.wrapped_compat ) in let alias_module = diff --git a/src/lib_rules.ml b/src/lib_rules.ml index c35bfc44..4074fa07 100644 --- a/src/lib_rules.ml +++ b/src/lib_rules.ml @@ -413,13 +413,13 @@ module Gen (P : Install_rules.Params) = struct else acc) in - let deprecated_modules = Module.Name.Map.values wrapped_compat in + let wrapped_compat = Module.Name.Map.values wrapped_compat in (* deprecated modules have implementations so we can just append them *) let top_sorted_modules = Ocamldep.Dep_graph.top_closed_implementations dep_graphs.impl modules - >>^ fun modules -> modules @ deprecated_modules + >>^ fun modules -> modules @ wrapped_compat in - (let modules = modules @ deprecated_modules in + (let modules = modules @ wrapped_compat in List.iter Mode.all ~f:(fun mode -> build_lib lib ~scope ~flags ~dir ~obj_dir ~mode ~top_sorted_modules ~modules))); diff --git a/src/module.ml b/src/module.ml index 7c8639c5..bb19fb20 100644 --- a/src/module.ml +++ b/src/module.ml @@ -164,7 +164,7 @@ let to_sexp { name; impl; intf; obj_name ; pp } = ; "pp", (option string) (Option.map ~f:(fun _ -> "has pp") pp) ] -let deprecate t = +let wrapped_compat t = { t with intf = None ; impl = @@ -176,6 +176,12 @@ let deprecate t = | Some intf, _ -> intf.path | None, None -> assert false in + let path = + Path.L.relative (Path.parent_exn path) + [ ".wrapped_compat" + ; Path.basename path + ] + in let (base, _) = Path.split_extension path in { syntax = OCaml ; path = Path.extend_basename base ~suffix:".ml-gen" diff --git a/src/module.mli b/src/module.mli index 4e3201da..fec3aa25 100644 --- a/src/module.mli +++ b/src/module.mli @@ -95,4 +95,4 @@ val set_pp : t -> (unit, string list) Build.t option -> t val to_sexp : t Sexp.To_sexp.t -val deprecate : t -> t +val wrapped_compat : t -> t diff --git a/src/stdune/path.ml b/src/stdune/path.ml index c277df2f..e832c76a 100644 --- a/src/stdune/path.ml +++ b/src/stdune/path.ml @@ -943,3 +943,8 @@ module Internal = struct | In_source_tree l -> Local l | External l -> External l end + +module L = struct + (* TODO more efficient implementation *) + let relative t = List.fold_left ~init:t ~f:relative +end diff --git a/src/stdune/path.mli b/src/stdune/path.mli index 6880fa24..3da71c48 100644 --- a/src/stdune/path.mli +++ b/src/stdune/path.mli @@ -169,3 +169,7 @@ val set_root : External.t -> unit module Internal : sig val raw_kind : t -> Kind.t end + +module L : sig + val relative : t -> string list -> t +end