Compare commits
No commits in common. "7d06439bbb772efce0db924b84eb1341e5fd6a20" and "cfa81ebb8963111de78be6ff245a565f99bf29c9" have entirely different histories.
7d06439bbb
...
cfa81ebb89
4 changed files with 14 additions and 121 deletions
101
Setup.hs
101
Setup.hs
|
@ -1,93 +1,17 @@
|
||||||
import Control.Exception (throw)
|
|
||||||
import Control.Monad (forM_, when)
|
|
||||||
import Data.Maybe (isNothing)
|
|
||||||
import Distribution.PackageDescription
|
import Distribution.PackageDescription
|
||||||
import Distribution.Simple
|
import Distribution.Simple
|
||||||
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), localPkgDescr)
|
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), localPkgDescr)
|
||||||
import Distribution.Simple.PreProcess
|
import Distribution.Simple.PreProcess
|
||||||
import Distribution.Simple.Program.Find
|
|
||||||
( defaultProgramSearchPath
|
|
||||||
, findProgramOnSearchPath
|
|
||||||
)
|
|
||||||
import Distribution.Simple.Setup
|
import Distribution.Simple.Setup
|
||||||
import Distribution.Simple.Utils
|
import System.Directory (getCurrentDirectory)
|
||||||
( IODataMode(IODataModeBinary)
|
|
||||||
, maybeExit
|
|
||||||
, rawSystemStdInOut
|
|
||||||
)
|
|
||||||
import Distribution.Verbosity (Verbosity)
|
|
||||||
import qualified Distribution.Verbosity as Verbosity
|
|
||||||
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
|
||||||
where
|
where
|
||||||
hooks =
|
hooks =
|
||||||
simpleUserHooks
|
simpleUserHooks
|
||||||
{ preConf =
|
{confHook = \a flags -> confHook simpleUserHooks a flags >>= rsAddDirs}
|
||||||
\_ flags -> do
|
|
||||||
prepDeps (fromFlag $ configVerbosity flags)
|
|
||||||
pure emptyHookedBuildInfo
|
|
||||||
--, confHook = \a flags -> confHook simpleUserHooks a flags >>= rsAddDirs
|
|
||||||
}
|
|
||||||
|
|
||||||
execCargo :: Verbosity -> String -> [String] -> IO ()
|
|
||||||
execCargo verbosity command args = do
|
|
||||||
cargoPath <-
|
|
||||||
findProgramOnSearchPath Verbosity.silent defaultProgramSearchPath "cargo"
|
|
||||||
dir <- getCurrentDirectory
|
|
||||||
let cargoExec =
|
|
||||||
case cargoPath of
|
|
||||||
Just (p, _) -> p
|
|
||||||
Nothing -> "cargo"
|
|
||||||
cargoArgs = command : args
|
|
||||||
workingDir = Just (dir </> rsFolder)
|
|
||||||
thirdComponent (_, _, c) = c
|
|
||||||
maybeExit . fmap thirdComponent $
|
|
||||||
rawSystemStdInOut
|
|
||||||
verbosity
|
|
||||||
cargoExec
|
|
||||||
cargoArgs
|
|
||||||
workingDir
|
|
||||||
Nothing
|
|
||||||
Nothing
|
|
||||||
IODataModeBinary
|
|
||||||
|
|
||||||
rsMake :: Verbosity -> IO ()
|
|
||||||
rsMake verbosity = do
|
|
||||||
execCargo verbosity "cbuild" []
|
|
||||||
|
|
||||||
prepDeps :: Verbosity -> IO ()
|
|
||||||
prepDeps verbosity = do
|
|
||||||
ldPath <- lookupEnv "LD_LIBRARY_PATH"
|
|
||||||
pkgPath <- lookupEnv "PKG_CONFIG_PATH"
|
|
||||||
if maybe False (matchTest (mkRegex ".*zcash-haskell.*")) ldPath &&
|
|
||||||
maybe False (matchTest (mkRegex ".*zcash-haskell.*")) pkgPath
|
|
||||||
then do
|
|
||||||
execCargo verbosity "cbuild" []
|
|
||||||
localData <- getXdgDirectory XdgData "zcash-haskell"
|
|
||||||
createDirectoryIfMissing True localData
|
|
||||||
dir <- getCurrentDirectory
|
|
||||||
let rustLibDir =
|
|
||||||
dir </> rsFolder </> "target/x86_64-unknown-linux-gnu/debug"
|
|
||||||
copyDir rustLibDir localData
|
|
||||||
else throw $
|
|
||||||
userError "Paths not set correctly, please run the 'configure' script."
|
|
||||||
|
|
||||||
rsFolder :: FilePath
|
rsFolder :: FilePath
|
||||||
rsFolder = "zcash-haskell/librustzcash-wrapper"
|
rsFolder = "zcash-haskell/librustzcash-wrapper"
|
||||||
|
@ -108,24 +32,3 @@ rsAddDirs lbi' = do
|
||||||
, extraLibDirs = rustLibDir : extraLibDirs libBuild
|
, extraLibDirs = rustLibDir : extraLibDirs libBuild
|
||||||
}
|
}
|
||||||
pure $ updateLbi lbi'
|
pure $ updateLbi lbi'
|
||||||
|
|
||||||
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
|
|
||||||
|
|
6
configure
vendored
6
configure
vendored
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
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
|
|
||||||
cd zcash-haskell && cabal build
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 419f041ca9d1dd921673721c56a673fe1dc058e8
|
Subproject commit 75cc947dda2dd24acd166cf17fadd5fb3243c22a
|
26
zenith.cabal
26
zenith.cabal
|
@ -1,6 +1,6 @@
|
||||||
cabal-version: 3.0
|
cabal-version: 3.0
|
||||||
name: zenith
|
name: zenith
|
||||||
version: 0.4.3.0
|
version: 0.4.2.1
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Rene Vergara
|
author: Rene Vergara
|
||||||
|
@ -18,12 +18,10 @@ common warnings
|
||||||
|
|
||||||
custom-setup
|
custom-setup
|
||||||
setup-depends:
|
setup-depends:
|
||||||
base >= 4.12 && < 5
|
base >= 4.7 && < 5
|
||||||
, Cabal >= 3.2.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
|
||||||
, regex-base
|
|
||||||
, regex-compat
|
|
||||||
|
|
||||||
library
|
library
|
||||||
import: warnings
|
import: warnings
|
||||||
|
@ -41,7 +39,7 @@ library
|
||||||
Clipboard
|
Clipboard
|
||||||
, aeson
|
, aeson
|
||||||
, array
|
, array
|
||||||
, base >=4.12 && <5
|
, base >=4.7 && <5
|
||||||
, base64-bytestring
|
, base64-bytestring
|
||||||
, brick
|
, brick
|
||||||
, bytestring
|
, bytestring
|
||||||
|
@ -64,8 +62,7 @@ library
|
||||||
, vector
|
, vector
|
||||||
, vty
|
, vty
|
||||||
, zcash-haskell
|
, zcash-haskell
|
||||||
--pkgconfig-depends: rustzcash_wrapper
|
default-language: GHC2021
|
||||||
default-language: Haskell2010
|
|
||||||
|
|
||||||
executable zenith
|
executable zenith
|
||||||
import: warnings
|
import: warnings
|
||||||
|
@ -73,7 +70,7 @@ executable zenith
|
||||||
hs-source-dirs:
|
hs-source-dirs:
|
||||||
app
|
app
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.12 && <5
|
base >=4.7 && <5
|
||||||
, brick
|
, brick
|
||||||
, bytestring
|
, bytestring
|
||||||
, configurator
|
, configurator
|
||||||
|
@ -83,9 +80,8 @@ executable zenith
|
||||||
, text
|
, text
|
||||||
, time
|
, time
|
||||||
, zenith
|
, zenith
|
||||||
, zcash-haskell
|
extra-libraries: rustzcash_wrapper
|
||||||
pkgconfig-depends: rustzcash_wrapper
|
default-language: GHC2021
|
||||||
default-language: Haskell2010
|
|
||||||
|
|
||||||
test-suite zenith-tests
|
test-suite zenith-tests
|
||||||
import: warnings
|
import: warnings
|
||||||
|
@ -94,7 +90,7 @@ test-suite zenith-tests
|
||||||
hs-source-dirs:
|
hs-source-dirs:
|
||||||
test
|
test
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.12 && <5
|
base >=4.7 && <5
|
||||||
, bytestring
|
, bytestring
|
||||||
, configurator
|
, configurator
|
||||||
, data-default
|
, data-default
|
||||||
|
@ -106,5 +102,5 @@ test-suite zenith-tests
|
||||||
, hspec
|
, hspec
|
||||||
, zcash-haskell
|
, zcash-haskell
|
||||||
, zenith
|
, zenith
|
||||||
pkgconfig-depends: rustzcash_wrapper
|
extra-libraries: rustzcash_wrapper
|
||||||
default-language: Haskell2010
|
default-language: GHC2021
|
||||||
|
|
Loading…
Reference in a new issue