Skip to content

Commit

Permalink
Supporting producing sdist tarballs for the HS ledger bindings (digit…
Browse files Browse the repository at this point in the history
…al-asset#2336)

* Supporting producing sdist tarballs for the HS ledger bindings

The README.md has an explanation for how you can use this.

This should hopefully allow others to experiment with the bindings.
  • Loading branch information
cocreature authored Jul 30, 2019
1 parent 18ecf0e commit 50a0439
Show file tree
Hide file tree
Showing 8 changed files with 497 additions and 10 deletions.
61 changes: 61 additions & 0 deletions compiler/daml-lf-ast/daml-lf-ast.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
cabal-version: 2.4
name: daml-lf-ast
build-type: Simple
version: 0.1.0
synopsis: DAML-LF AST
license: Apache-2.0
author: Digital Asset
maintainer: Digital Asset
copyright: Digital Asset 2019
homepage: https://github.com/digital-asset/daml#readme
bug-reports: https://github.com/digital-asset/daml/issues

source-repository head
type: git
location: https://github.com/digital-asset/daml.git

library
default-language: Haskell2010
hs-source-dirs: src
build-depends:
base,
containers,
da-hs-base,
deepseq,
extra,
hashable,
lens,
mtl,
recursion-schemes,
safe,
scientific,
template-haskell,
text,
time,
unordered-containers
exposed-modules:
DA.Daml.LF.Ast
DA.Daml.LF.Ast.Base
DA.Daml.LF.Ast.Optics
DA.Daml.LF.Ast.Pretty
DA.Daml.LF.Ast.Recursive
DA.Daml.LF.Ast.Type
DA.Daml.LF.Ast.Util
DA.Daml.LF.Ast.Version
DA.Daml.LF.Ast.World
default-extensions:
DeriveDataTypeable
DeriveFoldable
DeriveFunctor
DeriveGeneric
DeriveTraversable
FlexibleContexts
GeneralizedNewtypeDeriving
LambdaCase
NamedFieldPuns
PackageImports
OverloadedStrings
RecordWildCards
ScopedTypeVariables
StandaloneDeriving
ViewPatterns
53 changes: 53 additions & 0 deletions compiler/daml-lf-proto/daml-lf-proto.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cabal-version: 2.4
name: daml-lf-proto
build-type: Simple
version: 0.1.0
synopsis: DAML-LF Protobuf Encoding
license: Apache-2.0
author: Digital Asset
maintainer: Digital Asset
copyright: Digital Asset 2019
homepage: https://github.com/digital-asset/daml#readme
bug-reports: https://github.com/digital-asset/daml/issues

source-repository head
type: git
location: https://github.com/digital-asset/daml.git

library
default-language: Haskell2010
hs-source-dirs: src
build-depends:
base,
bytestring,
containers,
cryptonite,
da-hs-base,
daml-lf-ast,
daml-lf-proto-types,
either,
lens,
memory,
mtl,
proto3-suite,
scientific,
template-haskell,
text,
transformers,
vector,
exposed-modules:
DA.Daml.LF.Mangling
DA.Daml.LF.Proto3.Archive
DA.Daml.LF.Proto3.Decode
DA.Daml.LF.Proto3.DecodeV1
DA.Daml.LF.Proto3.Encode
DA.Daml.LF.Proto3.EncodeV1
DA.Daml.LF.Proto3.Error
default-extensions:
FlexibleContexts
LambdaCase
OverloadedStrings
PackageImports
RecordWildCards
TypeApplications
ViewPatterns
38 changes: 38 additions & 0 deletions daml-assistant/daml-project-config.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
cabal-version: 2.4
name: daml-project-config
build-type: Simple
version: 0.1.0
synopsis: daml project config
license: Apache-2.0
author: Digital Asset
maintainer: Digital Asset
copyright: Digital Asset 2019
homepage: https://github.com/digital-asset/daml#readme
bug-reports: https://github.com/digital-asset/daml/issues

source-repository head
type: git
location: https://github.com/digital-asset/daml.git

library
default-language: Haskell2010
hs-source-dirs: daml-project-config
build-depends:
base,
directory,
extra,
filepath,
lens,
safe-exceptions,
semver,
text,
yaml
exposed-modules:
DA.Daml.Project.Config
DA.Daml.Project.Consts
DA.Daml.Project.Types
DA.Daml.Project.Util
default-extensions:
GeneralizedNewtypeDeriving
LambdaCase
OverloadedStrings
20 changes: 20 additions & 0 deletions language-support/hs/bindings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Usage

Using the ledger bindings outside of this repository can be a bit
tricky since there are quite a few packages required that are not
published to Hackage at the moment.

To make things a bit easier there is a `build_packages.sh` script in
this directory that you can run as follows: `./build_packages.sh
TARGET_DIR`. This will build the tarballs for all cabal packages and
put them in `TARGET_DIR`. If `TARGET_DIR` does not already contain a
`cabal.project` file, it will also create a `cabal.project` file that
references the created tarballs so all dependencies should be resolved
properly. You will also need to install gRPC 1.22, see
https://github.com/grpc/grpc/blob/master/BUILDING.md for installation
instructions. If you install it in a non-standard location, you need
to adjust extra-lib-dirs and extra-include-dirs for
grpc-haskell-core. The default `cabal.project` file contains an
example of how to do this.

The main package for the ledger bindings is called `daml-ledger`.
165 changes: 165 additions & 0 deletions language-support/hs/bindings/build_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#!/usr/bin/env bash
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set -eou pipefail

if [ "$#" -ne 1 ]; then
echo "Expected exactly one argument."
echo "Usage: ./build_packages.sh TARGET_DIR"
exit 1
fi

cd "$(dirname ${BASH_SOURCE[0]})/../../.."
TARGET_DIR=$1

BAZEL_BIN=$(bazel info bazel-bin)

pushd daml-assistant
cabal new-sdist
cp dist-newstyle/sdist/daml-project-config-0.1.0.tar.gz "$TARGET_DIR"
popd

pushd libs-haskell/da-hs-base
cabal new-sdist
cp dist-newstyle/sdist/da-hs-base-0.1.0.tar.gz "$TARGET_DIR"
popd


pushd nix/third-party/gRPC-haskell/core
cabal new-sdist
cp dist-newstyle/sdist/grpc-haskell-core-0.0.0.0.tar.gz "$TARGET_DIR"
popd

pushd nix/third-party/gRPC-haskell
cabal new-sdist
cp dist-newstyle/sdist/grpc-haskell-0.0.0.0.tar.gz "$TARGET_DIR"
popd

pushd compiler/daml-lf-ast
cabal new-sdist
cp dist-newstyle/sdist/daml-lf-ast-0.1.0.tar.gz "$TARGET_DIR"
popd

pushd compiler/daml-lf-proto
cabal new-sdist
cp dist-newstyle/sdist/daml-lf-proto-0.1.0.tar.gz "$TARGET_DIR"
popd

bazel build //daml-lf/archive:daml_lf_haskell_proto
DIR=$(mktemp -d)
mkdir -p "$DIR/src"
cp -rL "$BAZEL_BIN/daml-lf/archive/Da" "$DIR/src/Da"
cat <<EOF > "$DIR/daml-lf-proto-types.cabal"
cabal-version: 2.4
name: daml-lf-proto-types
build-type: Simple
version: 0.1.0
library
default-language: Haskell2010
hs-source-dirs: src
build-depends:
base,
bytestring,
containers,
deepseq,
proto3-suite,
proto3-wire,
text,
vector,
exposed-modules:
Da.DamlLf
Da.DamlLf0
Da.DamlLf1
EOF
pushd "$DIR"
cabal new-sdist
cp dist-newstyle/sdist/daml-lf-proto-types-0.1.0.tar.gz "$TARGET_DIR"
popd
rm -rf "$DIR"

bazel build //ledger-api/grpc-definitions:ledger-api-haskellpb
DIR=$(mktemp -d)
mkdir -p "$DIR/src"
cp -rL "$BAZEL_BIN/ledger-api/grpc-definitions/Google" "$DIR/src/Google"
cp -rL "$BAZEL_BIN/ledger-api/grpc-definitions/Com" "$DIR/src/Com"
cat <<EOF > "$DIR/ledger-api-haskellpb.cabal"
cabal-version: 2.4
name: ledger-api-haskellpb
build-type: Simple
version: 0.1.0
library
default-language: Haskell2010
hs-source-dirs: src
build-depends:
base,
bytestring,
containers,
deepseq,
grpc-haskell,
proto3-suite,
proto3-wire,
text,
vector,
exposed-modules:
Com.Digitalasset.Ledger.Api.V1.ActiveContractsService
Com.Digitalasset.Ledger.Api.V1.Admin.PackageManagementService
Com.Digitalasset.Ledger.Api.V1.Admin.PartyManagementService
Com.Digitalasset.Ledger.Api.V1.CommandCompletionService
Com.Digitalasset.Ledger.Api.V1.CommandService
Com.Digitalasset.Ledger.Api.V1.CommandSubmissionService
Com.Digitalasset.Ledger.Api.V1.Commands
Com.Digitalasset.Ledger.Api.V1.Completion
Com.Digitalasset.Ledger.Api.V1.Event
Com.Digitalasset.Ledger.Api.V1.LedgerConfigurationService
Com.Digitalasset.Ledger.Api.V1.LedgerIdentityService
Com.Digitalasset.Ledger.Api.V1.LedgerOffset
Com.Digitalasset.Ledger.Api.V1.PackageService
Com.Digitalasset.Ledger.Api.V1.Testing.ResetService
Com.Digitalasset.Ledger.Api.V1.Testing.TimeService
Com.Digitalasset.Ledger.Api.V1.TraceContext
Com.Digitalasset.Ledger.Api.V1.Transaction
Com.Digitalasset.Ledger.Api.V1.TransactionFilter
Com.Digitalasset.Ledger.Api.V1.TransactionService
Com.Digitalasset.Ledger.Api.V1.Value
Google.Protobuf.Any
Google.Protobuf.Duration
Google.Protobuf.Empty
Google.Protobuf.Timestamp
Google.Protobuf.Wrappers
Google.Rpc.Status
EOF
pushd "$DIR"
cabal new-sdist
cp dist-newstyle/sdist/ledger-api-haskellpb-0.1.0.tar.gz "$TARGET_DIR"
popd
rm -rf "$DIR"

pushd language-support/hs/bindings
cabal new-sdist
cp dist-newstyle/sdist/daml-ledger-0.1.0.tar.gz "$TARGET_DIR"
popd

if [ ! -f "$TARGET_DIR/cabal.project" ]; then
cat <<EOF > "$TARGET_DIR/cabal.project"
packages:
./.
./daml-project-config-0.1.0.tar.gz
./daml-ledger-0.1.0.tar.gz
./da-hs-base-0.1.0.tar.gz
./grpc-haskell-0.0.0.0.tar.gz
./grpc-haskell-core-0.0.0.0.tar.gz
./ledger-api-haskellpb-0.1.0.tar.gz
./daml-lf-ast-0.1.0.tar.gz
./daml-lf-proto-0.1.0.tar.gz
./daml-lf-proto-types-0.1.0.tar.gz
-- package grpc-haskell-core
-- extra-lib-dirs: /usr/local/grpc/lib
-- extra-include-dirs: /usr/local/grpc/include
EOF
echo "Wrote $TARGET_DIR/cabal.project"
fi

Loading

0 comments on commit 50a0439

Please sign in to comment.