Remove damli completely (#481)

The only command that we still had in damli which afaik isn’t
something anyone uses (and if it is, we should move it do damlc).
This commit is contained in:
moritzkiefer-da 2019-04-15 14:47:59 +02:00 committed by Martin Huschenbett
parent 1a70bf68cc
commit dff9f17ac6
21 changed files with 19 additions and 216 deletions

View File

@ -182,13 +182,6 @@ bring the macros `haskell_toolchain`, `haskell_import`, `haskell_cc_import` and
Lastly, there are some aliases defined here. For example,
```
alias(
name = "damli",
actual = "//daml-foundations/daml-tools/da-hs-damli-app:damli"
)
```
and
```
alias(
name = "damlc",
actual = "//daml-foundations/daml-tools/da-hs-damlc-app"

View File

@ -894,7 +894,7 @@ describe the individual attributes.
```
daml(
name = "it-daml",
# The main DAML file. This file will be passed to damli.
# The main DAML file. This file will be passed to damlc.
main_src = "src/it/resources/TestAll.daml",
# Other DAML files that may be imported by the main DAML file.
srcs = glob(["src/it/resources/**/*.daml"]),

15
BUILD
View File

@ -128,21 +128,6 @@ genrule(
# Common aliases
#
alias(
name = "damli",
actual = "//daml-foundations/daml-tools/da-hs-damli-app:damli",
)
alias(
name = "damli@ghci",
actual = "//daml-foundations/daml-tools/da-hs-damli-app:damli@ghci",
)
alias(
name = "damli-dist",
actual = "//daml-foundations/daml-tools/da-hs-damli-app:dist",
)
alias(
name = "damlc",
actual = "//daml-foundations/daml-tools/da-hs-damlc-app:da-hs-damlc-app",

View File

@ -153,7 +153,7 @@ installation of the packages for type checking.
Currently a package database is provided together with the `damlc` Bazel rule and `bazel run damlc`
loads this database by default. This package database is also shipped together with
`da-hs-damli-app.tar.gz` and `da-hs-damlc-app.tar.gz` for the SDK and the platform and is contained
`da-hs-damlc-app.tar.gz` for the SDK and the platform and is contained
in the directory `resources/package-db/gen/`.
### Building the package database

View File

@ -5,9 +5,8 @@ are linked where available.
## DAML Command Line Interface
* `da-hs-daml-cli` is the Haskell library behind `damli` and `damlc`
* `da-hs-daml-cli` is the Haskell library behind `damlc`
* `da-hs-damlc-app` provides `damlc`
* `da-hs-damli-app` provides `damli`
* `damlc-jar:damlc.jar` packages up `damlc` for distribution inside a jar.
You can execute these directly with just
@ -16,12 +15,6 @@ You can execute these directly with just
$ bazel run damlc -- <command line options>
```
or
```
$ bazel run damli -- <command line options>
```
due to the brief aliases specified in the `BUILD` file in the
root of our repository.

View File

@ -14,8 +14,8 @@ import qualified Control.Monad.Managed as Managed
import qualified "cryptonite" Crypto.Hash as Crypto
import Codec.Archive.Zip
import qualified Da.DamlLf as PLF
import DA.Cli.Damli.BuildInfo
import DA.Cli.Damli.Command.Damldoc (cmdDamlDoc)
import DA.Cli.Damlc.BuildInfo
import DA.Cli.Damlc.Command.Damldoc (cmdDamlDoc)
import DA.Cli.Options
import DA.Cli.Output
import DA.Cli.Args

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module DA.Cli.Damli.Base
module DA.Cli.Damlc.Base
( module DA.Cli.Options
, module DA.Cli.Output
, module DA.Prelude

View File

@ -3,7 +3,7 @@
{-# LANGUAGE OverloadedStrings #-}
module DA.Cli.Damli.BuildInfo
module DA.Cli.Damlc.BuildInfo
( buildInfo
) where

View File

@ -3,9 +3,9 @@
{-# LANGUAGE OverloadedStrings #-}
module DA.Cli.Damli.Command.Damldoc(cmdDamlDoc, cmdRenderDoc) where
module DA.Cli.Damlc.Command.Damldoc(cmdDamlDoc, cmdRenderDoc) where
import DA.Cli.Damli.Base(Command)
import DA.Cli.Damlc.Base(Command)
import DA.Cli.Options
import DA.Daml.GHC.Damldoc.Driver

View File

@ -1,37 +0,0 @@
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
-- | Main entry-point of DAML-interpreter.
module DA.Cli.Damli
( run
) where
import Control.Monad.Except
import DA.Cli.Damli.Base
import DA.Cli.Damli.BuildInfo
import DA.Cli.Damli.Command.LF
import Options.Applicative
import qualified Text.PrettyPrint.ANSI.Leijen as PP
options :: Parser Command
options =
flag' (PP.putDoc buildInfo) (short 'v' <> long "version" <> help "Show version information")
<|>
subparser cmdRoundtripLF1
parserInfo :: ParserInfo Command
parserInfo =
info (helper <*> options)
( fullDesc
<> progDesc "Invoke the DAML interpreter. Use -h for help."
<> headerDoc (Just buildInfo)
)
run :: IO ()
run = do
join $ execParser parserInfo

View File

@ -1,72 +0,0 @@
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
{-# LANGUAGE OverloadedStrings #-}
module DA.Cli.Damli.Command.LF
( cmdRoundtripLF1
) where
import Control.Monad.Except
import DA.Cli.Damli.Base
import qualified DA.Daml.LF.Ast as LF
import qualified DA.Daml.LF.Proto3.Archive as Archive
import qualified DA.Daml.LF.TypeChecker as LF
import qualified Data.Text as T
import qualified DA.Pretty
import qualified Data.ByteString as BS
import Options.Applicative
-------------------------------------------------------------------------
-- Command specs
-------------------------------------------------------------------------
cmdRoundtripLF1 :: Mod CommandFields Command
cmdRoundtripLF1 =
command "roundtrip-lf-v1"
$ info (helper <*> cmd)
$ progDesc "Load a DAML-LF v1 archive, type-check it and dump it again, verifying that output matches."
<> fullDesc
where
cmd = execRoundtripLF1 <$> lfTypeCheckOpt <*> inputFileOpt <*> outputFileOpt
lfTypeCheckOpt :: Parser Bool
lfTypeCheckOpt =
not <$> switch (long "unsafe" <> short 'u' <> help "Skip DAML-LF type checker")
-------------------------------------------------------------------------
-- Implementation
-------------------------------------------------------------------------
loadLFPackage :: FilePath -> IO (LF.Package, BS.ByteString)
loadLFPackage inFile = do
-- Load, checksum and decode the LF package
bytes <- BS.readFile inFile
(_pkgId, package) <- errorOnLeft "Cannot decode header" $ Archive.decodeArchive bytes
return (package, bytes)
where
errorOnLeft desc (Left x) = error (desc <> ":" <> show x)
errorOnLeft _ (Right x) = pure x
execRoundtripLF1 :: Bool -> FilePath -> FilePath -> Command
execRoundtripLF1 _check inFile outFile = do
(package, bytes) <- loadLFPackage inFile
-- Type-check
case LF.checkPackage [] package of
Left err -> do
error $ T.unpack $ "Type-check failed:\n" <> DA.Pretty.renderPretty err
Right () ->
pure ()
-- Encode the package
let bytes' = Archive.encodeArchive package
-- And finally verify that the resulting bytes match.
when (bytes /= bytes') $ do
write bytes'
error $ "Resulting output differs. Dumped output to " <> outFile
where
write | outFile == "-" = BS.putStr
| otherwise = BS.writeFile outFile

View File

@ -1,5 +1,2 @@
This package defines the DAML cli utilities,
and specifically `damli`, which is meant for
internal use and offers a variety of commands
including various debugging ones, and `damlc`,
which is what we will ship as the DAML compiler.
specifically `damlc`.

View File

@ -1,34 +0,0 @@
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("//bazel_tools:haskell.bzl", "da_haskell_binary")
load("//bazel_tools:packaging/packaging.bzl", "package_app")
da_haskell_binary(
name = "damli",
srcs = ["src/Main.hs"],
data = [
"//compiler/scenario-service/server:scenario_service_jar",
"//daml-foundations/daml-ghc/package-database:package-db",
],
hazel_deps = [
"base",
],
linkstatic = True,
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//daml-foundations/daml-tools/da-hs-daml-cli",
],
)
package_app(
name = "dist",
binary = ":damli",
resources = [
"//compiler/scenario-service/server:scenario_service_jar",
"//daml-foundations/daml-ghc/package-database:package-db",
],
tags = ["no-cache"],
visibility = ["//visibility:public"],
)

View File

@ -1,3 +0,0 @@
Copyright (c) 2017 Digital Asset
All rights reserved.

View File

@ -1,4 +0,0 @@
This is a shim to `da-hs-daml-cli`. It exists only
for historical reasons and should be removed once
we change the build system. See readme for that
package.

View File

@ -1,9 +0,0 @@
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main (main) where
import qualified DA.Cli.Damli as Damli
main :: IO ()
main = Damli.run

View File

@ -62,7 +62,7 @@ export class DamlConnection {
this.connection.trace(Trace.Verbose, new ConsoleTracer());
} else {
// drain stderr in order to not block damli.
// drain stderr in order to not block damlc.
this.process.stderr.on('readable', () => { this.process.stderr.read() });
}

View File

@ -5,7 +5,7 @@
set -eu
DAML_LF_REPL=$1
DAMLI=$2
DAMLC=$2
MAIN=$3
TMPDIR=$(mktemp -d)
@ -19,7 +19,7 @@ case "${MAIN##*.}" in
$DAML_LF_REPL testAll "$MAIN"
;;
daml)
$DAMLI export-lf-v1 "$MAIN" -o $TMPDIR/out.dalf
$DAMLC export-lf-v1 "$MAIN" -o $TMPDIR/out.dalf
$DAML_LF_REPL testAll $TMPDIR/out.dalf
;;
*)

View File

@ -11,7 +11,7 @@ set -eu
export LC_ALL="en_US.UTF-8"
REPL=$1
DAMLI=$2
DAMLC=$2
TESTMAIN=$3
TESTDIR="$(dirname $TESTMAIN)"
TESTDALF="$TESTDIR/Main.dalf"
@ -21,7 +21,7 @@ TARGET="1.3"
REGEX_HIDE_HASHES="s,@[a-z0-9]{8},@XXXXXXXX,g"
$DAMLI compile --debug --target $TARGET $TESTMAIN -o $TESTDALF
$DAMLC compile --debug --target $TARGET $TESTMAIN -o $TESTDALF
$REPL test Test:run $TESTDALF $GHC_PRIM_DALF | sed '1d' | sed -E "$REGEX_HIDE_HASHES" > ${TESTDIR}/ACTUAL.ledger

View File

@ -10,9 +10,9 @@ import scala.sys.error
import scala.sys.process.Process
/**
* Run the HEAD version of damli from source, to create a DAR file from a DAML file.
* Run the HEAD version of damlc from source, to create a DAR file from a DAML file.
*/
object HeadDamli {
object HeadDamlc {
private val packageName = "Test"
def run(damlPath: String): (File, Unit => Unit) = {
@ -27,10 +27,10 @@ object HeadDamli {
// DAML -> DAR
val exitCode = Process(
s"bazel run damli -- package $damlPath $packageName --output ${darFile.getAbsolutePath}").!
s"bazel run damlc -- package $damlPath $packageName --output ${darFile.getAbsolutePath}").!
if (exitCode != 0) {
shutdown(())
error(s"Dar packager: error while running DAMLI package for $damlPath: exit code $exitCode")
error(s"Dar packager: error while running damlc package for $damlPath: exit code $exitCode")
}
(darFile, shutdown)

View File

@ -10,12 +10,6 @@ exports_files(
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_binary")
load("//rules_daml:daml.bzl", "daml_sandbox_version")
alias(
name = "damli",
actual = "//daml-foundations/daml-tools/da-hs-damli-app:damli",
visibility = ["//visibility:public"],
)
alias(
name = "codegen",
actual = "//language-support/scala/codegen:codegen-main",