2020-01-02 23:21:13 +03:00
|
|
|
# Copyright (c) 2020 The DAML Authors. All rights reserved.
|
2019-04-04 11:33:38 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
# Build rule for a DA Documentation Package.
|
|
|
|
def da_doc_package(**args):
|
|
|
|
src_name = args["name"] + "-srcs"
|
|
|
|
native.filegroup(
|
|
|
|
name = src_name,
|
|
|
|
srcs = native.glob(["source/**"]),
|
2019-04-12 14:10:16 +03:00
|
|
|
)
|
2019-04-04 11:33:38 +03:00
|
|
|
prepare = args.get("prepare", "")
|
|
|
|
extra_srcs = args.get("extra_srcs", [])
|
|
|
|
native.genrule(
|
2019-04-12 14:10:16 +03:00
|
|
|
name = args["name"],
|
|
|
|
outs = ["sources.tar.gz"],
|
|
|
|
srcs = [src_name, "@tar_dev_env//:tar", "@gzip_dev_env//:gzip"] + extra_srcs,
|
|
|
|
cmd = """
|
2019-04-04 11:33:38 +03:00
|
|
|
export PATH=$$(dirname $(location {gzip})):$$PATH
|
|
|
|
# Bazel makes it fairly hard to get the directory in a robust way so
|
|
|
|
# we take the first file and strip everything after source.
|
|
|
|
SRCS=($(locations {srcs}))
|
|
|
|
BASEDIR=$${{SRCS[0]%%source*}}
|
|
|
|
{prepare}
|
|
|
|
$(location {tar}) czhf $(location sources.tar.gz) -C $$BASEDIR source
|
|
|
|
""".format(
|
2019-04-12 14:10:16 +03:00
|
|
|
srcs = ":" + src_name,
|
|
|
|
prepare = prepare,
|
|
|
|
tar = "@tar_dev_env//:tar",
|
|
|
|
gzip = "@gzip_dev_env//:gzip",
|
|
|
|
),
|
|
|
|
)
|