Brian Silverman | cc09f18 | 2022-03-09 15:40:20 -0800 | [diff] [blame] | 1 | workspace(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 |
| 6 | local_repository( |
| 7 | name = "rules_rust", |
| 8 | path = "..", |
| 9 | ) |
| 10 | |
| 11 | load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains") |
| 12 | |
| 13 | rules_rust_dependencies() |
| 14 | |
Brian Silverman | 5f6f276 | 2022-08-13 19:30:05 -0700 | [diff] [blame^] | 15 | rust_register_toolchains( |
| 16 | edition = "2018", |
| 17 | ) |
Brian Silverman | cc09f18 | 2022-03-09 15:40:20 -0800 | [diff] [blame] | 18 | |
Brian Silverman | 5f6f276 | 2022-08-13 19:30:05 -0700 | [diff] [blame^] | 19 | load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies") |
Brian Silverman | cc09f18 | 2022-03-09 15:40:20 -0800 | [diff] [blame] | 20 | |
Brian Silverman | 5f6f276 | 2022-08-13 19:30:05 -0700 | [diff] [blame^] | 21 | crate_universe_dependencies(bootstrap = True) |
| 22 | |
| 23 | load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies") |
| 24 | |
| 25 | rust_analyzer_dependencies() |
| 26 | |
| 27 | load("@rules_rust//bindgen:repositories.bzl", "rust_bindgen_dependencies", "rust_bindgen_register_toolchains") |
| 28 | |
| 29 | rust_bindgen_dependencies() |
| 30 | |
| 31 | rust_bindgen_register_toolchains() |
Brian Silverman | cc09f18 | 2022-03-09 15:40:20 -0800 | [diff] [blame] | 32 | |
| 33 | load("@rules_rust//proto:repositories.bzl", "rust_proto_repositories") |
| 34 | |
| 35 | rust_proto_repositories() |
| 36 | |
| 37 | load("@rules_rust//proto:transitive_repositories.bzl", "rust_proto_transitive_repositories") |
| 38 | |
| 39 | rust_proto_transitive_repositories() |
| 40 | |
Brian Silverman | 5f6f276 | 2022-08-13 19:30:05 -0700 | [diff] [blame^] | 41 | load("@rules_rust//wasm_bindgen:repositories.bzl", "rust_wasm_bindgen_dependencies", "rust_wasm_bindgen_register_toolchains") |
Brian Silverman | cc09f18 | 2022-03-09 15:40:20 -0800 | [diff] [blame] | 42 | |
Brian Silverman | 5f6f276 | 2022-08-13 19:30:05 -0700 | [diff] [blame^] | 43 | rust_wasm_bindgen_dependencies() |
| 44 | |
| 45 | rust_wasm_bindgen_register_toolchains() |
Brian Silverman | cc09f18 | 2022-03-09 15:40:20 -0800 | [diff] [blame] | 46 | |
| 47 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| 48 | |
| 49 | ############################################################################### |
| 50 | # Workspace examples |
| 51 | ############################################################################### |
| 52 | |
| 53 | # buildifier: disable=same-origin-load |
| 54 | load("@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. |
| 59 | rust_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 Silverman | 5f6f276 | 2022-08-13 19:30:05 -0700 | [diff] [blame^] | 77 | http_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 Silverman | cc09f18 | 2022-03-09 15:40:20 -0800 | [diff] [blame] | 83 | load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories") |
| 84 | |
| 85 | node_repositories() |
| 86 | |
| 87 | http_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 | |
| 94 | load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") |
| 95 | |
| 96 | rules_foreign_cc_dependencies() |
| 97 | |
| 98 | load("//sys:sys_deps.bzl", "sys_deps") |
| 99 | |
| 100 | sys_deps() |
| 101 | |
| 102 | local_repository( |
| 103 | name = "rules_rust_example_cargo_manifest_dir", |
| 104 | path = "cargo_manifest_dir/external_crate", |
| 105 | ) |
| 106 | |
| 107 | _LIBC_BUILD_FILE_CONTENT = """\ |
| 108 | load("@rules_rust//rust:defs.bzl", "rust_library") |
| 109 | |
| 110 | rust_library( |
| 111 | name = "libc", |
| 112 | srcs = glob(["src/**/*.rs"]), |
| 113 | edition = "2015", |
Brian Silverman | 5f6f276 | 2022-08-13 19:30:05 -0700 | [diff] [blame^] | 114 | 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 Silverman | cc09f18 | 2022-03-09 15:40:20 -0800 | [diff] [blame] | 121 | visibility = ["//visibility:public"], |
| 122 | ) |
| 123 | """ |
| 124 | |
| 125 | http_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 | |
| 138 | http_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 | |
| 148 | load("@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. |
| 153 | rbe_autoconfig(name = "buildkite_config") |