1workspace(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 15rust_register_toolchains( 16 edition = "2018", 17) 18 19load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies") 20 21crate_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() 32 33load("@rules_rust//bindgen:transitive_repositories.bzl", "rust_bindgen_transitive_dependencies") 34 35rust_bindgen_transitive_dependencies() 36 37load("@rules_rust//proto/protobuf:repositories.bzl", "rust_proto_protobuf_dependencies", "rust_proto_protobuf_register_toolchains") 38 39rust_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() 46 47load("@rules_rust//wasm_bindgen:repositories.bzl", "rust_wasm_bindgen_dependencies", "rust_wasm_bindgen_register_toolchains") 48 49rust_wasm_bindgen_dependencies() 50 51rust_wasm_bindgen_register_toolchains() 52 53load("@rules_rust//wasm_bindgen/rules_nodejs:repositories.bzl", "nodejs_rust_wasm_bindgen_dependencies") 54 55nodejs_rust_wasm_bindgen_dependencies() 56 57load("@rules_rust//wasm_bindgen/rules_js:repositories.bzl", "js_rust_wasm_bindgen_dependencies") 58 59js_rust_wasm_bindgen_dependencies() 60 61load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 62 63############################################################################### 64# Workspace examples 65############################################################################### 66 67# buildifier: disable=same-origin-load 68load("@rules_rust//rust:repositories.bzl", "rust_repository_set") 69 70# `rust_repository_set` is the core repository rule for downloading and defining 71# a rust_toolchain. Should there be a need for a customized toolchain, this macro can 72# be used to define and register one. 73rust_repository_set( 74 name = "fake_toolchain_for_test_of_sha256", 75 edition = "2018", 76 exec_triple = "x86_64-unknown-linux-gnu", 77 extra_target_triples = [], 78 sha256s = { 79 "rust-1.46.0-x86_64-unknown-linux-gnu": "e3b98bc3440fe92817881933f9564389eccb396f5f431f33d48b979fa2fbdcf5", 80 "rust-std-1.46.0-x86_64-unknown-linux-gnu": "ac04aef80423f612c0079829b504902de27a6997214eb58ab0765d02f7ec1dbc", 81 "rustfmt-1.4.12-x86_64-unknown-linux-gnu": "1894e76913303d66bf40885a601462844eec15fca9e76a6d13c390d7000d64b0", 82 }, 83 versions = ["1.46.0"], 84) 85 86############################################################################### 87# Examples dependencies 88############################################################################### 89 90http_archive( 91 name = "build_bazel_rules_nodejs", 92 sha256 = "709cc0dcb51cf9028dd57c268066e5bc8f03a119ded410a13b5c3925d6e43c48", 93 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.4/rules_nodejs-5.8.4.tar.gz"], 94) 95 96load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories") 97 98node_repositories() 99 100load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") 101 102rules_js_dependencies() 103 104load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") 105 106nodejs_register_toolchains( 107 name = "nodejs", 108 node_version = DEFAULT_NODE_VERSION, 109) 110 111load("@bazel_features//:deps.bzl", "bazel_features_deps") 112 113bazel_features_deps() 114 115http_archive( 116 name = "rules_foreign_cc", 117 sha256 = "69023642d5781c68911beda769f91fcbc8ca48711db935a75da7f6536b65047f", 118 strip_prefix = "rules_foreign_cc-0.6.0", 119 url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.6.0.tar.gz", 120) 121 122load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") 123 124rules_foreign_cc_dependencies() 125 126load("//sys:sys_deps.bzl", "sys_deps") 127 128sys_deps() 129 130local_repository( 131 name = "rules_rust_example_cargo_manifest_dir", 132 path = "cargo_manifest_dir/external_crate", 133) 134 135_LIBC_BUILD_FILE_CONTENT = """\ 136load("@rules_rust//rust:defs.bzl", "rust_library") 137 138rust_library( 139 name = "libc", 140 srcs = glob(["src/**/*.rs"]), 141 edition = "2015", 142 rustc_flags = [ 143 # In most cases, warnings in 3rd party crates are not interesting as 144 # they're out of the control of consumers. The flag here silences 145 # warnings. For more details see: 146 # https://doc.rust-lang.org/rustc/lints/levels.html 147 "--cap-lints=allow", 148 ], 149 visibility = ["//visibility:public"], 150) 151""" 152 153http_archive( 154 name = "libc", 155 build_file_content = _LIBC_BUILD_FILE_CONTENT, 156 sha256 = "1ac4c2ac6ed5a8fb9020c166bc63316205f1dc78d4b964ad31f4f21eb73f0c6d", 157 strip_prefix = "libc-0.2.20", 158 urls = [ 159 "https://mirror.bazel.build/github.com/rust-lang/libc/archive/0.2.20.zip", 160 "https://github.com/rust-lang/libc/archive/0.2.20.zip", 161 ], 162) 163 164############################################################################### 165 166http_archive( 167 name = "bazelci_rules", 168 sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e", 169 strip_prefix = "bazelci_rules-1.0.0", 170 url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz", 171) 172 173load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig") 174 175# Creates a default toolchain config for RBE. 176# Use this as is if you are using the rbe_ubuntu16_04 container, 177# otherwise refer to RBE docs. 178rbe_preconfig( 179 name = "buildkite_config", 180 toolchain = "ubuntu1804-bazel-java11", 181) 182 183load("@build_bazel_apple_support//crosstool:setup.bzl", "apple_cc_configure") 184 185# As of Bazel 7, Bazel's bundled cc_toolchain only supports using CommandLineTools and not a full Xcode. 186# This manifests itself if you try to use anything which requires access to $DEVELOPER_DIR, such as our bindgen example which non-hermetically tries to read libc++ headers from the system. 187# On CI (and for some of our contributors), we have a full Xcode install, so this fails. 188# We register the apple_support cc_toolchain here because it supports both CommandLineTools and full Xcodes. 189# See https://github.com/bazelbuild/rules_rust/issues/2207 and https://github.com/bazelbuild/bazel/issues/20638 190apple_cc_configure() 191