Drop build hooks in favour of just using bundled libraries properly
The script addition is a bit hacky, but there's no obvious straightforward arch/version-independent way to get most of the build path. And eventually, once issues with HLS etc. are sorted out we will revert to using Cabal hooks anyway.
This commit is contained in:
parent
ddb9c300cf
commit
4ecd0b16e2
@ -1,33 +0,0 @@
|
||||
{-# LANGUAGE DisambiguateRecordFields #-}
|
||||
{-# LANGUAGE DuplicateRecordFields #-}
|
||||
{-# LANGUAGE NoFieldSelectors #-}
|
||||
|
||||
module SetupHooks (setupHooks) where
|
||||
|
||||
import Distribution.Simple.SetupHooks
|
||||
import Distribution.Utils.Path
|
||||
import System.Directory
|
||||
|
||||
setupHooks :: SetupHooks
|
||||
setupHooks =
|
||||
noSetupHooks
|
||||
{ configureHooks =
|
||||
noConfigureHooks
|
||||
{ preConfComponentHook = Just addRustLibDir
|
||||
}
|
||||
}
|
||||
|
||||
addRustLibDir :: PreConfComponentInputs -> IO PreConfComponentOutputs
|
||||
addRustLibDir inputs = do
|
||||
cwd <- getCurrentDirectory
|
||||
pure
|
||||
(noPreConfComponentOutputs inputs :: PreConfComponentOutputs)
|
||||
{ componentDiff =
|
||||
buildInfoComponentDiff
|
||||
(componentName (component inputs))
|
||||
emptyBuildInfo
|
||||
{ extraLibDirs =
|
||||
[ makeSymbolicPath $ cwd </> "rust" </> "target" </> "debug"
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -6,14 +6,6 @@ author: Patrick Aldis
|
||||
maintainer:
|
||||
george.thomas@obsidian.systems
|
||||
patrick.aldis@obsidian.systems
|
||||
build-type: Hooks
|
||||
|
||||
custom-setup
|
||||
setup-depends:
|
||||
base,
|
||||
Cabal-hooks,
|
||||
Cabal-syntax,
|
||||
directory,
|
||||
|
||||
common common
|
||||
default-language: GHC2024
|
||||
|
||||
@ -9,6 +9,7 @@ set -euo pipefail
|
||||
# 1. cargo build - build the Rust static library
|
||||
# 2. cbindgen - generate a C header from the Rust source
|
||||
# 3. awk - patch the header for hs-bindgen compatibility
|
||||
# 4. cp - copy static lib
|
||||
#
|
||||
# System include paths (needed by libclang on NixOS) are detected
|
||||
# automatically at TH compile time by GarnetRs.Raw — no env vars needed.
|
||||
@ -57,5 +58,10 @@ awk '
|
||||
|
||||
echo " Patched header at $HEADER"
|
||||
|
||||
# --- Step 4: Copy static lib for Cabal ---
|
||||
#
|
||||
# Place library in the location from which Cabal can bundle it.
|
||||
cp rust/target/debug/libgarnet_rs.a $(cabal list-bin . | sed -e 's=x/garnet/build/garnet/garnet=build=g')
|
||||
|
||||
echo "=== Done ==="
|
||||
echo "Run 'cabal run' to test."
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user