Merge pull request 'Update installation package' (#13) from rav001 into dev040
Reviewed-on: #13
This commit is contained in:
commit
c28addbfc3
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
|
||||
|
||||
- Update installation to `cabal`
|
||||
|
||||
### Removed
|
||||
|
||||
- `Makefile`
|
||||
|
||||
## [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 Distribution.PackageDescription
|
||||
import Distribution.Simple
|
||||
|
@ -15,8 +17,23 @@ import Distribution.Simple.Utils
|
|||
)
|
||||
import Distribution.Verbosity (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 Text.Regex
|
||||
import Text.Regex.Base
|
||||
|
||||
main :: IO ()
|
||||
main = defaultMainWithHooks hooks
|
||||
|
@ -58,10 +75,13 @@ execCargo verbosity command args = do
|
|||
IODataModeBinary
|
||||
|
||||
rsMake :: Verbosity -> IO ()
|
||||
rsMake verbosity = execCargo verbosity "cbuild" []
|
||||
rsMake verbosity = do
|
||||
execCargo verbosity "cbuild" []
|
||||
|
||||
rsAddDirs :: LocalBuildInfo -> IO LocalBuildInfo
|
||||
rsAddDirs lbi' = do
|
||||
localData <- getXdgDirectory XdgData "zcash-haskell"
|
||||
createDirectoryIfMissing True localData
|
||||
dir <- getCurrentDirectory
|
||||
let rustIncludeDir =
|
||||
dir </> rsFolder </> "target/x86_64-unknown-linux-gnu/debug"
|
||||
|
@ -73,8 +93,12 @@ rsAddDirs lbi' = do
|
|||
updateLibBi libBuild =
|
||||
libBuild
|
||||
{ includeDirs = rustIncludeDir : includeDirs libBuild
|
||||
, extraLibs = "rustzcash_wrapper" : extraLibs libBuild
|
||||
, extraLibDirs = rustLibDir : extraLibDirs libBuild
|
||||
, extraBundledLibs = "rustzcash_wrapper" : extraBundledLibs libBuild
|
||||
, ldOptions = ("-L" ++ localData) : ldOptions libBuild
|
||||
}
|
||||
copyDir rustLibDir localData
|
||||
pure $ updateLbi lbi'
|
||||
|
||||
rsClean :: Verbosity -> IO ()
|
||||
|
@ -93,3 +117,24 @@ applyUnlessM :: FlagName -> ConfigFlags -> (a -> IO a) -> a -> IO a
|
|||
applyUnlessM name flags apply a
|
||||
| cabalFlag name flags = pure 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
|
||||
|
||||
echo "export PKG_CONFIG_PATH=$(pwd)/librustzcash-wrapper/target/x86_64-unknown-linux-gnu/debug:\$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 PKG_CONFIG_PATH=$HOME/.local/share/zcash-haskell:\$PKG_CONFIG_PATH" | tee -a ~/.bashrc
|
||||
echo "export LD_LIBRARY_PATH=$HOME/.local/share/zcash-haskell:\$LD_LIBRARY_PATH" | tee -a ~/.bashrc
|
||||
source ~/.bashrc
|
||||
|
|
|
@ -4,9 +4,6 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[lib]
|
||||
crate-type=["staticlib"]
|
||||
|
||||
[dependencies]
|
||||
haskell-ffi.git = "https://github.com/BeFunctional/haskell-rust-ffi.git"
|
||||
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.
|
||||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
|
||||
name: zcash-haskell
|
||||
version: 0.4.2.2
|
||||
version: 0.4.2.3
|
||||
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>
|
||||
category: Blockchain
|
||||
|
@ -15,6 +15,8 @@ copyright: (c)2022-2024 Vergara Technologies LLC
|
|||
license: MIT
|
||||
license-file: LICENSE
|
||||
build-type: Custom
|
||||
extra-source-files:
|
||||
Setup.hs
|
||||
extra-doc-files:
|
||||
README.md
|
||||
CHANGELOG.md
|
||||
|
@ -25,6 +27,9 @@ custom-setup
|
|||
, Cabal >= 3.0.0.0
|
||||
, directory >= 1.3.6.0
|
||||
, filepath >= 1.3.0.2
|
||||
, envy
|
||||
, regex-compat
|
||||
, regex-base
|
||||
|
||||
library
|
||||
exposed-modules:
|
||||
|
@ -69,5 +74,5 @@ test-suite zcash-haskell-test
|
|||
, hspec
|
||||
, text
|
||||
, zcash-haskell
|
||||
extra-libraries: rustzcash_wrapper
|
||||
pkgconfig-depends: rustzcash_wrapper
|
||||
default-language: GHC2021
|
||||
|
|
Loading…
Reference in a new issue