ocaml / ocaml/dune

glob_file_rec is not recursive on generated folder

Open
#9,775 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

Expected Behavior

When using glob_files_rec inside a generated dir, I would expect the glob to be recursive.

Actual Behavior

It behaves like a non recursive glob.

Reproduction

  • PR with a reproducing test: #9774

Additional information

I think this is done on purpose, glob_files_rec.t has some sort of tests for that already. I think this either should not apply to target dirs built with an explicit rule, or should be disable if the generated dir is in the prefix of the glob.

That is :

  $ cat > dune <<EOF
  > (library
  >  (name foo))
  > 
  > (rule
  >  (alias x)
  >  (deps (glob_files_rec *.cmi))
  >  (action (bash "for i in %{deps}; do echo \$i; done")))
  > EOF

Would return nothing, but

  $ cat > dune <<EOF
  > (library
  >  (name foo))
  > 
  > (rule
  >  (alias x)
  >  (deps (glob_files_rec foo/*.cmi))
  >  (action (bash "for i in %{deps}; do echo \$i; done")))
  > EOF

would work recursively on subdirs of foo.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducing test in PR #9774 and the existing tests in glob_files_rec.t. Compare recursive glob behavior when the generated directory is implicit versus explicitly built. Done means resolving the generated-directory case without regressing the existing glob_files_rec.t behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.