Happy 和 Alex bootstrap 自己是怎么变成这样的?

How do Happy and Alex bootstrap themselves into being?

happy 的源代码树包含 AttrGrammarParser.ly and Parser.ly and the source tree for alex contains Scan.x。然而,据我所知,为了编译 happy,我们需要使用... happy.ly 文件转换为 .lhs 文件,并且为了编译 alex 我们需要使用... alex.

.x 文件转换为 .hs 文件

所以似乎必须进行一些引导才能编译任一工具。

每个项目的 Setup.lhs 文件都包含一些模板扩展,但据我所知,不要做任何特别的事情来进行引导。

如何以及在哪里完成引导?

我看到您在 darcs.haskell.org 上查看这些软件包的 darcs 存储库的源代码树。如果你查看 Hackage 上的实际 tarball,你会看到一些不同的东西:

https://hackage.haskell.org/package/alex-3.1.4/src/dist/build/alex/alex-tmp/

https://hackage.haskell.org/package/happy-1.19.5/src/dist/build/happy/happy-tmp/

所以基本上必要的构建工件与 Hackage tarball 一起提供。然后 Cabal 在构建过程中只使用构建工件,从而避免了在本地 bootstrap 的需要。 Cabal 也知道如何在你 运行 cabal sdist 为你自己的包保留这样的构建工件时,你不想依赖 happy 或 alex,但最后我检查了这不能与沙箱很好地互操作,fwiw .

对了,alex和happy development已经搬到了github:

https://github.com/simonmar/alex/

https://github.com/simonmar/happy/