-
Notifications
You must be signed in to change notification settings - Fork 409
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-install alias #11046
base: main
Are you sure you want to change the base?
Conversation
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 |
src/dune_rules/alias0.ml
Outdated
@@ -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. |
917e85f
to
3393cb5
Compare
@rgrinberg, I tried to follow the advises given during the Dune Dev Meeting. However, there are still some parts I don't understand or misunderstood. I push my broken code to have a support to discuss on (I didn't rewrite the test yet). As you can see in pkg_rules, I added a new rule that builds the target paths from the package universe and adds them as a dependency to the alias
Otherwise, was it similar to the approach you had in mind? |
Signed-off-by: Etienne Marais <[email protected]>
Signed-off-by: Etienne Marais <[email protected]>
Attached it to the workspace. Signed-off-by: Etienne Marais <[email protected]>
6849873
to
877dbbe
Compare
Signed-off-by: Etienne Marais <[email protected]>
let pkg_name = Dune_lang.Package_name.to_string pkg in | ||
Path.Build.L.relative | ||
Private_context.t.build_dir | ||
[ Context_name.to_string ctx_name; ".pkg"; pkg_name; "target" ] |
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.
You should go through the paths module to get this path
@@ -25,4 +25,5 @@ let check = standard "check" | |||
let install = standard "install" | |||
let ocaml_index = standard "ocaml-index" | |||
let runtest = standard "runtest" | |||
let pkg_install = standard "pkg-install" |
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's incorrect to mark this alias as "standard" as it's not defined in every single directory.
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.
If I don't mark it as standard, it will complain that it is not attached to any folder in the source. What is the best way to attached it to the source if I don't declare it as standard?
@@ -355,6 +368,7 @@ let gen_project_rules = | |||
and+ () = Odoc.gen_project_rules sctx project | |||
and+ () = Odoc_new.gen_project_rules sctx project | |||
and+ () = Ocaml_index.project_rule sctx project | |||
and+ () = gen_project_rule_for_package_alias sctx project |
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.
This needs to be done only once per context rather than for every project
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: