Skip to content

Commit d21e30a

Browse files
authored
Cache actions that generate symlinks (#4405)
* Fix a bug where dune always re-runs all actions that produce symlinks Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
1 parent 0e2641b commit d21e30a

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ Unreleased
111111
Previously, Dune would have re-executed the action again at the last
112112
line. Now it remembers the result of the first execution.
113113

114+
- Fix a bug where dune would always re-run all actions that produce symlinks,
115+
even if their dependencies did not change. (#4405, @aalekseyev)
116+
114117
2.8.2 (21/01/2021)
115118
------------------
116119

src/dune_engine/cached_digest.ml

+5
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ let refresh_and_chmod fn =
130130
if Cache.cachable stats.st_kind then
131131
Path.chmod ~stats:(Some stats) ~mode:0o222 ~op:`Remove fn
132132
in
133+
let stats =
134+
match stats.st_kind with
135+
| S_LNK -> Path.stat fn
136+
| _ -> stats
137+
in
133138
refresh_ stats fn
134139

135140
let peek_file fn =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Test demonstrating the handling of actions that produce symlinks.
2+
3+
$ echo "(lang dune 2.8)" > dune-project
4+
$ cat >dune <<EOF
5+
> (rule (targets b) (deps a) (action (bash "ln -s a b")))
6+
> EOF
7+
$ echo a > a
8+
$ dune build ./b --display=short
9+
bash b
10+
$ readlink _build/default/b
11+
a
12+
$ cat _build/default/b
13+
a
14+
15+
$ dune build ./b --display=short
16+
17+
18+
$ echo a-v2 > a
19+
$ dune build ./b --display=short
20+
bash b
21+
$ cat _build/default/b
22+
a-v2

0 commit comments

Comments
 (0)