forked from digital-asset/daml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.bzl
78 lines (65 loc) · 3.14 KB
/
util.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Copyright (c) 2019 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
def sdk_tarball(name, version):
native.genrule(
name = name,
srcs = [
":sdk-config.yaml.tmpl",
":install.sh",
":install.bat",
"//ledger-service/http-json:release/json-api-logback.xml",
"//:NOTICES",
version,
"//daml-assistant:daml-dist",
"//compiler/damlc:damlc-dist",
"//compiler/daml-extension:vsix",
"//daml-assistant/daml-helper:daml-helper-dist",
"//templates:templates-tarball.tar.gz",
"//triggers/daml:daml-trigger.dar",
"//daml-script/daml:daml-script.dar",
"//daml-assistant/daml-sdk:sdk_deploy.jar",
],
tools = ["@zip_dev_env//:zip"],
outs = ["{}.tar.gz".format(name)],
cmd = """
# damlc
VERSION=$$(cat $(location {version}))
ZIP=$$PWD/$(location @zip_dev_env//:zip)
OUT=sdk-$$VERSION
mkdir -p $$OUT
cp $(location //:NOTICES) $$OUT/NOTICES
cp $(location :install.sh) $$OUT/install.sh
cp $(location :install.bat) $$OUT/install.bat
cp $(location :sdk-config.yaml.tmpl) $$OUT/sdk-config.yaml
sed -i "s/__VERSION__/$$VERSION/" $$OUT/sdk-config.yaml
mkdir -p $$OUT/daml
tar xf $(location //daml-assistant:daml-dist) --strip-components=1 -C $$OUT/daml
mkdir -p $$OUT/damlc
tar xf $(location //compiler/damlc:damlc-dist) --strip-components=1 -C $$OUT/damlc
mkdir -p $$OUT/daml-libs
cp -t $$OUT/daml-libs $(location //triggers/daml:daml-trigger.dar)
cp -t $$OUT/daml-libs $(location //daml-script/daml:daml-script.dar)
# Patch the SDK version in all bundled DAML libraries.
# This is necessary to make daml-sdk-head work despite the check in damlc
# that DAR dependencies are built with the same SDK.
for file in $$OUT/daml-libs/*; do
file=$$PWD/$$file
chmod +w $$file
unzip -q $$file META-INF/MANIFEST.MF -d $$OUT/daml-libs
sed -i "s/Sdk-Version:.*/Sdk-Version: $$VERSION/" $$OUT/daml-libs/META-INF/MANIFEST.MF
(cd $$OUT/daml-libs; $$ZIP -q $$file META-INF/MANIFEST.MF)
rm $$OUT/daml-libs/META-INF/MANIFEST.MF
done
mkdir -p $$OUT/daml-helper
tar xf $(location //daml-assistant/daml-helper:daml-helper-dist) --strip-components=1 -C $$OUT/daml-helper
mkdir -p $$OUT/studio
cp $(location //compiler/daml-extension:vsix) $$OUT/studio/daml-bundled.vsix
mkdir -p $$OUT/templates
tar xf $(location //templates:templates-tarball.tar.gz) --strip-components=1 -C $$OUT/templates
mkdir -p $$OUT/daml-sdk
cp $(location //daml-assistant/daml-sdk:sdk_deploy.jar) $$OUT/daml-sdk/daml-sdk.jar
cp -L $(location //ledger-service/http-json:release/json-api-logback.xml) $$OUT/daml-sdk/
tar zcf $@ --format=ustar $$OUT
""".format(version = version),
visibility = ["//visibility:public"],
)