blob: a9ca0808c1fb27daf3bb09dd65c8b6070c515e9c [file] [log] [blame]
Brian Silvermancc09f182022-03-09 15:40:20 -08001workspace(name = "examples")
2
3# Users of `rules_rust` will commonly be unable to load it
4# using a `local_repository`. Instead, to setup the rules,
5# please see https://bazelbuild.github.io/rules_rust/#setup
6local_repository(
7 name = "rules_rust",
8 path = "..",
9)
10
11load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
12
13rules_rust_dependencies()
14
Brian Silverman5f6f2762022-08-13 19:30:05 -070015rust_register_toolchains(
16 edition = "2018",
17)
Brian Silvermancc09f182022-03-09 15:40:20 -080018
Brian Silverman5f6f2762022-08-13 19:30:05 -070019load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
Brian Silvermancc09f182022-03-09 15:40:20 -080020
Brian Silverman5f6f2762022-08-13 19:30:05 -070021crate_universe_dependencies(bootstrap = True)
22
23load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies")
24
25rust_analyzer_dependencies()
26
27load("@rules_rust//bindgen:repositories.bzl", "rust_bindgen_dependencies", "rust_bindgen_register_toolchains")
28
29rust_bindgen_dependencies()
30
31rust_bindgen_register_toolchains()
Brian Silvermancc09f182022-03-09 15:40:20 -080032
33load("@rules_rust//proto:repositories.bzl", "rust_proto_repositories")
34
35rust_proto_repositories()
36
37load("@rules_rust//proto:transitive_repositories.bzl", "rust_proto_transitive_repositories")
38
39rust_proto_transitive_repositories()
40
Brian Silverman5f6f2762022-08-13 19:30:05 -070041load("@rules_rust//wasm_bindgen:repositories.bzl", "rust_wasm_bindgen_dependencies", "rust_wasm_bindgen_register_toolchains")
Brian Silvermancc09f182022-03-09 15:40:20 -080042
Brian Silverman5f6f2762022-08-13 19:30:05 -070043rust_wasm_bindgen_dependencies()
44
45rust_wasm_bindgen_register_toolchains()
Brian Silvermancc09f182022-03-09 15:40:20 -080046
47load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
48
49###############################################################################
50# Workspace examples
51###############################################################################
52
53# buildifier: disable=same-origin-load
54load("@rules_rust//rust:repositories.bzl", "rust_repository_set")
55
56# `rust_repository_set` is the core repository rule for downloading and defining
57# a rust_toolchain. Should there be a need for a customized toolchain, this macro can
58# be used to define and register one.
59rust_repository_set(
60 name = "fake_toolchain_for_test_of_sha256",
61 edition = "2018",
62 exec_triple = "x86_64-unknown-linux-gnu",
63 extra_target_triples = [],
64 rustfmt_version = "1.4.12",
65 sha256s = {
66 "rust-1.46.0-x86_64-unknown-linux-gnu": "e3b98bc3440fe92817881933f9564389eccb396f5f431f33d48b979fa2fbdcf5",
67 "rust-std-1.46.0-x86_64-unknown-linux-gnu": "ac04aef80423f612c0079829b504902de27a6997214eb58ab0765d02f7ec1dbc",
68 "rustfmt-1.4.12-x86_64-unknown-linux-gnu": "1894e76913303d66bf40885a601462844eec15fca9e76a6d13c390d7000d64b0",
69 },
70 version = "1.46.0",
71)
72
73###############################################################################
74# Examples dependencies
75###############################################################################
76
Brian Silverman5f6f2762022-08-13 19:30:05 -070077http_archive(
78 name = "build_bazel_rules_nodejs",
79 sha256 = "c78216f5be5d451a42275b0b7dc809fb9347e2b04a68f68bad620a2b01f5c774",
80 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.5.2/rules_nodejs-5.5.2.tar.gz"],
81)
82
Brian Silvermancc09f182022-03-09 15:40:20 -080083load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")
84
85node_repositories()
86
87http_archive(
88 name = "rules_foreign_cc",
89 sha256 = "69023642d5781c68911beda769f91fcbc8ca48711db935a75da7f6536b65047f",
90 strip_prefix = "rules_foreign_cc-0.6.0",
91 url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.6.0.tar.gz",
92)
93
94load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
95
96rules_foreign_cc_dependencies()
97
98load("//sys:sys_deps.bzl", "sys_deps")
99
100sys_deps()
101
102local_repository(
103 name = "rules_rust_example_cargo_manifest_dir",
104 path = "cargo_manifest_dir/external_crate",
105)
106
107_LIBC_BUILD_FILE_CONTENT = """\
108load("@rules_rust//rust:defs.bzl", "rust_library")
109
110rust_library(
111 name = "libc",
112 srcs = glob(["src/**/*.rs"]),
113 edition = "2015",
Brian Silverman5f6f2762022-08-13 19:30:05 -0700114 rustc_flags = [
115 # In most cases, warnings in 3rd party crates are not interesting as
116 # they're out of the control of consumers. The flag here silences
117 # warnings. For more details see:
118 # https://doc.rust-lang.org/rustc/lints/levels.html
119 "--cap-lints=allow",
120 ],
Brian Silvermancc09f182022-03-09 15:40:20 -0800121 visibility = ["//visibility:public"],
122)
123"""
124
125http_archive(
126 name = "libc",
127 build_file_content = _LIBC_BUILD_FILE_CONTENT,
128 sha256 = "1ac4c2ac6ed5a8fb9020c166bc63316205f1dc78d4b964ad31f4f21eb73f0c6d",
129 strip_prefix = "libc-0.2.20",
130 urls = [
131 "https://mirror.bazel.build/github.com/rust-lang/libc/archive/0.2.20.zip",
132 "https://github.com/rust-lang/libc/archive/0.2.20.zip",
133 ],
134)
135
136###############################################################################
137
138http_archive(
139 name = "bazel_toolchains",
140 sha256 = "179ec02f809e86abf56356d8898c8bd74069f1bd7c56044050c2cd3d79d0e024",
141 strip_prefix = "bazel-toolchains-4.1.0",
142 urls = [
143 "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/4.1.0/bazel-toolchains-4.1.0.tar.gz",
144 "https://github.com/bazelbuild/bazel-toolchains/releases/download/4.1.0/bazel-toolchains-4.1.0.tar.gz",
145 ],
146)
147
148load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
149
150# Creates a default toolchain config for RBE.
151# Use this as is if you are using the rbe_ubuntu16_04 container,
152# otherwise refer to RBE docs.
153rbe_autoconfig(name = "buildkite_config")