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
|
|
|
|
|
2019-04-12 14:10:16 +03:00
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
|
2019-07-16 21:12:48 +03:00
|
|
|
filegroup(
|
|
|
|
name = "json-files",
|
|
|
|
srcs = glob([
|
|
|
|
"*.json",
|
|
|
|
"syntaxes/*.json",
|
|
|
|
]),
|
|
|
|
)
|
|
|
|
|
|
|
|
sh_test(
|
|
|
|
name = "valid-json",
|
|
|
|
srcs = ["ci-tests.sh"],
|
|
|
|
args = [
|
|
|
|
"$(location @jq_dev_env//:jq)",
|
|
|
|
"$(locations :json-files)",
|
|
|
|
],
|
|
|
|
data = [
|
|
|
|
":json-files",
|
|
|
|
"@jq_dev_env//:jq",
|
|
|
|
],
|
|
|
|
# This is required to get the test to run on Windows. Otherwise, it looks
|
|
|
|
# like Bazel decides that because it cannot create symlinks on Windows, it
|
|
|
|
# may as well just give up and start the test without any of its
|
|
|
|
# dependencies available at all. But not warn about it, so the script can
|
|
|
|
# just fail at build time when it doesn't find anything.
|
|
|
|
deps = ["@bazel_tools//tools/bash/runfiles"],
|
|
|
|
)
|
|
|
|
|
2019-07-13 00:35:05 +03:00
|
|
|
# For some reason,
|
|
|
|
# 1. Bazel only exposes the node_modules dependency as a list of files, not as
|
|
|
|
# a folder, and
|
|
|
|
# 2. Copying these files over is surprisingly slow on my machine.
|
|
|
|
#
|
|
|
|
# Because `vsce` needs to run in a folder where all of the node_modules
|
|
|
|
# dependencies are already populated, this separate step takes all of the
|
|
|
|
# node_module files, one by one (because that is how Bazel exposes them),
|
|
|
|
# copies them to their intended place, and then bundles the whole node_modules
|
|
|
|
# folder as a tarball so the next task, below, can depend on that cached
|
|
|
|
# tarball and be fast.
|
|
|
|
# Also for some reason on Windows I get "cannot ceate node_modules: file
|
|
|
|
# exists", so at this point I'm completely out of trust.
|
|
|
|
genrule(
|
|
|
|
name = "node_deps_cache",
|
|
|
|
srcs = ["@daml_extension_deps//:node_modules"],
|
|
|
|
outs = ["node_modules.tar.gz"],
|
|
|
|
cmd = """
|
|
|
|
if [[ -d node_modules ]]; then
|
|
|
|
rm -rf node_modules
|
|
|
|
fi
|
|
|
|
mkdir node_modules
|
|
|
|
cd node_modules
|
|
|
|
for f in $(locations @daml_extension_deps//:node_modules); do
|
|
|
|
# Because Bazel paths are weird, we need to remove everything
|
|
|
|
# before node_modules. We also need to extract the path separately
|
|
|
|
# from the filename because we need to create the path (mkdir -p)
|
|
|
|
# before we can write the file
|
|
|
|
file=$$(basename $$f)
|
|
|
|
dir=$$(dirname $$f | sed 's:^.*/node_modules/::')
|
|
|
|
mkdir -p $$dir
|
|
|
|
cp ../$$f $$dir/$$file
|
|
|
|
done
|
|
|
|
cd ..
|
|
|
|
tar czf node_modules.tar.gz node_modules
|
|
|
|
cp node_modules.tar.gz $@
|
|
|
|
""",
|
2019-04-04 11:33:38 +03:00
|
|
|
)
|
|
|
|
|
2019-07-13 00:35:05 +03:00
|
|
|
genrule(
|
|
|
|
name = "vsix",
|
2019-04-12 14:10:16 +03:00
|
|
|
srcs = glob([
|
|
|
|
"package.json",
|
|
|
|
"syntaxes/*",
|
|
|
|
"snippets/*",
|
|
|
|
"images/*",
|
|
|
|
"*.json",
|
|
|
|
"README.md",
|
2019-07-13 00:35:05 +03:00
|
|
|
"yarn.lock",
|
|
|
|
"src/*",
|
2019-04-12 14:10:16 +03:00
|
|
|
]) + [
|
2019-07-13 00:35:05 +03:00
|
|
|
":node_deps_cache",
|
2019-04-25 18:53:47 +03:00
|
|
|
"//:VERSION",
|
2019-04-12 14:10:16 +03:00
|
|
|
],
|
2019-07-13 00:35:05 +03:00
|
|
|
outs = ["daml-bundled.vsix"],
|
Bazel 1.1 (#3249)
* bazel: 0.28.1 --> 1.1.0
* bazel-watcher sha256
* Fix missing line in patch
* proto_source_root --> strip_import_prefix
See https://github.com/bazelbuild/bazel/issues/7153 for details.
* Update rules_nixpkgs
Required to avoid errors of the form
```
ERROR: An error occurred during the fetch of repository 'node_nix':
parameter 'sep' may not be specified by name, for call to method split(sep, maxsplit = None) of 'string'
```
and
```
ERROR: An error occurred during the fetch of repository 'node_nix':
Traceback (most recent call last):
File "/private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 149
_execute_or_fail(repository_ctx, <3 more arguments>)
File "/private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 318, in _execute_or_fail
fail(<1 more arguments>)
Cannot build Nix attribute 'nodejs'.
Command: [/Users/runner/.nix-profile/bin/nix-build, /private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/node_nix/nix/bazel.nix, "-A", "nodejs", "--out-link", "bazel-support/nix-out-link", "-I", "nixpkgs=/private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/nixpkgs/nixpkgs"]
Return code: 1
Error output:
src/main/tools/process-tools.cc:173: "setitimer": Invalid argument
```
* Update rules_scala
* .proto has been removed, use [ProtoInfo] instead
See
https://docs.bazel.build/versions/1.1.0/be/protocol-buffer.html#proto_library
* python3_nix add nix_file attribute
To avoid the following error
```
ERROR: /home/aj/tweag.io/da/da-bazel-1.1/BUILD:66:1: //:nix_python3_runtime depends on @python3_nix//:bin/python in repository @python3_nix which failed to fetch. no such package '@python3_nix//': Traceback (most recent call last):
File "/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 149
_execute_or_fail(repository_ctx, <3 more arguments>)
File "/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 318, in _execute_or_fail
fail(<1 more arguments>)
Cannot build Nix attribute 'python3'.
Command: [/home/aj/.nix-profile/bin/nix-build, "-E", "import <nixpkgs> { config = {}; overlays = []; }", "-A", "python3", "--out-link", "bazel-support/nix-out-link", "-I", "nixpkgs=/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/nixpkgs/nixpkgs"]
Return code: 1
Error output:
error: anonymous function at /home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/nixpkgs/nixpkgs.nix:3:1 called with unexpected argument 'config', at (string):1:1
```
* rules_haskell unnamed string.split(_, maxsplit = _)
The keyword argument may no longer be named.
* string.replace(_, _, maxsplit = _) may not be named
* Move proto sources from deps to data
Fixes
```
ERROR: /home/aj/tweag.io/da/da-bazel-1.1/daml-lf/archive/BUILD.bazel:150:1: in deps attribute of scala_test rule //daml-lf/archive:daml_lf_archive_reader_tests_test_suite_src_test_scala_com_digitalasset_daml_lf_archive_DecodeV1Spec.scala: '//daml-lf/archive:daml_lf_1.6_archive_proto_srcs' does not have mandatory providers: 'JavaInfo'. Since this rule was created by the macro 'da_scala_test_suite', the error might have been caused by the macro implementation
```
* Define sha256 for haskell_ghc__paths
Bazel 1.1.0 fails on missing hashes.
* Disable --incompatible_windows_native_test_wrapper
* //compiler/daml-extension don't modify sources
Modifying sources in-place can cause issues on Windows, where build
actions are not sandboxed and changes on sources can affect other build
steps.
* bazel-genfiles --> bazel-bin
The bazel-genfiles symlink has been removed since Bazel 1.0.
See https://github.com/bazelbuild/bazel/issues/8651
* Mark dev_env_tool repository rule as configure
See
https://docs.bazel.build/versions/1.1.0/skylark/lib/globals.html#repository_rule
* Move data deps into data attribute
* Mark dev_env_tool as local = True
* Manually fetch @makensis_dev_env
2019-11-11 12:06:03 +03:00
|
|
|
# rm -rf can fail with "directory not empty" on Windows.
|
|
|
|
# As a workaround we add `|| return`.
|
2019-04-04 11:33:38 +03:00
|
|
|
cmd = """
|
2019-07-31 18:10:30 +03:00
|
|
|
set -euo pipefail
|
Bazel 1.1 (#3249)
* bazel: 0.28.1 --> 1.1.0
* bazel-watcher sha256
* Fix missing line in patch
* proto_source_root --> strip_import_prefix
See https://github.com/bazelbuild/bazel/issues/7153 for details.
* Update rules_nixpkgs
Required to avoid errors of the form
```
ERROR: An error occurred during the fetch of repository 'node_nix':
parameter 'sep' may not be specified by name, for call to method split(sep, maxsplit = None) of 'string'
```
and
```
ERROR: An error occurred during the fetch of repository 'node_nix':
Traceback (most recent call last):
File "/private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 149
_execute_or_fail(repository_ctx, <3 more arguments>)
File "/private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 318, in _execute_or_fail
fail(<1 more arguments>)
Cannot build Nix attribute 'nodejs'.
Command: [/Users/runner/.nix-profile/bin/nix-build, /private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/node_nix/nix/bazel.nix, "-A", "nodejs", "--out-link", "bazel-support/nix-out-link", "-I", "nixpkgs=/private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/nixpkgs/nixpkgs"]
Return code: 1
Error output:
src/main/tools/process-tools.cc:173: "setitimer": Invalid argument
```
* Update rules_scala
* .proto has been removed, use [ProtoInfo] instead
See
https://docs.bazel.build/versions/1.1.0/be/protocol-buffer.html#proto_library
* python3_nix add nix_file attribute
To avoid the following error
```
ERROR: /home/aj/tweag.io/da/da-bazel-1.1/BUILD:66:1: //:nix_python3_runtime depends on @python3_nix//:bin/python in repository @python3_nix which failed to fetch. no such package '@python3_nix//': Traceback (most recent call last):
File "/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 149
_execute_or_fail(repository_ctx, <3 more arguments>)
File "/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 318, in _execute_or_fail
fail(<1 more arguments>)
Cannot build Nix attribute 'python3'.
Command: [/home/aj/.nix-profile/bin/nix-build, "-E", "import <nixpkgs> { config = {}; overlays = []; }", "-A", "python3", "--out-link", "bazel-support/nix-out-link", "-I", "nixpkgs=/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/nixpkgs/nixpkgs"]
Return code: 1
Error output:
error: anonymous function at /home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/nixpkgs/nixpkgs.nix:3:1 called with unexpected argument 'config', at (string):1:1
```
* rules_haskell unnamed string.split(_, maxsplit = _)
The keyword argument may no longer be named.
* string.replace(_, _, maxsplit = _) may not be named
* Move proto sources from deps to data
Fixes
```
ERROR: /home/aj/tweag.io/da/da-bazel-1.1/daml-lf/archive/BUILD.bazel:150:1: in deps attribute of scala_test rule //daml-lf/archive:daml_lf_archive_reader_tests_test_suite_src_test_scala_com_digitalasset_daml_lf_archive_DecodeV1Spec.scala: '//daml-lf/archive:daml_lf_1.6_archive_proto_srcs' does not have mandatory providers: 'JavaInfo'. Since this rule was created by the macro 'da_scala_test_suite', the error might have been caused by the macro implementation
```
* Define sha256 for haskell_ghc__paths
Bazel 1.1.0 fails on missing hashes.
* Disable --incompatible_windows_native_test_wrapper
* //compiler/daml-extension don't modify sources
Modifying sources in-place can cause issues on Windows, where build
actions are not sandboxed and changes on sources can affect other build
steps.
* bazel-genfiles --> bazel-bin
The bazel-genfiles symlink has been removed since Bazel 1.0.
See https://github.com/bazelbuild/bazel/issues/8651
* Mark dev_env_tool repository rule as configure
See
https://docs.bazel.build/versions/1.1.0/skylark/lib/globals.html#repository_rule
* Move data deps into data attribute
* Mark dev_env_tool as local = True
* Manually fetch @makensis_dev_env
2019-11-11 12:06:03 +03:00
|
|
|
TMP_DIR=$$(mktemp -d)
|
|
|
|
cleanup () { rm -rf $$TMP_DIR || return; }
|
|
|
|
trap cleanup EXIT
|
2019-07-13 00:35:05 +03:00
|
|
|
DIR=$$PWD
|
2019-06-28 10:03:55 +03:00
|
|
|
VERSION=$$(cat $(location //:VERSION))
|
Bazel 1.1 (#3249)
* bazel: 0.28.1 --> 1.1.0
* bazel-watcher sha256
* Fix missing line in patch
* proto_source_root --> strip_import_prefix
See https://github.com/bazelbuild/bazel/issues/7153 for details.
* Update rules_nixpkgs
Required to avoid errors of the form
```
ERROR: An error occurred during the fetch of repository 'node_nix':
parameter 'sep' may not be specified by name, for call to method split(sep, maxsplit = None) of 'string'
```
and
```
ERROR: An error occurred during the fetch of repository 'node_nix':
Traceback (most recent call last):
File "/private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 149
_execute_or_fail(repository_ctx, <3 more arguments>)
File "/private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 318, in _execute_or_fail
fail(<1 more arguments>)
Cannot build Nix attribute 'nodejs'.
Command: [/Users/runner/.nix-profile/bin/nix-build, /private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/node_nix/nix/bazel.nix, "-A", "nodejs", "--out-link", "bazel-support/nix-out-link", "-I", "nixpkgs=/private/var/tmp/_bazel_runner/17d2b3954f1c6dcf5414d5453467df9a/external/nixpkgs/nixpkgs"]
Return code: 1
Error output:
src/main/tools/process-tools.cc:173: "setitimer": Invalid argument
```
* Update rules_scala
* .proto has been removed, use [ProtoInfo] instead
See
https://docs.bazel.build/versions/1.1.0/be/protocol-buffer.html#proto_library
* python3_nix add nix_file attribute
To avoid the following error
```
ERROR: /home/aj/tweag.io/da/da-bazel-1.1/BUILD:66:1: //:nix_python3_runtime depends on @python3_nix//:bin/python in repository @python3_nix which failed to fetch. no such package '@python3_nix//': Traceback (most recent call last):
File "/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 149
_execute_or_fail(repository_ctx, <3 more arguments>)
File "/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl", line 318, in _execute_or_fail
fail(<1 more arguments>)
Cannot build Nix attribute 'python3'.
Command: [/home/aj/.nix-profile/bin/nix-build, "-E", "import <nixpkgs> { config = {}; overlays = []; }", "-A", "python3", "--out-link", "bazel-support/nix-out-link", "-I", "nixpkgs=/home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/nixpkgs/nixpkgs"]
Return code: 1
Error output:
error: anonymous function at /home/aj/.cache/bazel/_bazel_aj/5f825ad28f8e070f999ba37395e46ee5/external/nixpkgs/nixpkgs.nix:3:1 called with unexpected argument 'config', at (string):1:1
```
* rules_haskell unnamed string.split(_, maxsplit = _)
The keyword argument may no longer be named.
* string.replace(_, _, maxsplit = _) may not be named
* Move proto sources from deps to data
Fixes
```
ERROR: /home/aj/tweag.io/da/da-bazel-1.1/daml-lf/archive/BUILD.bazel:150:1: in deps attribute of scala_test rule //daml-lf/archive:daml_lf_archive_reader_tests_test_suite_src_test_scala_com_digitalasset_daml_lf_archive_DecodeV1Spec.scala: '//daml-lf/archive:daml_lf_1.6_archive_proto_srcs' does not have mandatory providers: 'JavaInfo'. Since this rule was created by the macro 'da_scala_test_suite', the error might have been caused by the macro implementation
```
* Define sha256 for haskell_ghc__paths
Bazel 1.1.0 fails on missing hashes.
* Disable --incompatible_windows_native_test_wrapper
* //compiler/daml-extension don't modify sources
Modifying sources in-place can cause issues on Windows, where build
actions are not sandboxed and changes on sources can affect other build
steps.
* bazel-genfiles --> bazel-bin
The bazel-genfiles symlink has been removed since Bazel 1.0.
See https://github.com/bazelbuild/bazel/issues/8651
* Mark dev_env_tool repository rule as configure
See
https://docs.bazel.build/versions/1.1.0/skylark/lib/globals.html#repository_rule
* Move data deps into data attribute
* Mark dev_env_tool as local = True
* Manually fetch @makensis_dev_env
2019-11-11 12:06:03 +03:00
|
|
|
cp -r compiler/daml-extension $$TMP_DIR
|
|
|
|
cd $$TMP_DIR/daml-extension
|
2019-07-13 00:35:05 +03:00
|
|
|
tar xzf $$DIR/$(location :node_deps_cache)
|
|
|
|
sed -i "s/__VERSION__/$$VERSION/" package.json
|
|
|
|
sed -i 's/"name": "daml"/"name": "daml-bundled"/' package.json
|
2019-12-09 16:22:21 +03:00
|
|
|
$$DIR/$(location //:yarn)
|
|
|
|
$$DIR/$(location //:yarn) compile
|
2019-07-13 00:35:05 +03:00
|
|
|
$$DIR/$(location @daml_extension_deps//vsce/bin:vsce) package -o $$DIR/$@
|
2019-04-04 11:33:38 +03:00
|
|
|
""",
|
2019-07-13 00:35:05 +03:00
|
|
|
tools = [
|
2019-12-09 16:22:21 +03:00
|
|
|
"//:yarn",
|
2019-07-13 00:35:05 +03:00
|
|
|
"@daml_extension_deps//vsce/bin:vsce",
|
|
|
|
],
|
2019-04-04 11:33:38 +03:00
|
|
|
)
|