Skip to content

Commit

Permalink
Switch to upstream gRPC-haskell (digital-asset#2642)
Browse files Browse the repository at this point in the history
* Switch to upstream gRPC-haskell
  • Loading branch information
cocreature authored Aug 23, 2019
1 parent 6d1d0b8 commit 67c2e2a
Show file tree
Hide file tree
Showing 110 changed files with 118 additions and 11,739 deletions.
18 changes: 18 additions & 0 deletions 3rdparty/haskell/BUILD.grpc-haskell
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@rules_haskell//haskell:defs.bzl", "haskell_library")
load("@ai_formation_hazel//:hazel.bzl", "hazel_library")

haskell_library(
name = "lib",
srcs = glob(["src/**/*.hs"]),
deps = [
hazel_library("async"),
hazel_library("base"),
hazel_library("bytestring"),
hazel_library("grpc-haskell-core"),
hazel_library("managed"),
hazel_library("proto3-suite"),
hazel_library("proto3-wire"),
],
src_strip_prefix = "src",
visibility = ["//visibility:public"],
)
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
load(
"//bazel_tools:haskell.bzl",
"@com_github_digital_asset_daml//bazel_tools:haskell.bzl",
"c2hs_suite",
"da_haskell_binary",
"da_haskell_library",
"da_haskell_test",
)
load("//bazel_tools:fat_cc_library.bzl", "fat_cc_library")
load("@com_github_digital_asset_daml//bazel_tools:fat_cc_library.bzl", "fat_cc_library")

c2hs_suite(
name = "grpc-haskell-core",
name = "lib",
srcs = [
"src/Network/GRPC/Unsafe/Constants.hsc",
] + glob(["src/**/*.hs"]),
Expand Down
38 changes: 32 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,11 @@ use_integer_simple = not is_windows

HASKELL_LSP_COMMIT = "bfbd8630504ebc57b70948689c37b85cfbe589da"

HASKELL_LSP_HASH = "a301d9409c3a19a042bdf5763611c6a60af5cbc1ff0f281acbc19b3ee70dde5f"
HASKELL_LSP_HASH = "9a5c2871333a5e7e82abdf0bd8c3ab52a130d03832a899aee68bea993cdead1b"

GRPC_HASKELL_COMMIT = "5ceeae74cc802f9d6e58a3a4110bc2c0d1b29c2b"

GRPC_HASKELL_HASH = "7888f3afa2a338834191e5b2d82cf2c340788fbe11834977e58a8778b8094eb2"

GHC_LIB_VERSION = "8.8.0.20190819"

Expand All @@ -485,6 +489,26 @@ http_archive(
urls = ["https://digitalassetsdk.bintray.com/ghc-lib/ghc-lib-parser-{}.tar.gz".format(GHC_LIB_VERSION)],
)

http_archive(
name = "haskell_grpc__haskell__core",
build_file = "//3rdparty/haskell:BUILD.grpc-haskell-core",
patch_args = ["-p2"],
patches = [
"@com_github_digital_asset_daml//bazel_tools:haskell-grpc-haskell-core-cabal.patch",
],
sha256 = GRPC_HASKELL_HASH,
strip_prefix = "gRPC-haskell-{}/core/".format(GRPC_HASKELL_COMMIT),
urls = ["https://github.com/awakesecurity/gRPC-haskell/archive/{}.tar.gz".format(GRPC_HASKELL_COMMIT)],
)

http_archive(
name = "haskell_grpc__haskell",
build_file = "//3rdparty/haskell:BUILD.grpc-haskell",
sha256 = GRPC_HASKELL_HASH,
strip_prefix = "gRPC-haskell-{}".format(GRPC_HASKELL_COMMIT),
urls = ["https://github.com/awakesecurity/gRPC-haskell/archive/{}.tar.gz".format(GRPC_HASKELL_COMMIT)],
)

hazel_repositories(
core_packages = dicts.add(
core_packages,
Expand All @@ -499,6 +523,8 @@ hazel_repositories(
# Excluded since we build it via the http_archive line above.
"ghc-lib-parser",
"ghc-paths",
"grpc-haskell",
"grpc-haskell-core",
"streaming-commons",
"wai-app-static",
"zlib",
Expand Down Expand Up @@ -531,13 +557,13 @@ hazel_repositories(
# Read [Working on ghc-lib] for ghc-lib update instructions at
# https://github.com/DACH-NY/daml/blob/master/ghc-lib/working-on-ghc-lib.md.
hazel_ghclibs(GHC_LIB_VERSION, "96c1d09bc2345563ce9f2f025a466502c1da5bcc937fcb01bd0541f934f6aa1d", "d543a49fc15e2895f2cb1be62a957b2397dc02760ee326c0a6cf67a147a59855") +
hazel_github_external("digital-asset", "hlint", "34133de4262f2b472ec855de8858ae0a74fe2b72", "8fd3fddc370929cdc8a16d52cb2e2ab5ac2a68c5f601da403b472cfd38f22e5d") +
hazel_github_external("awakesecurity", "proto3-wire", "4f355bbac895d577d8a28f567ab4380f042ccc24", "b49bd371847b0cffe0673592870e221708d4ec238589c1739a6d3d03f570ed66") +
hazel_github_external("digital-asset", "hlint", "34133de4262f2b472ec855de8858ae0a74fe2b72", "1a9d623926bdfe97a7a85b3159e259f440749f06bc75d59b981550ce6dca77ef") +
hazel_github_external("awakesecurity", "proto3-wire", "4f355bbac895d577d8a28f567ab4380f042ccc24", "031e05d523a887fbc546096618bc11dceabae224462a6cdd6aab11c1658e17a3") +
hazel_github_external(
"awakesecurity",
"proto3-suite",
"f5ca2bee361d518de5c60b9d05d0f54c5d2f22af",
"878ecbda73c6b7ed924e55f8c4314af39303c6b19a30312f9a1b4d41db67ad1d",
"6a803b1655824e5bec2c518b39b6def438af26135d631b60c9b70bf3af5f0db2",
) +

# Not in stackage
Expand Down Expand Up @@ -569,14 +595,14 @@ hazel_repositories(
"bubba",
"lsp-test",
"d126623dc6895d325e3d204d74e2a22d4f515587",
"a2be2d812010eaadd4885fb0228370a5467627bbb6bd43177fd1f6e5a7eb05f8",
"214848612d319bbded67341c51fd151d65cc80264b9cfe70755ef6941b450ec9",
patch_args = ["-p1"],
patches = ["@com_github_digital_asset_daml//bazel_tools:haskell-lsp-test-no-reexport.patch"],
) + hazel_github_external(
"mpickering",
"hie-bios",
"7a75f520b2e7a482440edd023be8e267a0fa153f",
"015a5ca3c9b2425cdec38cbc238ae8f6b1b5f73591f27af6ab6b2f9b96c08750",
"782469b30bb06cf26873e1c84bd58c8427020ff5777f4ef9d84c75cd26e3ea23",
patch_args = ["-p1"],
patches = ["@com_github_digital_asset_daml//bazel_tools:haskell-hie-bios.patch"],
) +
Expand Down
41 changes: 41 additions & 0 deletions bazel_tools/haskell-c2hs-prefix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl b/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl
index a06b45c0..ed084ac4 100644
--- a/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl
+++ b/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl
@@ -176,9 +176,11 @@ def _find_module_by_ending(modulePath, ending, sourceDirs):
module source file. See `_find_module` for details.
"""

+ fileName = modulePath + "." + ending
+
# Find module source file in source directories.
files = native.glob([
- paths.join(d if d != "." else "", modulePath + "." + ending)
+ paths.join(d if d != "." else "", fileName)
for d in sourceDirs
])
if len(files) == 0:
@@ -194,6 +196,7 @@ def _find_module_by_ending(modulePath, ending, sourceDirs):
return struct(
type = ending,
src = file,
+ prefix = file[:-len(fileName)],
out = _module_output(file, ending),
boot = bootFile,
)
@@ -212,6 +215,7 @@ def _find_module(module, sourceDirs):
`type`: The ending.
`src`: The source file that was found.
E.g. `Some/Module/Name.y`
+ `prefix`: The directory prefix before the file name of the module, E.g. `src`.
`out`: The expected generated output module file.
E.g. `Some/Module/Name.hs`.
`bootFile`: Haskell boot file path or `None` if no boot file was found.
@@ -318,6 +322,7 @@ def _get_build_attrs(
c2hs_library(
name = chs_name,
srcs = [info.src],
+ src_strip_prefix = info.prefix,
deps = (
_get_extra_libs(build_info.extraLibs, extra_libs) +
[cbits_name] +
12 changes: 12 additions & 0 deletions bazel_tools/haskell-grpc-haskell-core-cabal.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/core/grpc-haskell-core.cabal b/core/grpc-haskell-core.cabal
index 8c67ce9..8ffd432 100644
--- a/core/grpc-haskell-core.cabal
+++ b/core/grpc-haskell-core.cabal
@@ -10,6 +10,7 @@ copyright: Copyright 2016 Awake Networks
category: Network
build-type: Simple
cabal-version: >=1.10
+extra-source-files: include/grpc_haskell.h

Flag Debug
Description: Adds debug logging.
4 changes: 2 additions & 2 deletions compiler/scenario-service/client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ da_haskell_library(
"directory",
"extra",
"filepath",
"grpc-haskell",
"grpc-haskell-core",
"hashable",
"lens",
"mtl",
Expand All @@ -44,7 +46,5 @@ da_haskell_library(
"//daml-assistant:daml-project-config",
"//libs-haskell/bazel-runfiles",
"//libs-haskell/da-hs-base",
"//nix/third-party/gRPC-haskell:grpc-haskell",
"//nix/third-party/gRPC-haskell/core:grpc-haskell-core",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ withScenarioService opts@Options{..} f = do
liftIO $ optLogInfo $ "Scenario service backend running on port " <> show port
-- Using 127.0.0.1 instead of localhost helps when our packaging logic falls over
-- and DNS lookups break, e.g., on Alpine linux.
let grpcConfig = ClientConfig (Host "127.0.0.1") (Port port) [] Nothing
let grpcConfig = ClientConfig (Host "127.0.0.1") (Port port) [] Nothing Nothing
withGRPCClient grpcConfig $ \client -> do
ssClient <- SS.scenarioServiceClient client
f Handle
Expand Down
6 changes: 2 additions & 4 deletions compiler/scenario-service/protos/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ da_haskell_library(
"bytestring",
"containers",
"deepseq",
"grpc-haskell",
"grpc-haskell-core",
"proto3-suite",
"proto3-wire",
"text",
"vector",
],
visibility = ["//visibility:public"],
deps = [
"//nix/third-party/gRPC-haskell:grpc-haskell",
"//nix/third-party/gRPC-haskell/core:grpc-haskell-core",
],
)
2 changes: 2 additions & 0 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def daml_deps():
strip_prefix = "rules_haskell-{}/hazel".format(rules_haskell_version),
urls = ["https://github.com/tweag/rules_haskell/archive/%s.tar.gz" % rules_haskell_version],
sha256 = rules_haskell_sha256,
patch_args = ["-p2"],
patches = ["@com_github_digital_asset_daml//bazel_tools:haskell-c2hs-prefix.patch"],
)

if "com_github_madler_zlib" not in native.existing_rules():
Expand Down
2 changes: 1 addition & 1 deletion language-support/hs/bindings/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ da_haskell_library(
"containers",
"exceptions",
"extra",
"grpc-haskell",
"proto3-suite",
"retry",
"text",
Expand All @@ -29,7 +30,6 @@ da_haskell_library(
"//compiler/daml-lf-proto",
"//daml-lf/archive:daml_lf_haskell_proto",
"//ledger-api/grpc-definitions:ledger-api-haskellpb",
"//nix/third-party/gRPC-haskell:grpc-haskell",
],
)

Expand Down
1 change: 1 addition & 0 deletions language-support/hs/bindings/src/DA/Ledger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ configOfHostAndPort host port =
, clientServerPort = port
, clientArgs = []
, clientSSLConfig = Nothing
, clientAuthority = Nothing
}

withTimeout :: LedgerService a -> LedgerService (Maybe a)
Expand Down
6 changes: 2 additions & 4 deletions ledger-api/grpc-definitions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,14 @@ da_haskell_library(
"bytestring",
"containers",
"deepseq",
"grpc-haskell",
"grpc-haskell-core",
"proto3-suite",
"proto3-wire",
"text",
"vector",
],
visibility = ["//visibility:public"],
deps = [
"//nix/third-party/gRPC-haskell:grpc-haskell",
"//nix/third-party/gRPC-haskell/core:grpc-haskell-core",
],
)

scalapb_deps = [
Expand Down
13 changes: 0 additions & 13 deletions nix/third-party/README

This file was deleted.

10 changes: 0 additions & 10 deletions nix/third-party/gRPC-haskell/.gitignore

This file was deleted.

58 changes: 0 additions & 58 deletions nix/third-party/gRPC-haskell/BUILD.bazel

This file was deleted.

Loading

0 comments on commit 67c2e2a

Please sign in to comment.