Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 37 additions & 36 deletions sdk/compiler/daml-extension/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package(default_visibility = ["//visibility:public"])

load("@build_environment//:configuration.bzl", "npm_version")
load("@os_info//:os_info.bzl", "is_windows")

filegroup(
name = "json-files",
Expand Down Expand Up @@ -45,37 +46,33 @@ sh_test(
# 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",
"//compiler/daml-extension:yarn.lock",
],
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
# exclude scoped (@-prefixed) directories that will be copied below
if [[ $$f != *"@"* ]]; then
cp -r ../$$f ./
fi
done
# copy all scoped (@-prefixed) package directories
for scope_dir in ../$(BINDIR)/external/daml_extension_deps/node_modules/@*/; do
cp -r "$$scope_dir" ./
done
cd ..
# Check for poison!
# Avoid file path too long errors on Windows of the form
# .../tar_dev_env/usr/bin/tar: node_modules/.cache/terser-webpack-plugin/...: file name is too long (cannot be split); not dumped
$(execpath //bazel_tools/sh:mktgz) $@ node_modules --dereference
""",
tools = ["//bazel_tools/sh:mktgz"],
)
#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 ..
# # Avoid file path too long errors on Windows of the form
# # .../tar_dev_env/usr/bin/tar: node_modules/.cache/terser-webpack-plugin/...: file name is too long (cannot be split); not dumped
# $(execpath //bazel_tools/sh:mktgz) $@ --exclude="node_modules/.cache/*" node_modules
# """,
# tools = ["//bazel_tools/sh:mktgz"],
#)

genrule(
name = "webview-stylesheet",
Expand All @@ -102,9 +99,9 @@ genrule(
"yarn.lock",
".vscodeignore",
"src/*",
]) + [
":node_deps_cache",
],
"windows_node_modules.zip",
"unix_node_modules.zip",
]),
outs = ["daml-bundled.vsix"],
# rm -rf can fail with "directory not empty" on Windows.
# As a workaround we add `|| return`.
Expand All @@ -119,7 +116,8 @@ genrule(
# we store the target cpu value to ensure the archive is platform specific
echo $(TARGET_CPU) > $$TMP_DIR/target_cpu
cd $$TMP_DIR/daml-extension
tar xzf $$DIR/$(location :node_deps_cache)
tar xzf {node_modules_zip}
rm windows_node_modules.zip unix_node_modules.zip
sed -i "s/__VERSION__/{npm}/" package.json
sed -i 's/"name": "daml"/"name": "daml-bundled"/' package.json
$$DIR/$(location //:yarn) compile
Expand All @@ -129,7 +127,10 @@ genrule(
# So for now, we explicitly depend on concat-map in `package.json` to avoid this
# Check for poison!
PATH=$$(dirname $$DIR/$(location @nodejs//:node_bin)):$$(dirname $$DIR/$(location //:yarn)):$$PATH $$DIR/$(location @nodejs//:node_bin) node_modules/@vscode/vsce/vsce package --yarn -o $$DIR/$@
""".format(npm = npm_version),
""".format(
node_modules_zip = "windows_node_modules.zip" if is_windows else "unix_node_modules.zip",
npm = npm_version,
),
tools = [
"//:yarn",
"@nodejs//:node_bin",
Expand Down
Binary file added sdk/compiler/daml-extension/unix_node_modules.zip
Binary file not shown.
Binary file not shown.
Loading