From 9798f675c04e456320e23242a27a9e3f4f79aac2 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 22 Feb 2024 16:06:23 -0600 Subject: [PATCH] Replace `stack` compilation with custom `cabal` --- Setup.hs | 34 ++++++++++++++++++ cabal.project | 15 ++++++++ package.yaml | 90 ----------------------------------------------- stack.yaml | 81 ------------------------------------------ stack.yaml.lock | 77 ---------------------------------------- zenith.cabal | 93 +++++++++++++++++++++++++------------------------ 6 files changed, 97 insertions(+), 293 deletions(-) create mode 100644 Setup.hs create mode 100644 cabal.project delete mode 100644 package.yaml delete mode 100644 stack.yaml delete mode 100644 stack.yaml.lock diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..4cf4c9c --- /dev/null +++ b/Setup.hs @@ -0,0 +1,34 @@ +import Distribution.PackageDescription +import Distribution.Simple +import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), localPkgDescr) +import Distribution.Simple.PreProcess +import Distribution.Simple.Setup +import System.Directory (getCurrentDirectory) +import System.FilePath (()) + +main :: IO () +main = defaultMainWithHooks hooks + where + hooks = + simpleUserHooks + {confHook = \a flags -> confHook simpleUserHooks a flags >>= rsAddDirs} + +rsFolder :: FilePath +rsFolder = "zcash-haskell/librustzcash-wrapper" + +rsAddDirs :: LocalBuildInfo -> IO LocalBuildInfo +rsAddDirs lbi' = do + dir <- getCurrentDirectory + let rustIncludeDir = + dir rsFolder "target/x86_64-unknown-linux-gnu/debug" + rustLibDir = dir rsFolder "target/x86_64-unknown-linux-gnu/debug" + updateLbi lbi = lbi {localPkgDescr = updatePkgDescr (localPkgDescr lbi)} + updatePkgDescr pkgDescr = + pkgDescr {library = updateLib <$> library pkgDescr} + updateLib lib = lib {libBuildInfo = updateLibBi (libBuildInfo lib)} + updateLibBi libBuild = + libBuild + { includeDirs = rustIncludeDir : includeDirs libBuild + , extraLibDirs = rustLibDir : extraLibDirs libBuild + } + pure $ updateLbi lbi' diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..cf9dbbc --- /dev/null +++ b/cabal.project @@ -0,0 +1,15 @@ +packages: + ./*.cabal + zcash-haskell/zcash-haskell.cabal + +with-compiler: ghc-9.4.8 + +source-repository-package + type: git + location: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git + tag: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d + +source-repository-package + type: git + location: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git + tag: 335e804454cd30da2c526457be37e477f71e4665 diff --git a/package.yaml b/package.yaml deleted file mode 100644 index 5fcfaeb..0000000 --- a/package.yaml +++ /dev/null @@ -1,90 +0,0 @@ -name: zenith -version: 0.4.1 -git: "https://git.vergara.tech/Vergara_Tech/zenith" -license: MIT -author: "Rene Vergara" -maintainer: "rene@vergara.network" -copyright: "Copyright (c) 2022 Vergara Technologies LLC" - -extra-source-files: -- README.md -- CHANGELOG.md -- zenith.cfg - -# Metadata used when publishing your package -synopsis: Haskell CLI for Zcash Full Node -# category: Web - -# To avoid duplicated efforts in documentation and dealing with the -# complications of embedding Haddock markup inside cabal files, it is -# common to point users to the README.md file. -description: Please see the README on repo at - -dependencies: -- base >= 4.7 && < 5 - -library: - source-dirs: src - dependencies: - - aeson - - text - - bytestring - - http-conduit - - http-client - - scientific - - vector - - regex-base - - regex-posix - - regex-compat - - Clipboard - - process - - http-types - - array - - base64-bytestring - - persistent - - persistent-sqlite - - persistent-template - - brick - - mtl - - microlens - - microlens-mtl - - microlens-th - - vty - - zcash-haskell - -executables: - zenith: - main: Main.hs - source-dirs: app - ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N - - -Wall - - -Wunused-imports - dependencies: - - zenith - - configurator - - structured-cli - - data-default - - bytestring - - text - - time - - sort - - brick - -tests: - zenith-test: - main: Spec.hs - source-dirs: test - ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N - dependencies: - - zenith - - hspec - - persistent - - persistent-sqlite - - persistent-template - - zcash-haskell diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index 94817d2..0000000 --- a/stack.yaml +++ /dev/null @@ -1,81 +0,0 @@ -# This file was automatically generated by 'stack init' -# -# Some commonly used options have been documented as comments in this file. -# For advanced use and comprehensive documentation of the format, please see: -# https://docs.haskellstack.org/en/stable/yaml_configuration/ - -# Resolver to choose a 'specific' stackage snapshot or a compiler version. -# A snapshot resolver dictates the compiler version and the set of packages -# to be used for project dependencies. For example: -# -# resolver: lts-3.5 -# resolver: nightly-2015-09-21 -# resolver: ghc-7.10.2 -# -# The location of a snapshot can be provided as a file or url. Stack assumes -# a snapshot provided as a file might change, whereas a url resource does not. -# -# resolver: ./custom-snapshot.yaml -# resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-21.22 - -# User packages to be built. -# Various formats can be used as shown in the example below. -# -# packages: -# - some-directory -# - https://example.com/foo/bar/baz-0.0.2.tar.gz -# subdirs: -# - auto-update -# - wai -packages: -- . -#- haskoin-core -#- zcash-haskell -# Dependency packages to be pulled from upstream that are not in the resolver. -# These entries can reference officially published versions as well as -# forks / in-progress versions pinned to a git hash. For example: -# -# extra-deps: -# - acme-missiles-0.3 -# - git: https://github.com/commercialhaskell/stack.git -# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# -# extra-deps: [] -extra-deps: - - git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git - commit: 73d8125b83cda3b69d91770e1617b4a4d6a98c58 - - git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git - commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d - - git: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git - commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05 - - git: https://github.com/well-typed/borsh.git - commit: d2fcfa159e0a844b1ec5e8ed3e232d4b380fa831 - - vector-0.13.0.0@sha256:fa5cac81a17a5af388716792e8b99c24b3b66770086756d0d8b23f8272a0244c,9112 - - generically-0.1.1 - - vector-algorithms-0.9.0.1 - #- vector-0.12.3.1@sha256:abbfe8830e13549596e1295219d340eb01bd00e1c7124d0dd16586911a291c59,8218 -#extra-lib-dirs: [/home/rav/Documents/programs/haskoin] -# -# Override default flag values for local packages and extra-deps -# flags: {} - -# Extra package databases containing global packages -# extra-package-dbs: [] - -# Control whether we use the GHC we find on the path -# system-ghc: true -# -# Require a specific version of stack, using version ranges -# require-stack-version: -any # Default -# require-stack-version: ">=2.7" -# -# Override the architecture used by stack, especially useful on Windows -# arch: i386 -# arch: x86_64 -# -# Extra directories used by stack for building -# extra-include-dirs: [/path/to/dir] -# -# Allow a newer minor version of GHC than the snapshot specifies -# compiler-check: newer-minor diff --git a/stack.yaml.lock b/stack.yaml.lock deleted file mode 100644 index a23fcb3..0000000 --- a/stack.yaml.lock +++ /dev/null @@ -1,77 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: -- completed: - commit: 73d8125b83cda3b69d91770e1617b4a4d6a98c58 - git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git - name: zcash-haskell - pantry-tree: - sha256: 0b7870345d7ccc65ff51fbfe7c4e579fd497014ab0e0ee2084ba0ad0f68b8b69 - size: 1367 - version: 0.4.2 - original: - commit: 73d8125b83cda3b69d91770e1617b4a4d6a98c58 - git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git -- completed: - commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d - git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git - name: hexstring - pantry-tree: - sha256: 05af6ec085b0c8ac00e0c3043652095a6a9c9d3bd2112ffdcb4c4e28206e0b1c - size: 741 - version: 0.12.0 - original: - commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d - git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git -- completed: - commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05 - git: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git - name: foreign-rust - pantry-tree: - sha256: be2f6fc0fab58a90fec657bdb6bd0ccf0810c7dccfe95c78b85e174fae227e42 - size: 2315 - version: 0.1.0 - original: - commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05 - git: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git -- completed: - commit: d2fcfa159e0a844b1ec5e8ed3e232d4b380fa831 - git: https://github.com/well-typed/borsh.git - name: borsh - pantry-tree: - sha256: 8335925f495a5a653fcb74b6b8bb18cd0b6b7fe7099a1686108704e6ab82f47b - size: 2268 - version: 0.3.0 - original: - commit: d2fcfa159e0a844b1ec5e8ed3e232d4b380fa831 - git: https://github.com/well-typed/borsh.git -- completed: - hackage: vector-0.13.0.0@sha256:fa5cac81a17a5af388716792e8b99c24b3b66770086756d0d8b23f8272a0244c,9112 - pantry-tree: - sha256: d2461d28022c8c0a91da08b579b1bff478f617102d2f5ef596cc5b28d14b8b6a - size: 4092 - original: - hackage: vector-0.13.0.0@sha256:fa5cac81a17a5af388716792e8b99c24b3b66770086756d0d8b23f8272a0244c,9112 -- completed: - hackage: generically-0.1.1@sha256:378ec049bc2853b8011df116647fbd34bb9f00edce9840e4957f98abc097597c,1169 - pantry-tree: - sha256: 9f30503d1fe709f3849c5dd8b9751697a8db4d66105d7ba9c3b98bf4e36bb232 - size: 233 - original: - hackage: generically-0.1.1 -- completed: - hackage: vector-algorithms-0.9.0.1@sha256:222b01a4c0b9e13d73d04fba7c65930df16d1647acc07d84c47ef0356fa33dba,3880 - pantry-tree: - sha256: f2442ae23235b332dcd8b593bb20bfae02890ec891330c060ac4a410a5f1d64d - size: 1510 - original: - hackage: vector-algorithms-0.9.0.1 -snapshots: -- completed: - sha256: afd5ba64ab602cabc2d3942d3d7e7dd6311bc626dcb415b901eaf576cb62f0ea - size: 640060 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/22.yaml - original: lts-21.22 diff --git a/zenith.cabal b/zenith.cabal index 69397c7..148635e 100644 --- a/zenith.cabal +++ b/zenith.cabal @@ -1,40 +1,40 @@ -cabal-version: 1.12 +cabal-version: 3.0 +name: zenith +version: 0.4.2.1 +license: MIT +license-file: LICENSE +author: Rene Vergara +maintainer: pitmut@vergara.tech +copyright: (c) 2022-2024 Vergara Technologies LLC +build-type: Custom +category: Blockchain +extra-doc-files: + README.md + CHANGELOG.md + zenith.cfg --- This file has been generated from package.yaml by hpack version 0.36.0. --- --- see: https://github.com/sol/hpack +common warnings + ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N -Wunused-imports -name: zenith -version: 0.4.1 -synopsis: Haskell CLI for Zcash Full Node -description: Please see the README on repo at -author: Rene Vergara -maintainer: rene@vergara.network -copyright: Copyright (c) 2022 Vergara Technologies LLC -license: MIT -license-file: LICENSE -build-type: Simple -extra-source-files: - README.md - CHANGELOG.md - zenith.cfg - -source-repository head - type: git - location: https://git.vergara.tech/Vergara_Tech/zenith +custom-setup + setup-depends: + base >= 4.7 && < 5 + , Cabal >= 3.0.0.0 + , directory >= 1.3.6.0 + , filepath >= 1.3.0.2 library + import: warnings + ghc-options: -Wall -Wunused-imports exposed-modules: - Zenith.CLI - Zenith.Core - Zenith.DB - Zenith.Types - Zenith.Utils - Zenith.Zcashd - other-modules: - Paths_zenith + Zenith.CLI + Zenith.Core + Zenith.DB + Zenith.Types + Zenith.Utils + Zenith.Zcashd hs-source-dirs: - src + src build-depends: Clipboard , aeson @@ -62,15 +62,13 @@ library , vector , vty , zcash-haskell - default-language: Haskell2010 + default-language: GHC2021 executable zenith + import: warnings main-is: Main.hs - other-modules: - Paths_zenith hs-source-dirs: - app - ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Wunused-imports + app build-depends: base >=4.7 && <5 , brick @@ -82,22 +80,27 @@ executable zenith , text , time , zenith - default-language: Haskell2010 + extra-libraries: rustzcash_wrapper + default-language: GHC2021 -test-suite zenith-test +test-suite zenith-tests + import: warnings type: exitcode-stdio-1.0 main-is: Spec.hs - other-modules: - Paths_zenith hs-source-dirs: - test - ghc-options: -threaded -rtsopts -with-rtsopts=-N + test build-depends: base >=4.7 && <5 - , hspec + , bytestring + , configurator + , data-default + , sort + , text + , time , persistent , persistent-sqlite - , persistent-template + , hspec , zcash-haskell , zenith - default-language: Haskell2010 + extra-libraries: rustzcash_wrapper + default-language: GHC2021