Skip to content

Commit

Permalink
Build SDK head tarball directly (digital-asset#3723)
Browse files Browse the repository at this point in the history
Previously, we constructed the tarball used by daml-sdk-head by first
building the regular SDK release tarball only to the extract it, patch
the version file and recompress it. This adds about 30-60s to every
invocation of daml-sdk-head.

This PR changes this by factoring out the logic from building the
release tarball into a macro that we instantiate twice, once with the
proper version file and once with a dummy HEAD version file set to
0.0.0.

This does change the format of the sdk-head-tarball slightly, in
particular the files are now located under sdk-0.0.0 instead of
sdk-head. However, this doesn’t matter anyway afaik and I think the
new format makes more sense anyway considering that the regular
release tarballs have something like sdk-0.13.38.
  • Loading branch information
cocreature authored Dec 4, 2019
1 parent 50d689d commit 08b9860
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 83 deletions.
86 changes: 3 additions & 83 deletions release/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

load("//bazel_tools:haskell.bzl", "da_haskell_binary")
load("util.bzl", "sdk_tarball")

da_haskell_binary(
name = "release",
Expand Down Expand Up @@ -53,87 +54,6 @@ da_haskell_binary(
deps = [],
)

# This tarball is used by the new daml assistant.
genrule(
name = "sdk-release-tarball",
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",
],
outs = ["sdk-release-tarball.tar.gz"],
cmd = """
# damlc
VERSION=$$(cat $(location //:VERSION))
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)
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
sdk_tarball("sdk-release-tarball", "//:VERSION")

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 $(location sdk-release-tarball.tar.gz) --format=ustar $$OUT
""",
visibility = ["//visibility:public"],
)

# Same as the above, but with head version 0.0.0.
genrule(
name = "sdk-head-tarball",
srcs = [
":sdk-config.yaml.tmpl",
":sdk-release-tarball.tar.gz",
],
outs = ["sdk-head-tarball.tar.gz"],
cmd = """
VERSION=0.0.0
OUT=sdk-head
mkdir -p $$OUT
tar xf $(location sdk-release-tarball.tar.gz) --strip-components=1 -C $$OUT
cp $(location :sdk-config.yaml.tmpl) $$OUT/sdk-config.yaml
sed -i "s/__VERSION__/$$VERSION/" $$OUT/sdk-config.yaml
tar zcf $(location sdk-head-tarball.tar.gz) --format=ustar $$OUT
""",
visibility = ["//visibility:public"],
)
sdk_tarball("sdk-head-tarball", ":HEAD-VERSION")
1 change: 1 addition & 0 deletions release/HEAD-VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.0
64 changes: 64 additions & 0 deletions release/util.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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",
],
outs = ["{}.tar.gz".format(name)],
cmd = """
# damlc
VERSION=$$(cat $(location {version}))
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)
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"],
)

0 comments on commit 08b9860

Please sign in to comment.