#!/usr/bin/env bash set -euo pipefail # this is obviously kind of horrible... # when should we run this? during every `cabal build`, `cabal repl` etc. I guess # it's tricky because we really don't want it to be stale # we should also bear in mind `nix build` and Rust `debug`/`release` # eugh, I really wish Hooks just worked # remember also that we still need run `cargo build --manifest-path ./rust/Cargo.toml` before build, to avoid stale .so # that's only important at link time so I think it can be a `postBuildComponentHook` - then e.g. HLS won't try to run it # for now maybe we should do that in a single script alongside the symlinking # with comments explaining how we expect each workaround to go away eventually # oh, you know what, we could just symlink... # can we use `LD_LIBRARY_PATH` instead? # LD_LIBRARY_PATH=rust/target/debug/libgarnet_rs.a cabal run # LD_LIBRARY_PATH=$(pwd)/rust/target/debug cabal run # seemingly not # cabal run --extra-lib-dirs $(pwd)/rust/target/debug # it would be nice if Cabal had a declarative way of specifying input file, so we don't need custom setup or anything # place static lib in position for bundling with Cabal # symlink does work! # put it in Rust build script? # or maybe in shell hook? well, that's probably not often enough, since it won't survive a `cabal clean` ln -s $(pwd)/rust/target/debug/libgarnet_rs.a $(cabal list-bin . | sed -e 's=x/garnet/build/garnet/garnet=build=g') # cabal run