simple build script

This commit is contained in:
George Thomas 2026-03-19 11:47:19 +00:00
parent 1b45174f15
commit 19e9aafe71
2 changed files with 6 additions and 31 deletions

6
build Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
cargo build --manifest-path ./rust/Cargo.toml
ln -sf $(pwd)/rust/target/debug/libgarnet_rs.a $(cabal list-bin . | sed -e 's=x/garnet/build/garnet/garnet=build=g')
cabal build

View File

@ -1,31 +0,0 @@
#!/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