Skip to content

Commit

Permalink
Add build files for sdkjs
Browse files Browse the repository at this point in the history
  • Loading branch information
wginolas committed Jul 26, 2024
1 parent 6886985 commit d4d27ed
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bazel-*

.zed
17 changes: 17 additions & 0 deletions sdkjs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"],
)
7 changes: 4 additions & 3 deletions sdkjs/Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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 .
14 changes: 14 additions & 0 deletions sdkjs/make-in-bazel.sh
Original file line number Diff line number Diff line change
@@ -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 .
5 changes: 5 additions & 0 deletions web-apps/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
filegroup(
name = "files",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)

0 comments on commit d4d27ed

Please sign in to comment.