Update installation package #13
5 changed files with 61 additions and 10 deletions
|
@ -17,7 +17,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- Update installation to `cabal`
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- `Makefile`
|
||||||
|
|
||||||
## [0.3.0]
|
## [0.3.0]
|
||||||
|
|
||||||
|
|
49
Setup.hs
49
Setup.hs
|
@ -1,3 +1,5 @@
|
||||||
|
import Control.Exception (throw)
|
||||||
|
import Control.Monad (forM_, when)
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import Distribution.PackageDescription
|
import Distribution.PackageDescription
|
||||||
import Distribution.Simple
|
import Distribution.Simple
|
||||||
|
@ -15,8 +17,23 @@ import Distribution.Simple.Utils
|
||||||
)
|
)
|
||||||
import Distribution.Verbosity (Verbosity)
|
import Distribution.Verbosity (Verbosity)
|
||||||
import qualified Distribution.Verbosity as Verbosity
|
import qualified Distribution.Verbosity as Verbosity
|
||||||
import System.Directory (getCurrentDirectory)
|
import GHC.Generics
|
||||||
|
import System.Directory
|
||||||
|
( XdgDirectory(..)
|
||||||
|
, copyFile
|
||||||
|
, createDirectory
|
||||||
|
, createDirectoryIfMissing
|
||||||
|
, doesDirectoryExist
|
||||||
|
, doesFileExist
|
||||||
|
, getCurrentDirectory
|
||||||
|
, getDirectoryContents
|
||||||
|
, getHomeDirectory
|
||||||
|
, getXdgDirectory
|
||||||
|
)
|
||||||
|
import System.Environment
|
||||||
import System.FilePath ((</>))
|
import System.FilePath ((</>))
|
||||||
|
import Text.Regex
|
||||||
|
import Text.Regex.Base
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = defaultMainWithHooks hooks
|
main = defaultMainWithHooks hooks
|
||||||
|
@ -58,10 +75,13 @@ execCargo verbosity command args = do
|
||||||
IODataModeBinary
|
IODataModeBinary
|
||||||
|
|
||||||
rsMake :: Verbosity -> IO ()
|
rsMake :: Verbosity -> IO ()
|
||||||
rsMake verbosity = execCargo verbosity "cbuild" []
|
rsMake verbosity = do
|
||||||
|
execCargo verbosity "cbuild" []
|
||||||
|
|
||||||
rsAddDirs :: LocalBuildInfo -> IO LocalBuildInfo
|
rsAddDirs :: LocalBuildInfo -> IO LocalBuildInfo
|
||||||
rsAddDirs lbi' = do
|
rsAddDirs lbi' = do
|
||||||
|
localData <- getXdgDirectory XdgData "zcash-haskell"
|
||||||
|
createDirectoryIfMissing True localData
|
||||||
dir <- getCurrentDirectory
|
dir <- getCurrentDirectory
|
||||||
let rustIncludeDir =
|
let rustIncludeDir =
|
||||||
dir </> rsFolder </> "target/x86_64-unknown-linux-gnu/debug"
|
dir </> rsFolder </> "target/x86_64-unknown-linux-gnu/debug"
|
||||||
|
@ -73,8 +93,12 @@ rsAddDirs lbi' = do
|
||||||
updateLibBi libBuild =
|
updateLibBi libBuild =
|
||||||
libBuild
|
libBuild
|
||||||
{ includeDirs = rustIncludeDir : includeDirs libBuild
|
{ includeDirs = rustIncludeDir : includeDirs libBuild
|
||||||
|
, extraLibs = "rustzcash_wrapper" : extraLibs libBuild
|
||||||
, extraLibDirs = rustLibDir : extraLibDirs libBuild
|
, extraLibDirs = rustLibDir : extraLibDirs libBuild
|
||||||
|
, extraBundledLibs = "rustzcash_wrapper" : extraBundledLibs libBuild
|
||||||
|
, ldOptions = ("-L" ++ localData) : ldOptions libBuild
|
||||||
}
|
}
|
||||||
|
copyDir rustLibDir localData
|
||||||
pure $ updateLbi lbi'
|
pure $ updateLbi lbi'
|
||||||
|
|
||||||
rsClean :: Verbosity -> IO ()
|
rsClean :: Verbosity -> IO ()
|
||||||
|
@ -93,3 +117,24 @@ applyUnlessM :: FlagName -> ConfigFlags -> (a -> IO a) -> a -> IO a
|
||||||
applyUnlessM name flags apply a
|
applyUnlessM name flags apply a
|
||||||
| cabalFlag name flags = pure a
|
| cabalFlag name flags = pure a
|
||||||
| otherwise = apply a
|
| otherwise = apply a
|
||||||
|
|
||||||
|
copyDir :: FilePath -> FilePath -> IO ()
|
||||||
|
copyDir src dst = do
|
||||||
|
whenM (not <$> doesDirectoryExist src) $
|
||||||
|
throw (userError "source does not exist")
|
||||||
|
--whenM (doesFileOrDirectoryExist dst) $
|
||||||
|
--throw (userError "destination already exists")
|
||||||
|
createDirectoryIfMissing True dst
|
||||||
|
content <- getDirectoryContents src
|
||||||
|
let xs = filter (`notElem` [".", ".."]) content
|
||||||
|
forM_ xs $ \name -> do
|
||||||
|
let srcPath = src </> name
|
||||||
|
let dstPath = dst </> name
|
||||||
|
isDirectory <- doesDirectoryExist srcPath
|
||||||
|
if isDirectory
|
||||||
|
then copyDir srcPath dstPath
|
||||||
|
else copyFile srcPath dstPath
|
||||||
|
where
|
||||||
|
doesFileOrDirectoryExist x = orM [doesDirectoryExist x, doesFileExist x]
|
||||||
|
orM xs = or <$> sequence xs
|
||||||
|
whenM s r = s >>= flip when r
|
||||||
|
|
4
configure
vendored
4
configure
vendored
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "export PKG_CONFIG_PATH=$(pwd)/librustzcash-wrapper/target/x86_64-unknown-linux-gnu/debug:\$PKG_CONFIG_PATH" | tee -a ~/.bashrc
|
echo "export PKG_CONFIG_PATH=$HOME/.local/share/zcash-haskell:\$PKG_CONFIG_PATH" | tee -a ~/.bashrc
|
||||||
echo "export LD_LIBRARY_PATH=$(pwd)/librustzcash-wrapper/target/x86_64-unknown-linux-gnu/debug:\$LD_LIBRARY_PATH" | tee -a ~/.bashrc
|
echo "export LD_LIBRARY_PATH=$HOME/.local/share/zcash-haskell:\$LD_LIBRARY_PATH" | tee -a ~/.bashrc
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
|
|
|
@ -4,9 +4,6 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
[lib]
|
|
||||||
crate-type=["staticlib"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
haskell-ffi.git = "https://github.com/BeFunctional/haskell-rust-ffi.git"
|
haskell-ffi.git = "https://github.com/BeFunctional/haskell-rust-ffi.git"
|
||||||
haskell-ffi.rev = "2bf292e2e56eac8e9fb0fb2e1450cf4a4bd01274"
|
haskell-ffi.rev = "2bf292e2e56eac8e9fb0fb2e1450cf4a4bd01274"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
cabal-version: 3.0
|
cabal-version: 3.8
|
||||||
|
|
||||||
-- This file has been generated from package.yaml by hpack version 0.36.0.
|
-- This file has been generated from package.yaml by hpack version 0.36.0.
|
||||||
--
|
--
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
name: zcash-haskell
|
name: zcash-haskell
|
||||||
version: 0.4.2.2
|
version: 0.4.2.3
|
||||||
synopsis: Utilities to interact with the Zcash blockchain
|
synopsis: Utilities to interact with the Zcash blockchain
|
||||||
description: Please see the README on the repo at <https://git.vergara.tech/Vergara_Tech/zcash-haskell#readme>
|
description: Please see the README on the repo at <https://git.vergara.tech/Vergara_Tech/zcash-haskell#readme>
|
||||||
category: Blockchain
|
category: Blockchain
|
||||||
|
@ -15,6 +15,8 @@ copyright: (c)2022-2024 Vergara Technologies LLC
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
build-type: Custom
|
build-type: Custom
|
||||||
|
extra-source-files:
|
||||||
|
Setup.hs
|
||||||
extra-doc-files:
|
extra-doc-files:
|
||||||
README.md
|
README.md
|
||||||
CHANGELOG.md
|
CHANGELOG.md
|
||||||
|
@ -25,6 +27,9 @@ custom-setup
|
||||||
, Cabal >= 3.0.0.0
|
, Cabal >= 3.0.0.0
|
||||||
, directory >= 1.3.6.0
|
, directory >= 1.3.6.0
|
||||||
, filepath >= 1.3.0.2
|
, filepath >= 1.3.0.2
|
||||||
|
, envy
|
||||||
|
, regex-compat
|
||||||
|
, regex-base
|
||||||
|
|
||||||
library
|
library
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
|
@ -69,5 +74,5 @@ test-suite zcash-haskell-test
|
||||||
, hspec
|
, hspec
|
||||||
, text
|
, text
|
||||||
, zcash-haskell
|
, zcash-haskell
|
||||||
extra-libraries: rustzcash_wrapper
|
pkgconfig-depends: rustzcash_wrapper
|
||||||
default-language: GHC2021
|
default-language: GHC2021
|
||||||
|
|
Loading…
Reference in a new issue