Update bazel readme (#774)
* Update bazel/README.md
* Add deps instantiation to readme
* Add bazelrc explanations to readme
* Note the preferred way of using bazel emsdk
diff --git a/bazel/README.md b/bazel/README.md
index 17e9264..dc849fd 100644
--- a/bazel/README.md
+++ b/bazel/README.md
@@ -2,40 +2,34 @@
## Setup Instructions
-1. Merge the `WORKSPACE` file in with your own at the root of your bazel
-directory structure. If you don't have one, simply copy the file.
-2. Merge the `bazelrc` file in with your `.bazelrc` file at the root of your
-bazel directory structure. If you don't have one, simply copy the file and
-rename it to `.bazelrc`. (Note the `.`)
-3. Copy the `emscripten_toolchain` folder along with its contents to the root of
-your bazel directory.
-
-Your directory structure should look like this:
+In `WORKSPACE` file, put:
```
-bazel_root/
-├── .bazelrc
-├── WORKSPACE
-├── emscripten_toolchain/
-│ ├── BUILD.bazel
-│ ├── builddefs.bzl
-│ ├── crosstool.bzl
-│ ├── emar.sh
-│ ├── emcc.sh
-│ ├── emcc_link.sh
-│ ├── emscripten.BUILD
-│ ├── emscripten_config
-│ ├── env.sh
-│ ├── link_wrapper.py
-│ ├── wasm_binary.py
-│ ├── wasm_cc_binary.bzl
-│ ├── wasm_rules.bzl
-├── your_project_folder/
-│ ├── your_project.file
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+http_archive(
+ name = "emsdk",
+ strip_prefix = "emsdk-c1589b55641787d55d53e883852035beea9aec3f/bazel",
+ url = "https://github.com/emscripten-core/emsdk/archive/c1589b55641787d55d53e883852035beea9aec3f.tar.gz",
+ sha256 = "7a58a9996b113d3e0675df30b5f17e28aa47de2e684a844f05394fe2f6f12e8e",
+)
+
+load("@emsdk//:deps.bzl", emsdk_deps = "deps")
+emsdk_deps()
+
+load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps")
+emsdk_emscripten_deps()
```
## Building
### Using --config=wasm
+
+Put the following lines into your `.bazelrc`:
+```
+build:wasm --crosstool_top=//emscripten_toolchain:everything
+build:wasm --cpu=wasm
+build:wasm --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
+```
+
Simply pass `--config=wasm` when building a normal `cc_binary`. The result of
this build will be a tar archive containing any files produced by emscripten.
@@ -44,7 +38,7 @@
```
load("@rules_cc//cc:defs.bzl", "cc_binary")
-load("//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")
+load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")
cc_binary(
name = "hello-world",
@@ -61,3 +55,7 @@
be the individual files produced by emscripten. Note that some of these files
may be empty. This is because bazel has no concept of optional outputs for
rules.
+
+`wasm_cc_binary` uses transition to use emscripten toolchain on `cc_target`
+and all of its dependencies, and does not require amending `.bazelrc`. This
+is the preferred way, since it also unpacks the resulting tarball.