See https://sraka.xyz/posts/hs-bindgen-introduction.html. For now, this is a shell-based workflow, rather than using Nix to build everything, i.e. `nix develop` works but `nix build` doesn't. And `cargo build` has to be called manually to create the C library, rather than `cabal` being clever enough to invoke it itself. We ran `cargo cabal init` from the `rust` directory (`nix shell github:yvan-sraka/cargo-cabal`), which generated `hsbindgen.toml` (which we use), and `Setup.lhs` (which just added `extra-lib-dirs`, and with the wrong paths, so we dspecify those statically instead in `garnet.cabal`). We also follow its advice to use `staticlib`. Also, after we ran the first `cargo build` (requiring a `mkdir rust/src` before it would run), we took the generated the Haskell file, and moved the main contents in to `Main.hs` manually.
13 lines
614 B
TOML
13 lines
614 B
TOML
# Since the only `.cabal` format parser implementation and specification live
|
|
# in Cabal itself ... this deadly simple config file is used by `hs-bindgen`
|
|
# Rust crate to get needed data (like default exposed module name).
|
|
|
|
default = "GarnetRs"
|
|
|
|
# There is an unlikely future where instead we have a Rust `.cabal` parser,
|
|
# that most likely would rely under the hood on a Haskell static lib wrapper
|
|
# of `Cabal.Parse` or https://hackage.haskell.org/package/Cabal-syntax library.
|
|
# But even in this case, it would be nice to know the `cargo-cabal` version that
|
|
# generated the `.cabal` file used.
|
|
|
|
version = "0.8.0" |