From e71ce620494be5a55f2162f5535a033307006190 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Thu, 28 Mar 2024 12:06:48 +0100 Subject: [PATCH] fix(install): do substitution for sites files Fixes #10317 Signed-off-by: Etienne Millon --- bin/install_uninstall.ml | 9 ++++++--- otherlibs/dune-site/test/install-subst.t | 4 ---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bin/install_uninstall.ml b/bin/install_uninstall.ml index 212a523b3081..5ab77db14835 100644 --- a/bin/install_uninstall.ml +++ b/bin/install_uninstall.ml @@ -142,7 +142,6 @@ module Special_file = struct end type copy_kind = - | Plain (** Just copy the file. Can use fast paths through [Io.copy_file] *) | Substitute (** Use [Artifact_substitution.copy_file]. Will scan all bytes. *) | Special of Special_file.t (** Hooks to add version numbers, replace sections, etc *) @@ -348,7 +347,6 @@ module File_ops_real (W : sig Fiber.return () in match kind with - | Plain -> plain_copy () | Substitute -> Artifact_substitution.copy_file ~conf ~src ~dst ~chmod () | Special sf -> let open Fiber.O in @@ -515,7 +513,12 @@ let install_entry let kind = match special_file with | Some special -> Special special - | None -> if executable then Substitute else Plain + | None -> + (* CR-emillon: for most cases we could use a fast copy here, but some + kinds of files do need artifact substitution(at least + executable files and artifacts built from generated sites + modules), but it's too late to know without reading the file. *) + Substitute in Ops.copy_file ~src:entry.src ~dst ~executable ~kind ~package ~conf in diff --git a/otherlibs/dune-site/test/install-subst.t b/otherlibs/dune-site/test/install-subst.t index 07cdd9bad8c3..bd49e7b4fc42 100644 --- a/otherlibs/dune-site/test/install-subst.t +++ b/otherlibs/dune-site/test/install-subst.t @@ -38,7 +38,3 @@ The generated module has placeholders. We expect no placeholders to be present after installation. $ find out -type f | sort | while read f ; do check_placeholder $f ; done - placeholder found in out/lib/a/S.ml - placeholder found in out/lib/a/a.a - placeholder found in out/lib/a/a.cma - placeholder found in out/lib/a/a__S.cmt