Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache actions that generate symlinks #4405

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ Unreleased
Previously, Dune would have re-executed the action again at the last
line. Now it remembers the result of the first execution.

- Fix a bug where dune would always re-run all actions that produce symlinks,
even if their dependencies did not change. (#4405, @aalekseyev)

2.8.2 (21/01/2021)
------------------

Expand Down
5 changes: 5 additions & 0 deletions src/dune_engine/cached_digest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ let refresh_and_chmod fn =
if Cache.cachable stats.st_kind then
Path.chmod ~stats:(Some stats) ~mode:0o222 ~op:`Remove fn
in
let stats =
match stats.st_kind with
| S_LNK -> Path.stat fn
| _ -> stats
in
refresh_ stats fn

let peek_file fn =
Expand Down
22 changes: 22 additions & 0 deletions test/blackbox-tests/test-cases/symlink-targets.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Test demonstrating the handling of actions that produce symlinks.

$ echo "(lang dune 2.8)" > dune-project
$ cat >dune <<EOF
> (rule (targets b) (deps a) (action (bash "ln -s a b")))
> EOF
$ echo a > a
$ dune build ./b --display=short
bash b
$ readlink _build/default/b
a
$ cat _build/default/b
a

$ dune build ./b --display=short


$ echo a-v2 > a
$ dune build ./b --display=short
bash b
$ cat _build/default/b
a-v2