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

(optional) not respected in (executable) and (library) stanza #3970

Closed
fangyi-zhou opened this issue Nov 24, 2020 · 6 comments
Closed

(optional) not respected in (executable) and (library) stanza #3970

fangyi-zhou opened this issue Nov 24, 2020 · 6 comments
Assignees

Comments

@fangyi-zhou
Copy link
Contributor

Expected Behavior

  1. Run $ dune build
  2. main.exe is compiled, main_lwt.exe is not compiled because it's optional and lwt is not installed.

Actual Behavior

Failed with missing lwt

Reproduction

https://github.com/fangyi-zhou/dune-optional-repro

Specifications

@nojb
Copy link
Collaborator

nojb commented Nov 24, 2020

Hello, unless I missed something, there doesn't seem to be any (optional) annotation in your reproduction sample.

@nojb nojb self-assigned this Nov 24, 2020
@fangyi-zhou
Copy link
Contributor Author

fangyi-zhou commented Nov 24, 2020

Sorry, something was lost in creating the repro, but the behaviour is the same
https://github.com/fangyi-zhou/dune-optional-repro/blob/master/bin/dune#L12

@fangyi-zhou
Copy link
Contributor Author

https://github.com/ocaml/dune/blob/master/test/blackbox-tests/test-cases/optional-executable.t/run.t
https://github.com/ocaml/dune/blob/master/test/blackbox-tests/test-cases/optional.t/run.t
It seems that the behaviour of (optional) is correct, but dune build decides to build all stanza regardless of optional. Am I doing it wrong?

@nojb
Copy link
Collaborator

nojb commented Nov 27, 2020

I was able to reproduce. Indeed it is puzzling. I am investigating.

@nojb
Copy link
Collaborator

nojb commented Nov 27, 2020

... and actually I think this is the expected behaviour. Indeed, this feature is meant to avoid adding hard-dependencies to OPAM packages, so you will get the desired behaviour only if you build the @install target. Other targets will still try to build the (optional) stanzas.

It would be great if you can confirm that you see the same behaviour.

@fangyi-zhou
Copy link
Contributor Author

Thanks for the reply. I noticed that building @install omits the optional target.

I guess I can close this issue now.

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

No branches or pull requests

2 participants