daml/templates/BUILD.bazel
Gary Verhaegen 5086310499
maybe fix 2.8.0-rc2 (#17999)
Note: package.json is still a template as there is still `__PROJECT_NAME__` to
replace at expansion time.
2023-12-08 12:55:33 +01:00

147 lines
5.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("@os_info//:os_info.bzl", "is_windows")
load("@build_environment//:configuration.bzl", "sdk_version")
exports_files(glob(["create-daml-app-test-resources/*"]) + [
"copy-trigger/src/CopyTrigger.daml",
"create-daml-app/ui/package.json.template",
])
# Split out into a separate rule so we can cheaply include this in the
# live-preview.
genrule(
name = "create-daml-app-docs",
srcs = glob(
["create-daml-app/**"],
exclude = ["**/NO_AUTO_COPYRIGHT"],
) + [
"//templates:create-daml-app-test-resources/messaging.patch",
],
outs = ["create-daml-app-docs.tar.gz"],
cmd = """
set -eou pipefail
SRC=templates
OUT=create-daml-app
mkdir -p $$OUT
cp -rL $$SRC/create-daml-app/* $$OUT
# Undo project name templating since we dont want that to show up
# in the docs.
find $$OUT/ -name '*.template' -type f -exec sh -c 'mv "$$0" "$${0%.template}" && sed -i "s/__PROJECT_NAME__/create-daml-app/g" "$${0%.template}"' {} ';'
# Apply patch for messaging feature (we only need the "after" state)
PATCH_TOOL=$$PWD/$(location @patch_dev_env//:patch)
MESSAGING_PATCH=$$PWD/$(location //templates:create-daml-app-test-resources/messaging.patch)
$$PATCH_TOOL -s -p1 < $$MESSAGING_PATCH
$(execpath //bazel_tools/sh:mktgz) $@ create-daml-app
""",
tools = [
"//bazel_tools/sh:mktgz",
"@patch_dev_env//:patch",
],
visibility = ["//visibility:public"],
) if not is_windows else None
genrule(
name = "templates-tarball",
srcs = glob(
[
"default-gitattributes",
"default-gitignore",
"default-dlint.yaml",
"skeleton/**",
"empty-skeleton/**",
"create-daml-app/**",
"quickstart-java/**",
"copy-trigger/**",
"gsg-trigger.patch",
],
exclude = ["**/NO_AUTO_COPYRIGHT"],
) + [
"//docs:quickstart-java.tar.gz",
"//docs:daml-intro-templates",
"//docs:daml-patterns",
"//docs:script-example-template",
"@daml-finance//:quickstart",
"@daml-finance//:lifecycling",
"@daml-finance//:settlement",
"@daml-finance//:upgrades",
"@daml-finance//:payoff-modeling",
],
outs = ["templates-tarball.tar.gz"],
cmd = """
SRC=$$(mktemp -d)
OUT=$$(mktemp -d)/templates-tarball
trap "rm -rf $$SRC $$OUT" EXIT
mkdir -p $$OUT
cp -rL templates/* $$SRC/
PATCH_TOOL=$$PWD/$(location @patch_dev_env//:patch)
cp -rL $$SRC/create-daml-app $$SRC/gsg-trigger
"$$PATCH_TOOL" -d $$SRC/gsg-trigger -p1 < $$SRC/gsg-trigger.patch
# templates in templates dir
for d in skeleton \
empty-skeleton \
create-daml-app \
quickstart-java \
copy-trigger \
gsg-trigger; do
mkdir -p $$OUT/$$d
cp -rL $$SRC/$$d/* $$OUT/$$d/
for f in gitattributes gitignore dlint.yaml; do
if [ -f "$$SRC/$$d/.$$f" ]; then
cp "$$SRC/$$d/.$$f" "$$OUT/$$d/.$$f"
else
cp "$$SRC/default-$$f" "$$OUT/$$d/.$$f"
fi
done
done
sed -i 's|__VERSION__|{sdk_version}|' $$OUT/create-daml-app/ui/package.json.template
## special cases we should work to remove
# quickstart-java template
tar xf $(location //docs:quickstart-java.tar.gz) --strip-components=1 -C $$OUT/quickstart-java
# daml intro templates
tar xf $(location //docs:daml-intro-templates) -C $$OUT
mkdir -p $$OUT/script-example
tar xf $(location //docs:script-example-template) -C $$OUT/script-example
mkdir -p $$OUT/daml-patterns
tar xf $(location //docs:daml-patterns) --strip-components=1 -C $$OUT/daml-patterns
# daml finance quickstarter
mkdir -p $$OUT/quickstart-finance
tar xf $(location @daml-finance//:quickstart) -C $$OUT/quickstart-finance
# daml finance lifecycling
mkdir -p $$OUT/finance-lifecycling
tar xf $(location @daml-finance//:lifecycling) -C $$OUT/finance-lifecycling
# daml finance settlement
mkdir -p $$OUT/finance-settlement
tar xf $(location @daml-finance//:settlement) -C $$OUT/finance-settlement
# daml finance upgrades
mkdir -p $$OUT/finance-upgrades
tar xf $(location @daml-finance//:upgrades) -C $$OUT/finance-upgrades
# daml finance payoff-modeling
mkdir -p $$OUT/finance-payoff-modeling
tar xf $(location @daml-finance//:payoff-modeling) -C $$OUT/finance-payoff-modeling
DIR=$$(pwd)
cd $$OUT/..
$$DIR/$(execpath //bazel_tools/sh:mktgz) $$DIR/$@ templates-tarball
""".format(sdk_version = sdk_version),
tools = [
"//bazel_tools/sh:mktgz",
"@patch_dev_env//:patch",
],
visibility = ["//visibility:public"],
)