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 targets in subdirectories #3374

Open
samoht opened this issue Apr 15, 2020 · 6 comments
Open

Allow targets in subdirectories #3374

samoht opened this issue Apr 15, 2020 · 6 comments

Comments

@samoht
Copy link
Member

samoht commented Apr 15, 2020

When trying to wrap existing complex projects, it would be very convenient to write something like:

(rule
   (deps (source_tree src))
   (targets src/bin/foo)
   (action (run make -C src bin/foo)))

Unfortunately dune complains with:

Error: src/bin/foo does not denote a file in the current directory
@nojb
Copy link
Collaborator

nojb commented Apr 15, 2020

I think this should be doable with #3268

@samoht
Copy link
Member Author

samoht commented Apr 15, 2020

I haven't found a way to make it work with subdirs, as my use-case needs to call make at the root of src and it will produces files sub-directories (.e.g in src/bin, src/includes/, etc).

@samoht
Copy link
Member Author

samoht commented Apr 15, 2020

(also if I try to copy the files at the root in the action, I have a problem similar to #3345 where dune complains that it doesn't know how to generate this files)

@lubegasimon
Copy link
Collaborator

lubegasimon commented Apr 16, 2021

We’re (at odoc) also blocked by this issue. Basically, the current scheme for generator tests in odoc is so irritating, thus a need for improvement.

For example we have these rules that're generated as a result of generated dune files concept by the help of include stanza.

(rule
    (targets html.gen/test/Bugs/index.html)
    (deps bugs.odocl)
    (action
        (run odoc html-generate --indent -o html.gen %{deps})))
(rule
    (alias runtest)
    (action
        (diff html/test/Bugs/index.html html.gen/test/Bugs/index.html)))

And what we want is for dune to be able to generate the html.gen/test/Bugs/index.html in the _build/default/... dir and html/test/Bugs/index.html in our source tree.

But dune complains with

Error: html.gen/test/Bugs/index.html does not denote a file in the current
directory

(There is a RFC on this topic though)

@sim642
Copy link

sim642 commented Jun 24, 2022

I hit the same issue trying to gradually port configure+Makefile to dune. Eventually I came up with the following hacky workaround.

In dune:

(rule
 (alias configure)
 (deps
  ; ...
  )
 (targets
  ; ...
  ; HACK: workaround for https://github.com/ocaml/dune/issues/3374
  src__machdep-ml.c
  src__cilversion.ml
  lib__perl5__App__Cilly__CilConfig.pm)
 (action (progn
  (run ./configure)
  ; HACK: workaround for https://github.com/ocaml/dune/issues/3374
  ; HACK: use "run cp" instead of "copy" to avoid implicit unsupported subdir deps
  (run cp src/machdep-ml.c src__machdep-ml.c)
  (run cp src/cilversion.ml src__cilversion.ml)
  (run cp lib/perl5/App/Cilly/CilConfig.pm lib__perl5__App__Cilly__CilConfig.pm))))

In src/dune:

; HACK: workaround for https://github.com/ocaml/dune/issues/3374
(rule (action (copy ../src__machdep-ml.c machdep-ml.c)))
(rule (action (copy ../src__cilversion.ml cilversion.ml)))

@rgrinberg
Copy link
Member

There's now an experimental directory targets feature that you can try out. See test-cases/directory-targets/main.t for examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants