Make Cabal-hooks more self-sufficient with additional re-exports#11772
Make Cabal-hooks more self-sufficient with additional re-exports#11772sheaf wants to merge 1 commit into
Conversation
1712eec to
81fc867
Compare
Mikolaj
left a comment
There was a problem hiding this comment.
Looks good otherwise. Thank you.
|
I rebased over the previous documentation improvements, so this is good to go now. Anyone else want to take a look? |
This adds several re-exports that make the Cabal-hooks library more self-sufficient, together with some additional helper functions `findAndMonitorDirFileGlob` and `findAndMonitorSourceDirsFileExts` that allow easily finding and monitoring files for use with pre-build rules.
| searchDirs = hsSourceDirs $ componentBuildInfo comp | ||
| globText = case exts of | ||
| e NE.:| [] -> "**/*." ++ e | ||
| e NE.:| es -> "**/*.{" ++ intercalate "," (e : es) ++ "}" |
There was a problem hiding this comment.
Strictly speaking, we would need to escape those extensions before concatenating them into globs. The API would allow, for example, extensions like "*", "*/*", "}", "\\", etc., which would escape the extension context when injected into a glob like this (or simply produce a malformed glob).
| globText = case exts of | ||
| e NE.:| [] -> "**/*." ++ e | ||
| e NE.:| es -> "**/*.{" ++ intercalate "," (e : es) ++ "}" | ||
| globEither = parseFileGlob (specVersion $ localPkgDescr localBuildInfo) globText |
There was a problem hiding this comment.
It may also be better to construct a Glob directly from the extensions, and then render that as a string (I believe this functionality already exists) to obtain globText, instead of using string concatenation to construct globText and then running that through the glob parser. This way, we not only avoid the above problem of pathological extensions breaking the glob syntax, we also don't need to handle any glob parser errors.
This PR adds several re-exports that make the
Cabal-hookslibrary more self-sufficient, together with some additional helper functionsfindAndMonitorDirFileGlobandfindAndMonitorSourceDirsFileExtsthat allow easily finding and monitoring files for use with pre-build rules.TODO:
Template Α: This PR modifies behaviour or interface