给定这样的目录结构:
.
├── frontend
│ ├── _build/ -- build dir, all files produced by shake, except for Frontend.elm, go here
│ ├── Build.hs -- the build script
│ ├── build.sh -- wrap Build.hs with `stack exec build -- $@`
│ ├── other files ...
│ ├── Frontend.elm -- generated by a 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
目标_build/index.js
取决于所有.elm
个文件,包括Frontend.elm
,
但Frontend.elm
由Build.hs
中的规则生成,
如果我盲目地做:
want ["_build/index.js"]
"_build/index.js" %> \out -> do
elms <- filter (not . elmStuff)
<$> (liftIO $ getDirectoryFilesIO "" ["//*.elm"])
need elms
blah blah
want ["Frontend.elm"]
"Frontend.elm" %> \_out -> do
cmd ["protoc", "blah", "blah"]
build.sh clean
会给我:
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}
有没有办法告诉摇动注意动态生成的Frontend.elm
,可能先构建它,以便它在构建的其余部分没有改变,我试过priority 100 ("Frontend.elm" %> ...)
,不起作用。
答案 0 :(得分:2)
你可能应该:
getDirectoryFilesIO
切换到getDirectoryFiles
,这样做。Frontend.elm
的依赖,即使它在文件系统中不存在,您也知道它需要(因此getDirectoryFiles
可能不可见)。want
Frontend.elm
,因为您只想将其作为启用_build/index.js
的黑客攻击。通过这些更改,它看起来像这样:
want ["_build/index.js"]
"_build/index.js" %> \out -> do
need ["Frontend.elm"]
elms <- filter (not . elmStuff)
<$> getDirectoryFiles "" ["//*.elm"]
need elms
blah blah
"Frontend.elm" %> \_out -> do
cmd ["protoc", "blah", "blah"]
警告:我还没有测试过这个解决方案。