blob: 255b51d8feb0f2d7261712615bcdb4b65a450105 [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
Adam Snaider1c095c92023-07-08 02:09:58 -040033load("@rules_rust//bindgen:transitive_repositories.bzl", "rust_bindgen_transitive_dependencies")
Brian Silvermancc09f182022-03-09 15:40:20 -080034
Adam Snaider1c095c92023-07-08 02:09:58 -040035rust_bindgen_transitive_dependencies()
Brian Silvermancc09f182022-03-09 15:40:20 -080036
Adam Snaider1c095c92023-07-08 02:09:58 -040037load("@rules_rust//proto/protobuf:repositories.bzl", "rust_proto_protobuf_dependencies", "rust_proto_protobuf_register_toolchains")
Brian Silvermancc09f182022-03-09 15:40:20 -080038
Adam Snaider1c095c92023-07-08 02:09:58 -040039rust_proto_protobuf_dependencies()
40
41rust_proto_protobuf_register_toolchains()
42
43load("@rules_rust//proto/protobuf:transitive_repositories.bzl", "rust_proto_protobuf_transitive_repositories")
44
45rust_proto_protobuf_transitive_repositories()
Brian Silvermancc09f182022-03-09 15:40:20 -080046
Brian Silverman5f6f2762022-08-13 19:30:05 -070047load("@rules_rust//wasm_bindgen:repositories.bzl", "rust_wasm_bindgen_dependencies", "rust_wasm_bindgen_register_toolchains")
Brian Silvermancc09f182022-03-09 15:40:20 -080048
Brian Silverman5f6f2762022-08-13 19:30:05 -070049rust_wasm_bindgen_dependencies()
50
51rust_wasm_bindgen_register_toolchains()
Brian Silvermancc09f182022-03-09 15:40:20 -080052
53load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
54
55###############################################################################
56# Workspace examples
57###############################################################################
58
59# buildifier: disable=same-origin-load
60load("@rules_rust//rust:repositories.bzl", "rust_repository_set")
61
62# `rust_repository_set` is the core repository rule for downloading and defining
63# a rust_toolchain. Should there be a need for a customized toolchain, this macro can
64# be used to define and register one.
65rust_repository_set(
66 name = "fake_toolchain_for_test_of_sha256",
67 edition = "2018",
68 exec_triple = "x86_64-unknown-linux-gnu",
69 extra_target_triples = [],
Brian Silvermancc09f182022-03-09 15:40:20 -080070 sha256s = {
71 "rust-1.46.0-x86_64-unknown-linux-gnu": "e3b98bc3440fe92817881933f9564389eccb396f5f431f33d48b979fa2fbdcf5",
72 "rust-std-1.46.0-x86_64-unknown-linux-gnu": "ac04aef80423f612c0079829b504902de27a6997214eb58ab0765d02f7ec1dbc",
73 "rustfmt-1.4.12-x86_64-unknown-linux-gnu": "1894e76913303d66bf40885a601462844eec15fca9e76a6d13c390d7000d64b0",
74 },
Adam Snaider1c095c92023-07-08 02:09:58 -040075 versions = ["1.46.0"],
Brian Silvermancc09f182022-03-09 15:40:20 -080076)
77
78###############################################################################
79# Examples dependencies
80###############################################################################
81
Brian Silverman5f6f2762022-08-13 19:30:05 -070082http_archive(
83 name = "build_bazel_rules_nodejs",
84 sha256 = "c78216f5be5d451a42275b0b7dc809fb9347e2b04a68f68bad620a2b01f5c774",
85 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.5.2/rules_nodejs-5.5.2.tar.gz"],
86)
87
Brian Silvermancc09f182022-03-09 15:40:20 -080088load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")
89
90node_repositories()
91
92http_archive(
93 name = "rules_foreign_cc",
94 sha256 = "69023642d5781c68911beda769f91fcbc8ca48711db935a75da7f6536b65047f",
95 strip_prefix = "rules_foreign_cc-0.6.0",
96 url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.6.0.tar.gz",
97)
98
99load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
100
101rules_foreign_cc_dependencies()
102
103load("//sys:sys_deps.bzl", "sys_deps")
104
105sys_deps()
106
107local_repository(
108 name = "rules_rust_example_cargo_manifest_dir",
109 path = "cargo_manifest_dir/external_crate",
110)
111
112_LIBC_BUILD_FILE_CONTENT = """\
113load("@rules_rust//rust:defs.bzl", "rust_library")
114
115rust_library(
116 name = "libc",
117 srcs = glob(["src/**/*.rs"]),
118 edition = "2015",
Brian Silverman5f6f2762022-08-13 19:30:05 -0700119 rustc_flags = [
120 # In most cases, warnings in 3rd party crates are not interesting as
121 # they're out of the control of consumers. The flag here silences
122 # warnings. For more details see:
123 # https://doc.rust-lang.org/rustc/lints/levels.html
124 "--cap-lints=allow",
125 ],
Brian Silvermancc09f182022-03-09 15:40:20 -0800126 visibility = ["//visibility:public"],
127)
128"""
129
130http_archive(
131 name = "libc",
132 build_file_content = _LIBC_BUILD_FILE_CONTENT,
133 sha256 = "1ac4c2ac6ed5a8fb9020c166bc63316205f1dc78d4b964ad31f4f21eb73f0c6d",
134 strip_prefix = "libc-0.2.20",
135 urls = [
136 "https://mirror.bazel.build/github.com/rust-lang/libc/archive/0.2.20.zip",
137 "https://github.com/rust-lang/libc/archive/0.2.20.zip",
138 ],
139)
140
141###############################################################################
142
143http_archive(
Adam Snaider1c095c92023-07-08 02:09:58 -0400144 name = "bazelci_rules",
145 sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
146 strip_prefix = "bazelci_rules-1.0.0",
147 url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz",
Brian Silvermancc09f182022-03-09 15:40:20 -0800148)
149
Adam Snaider1c095c92023-07-08 02:09:58 -0400150load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
Brian Silvermancc09f182022-03-09 15:40:20 -0800151
152# Creates a default toolchain config for RBE.
153# Use this as is if you are using the rbe_ubuntu16_04 container,
154# otherwise refer to RBE docs.
Adam Snaider1c095c92023-07-08 02:09:58 -0400155rbe_preconfig(
156 name = "buildkite_config",
157 toolchain = "ubuntu1804-bazel-java11",
158)