diff --git a/.gitignore b/.gitignore index 57c461f462..b0ee97f5a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bazel-* +.zed diff --git a/sdkjs/BUILD.bazel b/sdkjs/BUILD.bazel new file mode 100644 index 0000000000..3ffe9f209b --- /dev/null +++ b/sdkjs/BUILD.bazel @@ -0,0 +1,17 @@ +load("@rules_tar//tar/unpack:defs.bzl", "tar_unpack") + +genrule( + name = "make-tar", + srcs = glob(["**"]) + [ + "//web-apps:files", + ], + cmd = "sdkjs/make-in-bazel.sh $@", + outs = ["deploy.tar"], +) + +# genrule can not output directories. We are using a tar file as workaround +tar_unpack( + name = "make", + src = ":make-tar", + visibility = ["//visibility:public"], +) diff --git a/sdkjs/Makefile b/sdkjs/Makefile index 3fd3facb86..a513873297 100644 --- a/sdkjs/Makefile +++ b/sdkjs/Makefile @@ -1,5 +1,5 @@ GRUNT = grunt -GRUNT_FLAGS = --no-color -v --noclosure --desktop=false +GRUNT_FLAGS = --no-color -v --noclosure --desktop=false OUTPUT_DIR = deploy OUTPUT = $(OUTPUT_DIR) @@ -54,9 +54,10 @@ $(SDKJS_FILES): $(NODE_MODULES) desktop: GRUNT_FLAGS += --desktop=true desktop: all - + clean: rm -f $(WEBAPPS_FILES) $(SDKJS_FILES) %/node_modules: %/package.json - cd $(dir $@) && npm install + # CryptPad: Disable cache, so this can build inside bazel + cd $(dir $@) && npm install --cache . diff --git a/sdkjs/make-in-bazel.sh b/sdkjs/make-in-bazel.sh new file mode 100755 index 0000000000..6ea4f4d860 --- /dev/null +++ b/sdkjs/make-in-bazel.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +OUT_FILE=$1 +WORK_DIR=$(mktemp -d -t build-oo.XXXXX) +START_PWD=`pwd` + +cp -r --dereference sdkjs web-apps $WORK_DIR +cd $WORK_DIR/sdkjs +make +mv "$WORK_DIR/sdkjs/deploy/web-apps/apps/api/documents/api.js" "$WORK_DIR/sdkjs/deploy/web-apps/apps/api/documents/api-orig.js" +cd deploy +tar cf $START_PWD/$OUT_FILE . diff --git a/web-apps/BUILD.bazel b/web-apps/BUILD.bazel new file mode 100644 index 0000000000..d5d3aafe3e --- /dev/null +++ b/web-apps/BUILD.bazel @@ -0,0 +1,5 @@ +filegroup( + name = "files", + srcs = glob(["**"]), + visibility = ["//visibility:public"], +)