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 overwrite of doc and all alias #10228

Open
Khady opened this issue Mar 7, 2024 · 0 comments
Open

allow overwrite of doc and all alias #10228

Khady opened this issue Mar 7, 2024 · 0 comments

Comments

@Khady
Copy link
Contributor

Khady commented Mar 7, 2024

Faced this problem while trying to get a workaround for #9692 and #9690.

I have a project which looks like this, with a dune-project at the root

├── backend/
├── experimental/
├── frontend/
└── infra/

Each of those folders contain some ocaml code compiled by dune. backend, frontend, and infra contain production code which should compile, be tested, have documentation, be formatted, etc. experimental on the other hand is a folder for quick POC, code snippets, ugly scripts, ... It is known that not all the code there will compile. Some of the code could compile but requires to have very specific dependencies installed. The problem is I would like to still be able to run dune command from the root of the project without involving experimental by default. Without ignoring experimental completely. One should still be able to use dune in experimental if they wish to do so.

One thing I tried is to overwrite the common aliases default/all/check/doc/doc-new/runtest. So I have a dune file at the root of the project which looks like this

(alias
 (name default)
 (deps
  (alias_rec backend/default)
  (alias_rec frontend/default)
  (alias_rec infra/default)))

(alias
 (name all)
 (deps
  (alias_rec backend/all)
  (alias_rec frontend/all)
  (alias_rec infra/all)))

(alias
 (name runtest)
 (deps
  (alias_rec backend/runtest)
  (alias_rec frontend/runtest)
  (alias_rec infra/runtest)))

(alias
 (name check)
 (deps
  (alias_rec backend/check)
  (alias_rec frontend/check)
  (alias_rec infra/check)))

(alias
 (name doc)
 (deps
  (alias_rec backend/doc)
  (alias_rec frontend/doc)
  (alias_rec infra/doc)))

(alias
 (name doc-new)
 (deps
  (alias_rec backend/doc-new)
  (alias_rec frontend/doc-new)
  (alias_rec infra/doc-new)))

For default, runtest, check, and doc-new things work as expected. It's not completely seemless, one has to run dune build @@check instead of dune build @check, but it's not too bad. But for all and doc it doesn't seem to work.

Lets simplify the dune file a bit to showcase the problem

(rule
 (alias default)
 (action
  (bash "echo default")))

(rule
 (alias all)
 (action
  (bash "echo all")))

(rule
 (alias runtest)
 (action
  (bash "echo runtest")))

(rule
 (alias check)
 (action
  (bash "echo check")))

(rule
 (alias doc)
 (action
  (bash "echo doc")))

(rule
 (alias doc-new)
 (action
  (bash "echo doc-new")))

Then run the aliases for which things work as expected. I get a mostly empty _build/log with basically only 4 calls to bash. And the expected output.

$ dune build --force @@default @@runtest @@check @@doc-new
default                           
runtest                           
check                             
doc-new                           

While if I build the other 2 aliases, dune will actually compile and generate code in addition of running my bash commands.

$ dune build --force @@all @@doc
all                        
doc                                 
Done: 12% (60/478, 418 left) (jobs: 0)
...
plenty of lines after that
@Khady Khady changed the title allow overwrite of doc and all` alias allow overwrite of doc and all alias Mar 7, 2024
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

1 participant