Minor cleanup (#130)

* Remove unnecessary self-dependency

* Regenerate core/default.nix and build -core via callCabal2nix

* grpc-haskell-core: -Wall -Werror and fix warnings

* grpc-haskell: -Wall -Werror and fix warnings

* Update documentation

* Remove LD_LIBRARY_PATH sets from usesGRPC

...as they no longer seem to be needed.

* Remove dead code

* Remove core/default.nix

...as suggested by @evanrelf.
This commit is contained in:
intractable 2021-06-30 12:31:45 -05:00 committed by GitHub
parent 28e9e68f3b
commit b9ed537f64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 27 additions and 69 deletions

View file

@ -7,7 +7,7 @@ have extended and released under the same [`LICENSE`](./LICENSE)
Installation Installation
------------ ------------
**The current version of this library requires gRPC version 1.2.0. Newer versions may work but have not been tested.** **The current version of this library requires gRPC version 1.34.1. Newer versions may work but have not been tested.**
Usage Usage
----- -----

View file

@ -1,25 +0,0 @@
{ mkDerivation, async, base, bytestring, c2hs, clock, containers
, grpc, managed, pipes, proto3-suite, proto3-wire, QuickCheck, safe
, sorted-list, stdenv, stm, tasty, tasty-hunit, tasty-quickcheck
, text, time, transformers, turtle, unix, vector
}:
mkDerivation {
pname = "grpc-haskell-core";
version = "0.0.0.0";
src = ./.;
libraryHaskellDepends = [
async base bytestring clock containers managed pipes proto3-suite
proto3-wire safe sorted-list stm tasty tasty-hunit tasty-quickcheck
transformers vector
];
librarySystemDepends = [ grpc ];
libraryToolDepends = [ c2hs ];
testHaskellDepends = [
async base bytestring clock containers managed pipes proto3-suite
QuickCheck safe tasty tasty-hunit tasty-quickcheck text time
transformers turtle unix
];
homepage = "https://github.com/awakenetworks/gRPC-haskell";
description = "Haskell implementation of gRPC layered on shared C library";
license = stdenv.lib.licenses.asl20;
}

View file

@ -68,7 +68,7 @@ library
, grpc/slice.h , grpc/slice.h
build-tools: c2hs build-tools: c2hs
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -fwarn-incomplete-patterns -fno-warn-unused-do-bind ghc-options: -Wall -Werror -fwarn-incomplete-patterns -fno-warn-unused-do-bind
include-dirs: include include-dirs: include
hs-source-dirs: src hs-source-dirs: src
default-extensions: CPP default-extensions: CPP
@ -103,7 +103,7 @@ test-suite tests
LowLevelTests.Op, LowLevelTests.Op,
UnsafeTests UnsafeTests
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -fwarn-incomplete-patterns -fno-warn-unused-do-bind -g -threaded -rtsopts ghc-options: -Wall -Werror -fwarn-incomplete-patterns -fno-warn-unused-do-bind -g -threaded -rtsopts
hs-source-dirs: tests hs-source-dirs: tests
main-is: Properties.hs main-is: Properties.hs
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0

View file

@ -5,7 +5,7 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-} {-# LANGUAGE KindSignatures #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
@ -212,8 +212,8 @@ destroyClientCall cc = do
C.grpcCallUnref (unsafeCC cc) C.grpcCallUnref (unsafeCC cc)
destroyServerCall :: ServerCall a -> IO () destroyServerCall :: ServerCall a -> IO ()
destroyServerCall sc@ServerCall{ unsafeSC = c, .. } = do destroyServerCall sc@ServerCall{ unsafeSC } = do
grpcDebug "destroyServerCall(R): entered." grpcDebug "destroyServerCall(R): entered."
debugServerCall sc debugServerCall sc
grpcDebug $ "Destroying server-side call object: " ++ show c grpcDebug $ "Destroying server-side call object: " ++ show unsafeSC
C.grpcCallUnref c C.grpcCallUnref unsafeSC

View file

@ -71,7 +71,7 @@ createCompletionQueue _ = do
-- Throws 'CallError' if 'grpcCallStartBatch' returns a non-OK code. -- Throws 'CallError' if 'grpcCallStartBatch' returns a non-OK code.
startBatch :: CompletionQueue -> C.Call -> C.OpArray -> Int -> C.Tag startBatch :: CompletionQueue -> C.Call -> C.OpArray -> Int -> C.Tag
-> IO (Either GRPCIOError ()) -> IO (Either GRPCIOError ())
startBatch cq@CompletionQueue{..} call opArray opArraySize tag = startBatch cq call opArray opArraySize tag =
withPermission Push cq $ fmap throwIfCallError $ do withPermission Push cq $ fmap throwIfCallError $ do
grpcDebug $ "startBatch: calling grpc_call_start_batch with pointers: " grpcDebug $ "startBatch: calling grpc_call_start_batch with pointers: "
++ show call ++ " " ++ show opArray ++ show call ++ " " ++ show opArray

View file

@ -104,7 +104,7 @@ withPermission op cq act = bracket acquire release $ \gotResource ->
-- 'serverRequestCall', this will block forever unless a timeout is given. -- 'serverRequestCall', this will block forever unless a timeout is given.
pluck :: CompletionQueue -> C.Tag -> Maybe TimeoutSeconds pluck :: CompletionQueue -> C.Tag -> Maybe TimeoutSeconds
-> IO (Either GRPCIOError ()) -> IO (Either GRPCIOError ())
pluck cq@CompletionQueue{..} tag mwait = do pluck cq tag mwait = do
grpcDebug $ "pluck: called with tag=" ++ show tag ++ ",mwait=" ++ show mwait grpcDebug $ "pluck: called with tag=" ++ show tag ++ ",mwait=" ++ show mwait
withPermission Pluck cq $ pluck' cq tag mwait withPermission Pluck cq $ pluck' cq tag mwait

View file

@ -7,7 +7,6 @@ import Control.Exception (bracket)
import Control.Monad import Control.Monad
import Data.ByteString (ByteString, useAsCString) import Data.ByteString (ByteString, useAsCString)
import Data.Semigroup (Semigroup)
import Foreign.C.String (CString, peekCString) import Foreign.C.String (CString, peekCString)
import Foreign.Marshal.Alloc (free) import Foreign.Marshal.Alloc (free)

View file

@ -12,7 +12,6 @@ import Data.Function (on)
import Data.ByteString (ByteString, useAsCString, import Data.ByteString (ByteString, useAsCString,
useAsCStringLen) useAsCStringLen)
import Data.List (sortBy, groupBy) import Data.List (sortBy, groupBy)
import Data.Semigroup (Semigroup((<>)))
import qualified Data.SortedList as SL import qualified Data.SortedList as SL
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.Ord (comparing) import Data.Ord (comparing)

View file

@ -22,7 +22,6 @@ import Data.List (find)
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import qualified Data.Set as S import qualified Data.Set as S
import GHC.Exts (fromList, toList) import GHC.Exts (fromList, toList)
import Network.GRPC.Unsafe.ChannelArgs (Arg(..))
import Network.GRPC.LowLevel import Network.GRPC.LowLevel
import qualified Network.GRPC.LowLevel.Call.Unregistered as U import qualified Network.GRPC.LowLevel.Call.Unregistered as U
import qualified Network.GRPC.LowLevel.Client.Unregistered as U import qualified Network.GRPC.LowLevel.Client.Unregistered as U
@ -183,7 +182,7 @@ testSSL =
Nothing) Nothing)
} }
server = TestServer serverConf' $ \s -> do server = TestServer serverConf' $ \s -> do
r <- U.serverHandleNormalCall s mempty $ \U.ServerCall{..} body -> do r <- U.serverHandleNormalCall s mempty $ \U.ServerCall{} body -> do
body @?= "hi" body @?= "hi"
return ("reply test", mempty, StatusOk, "") return ("reply test", mempty, StatusOk, "")
r @?= Right () r @?= Right ()
@ -282,7 +281,7 @@ testAuthMetadataTransfer =
serverProcessor) serverProcessor)
} }
server = TestServer serverConf' $ \s -> do server = TestServer serverConf' $ \s -> do
r <- U.serverHandleNormalCall s mempty $ \U.ServerCall{..} body -> do r <- U.serverHandleNormalCall s mempty $ \U.ServerCall{} body -> do
body @?= "hi" body @?= "hi"
return ("reply test", mempty, StatusOk, "") return ("reply test", mempty, StatusOk, "")
r @?= Right () r @?= Right ()

View file

@ -27,7 +27,7 @@ testCancelFromServer =
testCase "Client/Server - client receives server cancellation" $ testCase "Client/Server - client receives server cancellation" $
runSerialTest $ \grpc -> runSerialTest $ \grpc ->
withClientServerUnaryCall grpc $ withClientServerUnaryCall grpc $
\(Client {..}, Server {..}, ClientCall {..}, sc@ServerCall {..}) -> do \(Client {..}, Server {}, ClientCall {..}, sc@ServerCall {}) -> do
serverCallCancel sc StatusPermissionDenied "TestStatus" serverCallCancel sc StatusPermissionDenied "TestStatus"
clientRes <- runOps unsafeCC clientCQ clientRecvOps clientRes <- runOps unsafeCC clientCQ clientRecvOps
case clientRes of case clientRes of

View file

@ -20,7 +20,6 @@ import Network.GRPC.Unsafe.Slice
import Network.GRPC.Unsafe.Time import Network.GRPC.Unsafe.Time
import System.Clock import System.Clock
import Test.QuickCheck.Gen import Test.QuickCheck.Gen
import qualified Test.QuickCheck.Property as QC
import Test.Tasty import Test.Tasty
import Test.Tasty.HUnit as HU (testCase, (@?=)) import Test.Tasty.HUnit as HU (testCase, (@?=))
import Test.Tasty.QuickCheck as QC import Test.Tasty.QuickCheck as QC

View file

@ -12,7 +12,6 @@ import Data.ByteString (ByteString)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy as TL
import Echo import Echo
import GHC.Generics (Generic)
import Network.GRPC.HighLevel.Client import Network.GRPC.HighLevel.Client
import Network.GRPC.LowLevel import Network.GRPC.LowLevel
import Options.Generic import Options.Generic

View file

@ -9,7 +9,6 @@
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import GHC.Generics (Generic)
import Network.GRPC.HighLevel.Generated (GRPCMethodType (..), import Network.GRPC.HighLevel.Generated (GRPCMethodType (..),
Host (..), Port (..), Host (..), Port (..),
ServerRequest (..), ServerRequest (..),

View file

@ -42,7 +42,7 @@ library
Network.GRPC.HighLevel.Server.Unregistered Network.GRPC.HighLevel.Server.Unregistered
Network.GRPC.HighLevel.Client Network.GRPC.HighLevel.Client
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -fwarn-incomplete-patterns -fno-warn-unused-do-bind ghc-options: -Wall -Werror -fwarn-incomplete-patterns -fno-warn-unused-do-bind
hs-source-dirs: src hs-source-dirs: src
default-extensions: CPP default-extensions: CPP
CC-Options: -std=c99 CC-Options: -std=c99
@ -66,7 +66,7 @@ executable hellos-server
else else
buildable: False buildable: False
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2 ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
hs-source-dirs: examples/hellos/hellos-server hs-source-dirs: examples/hellos/hellos-server
main-is: Main.hs main-is: Main.hs
@ -86,7 +86,7 @@ executable hellos-client
else else
buildable: False buildable: False
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2 ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
hs-source-dirs: examples/hellos/hellos-client hs-source-dirs: examples/hellos/hellos-client
main-is: Main.hs main-is: Main.hs
@ -110,7 +110,7 @@ executable echo-server
else else
buildable: False buildable: False
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2 ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
hs-source-dirs: examples/echo/echo-hs hs-source-dirs: examples/echo/echo-hs
main-is: EchoServer.hs main-is: EchoServer.hs
@ -135,7 +135,7 @@ executable arithmetic-server
else else
buildable: False buildable: False
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2 ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
hs-source-dirs: examples/tutorial/ hs-source-dirs: examples/tutorial/
main-is: ArithmeticServer.hs main-is: ArithmeticServer.hs
@ -159,7 +159,7 @@ executable arithmetic-client
else else
buildable: False buildable: False
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2 ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
hs-source-dirs: examples/tutorial/ hs-source-dirs: examples/tutorial/
main-is: ArithmeticClient.hs main-is: ArithmeticClient.hs
@ -184,14 +184,13 @@ executable echo-client
else else
buildable: False buildable: False
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2 ghc-options: -Wall -Werror -g -threaded -rtsopts -with-rtsopts=-N -O2
hs-source-dirs: examples/echo/echo-hs hs-source-dirs: examples/echo/echo-hs
main-is: EchoClient.hs main-is: EchoClient.hs
test-suite tests test-suite tests
build-depends: build-depends:
base >=4.8 && <5.0 base >=4.8 && <5.0
, grpc-haskell
, bytestring ==0.10.* , bytestring ==0.10.*
, unix , unix
, time , time
@ -212,7 +211,7 @@ test-suite tests
other-modules: other-modules:
GeneratedTests GeneratedTests
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -fwarn-incomplete-patterns -fno-warn-unused-do-bind -g -threaded -rtsopts ghc-options: -Wall -Werror -fwarn-incomplete-patterns -fno-warn-unused-do-bind -g -threaded -rtsopts
hs-source-dirs: tests hs-source-dirs: tests
main-is: Properties.hs main-is: Properties.hs
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
@ -233,7 +232,7 @@ benchmark bench
, random >=1.0.0 , random >=1.0.0
hs-source-dirs: bench hs-source-dirs: bench
main-is: Bench.hs main-is: Bench.hs
ghc-options: -Wall -O2 -threaded -rtsopts -with-rtsopts=-N ghc-options: -Wall -Werror -O2 -threaded -rtsopts -with-rtsopts=-N
if flag(debug) if flag(debug)
CPP-Options: -DDEBUG CPP-Options: -DDEBUG
CC-Options: -DGRPC_HASKELL_DEBUG CC-Options: -DGRPC_HASKELL_DEBUG

View file

@ -94,9 +94,11 @@ let
grpc-haskell-core = grpc-haskell-core =
pkgsNew.haskell.lib.buildFromSdist (pkgsNew.usesGRPC pkgsNew.haskell.lib.buildFromSdist (pkgsNew.usesGRPC
(pkgsNew.haskell.lib.overrideCabal (haskellPackagesNew.callCabal2nix "grpc-haskell-core" ./core {
(haskellPackagesNew.callPackage ./core { }) gpr = pkgsNew.grpc;
(_: { buildDepends = [ haskellPackagesNew.c2hs ]; }))); }
)
);
grpc-haskell-no-tests = grpc-haskell-no-tests =
pkgsNew.haskell.lib.buildFromSdist (pkgsNew.usesGRPC pkgsNew.haskell.lib.buildFromSdist (pkgsNew.usesGRPC
@ -120,7 +122,6 @@ let
]); ]);
python = pkgsNew.python.withPackages (pkgs: [ python = pkgsNew.python.withPackages (pkgs: [
# pkgs.protobuf3_0
pkgs.grpcio-tools pkgs.grpcio-tools
]); ]);
@ -173,11 +174,6 @@ let
}; };
}; };
protobuf3_2NoCheck =
pkgsNew.stdenv.lib.overrideDerivation
pkgsNew.pythonPackages.protobuf
(oldAttrs : {doCheck = false; doInstallCheck = false;});
test-grpc-haskell = test-grpc-haskell =
pkgsNew.mkShell { pkgsNew.mkShell {
nativeBuildInputs = [ nativeBuildInputs = [
@ -190,21 +186,15 @@ let
}; };
usesGRPC = haskellPackage: usesGRPC = haskellPackage:
# TODO: Try using pkgsNew.fixDarwinDylibNames (see PR#129).
pkgsNew.haskell.lib.overrideCabal haskellPackage (oldAttributes: { pkgsNew.haskell.lib.overrideCabal haskellPackage (oldAttributes: {
preBuild = (oldAttributes.preBuild or "") + preBuild = (oldAttributes.preBuild or "") +
pkgsNew.lib.optionalString pkgsNew.stdenv.isDarwin '' pkgsNew.lib.optionalString pkgsNew.stdenv.isDarwin ''
export DYLD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH export DYLD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH
'' +
pkgsNew.lib.optionalString pkgsNew.stdenv.isLinux ''
export LD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
''; '';
shellHook = (oldAttributes.shellHook or "") + shellHook = (oldAttributes.shellHook or "") +
pkgsNew.lib.optionalString pkgsNew.stdenv.isDarwin '' pkgsNew.lib.optionalString pkgsNew.stdenv.isDarwin ''
export DYLD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH export DYLD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH
'' +
pkgsNew.lib.optionalString pkgsNew.stdenv.isLinux ''
export LD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
''; '';
} }
); );