Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed duplicate dependencies of examples in the top level workspace #407

Merged
merged 3 commits into from
Sep 24, 2020
Merged
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
33 changes: 6 additions & 27 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
workspace(name = "io_bazel_rules_rust")

load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_skylib",
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
urls = [
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

new_git_repository(
name = "libc",
build_file = "@io_bazel_rules_rust//:libc.BUILD",
remote = "https://github.com/rust-lang/libc",
tag = "0.2.20",
)

load("@io_bazel_rules_rust//proto:repositories.bzl", "rust_proto_repositories")

rust_proto_repositories()
Expand All @@ -35,8 +12,14 @@ load("@io_bazel_rules_rust//wasm_bindgen:repositories.bzl", "rust_wasm_bindgen_r

rust_wasm_bindgen_repositories()

load("@io_bazel_rules_rust//:workspace.bzl", "rust_workspace")

rust_workspace()

# --- end stardoc

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_toolchains",
sha256 = "d8c2f20deb2f6143bac792d210db1a4872102d81529fe0ea3476c1696addd7ff",
Expand All @@ -55,10 +38,6 @@ rbe_autoconfig(
name = "buildkite_config",
)

load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version")

bazel_version(name = "bazel_version")

# Load all dependencies for examples

local_repository(
Expand Down
33 changes: 13 additions & 20 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,25 @@ To use the Rust rules, add the following to your `WORKSPACE` file to add the ext
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_skylib",
urls = [
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
],
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()

http_archive(
name = "io_bazel_rules_rust",
sha256 = "b6da34e057a31b8a85e343c732de4af92a762f804fc36b0baa6c001423a70ebc",
strip_prefix = "rules_rust-55f77017a7f5b08e525ebeab6e11d8896a4499d2",
sha256 = "9158524bbbdfded6326d00e76d4fb293efbb07d4e4881416210bac221613432f",
strip_prefix = "rules_rust-7d9e890c58ca00eacf8dd4a2ba991cfe9c3f44e4",
urls = [
# Master branch as of 2019-10-07
"https://github.com/bazelbuild/rules_rust/archive/55f77017a7f5b08e525ebeab6e11d8896a4499d2.tar.gz",
# Master branch as of 2020-09-09
"https://github.com/bazelbuild/rules_rust/archive/7d9e890c58ca00eacf8dd4a2ba991cfe9c3f44e4.tar.gz",
],
)

load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories")

rust_repositories()

load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version")
bazel_version(name = "bazel_version")
load("@io_bazel_rules_rust//:workspace.bzl", "rust_workspace")

rust_workspace()
```

The rules are under active development, as such the lastest commit on the master branch should be used. `master` currently requires Bazel >= 0.26.0.

## Rules
Expand Down Expand Up @@ -85,9 +76,11 @@ Currently the most common approach to managing external dependencies is using

## WebAssembly

To build a `rust_binary` for wasm32-unknown-unknown add the `--platforms=//rust/platform:wasm` flag.
To build a `rust_binary` for wasm32-unknown-unknown add the `--platforms=@io_bazel_rules_rust//rust/platform:wasm` flag.

bazel build @examples//hello_world_wasm --platforms=//rust/platform:wasm
```command
bazel build @examples//hello_world_wasm --platforms=@io_bazel_rules_rust//rust/platform:wasm
```

`rust_wasm_bindgen` will automatically transition to the wasm platform and can be used when
building wasm code for the host target.
8 changes: 4 additions & 4 deletions examples/examples_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "npm_install")
load("@examples//hello_sys:workspace.bzl", "remote_deps")
load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version")
load("@io_bazel_rules_rust//:workspace.bzl", "rust_workspace")
load("@io_bazel_rules_rust//bindgen:repositories.bzl", "rust_bindgen_repositories")
load("@io_bazel_rules_rust//proto:repositories.bzl", "rust_proto_repositories")
load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories", "rust_repository_set")
Expand Down Expand Up @@ -37,15 +37,15 @@ def deps():
# Dependencies for the @examples//hello_world_wasm example.
npm_install(
name = "npm",
package_json = "//:package.json",
package_lock_json = "//:package-lock.json",
package_json = "@examples//:package.json",
package_lock_json = "@examples//:package-lock.json",
)

rust_bindgen_repositories()

rust_wasm_bindgen_repositories()

bazel_version(name = "bazel_version")
rust_workspace()

remote_deps()

Expand Down
2 changes: 1 addition & 1 deletion examples/examples_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def repositories():
maybe(
http_archive,
name = "libc",
build_file = "@//:libc.BUILD",
build_file = "@examples//:libc.BUILD",
sha256 = "1ac4c2ac6ed5a8fb9020c166bc63316205f1dc78d4b964ad31f4f21eb73f0c6d",
strip_prefix = "libc-0.2.20",
urls = [
Expand Down
7 changes: 0 additions & 7 deletions libc.BUILD

This file was deleted.

Loading