Adding an extra-deps that doesn't exist yet

左心房为你撑大大i 提交于 2021-02-11 15:53:32

问题


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:

  1. Set up the environment, make sure all dependencies are available: stack build
  2. In this environment, I can now execute a build script: stack runhaskell -- -iclash-shake/shake Shakefile.hs
  3. Run my code generator on the build script's output: clashilator clashilator -i _build/verilog/topEntity.manifest -o _build/verilator
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!