daml/compiler/daml-extension/BUILD.bazel

80 lines
2.4 KiB
Python

# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
package(default_visibility = ["//visibility:public"])
load("@npm_bazel_typescript//:index.bzl", "ts_library")
load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
load("//bazel_tools:pkg.bzl", "pkg_tar")
ts_library(
name = "daml_extension_lib",
# TODO(MH): Unfortunately, the current packaging setup does not work with
# multiple source files. We need to figure out how to split this file up
# before it gets too big and package it properly.
srcs = ["src/extension.ts"],
node_modules = "@daml_extension_deps//:node_modules",
tsconfig = ":tsconfig.json",
deps = [
"@daml_extension_deps//@types",
"@daml_extension_deps//vscode",
"@daml_extension_deps//vscode-languageclient",
],
)
# With this rule we get access to extension.js, as
# the ts_library only has the .d.ts file in the outputs.
# Could possibly also use filegroup, which allows specifying
# the output group (es5_source).
npm_package(
name = "out", # named out, so it goes to same place as before
deps = [
":daml_extension_lib",
],
)
pkg_tar(
name = "dot-dist",
srcs = glob([
"package.json",
"syntaxes/*",
"snippets/*",
"images/*",
"*.json",
"README.md",
]) + [
":out",
"src/webview.js",
"@daml_extension_deps//vscode-jsonrpc:vscode-jsonrpc",
"@daml_extension_deps//vscode-languageclient:vscode-languageclient",
"@daml_extension_deps//vscode-languageserver-types:vscode-languageserver-types",
"@daml_extension_deps//which:which",
"//:VERSION",
],
extension = "tar.gz",
mode = "0755",
package_dir = "daml-extension",
remap_paths = {
"../daml_extension_deps/node_modules": "node_modules",
},
strip_prefix = "./",
)
# NOTE(MH): The `pkg_tar` rule puts a `.` at the beginning of every path, which
# would break assumptions made in the sdk assistant. Hence we need to repack
# the tarball to get rid of the `.`.
genrule(
name = "dist",
srcs = [
":dot-dist",
"//:VERSION",
],
outs = ["dist.tar.gz"],
cmd = """
tar zxf $(location :dot-dist)
VERSION=$$(cat $(location //:VERSION))
sed -i "s/__VERSION__/$$VERSION/" daml-extension/package.json
tar zcf $@ daml-extension
""",
)