2021-01-01 21:49:51 +03:00
|
|
|
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
2019-04-04 11:33:38 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2019-04-12 14:10:16 +03:00
|
|
|
load("//bazel_tools:haskell.bzl", "da_haskell_test")
|
2020-07-23 10:46:04 +03:00
|
|
|
load("//bazel_tools/sh:sh.bzl", "sh_inline_test")
|
2019-04-04 11:33:38 +03:00
|
|
|
|
2020-07-23 10:46:04 +03:00
|
|
|
def damlc_compile_test(
|
|
|
|
name,
|
|
|
|
srcs,
|
|
|
|
main,
|
|
|
|
damlc = "//compiler/damlc",
|
|
|
|
stack_limit = "",
|
|
|
|
heap_limit = "",
|
|
|
|
**kwargs):
|
|
|
|
stack_opt = "-K" + stack_limit if stack_limit else ""
|
|
|
|
heap_opt = "-M" + heap_limit if heap_limit else ""
|
|
|
|
sh_inline_test(
|
|
|
|
name = name,
|
|
|
|
data = [damlc, main] + srcs,
|
|
|
|
cmd = """\
|
|
|
|
DAMLC=$$(canonicalize_rlocation $(rootpath {damlc}))
|
|
|
|
MAIN=$$(canonicalize_rlocation $(rootpath {main}))
|
2019-06-28 13:55:31 +03:00
|
|
|
|
2020-07-23 10:46:04 +03:00
|
|
|
TMP=$$(mktemp -d)
|
|
|
|
function cleanup() {{
|
|
|
|
rm -rf "$$TMP"
|
|
|
|
}}
|
|
|
|
trap cleanup EXIT
|
2019-05-28 16:45:38 +03:00
|
|
|
|
2020-07-23 10:46:04 +03:00
|
|
|
$$DAMLC compile $$MAIN -o $$TMP/out +RTS -s {stack_opt} {heap_opt}
|
|
|
|
""".format(
|
|
|
|
damlc = damlc,
|
|
|
|
main = main,
|
|
|
|
stack_opt = stack_opt,
|
|
|
|
heap_opt = heap_opt,
|
2019-04-12 14:10:16 +03:00
|
|
|
),
|
2020-07-23 10:46:04 +03:00
|
|
|
**kwargs
|
|
|
|
)
|