daml/bazel_tools/ghc_dwarf.bzl
Moritz Kiefer 3d0699a9a8
Add an option to build Haskell code with DWARF debug info (#2504)
For now, this only works on Linux (that’s a GHC limitation as far as I
know) and you have to enable it by setting the GHC_DWARF env var to a
non-empty string.
2019-08-13 20:00:14 +02:00

31 lines
754 B
Python

# Copyright (c) 2019 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# This repository rule exists so that we can switch the GHC attribute
# name in `WORKSPACE` as we cannot use `select` theer.
_ghc_dwarf_bzl_template = """
enable_ghc_dwarf = {GHC_DWARF}
"""
def _ghc_dwarf_impl(repository_ctx):
enable_dwarf = repository_ctx.os.environ.get("GHC_DWARF", "") != ""
substitutions = {
"GHC_DWARF": enable_dwarf,
}
repository_ctx.file(
"ghc_dwarf.bzl",
_ghc_dwarf_bzl_template.format(**substitutions),
False,
)
repository_ctx.file(
"BUILD",
"",
False,
)
ghc_dwarf = repository_rule(
implementation = _ghc_dwarf_impl,
local = True,
)