-
Notifications
You must be signed in to change notification settings - Fork 403
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
feat: introduce the @pkg-deps alias #11046
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Etienne Marais <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
ee81c9f
to
917e85f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unsure what our policy is about looking into _build
in tests, but I have some ideas how to avoid doing it.
$ dune build @pkg-deps | ||
$ ls _build/_private/default/.pkg/ | ||
foo | ||
$ ls _build/default/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about the way to detect that the build is happening is to maybe enable the console output and have the opam
file echo "foo is building"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should there be a build happening? This alias is supposed to only download the deps.
Verify that building the `bar.exe` file is working: | ||
$ dune build ./bar.exe | ||
$ ls _build/default/bar.exe | ||
_build/default/bar.exe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this could then just be replaced by dune exec ./bar.exe
?
This has the slight downside that bar.exe
could've been built before so maybe building bar.exe
should also echo something to stdout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would mean to add a rule that depends on the bar.exe
no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dune exec ./bar.exe
automatically adds a dependency. Unless I misunderstand your question.
> (depends foo)) | ||
> EOF | ||
$ add_mock_repo_if_needed | ||
$ dune pkg lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to involve the solver in this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was the easiest way to write the test. However, it should be possible to write it without using the lock
command. I'll rework it.
|
||
$ . ./helpers.sh | ||
|
||
Create a fake library to install in the target project as a dependency: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't really get why you need a fake library and executable in this test. I see the following as sufficient:
- Write a lock directory
- Build your new alias
- Verify that the sources exist
Everything else seems redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we want to build the library and ensure it is installed, you need the fake library to make sure dune build correctly. Otherwise, it will fail when you try to use it as a dependency.
To be consistent with dune, aliases should be attached to source directories. In particular: The following should build all the sources in dune.lock
The following should build all the sources in the workspace:
If you'd like to download the sources for a particular package, maybe you could add an alias like |
@@ -25,4 25,5 @@ let check = standard "check" | |||
let install = standard "install" | |||
let ocaml_index = standard "ocaml-index" | |||
let runtest = standard "runtest" | |||
let pkg_deps = standard "pkg-deps" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of this aliases is to download the sources? If it is, a more suggestive name would be pkg-sources
or even just sources
@rgrinberg, I feel there is a misunderstanding with the purpose of this PR... The goal is to introduce an alias that allows to download and build the sources of a project. In the issue related to it, we discuss two aliases with two different purposes:
I see. Where would be the best part to add the alias?
Isn't it something that should be attached to |
Okay, I think got confused by your implementation. It's currently adding the source deps to the alias. If you'd like the package build to included in the alias, you need to add the target directory of the package as a dependency. |
pkg_rules would be the ideal place
Don't think there's any difference between fetching and building here. But if you decide that you don't need per package granularity, that's OK too. Also, if you want to check that a package has been built, inspecting _build or using of the shell commands in helpers.sh seems like the better bet. Including extra libraries or executables is still unnecessary moving parts. Our tests suffer from being slow, redundant, and rather hard to understand when failing. Less is more here. |
This PR solves one part of #10949. It introduces a global alias with the source deps as a dependency. When you use it, you will automatically build the source deps of the project. Regarding the PR, I have various questions: