haskell - Shake: how do I depend on dynamically generated source files? -


given directory structure this:

. ├── frontend │   ├── _build/          -- build dir, files produced shake, except frontend.elm, go here │   ├── build.hs         -- build script │   ├── build.sh         -- wrap build.hs `stack exec build -- $@` │   ├── other files ... │   ├── frontend.elm     -- generated rule in build.hs, `protoc  -i../proto --elm_out=. ../proto/frontend.proto` │   ├── index.elm        -- hand written source file │   └── other elms ...   -- hand written source files └── proto     └── frontend.proto   -- protocol buffer message defination, hand written 

target _build/index.js depends on .elm files, including frontend.elm, frontend.elm generated rule in build.hs, if blindly do:

want ["_build/index.js"] "_build/index.js" %> \out ->     elms <- filter (not . elmstuff)             <$> (liftio $ getdirectoryfilesio "" ["//*.elm"])     need elms     blah blah  want ["frontend.elm"] "frontend.elm" %> \_out ->     cmd ["protoc", "blah", "blah"] 

build.sh clean give me:

lint checking error - value has changed since being depended upon:   key:  frontend.elm   old:  file {mod=0x608caaf7,size=0x53d,digest=neq}   new:  file {mod=0x608cab5b,size=0x53d,digest=neq} 

is there way tell shake watch out dynamically generated frontend.elm, maybe build first doesn't change during rest of build, tried priority 100 ("frontend.elm" %> ...), doesn't work.

you should probably:

  1. switch getdirectoryfilesio, not track changes file system, getdirectoryfiles, does.
  2. declare dependence on frontend.elm, know need if not exist in filesystem yet (hence might not visible getdirectoryfiles).
  3. (optional) don't bother wanting frontend.elm, since wanted hack enable _build/index.js.

with these changes, this:

want ["_build/index.js"] "_build/index.js" %> \out ->     need ["frontend.elm"]     elms <- filter (not . elmstuff)             <$> getdirectoryfiles "" ["//*.elm"]     need elms     blah blah  "frontend.elm" %> \_out ->     cmd ["protoc", "blah", "blah"] 

caveat lector: have not tested solution.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -