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

Allow implementation and interface files to live in different dirs #76

Merged
merged 3 commits into from
Mar 30, 2021

Conversation

anmonteiro
Copy link
Member

@anmonteiro anmonteiro commented Mar 28, 2021

TL;DR

This change relaxes the restriction that implementation and interface files for the same module must live in the same directory.

Motivation

  • Dune's virtual library support allows to compile parameterized libraries and defer the selection of a concrete implementation until linking.
    • It works by declaring a library with "virtual modules" (where only interface files are present), usually in a different directory than the corresponding implementation files
  • This change allows projects that share code between native and JS targets can now rely on these interface files (in another directory), and satisfy those interfaces with their JS specific implementations, by relaxing the restriction that implementation and interface files for the same module must live in the same directory
  • It makes code like this example compile seamlessly

Summary of the changes

  • When processing "file groups", we try to merge groups for the same module rather than exiting with a hard failure
  • We extend the .bsbuild database to account for modules where the implementation and interface files live in different directories
  • We also allow having different extensions across implementations / interfaces (e.g. you can have Foo.re and Foo.mli)

fixes #56

cc @jchavarri

@anmonteiro anmonteiro force-pushed the anmonteiro/virtual-libs branch from 2892a58 to 9004597 Compare March 29, 2021 08:30
@anmonteiro
Copy link
Member Author

The Esy failures are related to the arm64 machine configuration.

This has been tested in a few projects and works nicely, so I'm gonna merge it to unblock other work.

@anmonteiro anmonteiro merged commit 7351284 into fork Mar 30, 2021
@anmonteiro anmonteiro deleted the anmonteiro/virtual-libs branch March 30, 2021 21:20
@anmonteiro anmonteiro mentioned this pull request Apr 2, 2021
4 tasks
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.

Virtual libs support
1 participant