Skip to content

Refactor Dune_engine.Targets - #9407

Merged
rleshchinskiy merged 6 commits into
ocaml:mainfrom
rleshchinskiy:refactor-targets
Dec 12, 2023
Merged

rleshchinskiy merged 6 commits into
ocaml:mainfrom
rleshchinskiy:refactor-targets

Conversation

@rleshchinskiy

Copy link
Copy Markdown
Contributor

This is a bunch of refactoring around Targets and especially Targets.Produced. The main changes are:

  • We had similar but subtly different code for sandboxed and non-sandboxed directory targets which is now unified. As part of this, we no longer promote empty (sub)directories. Previously, this was only the case for sandboxed directory targets because we didn't move empty (sub)directories from the sandbox to the build dir.
  • We generalise Targets.Produced.collect_digests which allows us to remove Targets.Produced.Option.
  • We move everything to do with async file operations in Build_system which really is the only user of those, anyway.
  • We remove all dependencies on Dune_engine from Targets. A later PR will move those into a separate library which will allow us to use them in the cache as well.

@rleshchinskiy
rleshchinskiy marked this pull request as ready for review December 11, 2023 17:07

@snowleopard snowleopard left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! All reviewed, benchmarked and battle-tested internally.

@rgrinberg
rgrinberg force-pushed the refactor-targets branch 3 times, most recently from faa0d18 to 46011a8 Compare December 12, 2023 04:46

@rgrinberg rgrinberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced the use of symlinking to create a directory target with just normal copying as an experiment and it didn't seem to help. I've also experimented with sandboxing to make sure that we specified all dependencies correctly and again without success.

The fact that doing a clean build gives us the right answer in the install rules is rather concerning and my first assumption is that there's some bug in the engine.

Unfortunately, I didn't get anywhere investigating. I'll keep investigating, but I don't think this should block the PR.

I've left a commit (which I later reverted) switching the symlinking to copying in case anyone wants to experiment.

Roman Leshchinskiy and others added 6 commits December 12, 2023 09:47
We had similar but subtly different code for sandboxed and non-sandboxed directory targets. This patch unifies the two.

We also no longer promote empty (sub)directories. Previously, this was only the case for sandboxed directory targets because we didn't move empty (sub)directories from the sandbox to the build dir.

Signed-off-by: Roman Leshchinskiy <[email protected]>
There was some code duplication here which gets in the way of subsequent refactoring.  Let's get rid of it.

Signed-off-by: Roman Leshchinskiy <[email protected]>
This is a pure refactoring. The main goal is to be able to move Dune_engine.Targets into a separate package which can be used from dune_cache. However, I believe that it also makes the code simpler to follow overall.

The main change is that we move everything to do with async file operations into Build_system which really is the only user of those, anyway.

In addition, we also slightly generalise [Targets.Produced.collect_digests] and remove an unused pretty-printing function.

Signed-off-by: Roman Leshchinskiy <[email protected]>
The test was creating a broken symlink which was subsequently ignored by
Dune. We no longer ignore symlinks so this fails at a later stage. This
patch makes the symlink be valid.

Signed-off-by: Roman Leshchinskiy <[email protected]>
@rleshchinskiy
rleshchinskiy merged commit 1bdf15d into ocaml:main Dec 12, 2023
ejgallego added a commit to ejgallego/dune that referenced this pull request Sep 17, 2024
…cases

When the promoted directory has sub-directories with only other
sub-directories inside, the map will miss that directory and it will
not be properly re-created, failing at children creation time.

Regression in b1c339b / ocaml#9407

Signed-off-by: Emilio Jesus Gallego Arias <[email protected]>
ejgallego added a commit to ejgallego/dune that referenced this pull request Sep 17, 2024
…cases

When the promoted directory has sub-directories with only other
sub-directories inside, the map will miss that directory and it will
not be properly re-created, failing at children creation time.

I am not sure I fully follow the logic here (cc: @rleshchinskiy), for
example, I did have trouble making a testcase fail without using `npm`
to generate a large directory.

Regression in b1c339b / ocaml#9407

Signed-off-by: Emilio Jesus Gallego Arias <[email protected]>
ejgallego added a commit to ejgallego/dune that referenced this pull request Sep 17, 2024
…cases

When the promoted directory has sub-directories with only other
sub-directories inside, the map will miss that directory and it will
not be properly re-created, failing at children creation time.

I am not sure I fully follow the logic here (cc: @rleshchinskiy), for
example, I did have trouble making a testcase fail without using `npm`
to generate a large directory.

Regression in b1c339b / ocaml#9407

Closes ocaml#10609 .

Signed-off-by: Emilio Jesus Gallego Arias <[email protected]>
ejgallego added a commit to ejgallego/dune that referenced this pull request Sep 17, 2024
…cases

When the promoted directory has sub-directories with only other
sub-directories inside, the map will miss that directory and it will
not be properly re-created, failing at children creation time.

I am not sure I fully follow the logic here (cc: @rleshchinskiy).

The current test case works for me (TM), if we revert the fix we get:

```
Error: Cannot promote files to "node_modules/node-cmake/node_modules/ansi-regex".
Reason: opendir(node_modules/node-cmake/node_modules/ansi-regex): No such file or directory
```

Regression in b1c339b / ocaml#9407

Closes ocaml#10609 .

Signed-off-by: Emilio Jesus Gallego Arias <[email protected]>
@Alizter Alizter added this to the 3.13.0 milestone Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants