shake-build-system

filepatterns to exclude a match


Shake uses various forms of matching, filepath against pattern. Is there one which can be used to exclude a pattern?

Example: I have three directories a, b, c (somewhere in directory x) and each needs html files. There is a rule

(dir <> "//*.html") %> \out -> do -- deal with a and b

which should only deal with the directories a and b and a similar rule to process the files in c.

Is there a way (perhaps using ?>) to separate the two rules for one

(\f -> "x" prefixOf f && not "x/c" prefixOf f) <> "//*.html")
(\f -> "x/x" prefixOf f ) <> "//*.html")

and the other similarly?

The recommended approach to use xx.a.html and xx.b.html is here not possible, because files are processed with other programs which expect the regular html extension.

Alternatively


Solution

  • The rule:

    pattern %> action
    

    Is equivalent to:

    (pattern ?==) ?> action
    

    So you can write:

    (\x -> "//*.html" ?== x && not ("c//*.html" ?== x) ?> action
    

    To match rules matching //*.html, but not c//*.html.

    More generally, there is no requirement to use the FilePattern ?== operator at all, so arbitrary matching predicates can be used instead.