From 65f90fa3a8f4febd705b77f8b6497d7449d58dc8 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 2 Jan 2021 09:49:41 +1000 Subject: [PATCH] docs: musl and local node --- docs/linux.md | 4 ++++ docs/new-platform.md | 57 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/docs/linux.md b/docs/linux.md index b2a9ceb4a..275991dd0 100644 --- a/docs/linux.md +++ b/docs/linux.md @@ -4,6 +4,10 @@ These instructions are written for Debian/Ubuntu; adjust for your distribution. +Glibc is required - if you are on a distro like Alpine that uses musl, you'll need +to contribute fixes to the upstream [Rust rules](https://github.com/bazelbuild/rules_rust/issues/390), +then follow the steps in [Other Platforms](./new-platform.md). + **Ensure some basic tools are installed**: ``` diff --git a/docs/new-platform.md b/docs/new-platform.md index b5295de2a..777842287 100644 --- a/docs/new-platform.md +++ b/docs/new-platform.md @@ -7,6 +7,7 @@ version installed already, either from your Linux distro's archives, or by building from source. - Rust and Node must support your platform. +- If the Bazel Rust and Node rules do not support your platform, extra work may be required. ## 32 bit builds @@ -53,9 +54,59 @@ Examples of the required changes: ## NodeJS -If you node don't provide a binary for your platform and you have a local copy -installed, you may be able to modify node_repositories() in /defs.bzl to point -to your [local npm installation](https://bazelbuild.github.io/rules_nodejs/install.html). +If node doesn't provide a binary for your platform and you have a local copy +installed, you can create a local_node folder in the project root, symlink in +your local installation, and modify defs.bzl. + +```patch +diff --git a/defs.bzl b/defs.bzl +index eff3d9df2..fb2e9f7fe 100644 +--- a/defs.bzl ++++ b/defs.bzl +@@ -41,7 +41,15 @@ def setup_deps(): + python_runtime = "@python//:python", + ) + +- node_repositories(package_json = ["@net_ankiweb_anki//ts:package.json"]) ++ native.local_repository( ++ name = "local_node", ++ path = "local_node", ++ ) ++ ++ node_repositories( ++ package_json = ["@net_ankiweb_anki//ts:package.json"], ++ vendored_node = "@local_node//:node", ++ ) + + yarn_install( + name = "npm", +diff --git a/local_node/BUILD.bazel b/local_node/BUILD.bazel +new file mode 100644 +index 000000000..aa0c473ae +--- /dev/null ++++ b/local_node/BUILD.bazel +@@ -0,0 +1 @@ ++exports_files(["node/bin/node"] + glob(["node/lib/node_modules/**"])) +diff --git a/local_node/WORKSPACE b/local_node/WORKSPACE +new file mode 100644 +index 000000000..e69de29bb +diff --git a/local_node/node/bin/node b/local_node/node/bin/node +new file mode 120000 +index 000000000..d7b371472 +--- /dev/null ++++ b/local_node/node/bin/node +@@ -0,0 +1 @@ ++/usr/local/bin/node +\ No newline at end of file +diff --git a/local_node/node/lib/node_modules b/local_node/node/lib/node_modules +new file mode 120000 +index 000000000..23dd0736e +--- /dev/null ++++ b/local_node/node/lib/node_modules +@@ -0,0 +1 @@ ++/usr/local/lib/node_modules +\ No newline at end of file +``` ## Submitting changes