-
Notifications
You must be signed in to change notification settings - Fork 86
Description
Describe the bug
After updating the stackage snapshot to 2024-10-10, we get happy version 2.0.2 from hackage.
This version is no longer a simple executable but the package has been split into the command line tool and a library with multiple sublibraries.
First off, this means we have to declare dependencies between components of the library manually:
stack_snapshot(
name = "stackage",
components = {
"happy-lib": [
"lib",
"lib:grammar",
"lib:backend-glr",
"lib:backend-lalr",
"lib:frontend",
"lib:tabular",
],
},
components_dependencies = {
"happy-lib": repr({
"lib:backend-glr": ["lib:grammar", "lib:tabular"],
"lib:backend-lalr": ["lib:grammar", "lib:tabular"],
"lib:frontend": ["lib:grammar"],
"lib:happy-lib": ["lib:grammar", "lib:backend-glr", "lib:backend-lalr", "lib:frontend", "lib:tabular"],
"lib:tabular": ["lib:grammar"],
}),
},
...
)
Next, the problem is that the happy-lib component is basically empty (ie. it does not produce a static nor shared library and no haddock) since it just re-exports modules from sub-libraries.
Furthermore, the backend sublibraries depend on the Paths_happy_lib
module (see here) to locate its data-dir which fails at runtime since the location of the data-dir in the runfiles tree is completely different to what the Cabal generated (relocatable) Paths modules expects:
happy: /home/claudio/.cache/bazel/_bazel_claudio/f3d395587a4c32cd78e0bbc3318c2a29/execroot/rules_haskell_tests/bazel-out/k8-opt-exec-C7777A24/bin/external/stackage/happy-2.0.2/_install/happy-lib-2.0.2-backend-lalr_data/HappyTemplate.hs: openFile: does not exist (No such file or directory)
We would need to pass generate_paths_module = True
to the haskell_cabal_libary
stanzas generated by stack_snapshot
. But that would also require patching the .cabal file to disable auto-generation of the Paths modules and add the runfiles library as a dependency. Probably the best option would be to vendor the sources in this case.
To Reproduce
Use stack_snapshot with happy >= 2 and try to run it as a tool.
Expected behavior
We should be able to build happy (and happy-lib).
Environment
- OS name + version: linux / nixOS
- Bazel version: 6.5.0
- Version of the rules: 1.0.0
Additional context
Add any other context about the problem here.