问题
In the process of solving this tricky build situation, I have now encountered a problem with depending on a Cabal package that I generate myself (the full package, package.yaml
and Setup.hs
and source code and dependant C libraries and all).
I have a stack.yaml
and a package.yaml
which together describe an environment where I can run my code generator, so this works:
- Set up the environment, make sure all dependencies are available:
stack build
- In this environment, I can now execute a build script:
stack runhaskell -- -iclash-shake/shake Shakefile.hs
- Run my code generator on the build script's output:
clashilator clashilator -i _build/verilog/topEntity.manifest -o _build/verilator
- Build C part of generated code:
make -f _build/verilator/csrc/Makefile
All this leaves me with a perfectly configured Cabal library in _build/verilator
. I would like to add an executable to my outer package.yaml
that depends on this library. Of course, this executable will not be buildable until all 4 steps above have finished.
I can hide the executable under a build flag, like so:
executables:
draw-toy-verilator:
main: verilator.hs
when:
- condition: flag(verilator)
then:
dependencies:
- clashilator-ffi
else:
buildable: false
Here, clashilator-ffi
is the name of the Cabal package generated in step 3 and prepared for building in step 4. Since draw-toy-verilator
is now behind a flag that defaults to false
, the fact that clashilator-ffi
doesn't exist in step 1 is not a problem to running stack build
with no flags.
However, after step 4, I would then like to do a stack build --flag clash-draw-toy:verilator
and have it work. However, it doesn't because _build/verilator
is not know to Stack as an extra dependency. And I cannot add extra-deps: _build/verilator
to my stack.yaml
, because then step 1 will fail (the directory doesn't exist yet).
So I guess what I am looking for is to either have Stack look at extra-deps
lazily, or tie them to a Cabal flag, or somehow have the package location in the draw-toy-verilator
executable's section in package.yaml
instead of in stack.yaml
.
来源:https://stackoverflow.com/questions/61585694/adding-an-extra-deps-that-doesnt-exist-yet