Generating Shake Rules from Actions -
i find of 'makefiles' in project , generate rules based them. however, looks (purposely) nothing can escape action. so, instead lifted 'makefile' scanner io operation before shake function.
main = makefiles <- findmakefiles shake skakeoptions $ generate_rules makefiles
is there better way?
firstly, don't think there's wrong current approach. shake package uses similar approach built in ninja , makefile interpreters, see details makefile interpreter or the sake interpreter. long processing makefile sufficiently quick not matter (which is) writing interpreter custom build syntax using shake, works nicely.
there couple of reasons avoid approach, example, if processing of makefile expensive, or if makefile has other dependencies. in situation can use combination of newcache
parse makefile once, , addoracle
rules can depend on subset of makefile require. however, approach tricker right, since forces layer of indirection, , have make assumptions how generate_rules
works. ghc-make package uses technique (see "makefile" rule , call newcache
), , usingconfigfile
function shake package uses same newcache
/addoracle
pattern.
sticking original approach, there somewhere different can put findmakefiles
step. can do:
main = shakeargswith shakeoptions [] $ \_ -> xs -> makefiles <- findmakefiles let rules = generate_rules makefiles if null xs rules else withoutactions rules >> want xs
this has advantage can add command line flags figure out find makefile, or options processing it. both ninja , makefile systems in shake support that, using --makefile=file
override default. if don't want move generate_rules
, might want replace shake
shakeargs
in original example, provide command line handling.
Comments
Post a Comment