Is it necessary to "need" files returned by "getDirectoryFiles"

20 views
Skip to first unread message

mitchel...@gmail.com

unread,
Feb 15, 2018, 2:06:50 PM2/15/18
to Shake build system
Hi, my impression from reading the documentation is that "getDirectoryFiles" is supposed to cause matched files to automatically be tracked as dependencies, but I'm finding that not to be the case.

As an example, this invocation appears not to re-build things when any of the matched files changes:

"target" %> \out -> do
getDirectoryFiles "" ["src//*.hs"]
... build target ...

But this works:

"target" %> \out -> do
need =<< getDirectoryFiles "" ["src//*.hs"]
... build target ...

What, then, does the documentation mean when it says this?

"The result is tracked as a dependency, and if it changes the rule will rerun in subsequent builds."

Thanks!

mitchel...@gmail.com

unread,
Feb 15, 2018, 2:18:44 PM2/15/18
to Shake build system
Oh, I dug around the `-VVV` output a bit and I think I see what's going on.

"getDirectoryContents" tracks the list of files itself (so if a new file appears or is deleted, the associated rule will fire), but does not care whether individual files in the list are modified.

Neil Mitchell

unread,
Feb 16, 2018, 4:55:07 AM2/16/18
to mitchel...@gmail.com, Shake build system
Hi Mitchell,

You are exactly right - it tracks the output, e.g. the list of files,
but not the contents of the files themselves. I'll update the docs to
make that clearer.

Thanks, Neil

Neil Mitchell

unread,
Feb 16, 2018, 12:10:42 PM2/16/18
to mitchel...@gmail.com, Shake build system
Hi Mitchell,

getDirectoryFiles did explain that via an example at the bottom of its
docs, but it wasn't super clear, and the warning wasn't present on the
other directory functions. I've now added to the first paragraph:

-- The result itself is tracked as a dependency, but the files in the
result are not.
-- If the list of files changes in subsequent builds any rule calling
it will rerun.

Is that clear?

Thanks, Neil
Reply all
Reply to author
Forward
0 new messages