digital-asset / daml

The Daml smart contract language
https://www.digitalasset.com/developers
Other
802 stars 204 forks source link

Source dependencies between DAML projects. #4925

Open ghost opened 4 years ago

ghost commented 4 years ago

To improve the user experience for working with multiple DAML projects, we should add the ability to declare dependencies between projects directly, instead of having users manage binary dependencies (DAR files) manually.

The idea is that the user specifies the project folder in dependencies. For example, if you have a project in /home/user/foo that you want to depend on, you would add it to the dependencies field in daml.yaml:

dependencies:
- daml-prim
- daml-stdlib
- /home/user/foo

Then when you run daml build, the compiler will fetch the dependency's DAR file for you, and rebuild the DAR if it needs to be rebuilt. (By contrast, when a user specifies a DAR file directly, nothing can be rebuilt automatically because the sources are not available.)

Limitations:

Progress:

cocreature commented 4 years ago
ghost commented 4 years ago
  • It might still make sense to have an “all or nothing” mode in daml build since daml build --incremental=yes is sadly not deterministic wtr to package ids (on the other hand for dependencies that doesn’t really matter).

Yes, "all or nothing" is what I was thinking for --cached.

But thinking about how the user-invoked build should also go out and figure out all the source dependencies, transitively, to prevent looping forever when a cycle is encountered ... this means it will also have to determine everything that needs to be rebuilt. So perhaps --cached is a distraction from the real problem, which is to reimplement (a very restricted version of) make. 🙃

  • If we think of this as a stepping stone towards fetching dependencies from a proper package repository, I wonder if it might make sense to just completely ignore the .daml directory of the referenced project and instead try to always recompile it somewhere in .daml/deps of the current project and only cache that. That is less convenient for references to local folders but it means that there is basically no difference between the project coming from the package repository and a local reference.

I like this, I think it might be better than what I was thinking. Definitely worth trying.

Though I would still run daml build in the dependency's folder when building the dependency, and just pass a different -o. My reasoning here is to respect the build-options of the dependency, and whatever else may be relevant.

  • Somewhat related to the previous point is the IDE question. If you reference a local folder it would in principle be possible to work on both of them at the same time and have changes propagate through. However, that is not super easy to accomplish and it doesn’t make sense if you reference something from a package repository so I wouldn’t focus on this for now.

Agreed ... we can figure that out later.

cocreature commented 4 years ago

My reasoning here is to respect the build-options of the dependency, and whatever else may be relevant.

I would just have copied the daml.yaml over for that but either way that seems like a minor detail that we can figure out later and potentially change if the other option turns out to be more convenient :slightly_smiling_face:

garyverhaegen-da commented 4 years ago

Slightly tangential comment: if we have source dependencies and we aim for git integration, i.e. the ability to specify a dependency as url, sha, path in daml.yaml, we may not need to develop, maintain and host a package repository at all.