From 19d0e8f644529638758058601744ffdb304c6c90 Mon Sep 17 00:00:00 2001 From: Benjamin Brittain Date: Mon, 27 Jul 2020 16:38:59 -0400 Subject: [PATCH 01/49] add rust-src to known shas --- rust/known_shas.bzl | 27 +++++++++++++++++++++++++++ util/fetch_shas.sh | 9 ++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/rust/known_shas.bzl b/rust/known_shas.bzl index f2a98e2e77..93356f1c51 100644 --- a/rust/known_shas.bzl +++ b/rust/known_shas.bzl @@ -227,84 +227,111 @@ FILE_KEY_TO_SHA = { "rust-std-1.44.0-x86_64-apple-darwin": "af58f742764949765e09bb60bd1c16025a79a1be8152996fd5b3a44e5df90311", "rust-std-1.44.0-x86_64-unknown-freebsd": "a0315d028e72e221291dba257e8212e564574d87362cb07e06dc15950d1e6788", "rust-std-1.44.0-x86_64-unknown-linux-gnu": "3b7a4eede0ca550c256ca6721877de0154c27e71196d8b9a980a480682ead0aa", + "rustc-1.26.0-src": "4fb09bc4e233b71dcbe08a37a3f38cabc32219745ec6a628b18a55a1232281dd", "rustc-1.26.0-x86_64-apple-darwin": "5cb67314656d16cf2a1bdc84213aaaf6afdb5811825c7afba916e2d42d3d641f", "rustc-1.26.0-x86_64-unknown-freebsd": "9499ce5b68d631f8345c387e1f59b21892d97e0acb5650deb61a34719310bd38", "rustc-1.26.0-x86_64-unknown-linux-gnu": "7ca9a30010602aaf2244c376a3cc5baa89429d54da17b8ba1cb0cdfdc846cc61", + "rustc-1.26.1-src": "70a7961bd8ec43b2c01e9896e90b0a06804a7fbe0a5c05acc7fd6fed19500df0", "rustc-1.26.1-x86_64-apple-darwin": "e5f4291c3709b170fbeb17fab7fae50fe0c626dbdc5c42ddb1f342ea03acbad4", "rustc-1.26.1-x86_64-unknown-freebsd": "dc3dc36010d73349152e6158522e82830fda173007b9299b0a947c90769c54ff", "rustc-1.26.1-x86_64-unknown-linux-gnu": "45bc1c30e0c473c42889f22b182ec6f0b0fc3be0825e1607c64933592486eb2a", + "rustc-1.26.2-src": "fb9ecf304488c9b56600ab20cfd1937482057f7e5db7899fddb86e0774548700", "rustc-1.26.2-x86_64-apple-darwin": "5b0a3d94a4fa76ed28859123e35c09a91d7eb8ff65f40ec4c50dfa56ffed8ae5", "rustc-1.26.2-x86_64-unknown-freebsd": "48f20a8dc6bc54c90aae685d0c3fa2caf3677f1c4a4d0c53aee9d15588bd0735", "rustc-1.26.2-x86_64-unknown-linux-gnu": "1ebdafe52b581a63cea217a036fd6e77706d2715ae9cfe10a8c715d753326004", + "rustc-1.27.0-src": "2cb9803f690349c9fd429564d909ddd4676c68dc48b670b8ddf797c2613e2d21", "rustc-1.27.0-x86_64-apple-darwin": "0b00c6971ef524f68b911f621d199e60c339c390b18e12700d55e012b62aa90c", "rustc-1.27.0-x86_64-unknown-freebsd": "24c193213450ffacffebdd1413d77fc3c1ed00049cf1ede2d0f3f370dd86b462", "rustc-1.27.0-x86_64-unknown-linux-gnu": "29f399a1a208ea3f27f21e57f2d832e9d801c397a986aaea17e3a2ddeded6c3c", + "rustc-1.27.1-src": "2133beb01ddc3aa09eebc769dd884533c6cfb08ce684f042497e097068d733d1", "rustc-1.27.1-x86_64-apple-darwin": "747f616e07e5da9323a21c1cf9d76b53bb46094a68223d461a7333f26c714f19", "rustc-1.27.1-x86_64-unknown-freebsd": "9b199c21094f996fd9d4b620a5ff2c4bc5b8dab13e96bdf7c113291f601ec944", "rustc-1.27.1-x86_64-unknown-linux-gnu": "a6bf6205b345b854d705d0028a4e7161a0f5b209e464130e7d135fa01a296dc1", + "rustc-1.27.2-src": "9a818c50cdb7880abeaa68b3d97792711e6c64c1cdfb6efdc23f75b8ced0e15d", "rustc-1.27.2-x86_64-apple-darwin": "b5c5edd2094afd0a92ad776dbd12cb6ee37800b940437dece10229ccacd1f561", "rustc-1.27.2-x86_64-unknown-freebsd": "66d739632574fa52e82b40aca0eb4cef7a38047ed67cd6a240d8798a3cf9b6a6", "rustc-1.27.2-x86_64-unknown-linux-gnu": "ec3efc17ddbe6625840957049e15ebae960f447c8e8feb7da40c28dd6adf655f", + "rustc-1.28.0-src": "1d5a81729c6f23a0a23b584dd249e35abe9c6f7569cee967cc42b1758ecd6486", "rustc-1.28.0-x86_64-apple-darwin": "10a5bf35177508c72050149663ff679a770eafa8557c6be0052603ca1267ae4d", "rustc-1.28.0-x86_64-unknown-freebsd": "5eeaa17844f87e59aab821dc98dd15a920df0d1d7da3ef5808d2c586331c92a7", "rustc-1.28.0-x86_64-unknown-linux-gnu": "008bb3d714544bc991594b29a98a154441914c4771007130361bbadfb54143d0", + "rustc-1.29.0-src": "a4eb34ffd47f76afe2abd813f398512d5a19ef00989d37306217c9c9ec2f61e9", "rustc-1.29.0-x86_64-apple-darwin": "3462ba7e841485f93251762ce0b36a3922830a1249e5d79d6d010ceb43e4ee3f", "rustc-1.29.0-x86_64-unknown-freebsd": "38f30c96f0fa7ebfe94cd2db57e9b99961feca0a09045dbc1e955404b5d7f40a", "rustc-1.29.0-x86_64-unknown-linux-gnu": "229c51d51efc239e6eb9b428795bb7f57309f11287705dcba4877d5e220102a0", + "rustc-1.29.1-src": "f1b0728b66ce6bce6d72bbe5ea9e3a24ea22a045665da2ed8fcdfad14f61a349", "rustc-1.29.1-x86_64-apple-darwin": "64b86c923786dfafe8bbb5fcbef0d854132f29f0bf635830cd2d95ff225d2317", "rustc-1.29.1-x86_64-unknown-freebsd": "ed9b2ccbfc6028ce2c73105cebebdb9f2e2332018c687951639176358bfed9a2", "rustc-1.29.1-x86_64-unknown-linux-gnu": "b99324394ba20bd12efa9d30dad72b10747bd075f97c7a9fd0ce3f9394383fa7", + "rustc-1.29.2-src": "5088e796aa2e47478cdf41e7243fc5443fafab0a7c70a11423e57c80c04167c9", "rustc-1.29.2-x86_64-apple-darwin": "d9c0dd8127ed632e27d751f051bca933578317ffe891e39155ae721bc1d3ec05", "rustc-1.29.2-x86_64-unknown-freebsd": "94fba7a7b88ca86c037a48376b7e09bb4ca66e1268fc8d664796cdbdee97c0fa", "rustc-1.29.2-x86_64-unknown-linux-gnu": "b04146b09edc4bad0de7c8fa1a5a2aa4416d365c03c5962b8a5b26c7047b7cc9", + "rustc-1.30.0-src": "cd0ba83fcca55b64c0c9f23130fe731dfc1882b73ae21bef96be8f2362c108ee", "rustc-1.30.0-x86_64-apple-darwin": "d4fcbc61c7323e6fa1001ae268c5db1693ff07e5ef1ac25907138a2ee7bd8faf", "rustc-1.30.0-x86_64-unknown-freebsd": "68a74949e34118406673cf8cc0098b011907c840890e0640aa3b145ce91c521d", "rustc-1.30.0-x86_64-unknown-linux-gnu": "cc45058e9963d33ca28220e752d9e360b7e05f17e34284f5f8197738c3a88444", + "rustc-1.30.1-src": "36a38902dbd9a3e1240d46ab0f2ca40d2fd07c2ab6508ed7970c6c4c036b5b29", "rustc-1.30.1-x86_64-apple-darwin": "fd8ca09595e9d686aef9e3b94259500b482cf7a01de167a8c72a4f8d19a604f3", "rustc-1.30.1-x86_64-unknown-freebsd": "2f79e386bed201eb9b6ffa58240742617ec6006accb559dab7b6424f33b65b5f", "rustc-1.30.1-x86_64-unknown-linux-gnu": "d84de208499b59e4a3c074f9f3f2fcbb26fb20d6bfd19262e6d5f4181ddbe34d", + "rustc-1.31.0-src": "9ad54dc0baf1db5fc6a79d54e71c439c82aff85cd96778978456f2958211ef06", "rustc-1.31.0-x86_64-apple-darwin": "250fd3f3aba7d38c4af9682a12a37c733dbd6dde127665b0f493551e6c4aea8b", "rustc-1.31.0-x86_64-unknown-freebsd": "9ec40454e22e3494b9859c03e37e8851077f897845bcf838d69d4393900e7b33", "rustc-1.31.0-x86_64-unknown-linux-gnu": "5c4581f0fc05f0f5076db6231b0c1a4d27eb61c0b36bfb42d97243ad8f4e43a0", + "rustc-1.31.1-src": "91d2fc22f08d986adab7a54eb3a6a9b99e490f677d2d092e5b9e4e069c23686a", "rustc-1.31.1-x86_64-apple-darwin": "e3f9c5ccd0e6e09da8012f30ee9a1880efebc0c039cc1f3866cf50c984be16a7", "rustc-1.31.1-x86_64-unknown-freebsd": "fb38ad94976c273c0fb95d0b5ba2d1ce90684e58fa06fafc9f8050ba00559f50", "rustc-1.31.1-x86_64-unknown-linux-gnu": "77d47ce7e27a146e4301f11befd43f3fc5ac195ace0dfc07ac8154f130b057ea", + "rustc-1.32.0-src": "4c594c7712a0e7e8eae6526c464bf6ea1d82f77b4f61717c3fc28fb27ba2224a", "rustc-1.32.0-x86_64-apple-darwin": "0334c4568f09cae984e53e4a3f4ff207e2bcc50fce13ad32b8eca89f014e5e61", "rustc-1.32.0-x86_64-unknown-freebsd": "a14a0e288be8ce894a85810151a2eb70fc86afa36e4a5fae4e903c744b888687", "rustc-1.32.0-x86_64-unknown-linux-gnu": "75c31f32e19548c1608611d08b82b87560e02f15caac7b2663a8189a4609977c", + "rustc-1.33.0-src": "5a01a8d7e65126f6079042831385e77485fa5c014bf217e9f3e4aff36a485d94", "rustc-1.33.0-x86_64-apple-darwin": "ea1f0a95015bbefba9eac5890b12ee2887f464822ab579c8bbc2db3023c6dd08", "rustc-1.33.0-x86_64-unknown-freebsd": "8bfc7fc50c50294cf4ded35360b41b590180401a0d2e84256f5931c7c1ff35cd", "rustc-1.33.0-x86_64-unknown-linux-gnu": "54a342f718b712d8a17fd7878ebd37d22a82ebc70b59c421168cd4153fd04c2b", + "rustc-1.34.0-src": "7ac85acffd79dd3a7c44305d9eaabd1f1e7116e2e6e11e770e4bf5f92c0f1f59", "rustc-1.34.0-x86_64-apple-darwin": "2044d44f01a8aa7fb3382f35fc839facfde4fc1eb6f951ead42aef954e317088", "rustc-1.34.0-x86_64-unknown-freebsd": "522662f147d0550e4f4f49026b4ebcc5e05a0935fa88acc9b99da5d7435755aa", "rustc-1.34.0-x86_64-unknown-linux-gnu": "5852e84dd30e4a552a7cd4d7c0172648d7ffb4d9ac7078871adbb902c183ffc2", + "rustc-1.35.0-src": "5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d", "rustc-1.35.0-x86_64-apple-darwin": "5b2fb7581332f349c041860479ffdbfec0eebf87fc3016146836b8868afc3ae5", "rustc-1.35.0-x86_64-unknown-freebsd": "d3b5a6cfa41264e1873287bdb89892a7edc40333d581f468890c68336f50a601", "rustc-1.35.0-x86_64-unknown-linux-gnu": "bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e", + "rustc-1.36.0-src": "04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b", "rustc-1.36.0-x86_64-apple-darwin": "97568272717ffa62dbf4459dff6086e69c808df252a912146e28468412667013", "rustc-1.36.0-x86_64-unknown-freebsd": "c2dd0cec49b054ed9439762fb31555b8df9a3d81747b194f7d3afbc6d8adb8de", "rustc-1.36.0-x86_64-unknown-linux-gnu": "7c149fa1695b41e8e1edcb95dca199522889f119be99f922741084d50470a9e5", + "rustc-1.37.0-src": "120e7020d065499cc6b28759ff04153bfdc2ac9b5adeb252331a4eb87cbe38c3", "rustc-1.37.0-x86_64-apple-darwin": "00d4d15b4d9a4d188e0db8bbc17cd5f0c3c3a87ad681e80ef15580c0d5bd4ff3", "rustc-1.37.0-x86_64-unknown-freebsd": "a4dd357a0b39abf1ebbe8a0f64973c3b0c5bc527e374c12afe51266279fc1ca6", "rustc-1.37.0-x86_64-unknown-linux-gnu": "c759b318f333639a45f29c1551ca7ce55b1bf64e0fc3a3357d6b9356885d1626", + "rustc-1.38.0-src": "644263ca7c7106f8ee8fcde6bb16910d246b30668a74be20b8c7e0e9f4a52d80", "rustc-1.38.0-x86_64-apple-darwin": "ac34aee5a5f67003b8f7f857ddb1fa68f89a32680a591ab77561282721b75256", "rustc-1.38.0-x86_64-unknown-freebsd": "1d99318bbdc947c6dc375215f0eddcd767348c309811cd141e5d18e17d5aaaa4", "rustc-1.38.0-x86_64-unknown-linux-gnu": "790a611695fabd12c3a141efa58b3dc5913d749947c1a95d3f5b6eb5476ee612", + "rustc-1.39.0-src": "b4a1f6b6a93931f270691aba4fc85eee032fecda973e6b9c774cd06857609357", "rustc-1.39.0-x86_64-apple-darwin": "9347ffb47e936fb44666ada525f8bfb86758a719e7c0330e93e17bbd5f3623be", "rustc-1.39.0-x86_64-unknown-freebsd": "3714bf7bd4163a3bfe18291d49acaeda02f4bf2beb9fe36c520d2ecdc29ca031", "rustc-1.39.0-x86_64-unknown-linux-gnu": "333399dbf96dd6b8a9dc9cc56b1cb5d8aac2296b4e4aa857bd59d906d6df6fa1", + "rustc-1.40.0-src": "dd97005578defc10a482bff3e4e728350d2099c60ffcf1f5e189540c39a549ad", "rustc-1.40.0-x86_64-apple-darwin": "f45bb00a9a59ca819a8266e9de77f7232f4b704d64f1c45d3870e2db4f646a77", "rustc-1.40.0-x86_64-unknown-freebsd": "65810804d3e4cf8f845978c6226f8e23d77a7ccf35ebafdd5f8dac027627f396", "rustc-1.40.0-x86_64-unknown-linux-gnu": "5085a26abdc932fd9339aab2078084f9ab654f8298ad9f301611ac41ba8eca19", + "rustc-1.41.0-src": "5546822c09944c4d847968e9b7b3d0e299f143f307c00fa40e84a99fabf8d74b", "rustc-1.41.0-x86_64-apple-darwin": "25ee8865e21007c282cd1f3457c3bf932591337c3044e55ba574fc988bead3ad", "rustc-1.41.0-x86_64-unknown-freebsd": "de3386f79a0e261b8f6133dc0d5a7d51b70ad73dba5a14dd30204ac285d04f3a", "rustc-1.41.0-x86_64-unknown-linux-gnu": "531b4cc77cc25e960aafa2ebaee073c137fceb0004447c6b7274557281c62a6d", + "rustc-1.42.0-src": "d2e8f931d16a0539faaaacd801e0d92c58df190269014b2360c6ab2a90ee3475", "rustc-1.42.0-x86_64-apple-darwin": "778dea93d7e46261e2c06cadec35b68f9857604f279ce6fbd1b37c1a89634625", "rustc-1.42.0-x86_64-unknown-freebsd": "e6e36a7df9886b18cce32752f5ac7a8da6977c6a1878fae696340f3843176fe5", "rustc-1.42.0-x86_64-unknown-linux-gnu": "4242a728b850bf6e74db9a95c68e8ed316fa4813b38e6b8bc296396b5f47ea5a", + "rustc-1.43.0-src": "75f6ac6c9da9f897f4634d5a07be4084692f7ccc2d2bb89337be86cfc18453a1", "rustc-1.43.0-x86_64-apple-darwin": "3723b8194e38d7238262b4cc49762a22037f53f58ab1df199c1d710dad5728a5", "rustc-1.43.0-x86_64-unknown-freebsd": "69d572e80e13da85599557f662ce71909823194c874eea0fe91f82da0958fa68", "rustc-1.43.0-x86_64-unknown-linux-gnu": "950b323044ae9a7932b697a2e4f4f62b59248f58faa320e22dc20f8ad9521f6b", + "rustc-1.44.0-src": "bf2df62317e533e84167c5bc7d4351a99fdab1f9cd6e6ba09f51996ad8561100", "rustc-1.44.0-x86_64-apple-darwin": "4fd09afcae85f656d4a545ee415e19546e03e34f1ca23be5eaa68c489e3186ab", "rustc-1.44.0-x86_64-unknown-freebsd": "6f3c4e16bbda8719e5c07dc687e84a7236e097da55c4fabea13ef1cbd6a30c40", "rustc-1.44.0-x86_64-unknown-linux-gnu": "52671652e7045df0702d8f2e8af60bf6f20da3e3a5db1aa6022bf9545e914449", diff --git a/util/fetch_shas.sh b/util/fetch_shas.sh index 0d28cf7932..b9c4962082 100755 --- a/util/fetch_shas.sh +++ b/util/fetch_shas.sh @@ -15,6 +15,13 @@ NIGHTLY_ISO_DATES="$(cat ./util/fetch_shas_NIGHTLY_ISO_DATES.txt)" RUSTFMT_TARGETS="$(cat ./util/fetch_shas_RUSTFMT_TARGETS.txt)" RUSTFMT_VERSIONS="$(cat ./util/fetch_shas_RUSTFMT_VERSIONS.txt)" +enumerate_rust_src_keys() { + for VERSION in $VERSIONS + do + echo "rustc-$VERSION-src" + done +} + enumerate_keys() { for TOOL in $TOOLS do @@ -60,4 +67,4 @@ emit_bzl_file_contents() { echo "}" } -echo "$(emit_bzl_file_contents $(enumerate_keys) $(enumerate_rustfmt_keys))" > ./rust/known_shas.bzl +echo "$(emit_bzl_file_contents $(enumerate_keys) $(enumerate_rust_src_keys) $(enumerate_rustfmt_keys))" > ./rust/known_shas.bzl From 432444e6ff8f91675f7978cfcf3401f78c664a87 Mon Sep 17 00:00:00 2001 From: Benjamin Brittain Date: Fri, 24 Jul 2020 17:07:34 -0400 Subject: [PATCH 02/49] rust-analyzer support --- WORKSPACE | 3 + aspects.bzl | 153 ++++++++++++++++++++++++++++++++++++++++++ rust/repositories.bzl | 39 +++++++++++ rust/toolchain.bzl | 5 ++ 4 files changed, 200 insertions(+) create mode 100644 aspects.bzl diff --git a/WORKSPACE b/WORKSPACE index 26717d21cc..ac467b2032 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -89,3 +89,6 @@ bazel_version(name = "bazel_version") load("@examples//hello_sys:workspace.bzl", "remote_deps") remote_deps() + + +# Rust-analyzer rules diff --git a/aspects.bzl b/aspects.bzl new file mode 100644 index 0000000000..dd87ef6cf6 --- /dev/null +++ b/aspects.bzl @@ -0,0 +1,153 @@ +# Copyright 2020 Google +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Rust Analyzer Bazel rules. + +rust_analyzer will generate a rust-project.json file for the +given targets. This file can be consumed by rust-analyzer as an alternative +to Cargo.toml files. +""" + +load("@io_bazel_rules_rust//rust:private/utils.bzl", "find_toolchain") + +_rust_rules = [ + "rust_library", + "rust_binary", +] + +TargetInfo = provider( + fields = { + 'name' : 'target name', + 'root' : 'crate root', + 'edition' : 'edition', + 'dependencies' : 'dependencies', + 'cfgs' : 'compilation cfgs', + 'env' : 'Environment variables, used for the `env!` macro', + } +) + +def _rust_project_aspect_impl(target, ctx): + # We support only these rule kinds. + if ctx.rule.kind not in _rust_rules: + return [] + + info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] + + # extract the crate_root path + edition = ctx.rule.attr.edition + if not edition: + # TODO if edition isn't specified, default to what is in the rust toolchain + edition = info.default_edition + + crate_name = ctx.rule.attr.name + + crate_root = ctx.rule.attr.crate_root + if not crate_root: + if len(ctx.rule.attr.srcs) == 1: + crate_root = ctx.rule.attr.srcs[0] + else: + for src in ctx.rule.attr.srcs: + # TODO check this logic + if src.contains("lib.rs"): + crate_root = src + break + # this will always be the first in the depset + crate_root = crate_root.files.to_list()[0].path + + cfgs = ctx.rule.attr.crate_features + env = ctx.rule.attr.rustc_env + + deps = [] + for dep in ctx.rule.attr.deps: + deps.append(dep[TargetInfo]) + + return [TargetInfo(name = crate_name, edition = edition, cfgs = cfgs, root= crate_root, env=env,dependencies = deps)] + +rust_project_aspect = aspect( + attr_aspects = ["deps"], + implementation = _rust_project_aspect_impl, + toolchains = [ "@io_bazel_rules_rust//rust:toolchain" ] +) + +def create_crate(target): + crate = dict() + crate["name"] = target.name + crate["root_module"] = target.root + crate["edition"] = target.edition + deps = [] + for dep in target.dependencies: + crate_dep = dict() + # We fill in the crate id in the second iteration over the crates + crate_dep["crate"] = None + crate_dep["name"] = dep.name + deps.append(crate_dep) + crate["deps"] = deps + crate["cfg"] = target.cfgs + crate["env"] = target.env + return crate + +def populate_sysroot(ctx, idx, crate_mapping, output): + #TODO fill in sysroot + root = ctx.attr.exec_root + info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] + + for lib in info.rust_lib.files.to_list(): + print(root + "/" + lib.path) + + return + +def _rust_project_impl(ctx): + output = dict() + output["crates"] = [] + + crate_mapping = dict() + + idx = 0 + populate_sysroot(ctx, idx, crate_mapping, output) + for target in ctx.attr.targets: + for dep in target[TargetInfo].dependencies: + crate = create_crate(dep) + crate_mapping[crate["name"]] = idx + idx += 1 + output["crates"].append(crate) + crate = create_crate(target[TargetInfo]) + output["crates"].append(crate) + + # Go through the targets a second time and fill in their dependencies since we now have stable placement + # for their index. + for crate in output["crates"]: + for dep in crate["deps"]: + dep["crate"] = crate_mapping[dep["name"]] + + ctx.actions.write(output = ctx.outputs.filename, content = struct(**output).to_json()) + + +rust_analyzer = rule( + attrs = { + "targets": attr.label_list( + aspects = [rust_project_aspect], + doc = "List of all targets to be included in the index", + ), + "exec_root": attr.string( + default = "__EXEC_ROOT__", + doc = "Execution root of Bazel as returned by 'bazel info execution_root'.", + ), + }, + outputs = { + "filename": "rust-project.json", + }, + implementation = _rust_project_impl, + toolchains = [ "@io_bazel_rules_rust//rust:toolchain" ] +) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index e054a38824..dfbd3a0cb7 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -166,6 +166,23 @@ filegroup( ) """.format(binary_ext = system_to_binary_ext(system)) +def BUILD_for_rustsrc(target_triple): + """Emits a BUILD file the rustsrc .tar.gz.""" + + system = triple_to_system(target_triple) + return """ +load("@io_bazel_rules_rust//rust:toolchain.bzl", "rust_toolchain") + +filegroup( + name = "rustsrc", + srcs = ["bin/rustfmt{binary_ext}"], + visibility = ["//visibility:public"], +) + +""".format( + binary_ext = system_to_binary_ext(system), + ) + def BUILD_for_stdlib(target_triple): """Emits a BUILD file the stdlib .tar.gz.""" @@ -373,6 +390,28 @@ def _load_rust_compiler(ctx): return compiler_BUILD +def _load_rust_src(ctx): + """Loads the rust source code. This is used by the rust-analyzer rust-project.json + generator. + + Args: + ctx: A repository_ctx. + Returns: + The BUILD file contents for this compiler and compiler library + """ + target_triple = ctx.attr.exec_triple + load_arbitrary_tool( + ctx, + iso_date = ctx.attr.iso_date, + param_prefix = "src_", + target_triple = target_triple, + tool_name = "src", + tool_subdirectory = "src", + version = ctx.attr.rustfmt_version, + ) + + return BUILD_for_rustsrc(target_triple) + def _load_rust_stdlib(ctx, target_triple): """Loads a rust standard library and yields corresponding BUILD for it diff --git a/rust/toolchain.bzl b/rust/toolchain.bzl index 0192733d50..f2a4f007df 100644 --- a/rust/toolchain.bzl +++ b/rust/toolchain.bzl @@ -16,6 +16,7 @@ def _rust_toolchain_impl(ctx): rustc = ctx.file.rustc, rust_doc = ctx.file.rust_doc, rustfmt = ctx.file.rustfmt, + rustsrc = ctx.file.rustsrc, clippy_driver = ctx.file.clippy_driver, rustc_lib = ctx.attr.rustc_lib, rust_lib = ctx.attr.rust_lib, @@ -48,6 +49,10 @@ rust_toolchain = rule( doc = "The location of the `rustfmt` binary. Can be a direct source or a filegroup containing one item.", allow_single_file = True, ), + "rustsrc": attr.label( + doc = "The location of the rust source code. Can be a direct source or a filegroup containing one item.", + allow_single_file = True, + ), "clippy_driver": attr.label( doc = "The location of the `clippy-driver` binary. Can be a direct source or a filegroup containing one item.", allow_single_file = True, From 82895e584cef3ea696bd4c54a2dca999e9808741 Mon Sep 17 00:00:00 2001 From: Benjamin Brittain Date: Mon, 27 Jul 2020 18:35:44 -0400 Subject: [PATCH 03/49] populate sysroot --- aspects.bzl | 68 +++++++++++++++++++++++++++++++++---------- rust/repositories.bzl | 47 +++++++++++++++++------------- rust/toolchain.bzl | 9 +++--- 3 files changed, 84 insertions(+), 40 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index dd87ef6cf6..6cbfba957d 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -84,29 +84,63 @@ rust_project_aspect = aspect( def create_crate(target): crate = dict() crate["name"] = target.name + crate["ID"] = target.name crate["root_module"] = target.root crate["edition"] = target.edition deps = [] for dep in target.dependencies: - crate_dep = dict() - # We fill in the crate id in the second iteration over the crates - crate_dep["crate"] = None - crate_dep["name"] = dep.name - deps.append(crate_dep) + deps.append({ + "name": dep.name, + "ID": dep.name, + }) + + # TODO add no_std support + std_dep = dict() + std_dep["ID"] = "SYSROOT-std" + std_dep["name"] = "std" + deps.append(std_dep) + crate["deps"] = deps crate["cfg"] = target.cfgs crate["env"] = target.env return crate -def populate_sysroot(ctx, idx, crate_mapping, output): - #TODO fill in sysroot +def populate_sysroot(ctx, crate_mapping, output): + # Hardcode the relevant sysroot structure for now. + # Anything smarter than this requires a Toml parser + + sysroot = ["alloc", "core", "std", "panic_abort", "unwind"] + sysroot_deps_map = { + "alloc": ["core"], + "std": ["alloc", "core", "panic_abort", "unwind"], + } + root = ctx.attr.exec_root info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] - for lib in info.rust_lib.files.to_list(): - print(root + "/" + lib.path) - - return + idx = 0 + for sysroot_crate in sysroot: + crate = dict() + crate["ID"] = "SYSROOT-" + sysroot_crate + crate["name"] = sysroot_crate + # TODO better way of getting source. gotta be a way of getting + # the root of a depset or something? + crate["root_module"] = root + "/" + info.rustc_src.files.to_list()[0].dirname + "/../../lib" + sysroot_crate + "/lib.rs" + crate["edition"] = "2018" + crate["cfg"] = [] + crate["env"] = {} + crate["deps"] = [] + if sysroot_crate in sysroot_deps_map.keys(): + for dep in sysroot_deps_map[sysroot_crate]: + crate["deps"].append({ + "ID": "SYSROOT-" + dep, + "name": dep, + }) + crate_mapping[crate["ID"]] = idx + idx += 1 + output["crates"].append(crate) + + return idx def _rust_project_impl(ctx): output = dict() @@ -114,12 +148,13 @@ def _rust_project_impl(ctx): crate_mapping = dict() - idx = 0 - populate_sysroot(ctx, idx, crate_mapping, output) + # idx starts after the sysroot is already populated + idx = populate_sysroot(ctx, crate_mapping, output) + for target in ctx.attr.targets: for dep in target[TargetInfo].dependencies: crate = create_crate(dep) - crate_mapping[crate["name"]] = idx + crate_mapping[crate["ID"]] = idx idx += 1 output["crates"].append(crate) crate = create_crate(target[TargetInfo]) @@ -129,7 +164,10 @@ def _rust_project_impl(ctx): # for their index. for crate in output["crates"]: for dep in crate["deps"]: - dep["crate"] = crate_mapping[dep["name"]] + crate_id = dep["ID"] + dep["crate"] = crate_mapping[crate_id] + # clean up ID for cleaner output + dep.pop("ID", None) ctx.actions.write(output = ctx.outputs.filename, content = struct(**output).to_json()) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index dfbd3a0cb7..cda41e47d1 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -166,22 +166,22 @@ filegroup( ) """.format(binary_ext = system_to_binary_ext(system)) -def BUILD_for_rustsrc(target_triple): - """Emits a BUILD file the rustsrc .tar.gz.""" +def BUILD_for_rustc_src(): + """Emits a BUILD file for the rustc src extracted files.""" - system = triple_to_system(target_triple) return """ load("@io_bazel_rules_rust//rust:toolchain.bzl", "rust_toolchain") filegroup( - name = "rustsrc", - srcs = ["bin/rustfmt{binary_ext}"], + name = "rustc_src", + srcs = glob( + [ + "**/*.rs", + ], + ), visibility = ["//visibility:public"], ) - -""".format( - binary_ext = system_to_binary_ext(system), - ) +""" def BUILD_for_stdlib(target_triple): """Emits a BUILD file the stdlib .tar.gz.""" @@ -233,6 +233,7 @@ rust_toolchain( rustfmt = "@{workspace_name}//:rustfmt_bin", clippy_driver = "@{workspace_name}//:clippy_driver_bin", rustc_lib = "@{workspace_name}//:rustc_lib", + rustc_src = "@{workspace_name}//:rustc_src", binary_ext = "{binary_ext}", staticlib_ext = "{staticlib_ext}", dylib_ext = "{dylib_ext}", @@ -399,18 +400,23 @@ def _load_rust_src(ctx): Returns: The BUILD file contents for this compiler and compiler library """ - target_triple = ctx.attr.exec_triple - load_arbitrary_tool( - ctx, - iso_date = ctx.attr.iso_date, - param_prefix = "src_", - target_triple = target_triple, - tool_name = "src", - tool_subdirectory = "src", - version = ctx.attr.rustfmt_version, - ) + version = ctx.attr.version + static_rust = ctx.os.environ["STATIC_RUST_URL"] if "STATIC_RUST_URL" in ctx.os.environ else "https://static.rust-lang.org" - return BUILD_for_rustsrc(target_triple) + tool_suburl = "rustc-{}-src".format(version) + url = "{}/dist/{}.tar.gz".format(static_rust, tool_suburl) + archive_path = tool_suburl + ".tar.gz" + ctx.download( + url, + output = archive_path, + sha256 = FILE_KEY_TO_SHA.get(tool_suburl), + ) + ctx.extract( + archive_path, + output = "src", + stripPrefix = "{}/src".format(tool_suburl), + ) + return BUILD_for_rustc_src() def _load_rust_stdlib(ctx, target_triple): """Loads a rust standard library and yields corresponding BUILD for it @@ -500,6 +506,7 @@ def _rust_toolchain_repository_impl(ctx): if ctx.attr.rustfmt_version: BUILD_components.append(_load_rustfmt(ctx)) + BUILD_components.append(_load_rust_src(ctx)) # Nightly Rust builds after 2020-05-22 need the llvm-tools gzip to get the libLLVM dylib if ctx.attr.version == "nightly" and ctx.attr.iso_date > "2020-05-22": _load_llvm_tools(ctx, ctx.attr.exec_triple) diff --git a/rust/toolchain.bzl b/rust/toolchain.bzl index f2a4f007df..6be37a6093 100644 --- a/rust/toolchain.bzl +++ b/rust/toolchain.bzl @@ -16,9 +16,9 @@ def _rust_toolchain_impl(ctx): rustc = ctx.file.rustc, rust_doc = ctx.file.rust_doc, rustfmt = ctx.file.rustfmt, - rustsrc = ctx.file.rustsrc, clippy_driver = ctx.file.clippy_driver, rustc_lib = ctx.attr.rustc_lib, + rustc_src = ctx.attr.rustc_src, rust_lib = ctx.attr.rust_lib, binary_ext = ctx.attr.binary_ext, staticlib_ext = ctx.attr.staticlib_ext, @@ -49,10 +49,6 @@ rust_toolchain = rule( doc = "The location of the `rustfmt` binary. Can be a direct source or a filegroup containing one item.", allow_single_file = True, ), - "rustsrc": attr.label( - doc = "The location of the rust source code. Can be a direct source or a filegroup containing one item.", - allow_single_file = True, - ), "clippy_driver": attr.label( doc = "The location of the `clippy-driver` binary. Can be a direct source or a filegroup containing one item.", allow_single_file = True, @@ -60,6 +56,9 @@ rust_toolchain = rule( "rustc_lib": attr.label( doc = "The libraries used by rustc during compilation.", ), + "rustc_src": attr.label( + doc = "The source code of rustc.", + ), "rust_lib": attr.label( doc = "The rust standard library.", ), From 29bc84589511cbe1b067bc811a790897236bd3d2 Mon Sep 17 00:00:00 2001 From: Benjamin Brittain Date: Wed, 29 Jul 2020 08:58:14 -0400 Subject: [PATCH 04/49] use workspace_root instead of path hack --- aspects.bzl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index 6cbfba957d..05c9e4dfe0 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -123,9 +123,7 @@ def populate_sysroot(ctx, crate_mapping, output): crate = dict() crate["ID"] = "SYSROOT-" + sysroot_crate crate["name"] = sysroot_crate - # TODO better way of getting source. gotta be a way of getting - # the root of a depset or something? - crate["root_module"] = root + "/" + info.rustc_src.files.to_list()[0].dirname + "/../../lib" + sysroot_crate + "/lib.rs" + crate["root_module"] = root + "/" + info.rustc_src.label.workspace_root + "/src/lib" + sysroot_crate + "/lib.rs" crate["edition"] = "2018" crate["cfg"] = [] crate["env"] = {} From 8b12f2d0ed94e41147e91c28af9bcdec020718c8 Mon Sep 17 00:00:00 2001 From: Benjamin Brittain Date: Sun, 2 Aug 2020 11:57:14 -0400 Subject: [PATCH 05/49] generate correct cfgs & workspace markers --- aspects.bzl | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index 05c9e4dfe0..2f933d3ab8 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -33,6 +33,7 @@ TargetInfo = provider( 'root' : 'crate root', 'edition' : 'edition', 'dependencies' : 'dependencies', + 'transitive_deps' : 'closure of all transitive dependencies', 'cfgs' : 'compilation cfgs', 'env' : 'Environment variables, used for the `env!` macro', } @@ -66,14 +67,26 @@ def _rust_project_aspect_impl(target, ctx): # this will always be the first in the depset crate_root = crate_root.files.to_list()[0].path - cfgs = ctx.rule.attr.crate_features + cfgs = [] + for feature in ctx.rule.attr.crate_features: + cfgs.append("feature=\"" + feature + "\"") + for flag in ctx.rule.attr.rustc_flags: + # --cfg flags should be passed as well but as an atomic + # config, not key/value + if flag.startswith("--cfg"): + cfgs.append(flag[6:]) env = ctx.rule.attr.rustc_env deps = [] + transitive_deps = [] for dep in ctx.rule.attr.deps: deps.append(dep[TargetInfo]) + transitive_deps.append(dep[TargetInfo]) + if TargetInfo not in dep: + continue + transitive_deps.extend(dep[TargetInfo].dependencies) - return [TargetInfo(name = crate_name, edition = edition, cfgs = cfgs, root= crate_root, env=env,dependencies = deps)] + return [TargetInfo(name = crate_name, edition = edition, cfgs = cfgs, root= crate_root, env=env,dependencies = deps, transitive_deps = transitive_deps)] rust_project_aspect = aspect( attr_aspects = ["deps"], @@ -84,17 +97,28 @@ rust_project_aspect = aspect( def create_crate(target): crate = dict() crate["name"] = target.name - crate["ID"] = target.name + crate["ID"] = "ID-" + target.name crate["root_module"] = target.root crate["edition"] = target.edition + # TODO(bwb): smarter heuristic for workpace member indexing + crate["is_workspace_member"] = True deps = [] for dep in target.dependencies: deps.append({ "name": dep.name, - "ID": dep.name, + "ID": "ID-" + dep.name, }) - # TODO add no_std support + alloc_dep = dict() + alloc_dep["ID"] = "SYSROOT-alloc" + alloc_dep["name"] = "alloc" + deps.append(alloc_dep) + + core_dep = dict() + core_dep["ID"] = "SYSROOT-core" + core_dep["name"] = "core" + deps.append(core_dep) + std_dep = dict() std_dep["ID"] = "SYSROOT-std" std_dep["name"] = "std" @@ -125,6 +149,9 @@ def populate_sysroot(ctx, crate_mapping, output): crate["name"] = sysroot_crate crate["root_module"] = root + "/" + info.rustc_src.label.workspace_root + "/src/lib" + sysroot_crate + "/lib.rs" crate["edition"] = "2018" + # sysroot crates are rarely modified. Mark as not a member of the workspace + # for faster indexing + crate["is_workspace_member"] = False crate["cfg"] = [] crate["env"] = {} crate["deps"] = [] @@ -150,7 +177,7 @@ def _rust_project_impl(ctx): idx = populate_sysroot(ctx, crate_mapping, output) for target in ctx.attr.targets: - for dep in target[TargetInfo].dependencies: + for dep in target[TargetInfo].transitive_deps: crate = create_crate(dep) crate_mapping[crate["ID"]] = idx idx += 1 @@ -158,18 +185,18 @@ def _rust_project_impl(ctx): crate = create_crate(target[TargetInfo]) output["crates"].append(crate) - # Go through the targets a second time and fill in their dependencies since we now have stable placement - # for their index. + # Go through the targets a second time and fill in their dependencies + # since we now have stable placement for their index. for crate in output["crates"]: for dep in crate["deps"]: crate_id = dep["ID"] dep["crate"] = crate_mapping[crate_id] # clean up ID for cleaner output dep.pop("ID", None) + crate.pop("ID", None) ctx.actions.write(output = ctx.outputs.filename, content = struct(**output).to_json()) - rust_analyzer = rule( attrs = { "targets": attr.label_list( From db781812e441e2a4b44f0ef5f64ae71634453853 Mon Sep 17 00:00:00 2001 From: Benjamin Brittain Date: Sun, 2 Aug 2020 12:11:58 -0400 Subject: [PATCH 06/49] select proper source file --- aspects.bzl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index 2f933d3ab8..ec7f8e9ce1 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -60,8 +60,10 @@ def _rust_project_aspect_impl(target, ctx): crate_root = ctx.rule.attr.srcs[0] else: for src in ctx.rule.attr.srcs: - # TODO check this logic - if src.contains("lib.rs"): + if ctx.rule.attr.crate_type == "bin" and src.contains("main.rs"): + crate_root = src + break + if ctx.rule.attr.crate_type == "lib" and src.contains("lib.rs"): crate_root = src break # this will always be the first in the depset @@ -86,7 +88,14 @@ def _rust_project_aspect_impl(target, ctx): continue transitive_deps.extend(dep[TargetInfo].dependencies) - return [TargetInfo(name = crate_name, edition = edition, cfgs = cfgs, root= crate_root, env=env,dependencies = deps, transitive_deps = transitive_deps)] + return [TargetInfo( + name = crate_name, + edition = edition, + cfgs = cfgs, + root= crate_root, + env=env, + dependencies = deps, + transitive_deps = transitive_deps)] rust_project_aspect = aspect( attr_aspects = ["deps"], From f94e79c766785b995c38c9fc60bfd76616ba0192 Mon Sep 17 00:00:00 2001 From: Benjamin Brittain Date: Sun, 2 Aug 2020 12:15:59 -0400 Subject: [PATCH 07/49] add basic example generating rust-project.json --- WORKSPACE | 3 --- examples/hello_lib/BUILD | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index ac467b2032..26717d21cc 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -89,6 +89,3 @@ bazel_version(name = "bazel_version") load("@examples//hello_sys:workspace.bzl", "remote_deps") remote_deps() - - -# Rust-analyzer rules diff --git a/examples/hello_lib/BUILD b/examples/hello_lib/BUILD index 177beafdc7..b5d02904d9 100644 --- a/examples/hello_lib/BUILD +++ b/examples/hello_lib/BUILD @@ -7,6 +7,7 @@ load( "rust_library", "rust_test", ) +load("@io_bazel_rules_rust//:aspects.bzl", "rust_analyzer") rust_library( name = "hello_lib", @@ -85,3 +86,9 @@ rust_doc_test( name = "hello_lib_doc_test", dep = ":hello_lib", ) + +rust_analyzer( + name = "hello_rust_analyzer", + targets = [ ":hello_lib" ], + exec_root = "hello_lib" +) From 4f8b492c1f689b052ba828e41faf79d1dec5a756 Mon Sep 17 00:00:00 2001 From: Benjamin Brittain Date: Sun, 2 Aug 2020 17:06:49 -0400 Subject: [PATCH 08/49] fix example --- aspects.bzl | 11 +++++++---- examples/hello_lib/BUILD | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index ec7f8e9ce1..b9164fffbe 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -60,12 +60,15 @@ def _rust_project_aspect_impl(target, ctx): crate_root = ctx.rule.attr.srcs[0] else: for src in ctx.rule.attr.srcs: - if ctx.rule.attr.crate_type == "bin" and src.contains("main.rs"): - crate_root = src - break - if ctx.rule.attr.crate_type == "lib" and src.contains("lib.rs"): + file_name = src.label.name + crate_type = ctx.rule.attr.crate_type + if crate_type == "bin" and file_name.endswith("main.rs"): crate_root = src break + if crate_type == "rlib" or crate_type == "dylib": + if file_name.endswith("lib.rs"): + crate_root = src + break # this will always be the first in the depset crate_root = crate_root.files.to_list()[0].path diff --git a/examples/hello_lib/BUILD b/examples/hello_lib/BUILD index b5d02904d9..8862d51b59 100644 --- a/examples/hello_lib/BUILD +++ b/examples/hello_lib/BUILD @@ -90,5 +90,5 @@ rust_doc_test( rust_analyzer( name = "hello_rust_analyzer", targets = [ ":hello_lib" ], - exec_root = "hello_lib" + exec_root = "bazel-rules_rust" ) From 999f5dfc8d27e94c4f97a5c67386ea4419acd6ca Mon Sep 17 00:00:00 2001 From: Benjamin Brittain Date: Mon, 10 Aug 2020 18:25:04 -0400 Subject: [PATCH 09/49] implement suggested fixes --- aspects.bzl | 59 +++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index b9164fffbe..77d7ca98e1 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -22,12 +22,13 @@ to Cargo.toml files. load("@io_bazel_rules_rust//rust:private/utils.bzl", "find_toolchain") +# We support only these rule kinds. _rust_rules = [ "rust_library", "rust_binary", ] -TargetInfo = provider( +RustTargetInfo = provider( fields = { 'name' : 'target name', 'root' : 'crate root', @@ -39,21 +40,10 @@ TargetInfo = provider( } ) -def _rust_project_aspect_impl(target, ctx): - # We support only these rule kinds. - if ctx.rule.kind not in _rust_rules: - return [] - - info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] - - # extract the crate_root path - edition = ctx.rule.attr.edition - if not edition: - # TODO if edition isn't specified, default to what is in the rust toolchain - edition = info.default_edition - - crate_name = ctx.rule.attr.name - +# Gets the crate_root file from the context. +# If the file is not specified, find lib.rs or main.rs +# in a library or binary rule respectively. +def fetch_crate_root_file(ctx): crate_root = ctx.rule.attr.crate_root if not crate_root: if len(ctx.rule.attr.srcs) == 1: @@ -69,9 +59,25 @@ def _rust_project_aspect_impl(target, ctx): if file_name.endswith("lib.rs"): crate_root = src break - # this will always be the first in the depset + # The rules are structured such that the crate_root path will always be + # the first element in the in the depset crate_root = crate_root.files.to_list()[0].path +def _rust_project_aspect_impl(target, ctx): + if ctx.rule.kind not in _rust_rules: + return [] + + info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] + + # extract the crate_root path + edition = ctx.rule.attr.edition + if not edition: + edition = info.default_edition + + crate_name = ctx.rule.attr.name + + crate_root = fetch_crate_root_file(ctx) + cfgs = [] for feature in ctx.rule.attr.crate_features: cfgs.append("feature=\"" + feature + "\"") @@ -82,16 +88,11 @@ def _rust_project_aspect_impl(target, ctx): cfgs.append(flag[6:]) env = ctx.rule.attr.rustc_env - deps = [] - transitive_deps = [] - for dep in ctx.rule.attr.deps: - deps.append(dep[TargetInfo]) - transitive_deps.append(dep[TargetInfo]) - if TargetInfo not in dep: - continue - transitive_deps.extend(dep[TargetInfo].dependencies) - - return [TargetInfo( + deps = [dep[RustTargetInfo] for dep in ctx.rule.attr.deps if RustTargetInfo in dep] + transitive_deps = depset(direct = deps, transitive = + [dep[RustTargetInfo].transitive_deps for dep in ctx.rule.attr.deps]) + + return [RustTargetInfo( name = crate_name, edition = edition, cfgs = cfgs, @@ -189,12 +190,12 @@ def _rust_project_impl(ctx): idx = populate_sysroot(ctx, crate_mapping, output) for target in ctx.attr.targets: - for dep in target[TargetInfo].transitive_deps: + for dep in target[RustTargetInfo].transitive_deps.to_list(): crate = create_crate(dep) crate_mapping[crate["ID"]] = idx idx += 1 output["crates"].append(crate) - crate = create_crate(target[TargetInfo]) + crate = create_crate(target[RustTargetInfo]) output["crates"].append(crate) # Go through the targets a second time and fill in their dependencies From 610f3aede3f1bfa45e5558df0bcdfb457c060858 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Tue, 24 Nov 2020 07:07:49 +0000 Subject: [PATCH 10/49] Allow specifying sha256 for non-blessed nightly versions --- rust/repositories.bzl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index db5126f25c..96489829a2 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -520,21 +520,21 @@ def _load_rust_src(ctx): Returns: The BUILD file contents for this compiler and compiler library """ - version = ctx.attr.version + tool_suburl = produce_tool_suburl("rustc", "src", ctx.attr.version, ctx.attr.iso_date) static_rust = ctx.os.environ["STATIC_RUST_URL"] if "STATIC_RUST_URL" in ctx.os.environ else "https://static.rust-lang.org" - - tool_suburl = "rustc-{}-src".format(version) url = "{}/dist/{}.tar.gz".format(static_rust, tool_suburl) - archive_path = tool_suburl + ".tar.gz" + + tool_path = produce_tool_path("rustc", "src", ctx.attr.version) + archive_path = tool_path + ".tar.gz" ctx.download( url, output = archive_path, - sha256 = FILE_KEY_TO_SHA.get(tool_suburl), + sha256 = ctx.attr.sha256s.get(tool_suburl) or FILE_KEY_TO_SHA.get(tool_suburl), ) ctx.extract( - archive_path, - output = "src", - stripPrefix = "{}/src".format(tool_suburl), + archive_path, + output = "", + stripPrefix = tool_path, ) return BUILD_for_rustc_src() From 18283bc59f7b8230174a6e91cd85685fb3a14cc0 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Tue, 24 Nov 2020 09:27:57 +0000 Subject: [PATCH 11/49] Hardcoded paths and excessive debugging --- aspects.bzl | 26 +++++++++++++++++++++----- rust/repositories.bzl | 3 +-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index 77d7ca98e1..27133b4c35 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -45,23 +45,27 @@ RustTargetInfo = provider( # in a library or binary rule respectively. def fetch_crate_root_file(ctx): crate_root = ctx.rule.attr.crate_root + print("crate root from context: ", crate_root) if not crate_root: if len(ctx.rule.attr.srcs) == 1: crate_root = ctx.rule.attr.srcs[0] + print("crate root from 1: ", crate_root) else: for src in ctx.rule.attr.srcs: file_name = src.label.name crate_type = ctx.rule.attr.crate_type + print("crate root trying: ", src, " on crate type ", crate_type) if crate_type == "bin" and file_name.endswith("main.rs"): crate_root = src break - if crate_type == "rlib" or crate_type == "dylib": + if crate_type == "rlib" or crate_type == "dylib" or crate_type == "cdylib": if file_name.endswith("lib.rs"): crate_root = src break # The rules are structured such that the crate_root path will always be # the first element in the in the depset - crate_root = crate_root.files.to_list()[0].path + print("crate_root: ", crate_root, " files: ", crate_root.files.to_list()[0].path) + return crate_root.files.to_list()[0].path def _rust_project_aspect_impl(target, ctx): if ctx.rule.kind not in _rust_rules: @@ -76,7 +80,14 @@ def _rust_project_aspect_impl(target, ctx): crate_name = ctx.rule.attr.name + print("_rust_project_aspect_impl: ", crate_name) crate_root = fetch_crate_root_file(ctx) + print("_rust_project_aspect_impl crate_root: ", crate_root) + if crate_root.startswith("external"): + crate_root = "/home/vagrant/.cache/bazel/_bazel_vagrant/71ed060a30795ab0736b520a305b19cd" + "/" + crate_root + else: + crate_root = "../" + crate_root + print("_rust_project_aspect_impl crate_root: ", crate_root) cfgs = [] for feature in ctx.rule.attr.crate_features: @@ -90,7 +101,7 @@ def _rust_project_aspect_impl(target, ctx): deps = [dep[RustTargetInfo] for dep in ctx.rule.attr.deps if RustTargetInfo in dep] transitive_deps = depset(direct = deps, transitive = - [dep[RustTargetInfo].transitive_deps for dep in ctx.rule.attr.deps]) + [dep[RustTargetInfo].transitive_deps for dep in ctx.rule.attr.deps if RustTargetInfo in dep]) return [RustTargetInfo( name = crate_name, @@ -108,6 +119,7 @@ rust_project_aspect = aspect( ) def create_crate(target): + print("create_crate: ", target.name, " ", target.root) crate = dict() crate["name"] = target.name crate["ID"] = "ID-" + target.name @@ -154,13 +166,16 @@ def populate_sysroot(ctx, crate_mapping, output): root = ctx.attr.exec_root info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] - + print("root: ", root, " info: ", info) + print("rustc_src: ", info.rustc_src, " label: ", info.rustc_src.label, "workspace_root: ", info.rustc_src.label.workspace_root) + print("rustc_lib: ", info.rustc_lib, " label: ", info.rustc_lib.label, "workspace_root: ", info.rustc_lib.label.workspace_root) + print("rust_lib: ", info.rust_lib, " label: ", info.rust_lib.label, "workspace_root: ", info.rust_lib.label.workspace_root) idx = 0 for sysroot_crate in sysroot: crate = dict() crate["ID"] = "SYSROOT-" + sysroot_crate crate["name"] = sysroot_crate - crate["root_module"] = root + "/" + info.rustc_src.label.workspace_root + "/src/lib" + sysroot_crate + "/lib.rs" + crate["root_module"] = root + "/" + info.rust_lib.label.workspace_root + "/library/" + sysroot_crate + "/src/lib.rs" crate["edition"] = "2018" # sysroot crates are rarely modified. Mark as not a member of the workspace # for faster indexing @@ -191,6 +206,7 @@ def _rust_project_impl(ctx): for target in ctx.attr.targets: for dep in target[RustTargetInfo].transitive_deps.to_list(): + print("_rust_project_impl dep: ", dep.name) crate = create_crate(dep) crate_mapping[crate["ID"]] = idx idx += 1 diff --git a/rust/repositories.bzl b/rust/repositories.bzl index 96489829a2..6bdaa9698d 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -512,8 +512,7 @@ def _load_rust_compiler(ctx): return compiler_build_file def _load_rust_src(ctx): - """Loads the rust source code. This is used by the rust-analyzer rust-project.json - generator. + """Loads the rust source code. Used by the rust-analyzer rust-project.json generator. Args: ctx: A repository_ctx. From b1d24bc0326e35e43aaf5ab655722a24b4de9b24 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Tue, 24 Nov 2020 19:25:08 +0000 Subject: [PATCH 12/49] fix formatting --- aspects.bzl | 351 ++++++++++++++++++++++++++-------------------------- 1 file changed, 174 insertions(+), 177 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index 27133b4c35..3732ed65b6 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -30,201 +30,198 @@ _rust_rules = [ RustTargetInfo = provider( fields = { - 'name' : 'target name', - 'root' : 'crate root', - 'edition' : 'edition', - 'dependencies' : 'dependencies', - 'transitive_deps' : 'closure of all transitive dependencies', - 'cfgs' : 'compilation cfgs', - 'env' : 'Environment variables, used for the `env!` macro', - } + "name": "target name", + "root": "crate root", + "edition": "edition", + "dependencies": "dependencies", + "transitive_deps": "closure of all transitive dependencies", + "cfgs": "compilation cfgs", + "env": "Environment variables, used for the `env!` macro", + }, ) # Gets the crate_root file from the context. # If the file is not specified, find lib.rs or main.rs # in a library or binary rule respectively. def fetch_crate_root_file(ctx): - crate_root = ctx.rule.attr.crate_root - print("crate root from context: ", crate_root) - if not crate_root: - if len(ctx.rule.attr.srcs) == 1: - crate_root = ctx.rule.attr.srcs[0] - print("crate root from 1: ", crate_root) - else: - for src in ctx.rule.attr.srcs: - file_name = src.label.name - crate_type = ctx.rule.attr.crate_type - print("crate root trying: ", src, " on crate type ", crate_type) - if crate_type == "bin" and file_name.endswith("main.rs"): - crate_root = src - break - if crate_type == "rlib" or crate_type == "dylib" or crate_type == "cdylib": - if file_name.endswith("lib.rs"): - crate_root = src - break - # The rules are structured such that the crate_root path will always be - # the first element in the in the depset - print("crate_root: ", crate_root, " files: ", crate_root.files.to_list()[0].path) - return crate_root.files.to_list()[0].path + crate_root = ctx.rule.attr.crate_root + print("crate root from context: ", crate_root) + if not crate_root: + if len(ctx.rule.attr.srcs) == 1: + crate_root = ctx.rule.attr.srcs[0] + print("crate root from 1: ", crate_root) + else: + for src in ctx.rule.attr.srcs: + file_name = src.label.name + crate_type = ctx.rule.attr.crate_type + print("crate root trying: ", src, " on crate type ", crate_type) + if crate_type == "bin" and file_name.endswith("main.rs"): + crate_root = src + break + if crate_type == "rlib" or crate_type == "dylib" or crate_type == "cdylib": + if file_name.endswith("lib.rs"): + crate_root = src + break + + # The rules are structured such that the crate_root path will always be + # the first element in the in the depset + print("crate_root: ", crate_root, " files: ", crate_root.files.to_list()[0].path) + return crate_root.files.to_list()[0].path def _rust_project_aspect_impl(target, ctx): - if ctx.rule.kind not in _rust_rules: - return [] - - info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] - - # extract the crate_root path - edition = ctx.rule.attr.edition - if not edition: - edition = info.default_edition - - crate_name = ctx.rule.attr.name - - print("_rust_project_aspect_impl: ", crate_name) - crate_root = fetch_crate_root_file(ctx) - print("_rust_project_aspect_impl crate_root: ", crate_root) - if crate_root.startswith("external"): - crate_root = "/home/vagrant/.cache/bazel/_bazel_vagrant/71ed060a30795ab0736b520a305b19cd" + "/" + crate_root - else: - crate_root = "../" + crate_root - print("_rust_project_aspect_impl crate_root: ", crate_root) - - cfgs = [] - for feature in ctx.rule.attr.crate_features: - cfgs.append("feature=\"" + feature + "\"") - for flag in ctx.rule.attr.rustc_flags: - # --cfg flags should be passed as well but as an atomic - # config, not key/value - if flag.startswith("--cfg"): - cfgs.append(flag[6:]) - env = ctx.rule.attr.rustc_env - - deps = [dep[RustTargetInfo] for dep in ctx.rule.attr.deps if RustTargetInfo in dep] - transitive_deps = depset(direct = deps, transitive = - [dep[RustTargetInfo].transitive_deps for dep in ctx.rule.attr.deps if RustTargetInfo in dep]) - - return [RustTargetInfo( - name = crate_name, - edition = edition, - cfgs = cfgs, - root= crate_root, - env=env, - dependencies = deps, - transitive_deps = transitive_deps)] + if ctx.rule.kind not in _rust_rules: + return [] + + info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] + + # extract the crate_root path + edition = ctx.rule.attr.edition + if not edition: + edition = info.default_edition + + crate_name = ctx.rule.attr.name + + print("_rust_project_aspect_impl: ", crate_name) + crate_root = fetch_crate_root_file(ctx) + + cfgs = [] + for feature in ctx.rule.attr.crate_features: + cfgs.append("feature=\"" + feature + "\"") + for flag in ctx.rule.attr.rustc_flags: + # --cfg flags should be passed as well but as an atomic + # config, not key/value + if flag.startswith("--cfg"): + cfgs.append(flag[6:]) + env = ctx.rule.attr.rustc_env + + deps = [dep[RustTargetInfo] for dep in ctx.rule.attr.deps if RustTargetInfo in dep] + transitive_deps = depset(direct = deps, transitive = + [dep[RustTargetInfo].transitive_deps for dep in ctx.rule.attr.deps if RustTargetInfo in dep]) + + return [RustTargetInfo( + name = crate_name, + edition = edition, + cfgs = cfgs, + root = crate_root, + env = env, + dependencies = deps, + transitive_deps = transitive_deps, + )] rust_project_aspect = aspect( attr_aspects = ["deps"], implementation = _rust_project_aspect_impl, - toolchains = [ "@io_bazel_rules_rust//rust:toolchain" ] + toolchains = ["@io_bazel_rules_rust//rust:toolchain"], ) -def create_crate(target): - print("create_crate: ", target.name, " ", target.root) - crate = dict() - crate["name"] = target.name - crate["ID"] = "ID-" + target.name - crate["root_module"] = target.root - crate["edition"] = target.edition - # TODO(bwb): smarter heuristic for workpace member indexing - crate["is_workspace_member"] = True - deps = [] - for dep in target.dependencies: - deps.append({ - "name": dep.name, - "ID": "ID-" + dep.name, - }) - - alloc_dep = dict() - alloc_dep["ID"] = "SYSROOT-alloc" - alloc_dep["name"] = "alloc" - deps.append(alloc_dep) - - core_dep = dict() - core_dep["ID"] = "SYSROOT-core" - core_dep["name"] = "core" - deps.append(core_dep) - - std_dep = dict() - std_dep["ID"] = "SYSROOT-std" - std_dep["name"] = "std" - deps.append(std_dep) - - crate["deps"] = deps - crate["cfg"] = target.cfgs - crate["env"] = target.env - return crate - -def populate_sysroot(ctx, crate_mapping, output): - # Hardcode the relevant sysroot structure for now. - # Anything smarter than this requires a Toml parser - - sysroot = ["alloc", "core", "std", "panic_abort", "unwind"] - sysroot_deps_map = { - "alloc": ["core"], - "std": ["alloc", "core", "panic_abort", "unwind"], - } - - root = ctx.attr.exec_root - info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] - print("root: ", root, " info: ", info) - print("rustc_src: ", info.rustc_src, " label: ", info.rustc_src.label, "workspace_root: ", info.rustc_src.label.workspace_root) - print("rustc_lib: ", info.rustc_lib, " label: ", info.rustc_lib.label, "workspace_root: ", info.rustc_lib.label.workspace_root) - print("rust_lib: ", info.rust_lib, " label: ", info.rust_lib.label, "workspace_root: ", info.rust_lib.label.workspace_root) - idx = 0 - for sysroot_crate in sysroot: +def create_crate(ctx, target): + print("create_crate: ", target.name, " ", target.root) crate = dict() - crate["ID"] = "SYSROOT-" + sysroot_crate - crate["name"] = sysroot_crate - crate["root_module"] = root + "/" + info.rust_lib.label.workspace_root + "/library/" + sysroot_crate + "/src/lib.rs" - crate["edition"] = "2018" - # sysroot crates are rarely modified. Mark as not a member of the workspace - # for faster indexing - crate["is_workspace_member"] = False - crate["cfg"] = [] - crate["env"] = {} - crate["deps"] = [] - if sysroot_crate in sysroot_deps_map.keys(): - for dep in sysroot_deps_map[sysroot_crate]: - crate["deps"].append({ - "ID": "SYSROOT-" + dep, - "name": dep, + crate["name"] = target.name + crate["ID"] = "ID-" + target.name + crate["root_module"] = ctx.attr.exec_root + "/" + target.root + crate["edition"] = target.edition + crate["is_workspace_member"] = not target.root.startswith("external") + deps = [] + for dep in target.dependencies: + deps.append({ + "name": dep.name, + "ID": "ID-" + dep.name, }) - crate_mapping[crate["ID"]] = idx - idx += 1 - output["crates"].append(crate) - return idx + alloc_dep = dict() + alloc_dep["ID"] = "SYSROOT-alloc" + alloc_dep["name"] = "alloc" + deps.append(alloc_dep) + + core_dep = dict() + core_dep["ID"] = "SYSROOT-core" + core_dep["name"] = "core" + deps.append(core_dep) + + std_dep = dict() + std_dep["ID"] = "SYSROOT-std" + std_dep["name"] = "std" + deps.append(std_dep) + + crate["deps"] = deps + crate["cfg"] = target.cfgs + crate["env"] = target.env + return crate + +def populate_sysroot(ctx, crate_mapping, output): + # Hardcode the relevant sysroot structure for now. + # Anything smarter than this requires a Toml parser + + sysroot = ["alloc", "core", "std", "panic_abort", "unwind"] + sysroot_deps_map = { + "alloc": ["core"], + "std": ["alloc", "core", "panic_abort", "unwind"], + } + + root = ctx.attr.exec_root + info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] + print("root: ", root, " info: ", info) + print("rustc_src: ", info.rustc_src, " label: ", info.rustc_src.label, "workspace_root: ", info.rustc_src.label.workspace_root) + print("rustc_lib: ", info.rustc_lib, " label: ", info.rustc_lib.label, "workspace_root: ", info.rustc_lib.label.workspace_root) + print("rust_lib: ", info.rust_lib, " label: ", info.rust_lib.label, "workspace_root: ", info.rust_lib.label.workspace_root) + idx = 0 + for sysroot_crate in sysroot: + crate = dict() + crate["ID"] = "SYSROOT-" + sysroot_crate + crate["name"] = sysroot_crate + crate["root_module"] = root + "/" + info.rust_lib.label.workspace_root + "/library/" + sysroot_crate + "/src/lib.rs" + crate["edition"] = "2018" + + # sysroot crates are rarely modified. Mark as not a member of the workspace + # for faster indexing + crate["is_workspace_member"] = False + crate["cfg"] = [] + crate["env"] = {} + crate["deps"] = [] + if sysroot_crate in sysroot_deps_map.keys(): + for dep in sysroot_deps_map[sysroot_crate]: + crate["deps"].append({ + "ID": "SYSROOT-" + dep, + "name": dep, + }) + crate_mapping[crate["ID"]] = idx + idx += 1 + output["crates"].append(crate) + + return idx def _rust_project_impl(ctx): - output = dict() - output["crates"] = [] - - crate_mapping = dict() - - # idx starts after the sysroot is already populated - idx = populate_sysroot(ctx, crate_mapping, output) - - for target in ctx.attr.targets: - for dep in target[RustTargetInfo].transitive_deps.to_list(): - print("_rust_project_impl dep: ", dep.name) - crate = create_crate(dep) - crate_mapping[crate["ID"]] = idx - idx += 1 - output["crates"].append(crate) - crate = create_crate(target[RustTargetInfo]) - output["crates"].append(crate) - - # Go through the targets a second time and fill in their dependencies - # since we now have stable placement for their index. - for crate in output["crates"]: - for dep in crate["deps"]: - crate_id = dep["ID"] - dep["crate"] = crate_mapping[crate_id] - # clean up ID for cleaner output - dep.pop("ID", None) - crate.pop("ID", None) - - ctx.actions.write(output = ctx.outputs.filename, content = struct(**output).to_json()) + output = dict() + output["crates"] = [] + + crate_mapping = dict() + + # idx starts after the sysroot is already populated + idx = populate_sysroot(ctx, crate_mapping, output) + + for target in ctx.attr.targets: + for dep in target[RustTargetInfo].transitive_deps.to_list(): + print("_rust_project_impl dep: ", dep.name) + crate = create_crate(ctx, dep) + crate_mapping[crate["ID"]] = idx + idx += 1 + output["crates"].append(crate) + crate = create_crate(ctx, target[RustTargetInfo]) + output["crates"].append(crate) + + # Go through the targets a second time and fill in their dependencies + # since we now have stable placement for their index. + for crate in output["crates"]: + for dep in crate["deps"]: + crate_id = dep["ID"] + dep["crate"] = crate_mapping[crate_id] + + # clean up ID for cleaner output + dep.pop("ID", None) + crate.pop("ID", None) + + ctx.actions.write(output = ctx.outputs.filename, content = struct(**output).to_json()) rust_analyzer = rule( attrs = { @@ -241,5 +238,5 @@ rust_analyzer = rule( "filename": "rust-project.json", }, implementation = _rust_project_impl, - toolchains = [ "@io_bazel_rules_rust//rust:toolchain" ] + toolchains = ["@io_bazel_rules_rust//rust:toolchain"], ) From 8bbd77bb5f9c210684694b33487a6df55da45dd9 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Tue, 24 Nov 2020 19:30:59 +0000 Subject: [PATCH 13/49] remove debug statements --- aspects.bzl | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index 3732ed65b6..6f9da2b653 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -45,16 +45,13 @@ RustTargetInfo = provider( # in a library or binary rule respectively. def fetch_crate_root_file(ctx): crate_root = ctx.rule.attr.crate_root - print("crate root from context: ", crate_root) if not crate_root: if len(ctx.rule.attr.srcs) == 1: crate_root = ctx.rule.attr.srcs[0] - print("crate root from 1: ", crate_root) else: for src in ctx.rule.attr.srcs: file_name = src.label.name crate_type = ctx.rule.attr.crate_type - print("crate root trying: ", src, " on crate type ", crate_type) if crate_type == "bin" and file_name.endswith("main.rs"): crate_root = src break @@ -65,7 +62,6 @@ def fetch_crate_root_file(ctx): # The rules are structured such that the crate_root path will always be # the first element in the in the depset - print("crate_root: ", crate_root, " files: ", crate_root.files.to_list()[0].path) return crate_root.files.to_list()[0].path def _rust_project_aspect_impl(target, ctx): @@ -81,7 +77,6 @@ def _rust_project_aspect_impl(target, ctx): crate_name = ctx.rule.attr.name - print("_rust_project_aspect_impl: ", crate_name) crate_root = fetch_crate_root_file(ctx) cfgs = [] @@ -115,7 +110,6 @@ rust_project_aspect = aspect( ) def create_crate(ctx, target): - print("create_crate: ", target.name, " ", target.root) crate = dict() crate["name"] = target.name crate["ID"] = "ID-" + target.name @@ -161,10 +155,6 @@ def populate_sysroot(ctx, crate_mapping, output): root = ctx.attr.exec_root info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] - print("root: ", root, " info: ", info) - print("rustc_src: ", info.rustc_src, " label: ", info.rustc_src.label, "workspace_root: ", info.rustc_src.label.workspace_root) - print("rustc_lib: ", info.rustc_lib, " label: ", info.rustc_lib.label, "workspace_root: ", info.rustc_lib.label.workspace_root) - print("rust_lib: ", info.rust_lib, " label: ", info.rust_lib.label, "workspace_root: ", info.rust_lib.label.workspace_root) idx = 0 for sysroot_crate in sysroot: crate = dict() @@ -202,7 +192,6 @@ def _rust_project_impl(ctx): for target in ctx.attr.targets: for dep in target[RustTargetInfo].transitive_deps.to_list(): - print("_rust_project_impl dep: ", dep.name) crate = create_crate(ctx, dep) crate_mapping[crate["ID"]] = idx idx += 1 From 9eb96ed64d25e03e104436b6697779055cf0c668 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Tue, 24 Nov 2020 21:25:55 +0000 Subject: [PATCH 14/49] Remove sysroot code, simplify file generation --- aspects.bzl | 121 ++++++++++++++++------------------------------------ 1 file changed, 36 insertions(+), 85 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index 6f9da2b653..637a21aca2 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -29,11 +29,12 @@ _rust_rules = [ ] RustTargetInfo = provider( + "RustTargetInfo holds rust crate metadata for targets", fields = { "name": "target name", "root": "crate root", "edition": "edition", - "dependencies": "dependencies", + "deps": "dependencies", "transitive_deps": "closure of all transitive dependencies", "cfgs": "compilation cfgs", "env": "Environment variables, used for the `env!` macro", @@ -68,12 +69,12 @@ def _rust_project_aspect_impl(target, ctx): if ctx.rule.kind not in _rust_rules: return [] - info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] + toolchain = find_toolchain(ctx) # extract the crate_root path edition = ctx.rule.attr.edition if not edition: - edition = info.default_edition + edition = toolchain.default_edition crate_name = ctx.rule.attr.name @@ -90,8 +91,11 @@ def _rust_project_aspect_impl(target, ctx): env = ctx.rule.attr.rustc_env deps = [dep[RustTargetInfo] for dep in ctx.rule.attr.deps if RustTargetInfo in dep] - transitive_deps = depset(direct = deps, transitive = - [dep[RustTargetInfo].transitive_deps for dep in ctx.rule.attr.deps if RustTargetInfo in dep]) + transitive_deps = depset( + direct = deps, + order = "postorder", + transitive = [dep[RustTargetInfo].transitive_deps for dep in ctx.rule.attr.deps if RustTargetInfo in dep], + ) return [RustTargetInfo( name = crate_name, @@ -99,7 +103,7 @@ def _rust_project_aspect_impl(target, ctx): cfgs = cfgs, root = crate_root, env = env, - dependencies = deps, + deps = deps, transitive_deps = transitive_deps, )] @@ -109,106 +113,53 @@ rust_project_aspect = aspect( toolchains = ["@io_bazel_rules_rust//rust:toolchain"], ) -def create_crate(ctx, target): +def create_crate(ctx, target, crate_mapping): crate = dict() crate["name"] = target.name - crate["ID"] = "ID-" + target.name - crate["root_module"] = ctx.attr.exec_root + "/" + target.root crate["edition"] = target.edition - crate["is_workspace_member"] = not target.root.startswith("external") + if target.root.startswith("external"): + crate["root_module"] = ctx.attr.exec_root + "/" + target.root + crate["is_workspace_member"] = False + else: + crate["root_module"] = "../" + target.root + crate["is_workspace_member"] = True + deps = [] - for dep in target.dependencies: + for dep in target.deps: deps.append({ "name": dep.name, - "ID": "ID-" + dep.name, + "crate": crate_mapping["ID-" + dep.root], }) - alloc_dep = dict() - alloc_dep["ID"] = "SYSROOT-alloc" - alloc_dep["name"] = "alloc" - deps.append(alloc_dep) - - core_dep = dict() - core_dep["ID"] = "SYSROOT-core" - core_dep["name"] = "core" - deps.append(core_dep) - - std_dep = dict() - std_dep["ID"] = "SYSROOT-std" - std_dep["name"] = "std" - deps.append(std_dep) - crate["deps"] = deps crate["cfg"] = target.cfgs crate["env"] = target.env - return crate - -def populate_sysroot(ctx, crate_mapping, output): - # Hardcode the relevant sysroot structure for now. - # Anything smarter than this requires a Toml parser - - sysroot = ["alloc", "core", "std", "panic_abort", "unwind"] - sysroot_deps_map = { - "alloc": ["core"], - "std": ["alloc", "core", "panic_abort", "unwind"], - } - - root = ctx.attr.exec_root - info = ctx.toolchains["@io_bazel_rules_rust//rust:toolchain"] - idx = 0 - for sysroot_crate in sysroot: - crate = dict() - crate["ID"] = "SYSROOT-" + sysroot_crate - crate["name"] = sysroot_crate - crate["root_module"] = root + "/" + info.rust_lib.label.workspace_root + "/library/" + sysroot_crate + "/src/lib.rs" - crate["edition"] = "2018" - - # sysroot crates are rarely modified. Mark as not a member of the workspace - # for faster indexing - crate["is_workspace_member"] = False - crate["cfg"] = [] - crate["env"] = {} - crate["deps"] = [] - if sysroot_crate in sysroot_deps_map.keys(): - for dep in sysroot_deps_map[sysroot_crate]: - crate["deps"].append({ - "ID": "SYSROOT-" + dep, - "name": dep, - }) - crate_mapping[crate["ID"]] = idx - idx += 1 - output["crates"].append(crate) - - return idx + return "ID-" + target.root, crate def _rust_project_impl(ctx): output = dict() + rust_toolchain = find_toolchain(ctx) + output["sysroot_src"] = ctx.attr.exec_root + "/" + rust_toolchain.rust_lib.label.workspace_root + "/library" output["crates"] = [] crate_mapping = dict() - # idx starts after the sysroot is already populated - idx = populate_sysroot(ctx, crate_mapping, output) - + idx = 0 for target in ctx.attr.targets: + # Add our transitive dependencies for dep in target[RustTargetInfo].transitive_deps.to_list(): - crate = create_crate(ctx, dep) - crate_mapping[crate["ID"]] = idx + crate_id, crate = create_crate(ctx, dep, crate_mapping) + if crate_id not in crate_mapping: + crate_mapping[crate_id] = idx + idx += 1 + output["crates"].append(crate) + + # Add this crate to the crate mapping and output. + crate_id, crate = create_crate(ctx, target[RustTargetInfo], crate_mapping) + if crate_id not in crate_mapping: + crate_mapping[crate_id] = idx idx += 1 output["crates"].append(crate) - crate = create_crate(ctx, target[RustTargetInfo]) - output["crates"].append(crate) - - # Go through the targets a second time and fill in their dependencies - # since we now have stable placement for their index. - for crate in output["crates"]: - for dep in crate["deps"]: - crate_id = dep["ID"] - dep["crate"] = crate_mapping[crate_id] - - # clean up ID for cleaner output - dep.pop("ID", None) - crate.pop("ID", None) ctx.actions.write(output = ctx.outputs.filename, content = struct(**output).to_json()) @@ -219,7 +170,7 @@ rust_analyzer = rule( doc = "List of all targets to be included in the index", ), "exec_root": attr.string( - default = "__EXEC_ROOT__", + mandatory = True, doc = "Execution root of Bazel as returned by 'bazel info execution_root'.", ), }, From e1d451abd50747cc079cd80cb6c122b09fed595c Mon Sep 17 00:00:00 2001 From: David Marcin Date: Wed, 25 Nov 2020 16:37:29 +0000 Subject: [PATCH 15/49] clippy stuff --- aspects.bzl | 26 +++++++++++++++++++------- rust/private/clippy.bzl | 2 +- rust/private/rustc.bzl | 4 ++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/aspects.bzl b/aspects.bzl index 637a21aca2..bedf908166 100644 --- a/aspects.bzl +++ b/aspects.bzl @@ -20,6 +20,7 @@ given targets. This file can be consumed by rust-analyzer as an alternative to Cargo.toml files. """ +load("@io_bazel_rules_rust//rust:private/rustc.bzl", "BuildInfo") load("@io_bazel_rules_rust//rust:private/utils.bzl", "find_toolchain") # We support only these rule kinds. @@ -53,13 +54,16 @@ def fetch_crate_root_file(ctx): for src in ctx.rule.attr.srcs: file_name = src.label.name crate_type = ctx.rule.attr.crate_type - if crate_type == "bin" and file_name.endswith("main.rs"): - crate_root = src - break - if crate_type == "rlib" or crate_type == "dylib" or crate_type == "cdylib": + if crate_type == "bin": + if file_name.endswith("main.rs"): + crate_root = src + break + elif crate_type in ("rlib", "dylib", "cdylib", "staticlib", "proc-macro"): if file_name.endswith("lib.rs"): crate_root = src break + else: + print("MISSED CRATE TYPE: ", crate_type) # The rules are structured such that the crate_root path will always be # the first element in the in the depset @@ -88,13 +92,21 @@ def _rust_project_aspect_impl(target, ctx): # config, not key/value if flag.startswith("--cfg"): cfgs.append(flag[6:]) - env = ctx.rule.attr.rustc_env + + env = {} + for dep in ctx.rule.attr.deps: + if BuildInfo in dep: + env.update({ + "OUT_DIR": "../" + dep[BuildInfo].out_dir.path, + }) + env.update(ctx.rule.attr.rustc_env) deps = [dep[RustTargetInfo] for dep in ctx.rule.attr.deps if RustTargetInfo in dep] + deps += [dep[RustTargetInfo] for dep in ctx.rule.attr.proc_macro_deps if RustTargetInfo in dep] transitive_deps = depset( direct = deps, order = "postorder", - transitive = [dep[RustTargetInfo].transitive_deps for dep in ctx.rule.attr.deps if RustTargetInfo in dep], + transitive = [dep.transitive_deps for dep in deps], ) return [RustTargetInfo( @@ -108,7 +120,7 @@ def _rust_project_aspect_impl(target, ctx): )] rust_project_aspect = aspect( - attr_aspects = ["deps"], + attr_aspects = ["deps", "proc_macro_deps"], implementation = _rust_project_aspect_impl, toolchains = ["@io_bazel_rules_rust//rust:toolchain"], ) diff --git a/rust/private/clippy.bzl b/rust/private/clippy.bzl index 610aeea4ae..674d6d8b2d 100644 --- a/rust/private/clippy.bzl +++ b/rust/private/clippy.bzl @@ -87,7 +87,7 @@ def _clippy_aspect_impl(target, ctx): crate_info, dep_info, output_hash = determine_output_hash(root), - rust_flags = [], + rust_flags = ["--error-format=json"], out_dir = out_dir, build_env_file = build_env_file, build_flags_files = build_flags_files, diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index fd1754bcdd..9284122dfb 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -750,12 +750,16 @@ def _create_extra_input_args(ctx, file, build_info, dep_info): build_flags_files = [] if build_info: + # print("BUILD INFO: ", build_info) out_dir = build_info.out_dir.path + # print("out_dir: ", out_dir) build_env_file = build_info.rustc_env.path + # print("build_env_file: ", build_env_file) build_flags_files.append(build_info.flags.path) build_flags_files.append(build_info.link_flags.path) input_files.append(build_info.out_dir) input_files.append(build_info.link_flags) + return input_files, out_dir, build_env_file, build_flags_files From a6dcdd3fb18657f5b1d23f8ce5737ef8b3a7e4e8 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Wed, 25 Nov 2020 19:48:54 +0000 Subject: [PATCH 16/49] Move to rust/private --- rust/known_shas.bzl | 38 ------------------- aspects.bzl => rust/private/rust_analyzer.bzl | 0 util/fetch_shas.sh | 7 ---- 3 files changed, 45 deletions(-) rename aspects.bzl => rust/private/rust_analyzer.bzl (100%) diff --git a/rust/known_shas.bzl b/rust/known_shas.bzl index 21f99086d9..ca7a1a2b2d 100644 --- a/rust/known_shas.bzl +++ b/rust/known_shas.bzl @@ -18,7 +18,6 @@ FILE_KEY_TO_SHA = { "2018-10-30/rust-std-beta-x86_64-unknown-freebsd": "5aef62464a5580ab6b38c9e54203db12f90ad42de538b7a5eefc7778b55b6497", "2018-10-30/rust-std-beta-x86_64-unknown-linux-gnu": "34996a688d6a4c3587f873b0a8c86fe1d2fee2a269b6e669b1cb8c6908fb77b8", "2018-10-30/rustc-beta-aarch64-unknown-linux-gnu": "e6bb89261baa494ef98239bde9821b66671de5cd78352a9c100abce3a18ca250", - "2018-10-30/rustc-beta-src": "4dfc6db5f3cbe760c089d498b4190e49e778ac677c72f6bfc9325fc140f12483", "2018-10-30/rustc-beta-x86_64-apple-darwin": "22153f359b8b98341aa0349233112fff2b9f092988f9d678626207ba29666b5b", "2018-10-30/rustc-beta-x86_64-pc-windows-msvc": "9cd8225f1307aab95b439dbecd70aaa35e03c913ba0897dc7fe3a04755fc15b1", "2018-10-30/rustc-beta-x86_64-unknown-freebsd": "e207562cd5e3a17497e029bcb1cab56d9fa474d788906f13e389a3cb804ea4d6", @@ -45,7 +44,6 @@ FILE_KEY_TO_SHA = { "2018-11-01/rust-std-beta-x86_64-unknown-freebsd": "eed13a5c36c0731b01b8926f26be5b054c341a0487628fca688e8e99f33b200b", "2018-11-01/rust-std-beta-x86_64-unknown-linux-gnu": "f38a224bccfc89bd0d598764363271985d0b2696123ea10de6399c4cc7dd8adb", "2018-11-01/rustc-beta-aarch64-unknown-linux-gnu": "acf359a4cecfc827f5ca4255c0492d46223d09d535444f0b303678918944c87c", - "2018-11-01/rustc-beta-src": "b2723ad2ca3c643b60a7ea1f1f1184aa8af9f7c2570f199ff5971d47791b4145", "2018-11-01/rustc-beta-x86_64-apple-darwin": "64b5a5fc8b3dc348395137df2c422adbf483168c58af5cd9acc8522dd9b4392b", "2018-11-01/rustc-beta-x86_64-pc-windows-msvc": "71cbfd2793f6b55653f5ef4bdf0350dfe6d9b0952d518a3a355044ec7caa03c2", "2018-11-01/rustc-beta-x86_64-unknown-freebsd": "51a5370f1776229bede506e5ab05da7cfeb5bd21a5374561acb4b7138c75d508", @@ -72,7 +70,6 @@ FILE_KEY_TO_SHA = { "2018-11-02/rust-std-beta-x86_64-unknown-freebsd": "4661fdd15b5cee0fafd4c9cb085d0614abab0b2b1d62a55540b3d4d2634c4ba7", "2018-11-02/rust-std-beta-x86_64-unknown-linux-gnu": "3e2f68697620e501a9439bb7923f5676c82f7a4b4aaf822a141188c92619fe13", "2018-11-02/rustc-beta-aarch64-unknown-linux-gnu": "d703f1cdecd77aba85024db5e94f13e50c74e66af21091107c7cd67a3179da15", - "2018-11-02/rustc-beta-src": "a0610ac06b0d9655e5d46794cc9b5e6479e2f2f8a8aeb86472760b66b81b0366", "2018-11-02/rustc-beta-x86_64-apple-darwin": "199a0776ad4f1406b8b6f477d12c58858816f07246d52842384e1084d8c9000e", "2018-11-02/rustc-beta-x86_64-pc-windows-msvc": "a4fd3838f4459a151e83d540784953cd80c5a1a68fe3bf965399c1f07f6476bb", "2018-11-02/rustc-beta-x86_64-unknown-freebsd": "f931cb44b892dc3899c9379238d8f51d35c9503db9e93ce5700f3121712c9b62", @@ -99,7 +96,6 @@ FILE_KEY_TO_SHA = { "2018-11-07/rust-std-nightly-x86_64-unknown-freebsd": "ca648e7eb243cec32dc5a1b4e2fe6d67c2a00be56326e4d7aec9f2bbeb4dc138", "2018-11-07/rust-std-nightly-x86_64-unknown-linux-gnu": "bd8daba5c2d36e261da6f0ea8b5893e7fe94252eca7478d581c036fc1acb7c36", "2018-11-07/rustc-nightly-aarch64-unknown-linux-gnu": "11caf45fef229d85efb36cdbcf955d95fae648c27ca4ffd153bad316eb58793a", - "2018-11-07/rustc-nightly-src": "0b048ce086ce939964333aef3917de0f51a6dfb81b3b4ce846f98b439651f129", "2018-11-07/rustc-nightly-x86_64-apple-darwin": "cddecdb0d595cb8b944bf70b2284f557743f5637536f2181ad0036806cf56217", "2018-11-07/rustc-nightly-x86_64-pc-windows-msvc": "479f58f34616b83c003fa29e68ee84c91ee5521038f255a7cd3b597a2f5082d0", "2018-11-07/rustc-nightly-x86_64-unknown-freebsd": "47f81ec8c4ebbcd4e948033b5db72c1e9bec6f284fdaa5bdf59bcc92b075333f", @@ -126,7 +122,6 @@ FILE_KEY_TO_SHA = { "2018-11-08/rust-std-nightly-x86_64-unknown-freebsd": "64aabfec15a2b773c27892e58514161cb05ab370e3291beb1cafc7d270772389", "2018-11-08/rust-std-nightly-x86_64-unknown-linux-gnu": "efb8f6f6aa2c5a3f1c069e05b74fde6a85985837054faf3bc565d839902efedc", "2018-11-08/rustc-nightly-aarch64-unknown-linux-gnu": "494173aa705efeef4df2d88278608bd71b477183d85a670a577051c76c5ee99c", - "2018-11-08/rustc-nightly-src": "e95ffea78eb6e37a420ac14c50b5d6877af7005b181f5a05cca3d8c642325c64", "2018-11-08/rustc-nightly-x86_64-apple-darwin": "316e7727a136a82a20832a69b18f74add335e9b659fa7e0d8c7d12c0d11224b7", "2018-11-08/rustc-nightly-x86_64-pc-windows-msvc": "489cb54446374eccc78eca18aa86b4159d47fdfa7bab0ea9a20cb68fa4d80071", "2018-11-08/rustc-nightly-x86_64-unknown-freebsd": "874b7055e0cb609ce34d38456bda888865c63fcbc7abac5aad147f2a21a7d147", @@ -153,7 +148,6 @@ FILE_KEY_TO_SHA = { "2018-11-09/rust-std-nightly-x86_64-unknown-freebsd": "ab8a32d8efb0ab4686526c6cf1380161e87a89015464f5d5f5438c99723675c7", "2018-11-09/rust-std-nightly-x86_64-unknown-linux-gnu": "1418ba09f97c6ba91e2df5ba0b11cf1c53498710bc6a147fe8f4be455a96c4d8", "2018-11-09/rustc-nightly-aarch64-unknown-linux-gnu": "167fec713804d8af1fa4f543e79ca5cee259f1b966b8e04c99efba75901f4c8e", - "2018-11-09/rustc-nightly-src": "9341a72e1616ed0c7b81036f388cf4e87d49f748a09467f9366ab8d7e6d3e664", "2018-11-09/rustc-nightly-x86_64-apple-darwin": "55ca5ad85b0afd61a419e374f8e6320b4f4fe30f8092005cdec9e63103812ea7", "2018-11-09/rustc-nightly-x86_64-pc-windows-msvc": "dd19c5a4b209a9f46dd2f99eb7ec0898bd00accf1c6e8a97222c580bcf62e32a", "2018-11-09/rustc-nightly-x86_64-unknown-freebsd": "bd6bb0228aeab01f425cb2ad55b2e0409b43e79450c2830183a6878cc2d2bdc4", @@ -181,7 +175,6 @@ FILE_KEY_TO_SHA = { "2020-02-16/rust-std-nightly-x86_64-unknown-freebsd": "6575eabdfaed4b0490cdfffcbb5860036dcc36bebdabc58d839c088ff5556a6f", "2020-02-16/rust-std-nightly-x86_64-unknown-linux-gnu": "28a169e9b0f0986a50254caf14be863cf6f1ed3aec8342a7fa756dc1af76f38b", "2020-02-16/rustc-nightly-aarch64-unknown-linux-gnu": "e9cf265820f69331abc9a7c4da0c26febffd4017cf4e6d0840d4ed22b3dd332b", - "2020-02-16/rustc-nightly-src": "605e6753e606a23ce85bbf44566e9c66e8de5df492e3bab1029ea3c4c3c11c10", "2020-02-16/rustc-nightly-x86_64-apple-darwin": "db0338b3e1934147dce0bf6420d9c147caa6aef2db1aca44ca8fef47b7247615", "2020-02-16/rustc-nightly-x86_64-pc-windows-msvc": "d51440d4004e49670c5cf803f96aa222c68f09348bfca46f6e0d4c8728908065", "2020-02-16/rustc-nightly-x86_64-unknown-freebsd": "c76fa125e6d17b16a96b01a875d826f20849b09970b49ed1183601a0e7803f6f", @@ -213,7 +206,6 @@ FILE_KEY_TO_SHA = { "2020-11-10/rust-std-nightly-x86_64-unknown-linux-gnu": "367c14b7fbe98e264b0e4b5a9ddaf3f78ce3ce09bbef4c7be33a3f2abade9ad9", "2020-11-10/rustc-nightly-aarch64-apple-darwin": "a461f2486013b5cec450c8f79230e83878689b803a38df7304adea27b025ef1b", "2020-11-10/rustc-nightly-aarch64-unknown-linux-gnu": "900170006c4c2d88cadc0d915d410588cb80150817e53aa7fca41a459a5ec500", - "2020-11-10/rustc-nightly-src": "c8fb001c1e44e40cae30b7f098b069b7a65343dfa0159a224dc5329266bc59fd", "2020-11-10/rustc-nightly-x86_64-apple-darwin": "7a443dfb068bb7e3854dd6475564da33a57d3f225ce03ad8bc973e8900960b69", "2020-11-10/rustc-nightly-x86_64-pc-windows-msvc": "e7b325e55d372aaf4be400273673711fe78271b655c0b710d62a972b8044b9ef", "2020-11-10/rustc-nightly-x86_64-unknown-freebsd": "3ef55f82aefad5eac4398977d34b1963feb05b1cd654005d385da26624cb2f7e", @@ -627,181 +619,151 @@ FILE_KEY_TO_SHA = { "rust-std-1.47.0-x86_64-unknown-freebsd": "80f5dee782bd74b41c55a676c624ce2260ab54c834102c90ea54e0c5e7e513c6", "rust-std-1.47.0-x86_64-unknown-linux-gnu": "17ecad27d96b331608e4a96dfa3cad05ccb2ccecb888894ed35054e0d1f5207f", "rustc-1.26.0-aarch64-unknown-linux-gnu": "ddddaddb585b95d81854171ac4e02d07790505853cee3034f199c8b7897f32e2", - "rustc-1.26.0-src": "4fb09bc4e233b71dcbe08a37a3f38cabc32219745ec6a628b18a55a1232281dd", "rustc-1.26.0-x86_64-apple-darwin": "5cb67314656d16cf2a1bdc84213aaaf6afdb5811825c7afba916e2d42d3d641f", "rustc-1.26.0-x86_64-pc-windows-msvc": "427ae4a43a901be288ff3a4dc85d3a14f7e95108cfdaae63e8dbb4a227e07cdd", "rustc-1.26.0-x86_64-unknown-freebsd": "9499ce5b68d631f8345c387e1f59b21892d97e0acb5650deb61a34719310bd38", "rustc-1.26.0-x86_64-unknown-linux-gnu": "7ca9a30010602aaf2244c376a3cc5baa89429d54da17b8ba1cb0cdfdc846cc61", "rustc-1.26.1-aarch64-unknown-linux-gnu": "7a06bd5312cbe8bb19e526b4c9ab04de1628019815a566ce0ff9401515bc2c04", - "rustc-1.26.1-src": "70a7961bd8ec43b2c01e9896e90b0a06804a7fbe0a5c05acc7fd6fed19500df0", "rustc-1.26.1-x86_64-apple-darwin": "e5f4291c3709b170fbeb17fab7fae50fe0c626dbdc5c42ddb1f342ea03acbad4", "rustc-1.26.1-x86_64-pc-windows-msvc": "e84dca395837aa24b4ea87d46d06a333c2e87d0be5fc5259476a95fbcb05accc", "rustc-1.26.1-x86_64-unknown-freebsd": "dc3dc36010d73349152e6158522e82830fda173007b9299b0a947c90769c54ff", "rustc-1.26.1-x86_64-unknown-linux-gnu": "45bc1c30e0c473c42889f22b182ec6f0b0fc3be0825e1607c64933592486eb2a", "rustc-1.26.2-aarch64-unknown-linux-gnu": "b09fea72e259811fcbc6aade942329bc4588356470765987ee37d6108a82f7b6", - "rustc-1.26.2-src": "fb9ecf304488c9b56600ab20cfd1937482057f7e5db7899fddb86e0774548700", "rustc-1.26.2-x86_64-apple-darwin": "5b0a3d94a4fa76ed28859123e35c09a91d7eb8ff65f40ec4c50dfa56ffed8ae5", "rustc-1.26.2-x86_64-pc-windows-msvc": "15eb657747a86a4481501bb21e2dbcf56a06c0beea00e8677c86ef74b8812576", "rustc-1.26.2-x86_64-unknown-freebsd": "48f20a8dc6bc54c90aae685d0c3fa2caf3677f1c4a4d0c53aee9d15588bd0735", "rustc-1.26.2-x86_64-unknown-linux-gnu": "1ebdafe52b581a63cea217a036fd6e77706d2715ae9cfe10a8c715d753326004", "rustc-1.27.0-aarch64-unknown-linux-gnu": "b58c0373df43623adcc990d36190ee157f46f6fba650d0242632f3df2dfbc425", - "rustc-1.27.0-src": "2cb9803f690349c9fd429564d909ddd4676c68dc48b670b8ddf797c2613e2d21", "rustc-1.27.0-x86_64-apple-darwin": "0b00c6971ef524f68b911f621d199e60c339c390b18e12700d55e012b62aa90c", "rustc-1.27.0-x86_64-pc-windows-msvc": "22eeac4f4b4d91c28cf18c6a4a8b477091e6661e3e827c0b32355d52e634a517", "rustc-1.27.0-x86_64-unknown-freebsd": "24c193213450ffacffebdd1413d77fc3c1ed00049cf1ede2d0f3f370dd86b462", "rustc-1.27.0-x86_64-unknown-linux-gnu": "29f399a1a208ea3f27f21e57f2d832e9d801c397a986aaea17e3a2ddeded6c3c", "rustc-1.27.1-aarch64-unknown-linux-gnu": "c48d19ff5474ce75ebbb97e1b26ca8dc23d38f635ae7a3e21b8a4139df5cfb8e", - "rustc-1.27.1-src": "2133beb01ddc3aa09eebc769dd884533c6cfb08ce684f042497e097068d733d1", "rustc-1.27.1-x86_64-apple-darwin": "747f616e07e5da9323a21c1cf9d76b53bb46094a68223d461a7333f26c714f19", "rustc-1.27.1-x86_64-pc-windows-msvc": "76abfd523f876516e589f62a83eaaa6e55496745e32f2e9f3f87aca55da3e8b8", "rustc-1.27.1-x86_64-unknown-freebsd": "9b199c21094f996fd9d4b620a5ff2c4bc5b8dab13e96bdf7c113291f601ec944", "rustc-1.27.1-x86_64-unknown-linux-gnu": "a6bf6205b345b854d705d0028a4e7161a0f5b209e464130e7d135fa01a296dc1", "rustc-1.27.2-aarch64-unknown-linux-gnu": "c1a5ddc6e40be5eef7afad8c126c6f426d07eb1a297902c7ef871279fdbeea49", - "rustc-1.27.2-src": "9a818c50cdb7880abeaa68b3d97792711e6c64c1cdfb6efdc23f75b8ced0e15d", "rustc-1.27.2-x86_64-apple-darwin": "b5c5edd2094afd0a92ad776dbd12cb6ee37800b940437dece10229ccacd1f561", "rustc-1.27.2-x86_64-pc-windows-msvc": "c00dde7df7475340f5574b09c86d0e19f6707f838bf95d2ff463a8f4d4d76d33", "rustc-1.27.2-x86_64-unknown-freebsd": "66d739632574fa52e82b40aca0eb4cef7a38047ed67cd6a240d8798a3cf9b6a6", "rustc-1.27.2-x86_64-unknown-linux-gnu": "ec3efc17ddbe6625840957049e15ebae960f447c8e8feb7da40c28dd6adf655f", "rustc-1.28.0-aarch64-unknown-linux-gnu": "09d1fa08d7403495ca07565eaabfcbe6703e842b765a68d5110cf4e64e988476", - "rustc-1.28.0-src": "1d5a81729c6f23a0a23b584dd249e35abe9c6f7569cee967cc42b1758ecd6486", "rustc-1.28.0-x86_64-apple-darwin": "10a5bf35177508c72050149663ff679a770eafa8557c6be0052603ca1267ae4d", "rustc-1.28.0-x86_64-pc-windows-msvc": "39871017768fe779dbffaaff8696baf0788bb9c4d6c4caa3d2564e1153ab2199", "rustc-1.28.0-x86_64-unknown-freebsd": "5eeaa17844f87e59aab821dc98dd15a920df0d1d7da3ef5808d2c586331c92a7", "rustc-1.28.0-x86_64-unknown-linux-gnu": "008bb3d714544bc991594b29a98a154441914c4771007130361bbadfb54143d0", "rustc-1.29.0-aarch64-unknown-linux-gnu": "c7480c0b98ae84151ffa8cadcb06d1ed2a11a755b6619ac1b89e7c886e98b7ff", - "rustc-1.29.0-src": "a4eb34ffd47f76afe2abd813f398512d5a19ef00989d37306217c9c9ec2f61e9", "rustc-1.29.0-x86_64-apple-darwin": "3462ba7e841485f93251762ce0b36a3922830a1249e5d79d6d010ceb43e4ee3f", "rustc-1.29.0-x86_64-pc-windows-msvc": "b27c38cb60092e9cac8afc4ad760349821e6b068d986e13ad46233b9676ab35e", "rustc-1.29.0-x86_64-unknown-freebsd": "38f30c96f0fa7ebfe94cd2db57e9b99961feca0a09045dbc1e955404b5d7f40a", "rustc-1.29.0-x86_64-unknown-linux-gnu": "229c51d51efc239e6eb9b428795bb7f57309f11287705dcba4877d5e220102a0", "rustc-1.29.1-aarch64-unknown-linux-gnu": "784ea61ff852225be622141600c79621456f1ad9f9becdf7070eb0217b8635aa", - "rustc-1.29.1-src": "f1b0728b66ce6bce6d72bbe5ea9e3a24ea22a045665da2ed8fcdfad14f61a349", "rustc-1.29.1-x86_64-apple-darwin": "64b86c923786dfafe8bbb5fcbef0d854132f29f0bf635830cd2d95ff225d2317", "rustc-1.29.1-x86_64-pc-windows-msvc": "2675bf444df8fe900b84098917db3e765c87ad3c812ef2a818c7e622d77db457", "rustc-1.29.1-x86_64-unknown-freebsd": "ed9b2ccbfc6028ce2c73105cebebdb9f2e2332018c687951639176358bfed9a2", "rustc-1.29.1-x86_64-unknown-linux-gnu": "b99324394ba20bd12efa9d30dad72b10747bd075f97c7a9fd0ce3f9394383fa7", "rustc-1.29.2-aarch64-unknown-linux-gnu": "54a8c54f04dec72d7f8655ce1c3037dc23ded2f9ada26e7ea77aa45fc8b0d0c5", - "rustc-1.29.2-src": "5088e796aa2e47478cdf41e7243fc5443fafab0a7c70a11423e57c80c04167c9", "rustc-1.29.2-x86_64-apple-darwin": "d9c0dd8127ed632e27d751f051bca933578317ffe891e39155ae721bc1d3ec05", "rustc-1.29.2-x86_64-pc-windows-msvc": "53dcf97ed9461784d713c5a413df7e8e5aa4c9158a4d5921a038b77b17120a17", "rustc-1.29.2-x86_64-unknown-freebsd": "94fba7a7b88ca86c037a48376b7e09bb4ca66e1268fc8d664796cdbdee97c0fa", "rustc-1.29.2-x86_64-unknown-linux-gnu": "b04146b09edc4bad0de7c8fa1a5a2aa4416d365c03c5962b8a5b26c7047b7cc9", "rustc-1.30.0-aarch64-unknown-linux-gnu": "ccff6c6d8386655955265f586862314dd3b646bbeccd1369877f4343b1960a53", - "rustc-1.30.0-src": "cd0ba83fcca55b64c0c9f23130fe731dfc1882b73ae21bef96be8f2362c108ee", "rustc-1.30.0-x86_64-apple-darwin": "d4fcbc61c7323e6fa1001ae268c5db1693ff07e5ef1ac25907138a2ee7bd8faf", "rustc-1.30.0-x86_64-pc-windows-msvc": "2d2d1a51bb15794920a2f0cccf7fd2c8bfb037d00975e799ff4a4ac3b83032ce", "rustc-1.30.0-x86_64-unknown-freebsd": "68a74949e34118406673cf8cc0098b011907c840890e0640aa3b145ce91c521d", "rustc-1.30.0-x86_64-unknown-linux-gnu": "cc45058e9963d33ca28220e752d9e360b7e05f17e34284f5f8197738c3a88444", "rustc-1.30.1-aarch64-unknown-linux-gnu": "f3569c0a74f07aa2e56bf93c9f2aaddf7434ce17f85d6d6ff854fb9245888bcf", - "rustc-1.30.1-src": "36a38902dbd9a3e1240d46ab0f2ca40d2fd07c2ab6508ed7970c6c4c036b5b29", "rustc-1.30.1-x86_64-apple-darwin": "fd8ca09595e9d686aef9e3b94259500b482cf7a01de167a8c72a4f8d19a604f3", "rustc-1.30.1-x86_64-pc-windows-msvc": "8ad1551132de8c766d2d7c66d9bb93a959ebbfa7d86c47f196227fea914583dd", "rustc-1.30.1-x86_64-unknown-freebsd": "2f79e386bed201eb9b6ffa58240742617ec6006accb559dab7b6424f33b65b5f", "rustc-1.30.1-x86_64-unknown-linux-gnu": "d84de208499b59e4a3c074f9f3f2fcbb26fb20d6bfd19262e6d5f4181ddbe34d", "rustc-1.31.0-aarch64-unknown-linux-gnu": "1e480d8cadceff39ad39d30fe874bfd485386c98842f16423310cb2ada1923c0", - "rustc-1.31.0-src": "9ad54dc0baf1db5fc6a79d54e71c439c82aff85cd96778978456f2958211ef06", "rustc-1.31.0-x86_64-apple-darwin": "250fd3f3aba7d38c4af9682a12a37c733dbd6dde127665b0f493551e6c4aea8b", "rustc-1.31.0-x86_64-pc-windows-msvc": "418abc285870ab4d85d53769eac229cd66b7fc7cdaa6e73699530e88ee5dfaf4", "rustc-1.31.0-x86_64-unknown-freebsd": "9ec40454e22e3494b9859c03e37e8851077f897845bcf838d69d4393900e7b33", "rustc-1.31.0-x86_64-unknown-linux-gnu": "5c4581f0fc05f0f5076db6231b0c1a4d27eb61c0b36bfb42d97243ad8f4e43a0", "rustc-1.31.1-aarch64-unknown-linux-gnu": "315ea9c981e4320a557f6c75b58242c0598a90316f610b4dfef5d06e82b927f2", - "rustc-1.31.1-src": "91d2fc22f08d986adab7a54eb3a6a9b99e490f677d2d092e5b9e4e069c23686a", "rustc-1.31.1-x86_64-apple-darwin": "e3f9c5ccd0e6e09da8012f30ee9a1880efebc0c039cc1f3866cf50c984be16a7", "rustc-1.31.1-x86_64-pc-windows-msvc": "0320b7544de463d4444c6445fd2e23044e28fde1173f614145a72a4bcfc6ccd9", "rustc-1.31.1-x86_64-unknown-freebsd": "fb38ad94976c273c0fb95d0b5ba2d1ce90684e58fa06fafc9f8050ba00559f50", "rustc-1.31.1-x86_64-unknown-linux-gnu": "77d47ce7e27a146e4301f11befd43f3fc5ac195ace0dfc07ac8154f130b057ea", "rustc-1.32.0-aarch64-unknown-linux-gnu": "193cbe67161e20a0bf4eeb8bafeb302f3e61a59ca939a0454fc3fbc76e9524cc", - "rustc-1.32.0-src": "4c594c7712a0e7e8eae6526c464bf6ea1d82f77b4f61717c3fc28fb27ba2224a", "rustc-1.32.0-x86_64-apple-darwin": "0334c4568f09cae984e53e4a3f4ff207e2bcc50fce13ad32b8eca89f014e5e61", "rustc-1.32.0-x86_64-pc-windows-msvc": "a7799495d3032c5ad6b5f712f7d7a9538f695c6d8d2e5258c0f7aadac8cea1d4", "rustc-1.32.0-x86_64-unknown-freebsd": "a14a0e288be8ce894a85810151a2eb70fc86afa36e4a5fae4e903c744b888687", "rustc-1.32.0-x86_64-unknown-linux-gnu": "75c31f32e19548c1608611d08b82b87560e02f15caac7b2663a8189a4609977c", "rustc-1.33.0-aarch64-unknown-linux-gnu": "e23141cc65d1d8e3957a96f3a601bdb7a9d09026ac20396aeaebd2613ea0d08e", - "rustc-1.33.0-src": "5a01a8d7e65126f6079042831385e77485fa5c014bf217e9f3e4aff36a485d94", "rustc-1.33.0-x86_64-apple-darwin": "ea1f0a95015bbefba9eac5890b12ee2887f464822ab579c8bbc2db3023c6dd08", "rustc-1.33.0-x86_64-pc-windows-msvc": "b935a78d072b9ae91ff8ddf9155df95d77fd8a1c6293e39df3c65b18d860320e", "rustc-1.33.0-x86_64-unknown-freebsd": "8bfc7fc50c50294cf4ded35360b41b590180401a0d2e84256f5931c7c1ff35cd", "rustc-1.33.0-x86_64-unknown-linux-gnu": "54a342f718b712d8a17fd7878ebd37d22a82ebc70b59c421168cd4153fd04c2b", "rustc-1.34.0-aarch64-unknown-linux-gnu": "364328a40c7aa5749be80b13a14466149a559205e34aef3d8823dc2580f55921", - "rustc-1.34.0-src": "7ac85acffd79dd3a7c44305d9eaabd1f1e7116e2e6e11e770e4bf5f92c0f1f59", "rustc-1.34.0-x86_64-apple-darwin": "2044d44f01a8aa7fb3382f35fc839facfde4fc1eb6f951ead42aef954e317088", "rustc-1.34.0-x86_64-pc-windows-msvc": "371f9abd2bc615b339dfd606d93e6b4892594fd86084d513e07a9f80ff21a828", "rustc-1.34.0-x86_64-unknown-freebsd": "522662f147d0550e4f4f49026b4ebcc5e05a0935fa88acc9b99da5d7435755aa", "rustc-1.34.0-x86_64-unknown-linux-gnu": "5852e84dd30e4a552a7cd4d7c0172648d7ffb4d9ac7078871adbb902c183ffc2", "rustc-1.35.0-aarch64-unknown-linux-gnu": "dc06d77e6cdc06693d3b87ce473f151c96bda2c1e5dbba8c0354c54990c64fc2", - "rustc-1.35.0-src": "5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d", "rustc-1.35.0-x86_64-apple-darwin": "5b2fb7581332f349c041860479ffdbfec0eebf87fc3016146836b8868afc3ae5", "rustc-1.35.0-x86_64-pc-windows-msvc": "df4f94d29d10fde2486d9fac3247a566d99a2b7f97fa6ebd416f308b804f7693", "rustc-1.35.0-x86_64-unknown-freebsd": "d3b5a6cfa41264e1873287bdb89892a7edc40333d581f468890c68336f50a601", "rustc-1.35.0-x86_64-unknown-linux-gnu": "bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e", "rustc-1.36.0-aarch64-unknown-linux-gnu": "62e40e0677032ae0cd91a7f8b4450dbaaf5223050a05b28a9174802d09691da6", - "rustc-1.36.0-src": "04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b", "rustc-1.36.0-x86_64-apple-darwin": "97568272717ffa62dbf4459dff6086e69c808df252a912146e28468412667013", "rustc-1.36.0-x86_64-pc-windows-msvc": "4c131f68eac74bc20315eda097578c43de2b695445739462a4b273f90a131ffc", "rustc-1.36.0-x86_64-unknown-freebsd": "c2dd0cec49b054ed9439762fb31555b8df9a3d81747b194f7d3afbc6d8adb8de", "rustc-1.36.0-x86_64-unknown-linux-gnu": "7c149fa1695b41e8e1edcb95dca199522889f119be99f922741084d50470a9e5", "rustc-1.37.0-aarch64-unknown-linux-gnu": "721ba21dbe9b350a8c50a4c783c76ba3f6926525480518851dd6ba92ecdb042c", - "rustc-1.37.0-src": "120e7020d065499cc6b28759ff04153bfdc2ac9b5adeb252331a4eb87cbe38c3", "rustc-1.37.0-x86_64-apple-darwin": "00d4d15b4d9a4d188e0db8bbc17cd5f0c3c3a87ad681e80ef15580c0d5bd4ff3", "rustc-1.37.0-x86_64-pc-windows-msvc": "790bdb5b57f397d7481151ad8715f7ac3f32b343efaf2922650f4fc6e374d7d7", "rustc-1.37.0-x86_64-unknown-freebsd": "a4dd357a0b39abf1ebbe8a0f64973c3b0c5bc527e374c12afe51266279fc1ca6", "rustc-1.37.0-x86_64-unknown-linux-gnu": "c759b318f333639a45f29c1551ca7ce55b1bf64e0fc3a3357d6b9356885d1626", "rustc-1.38.0-aarch64-unknown-linux-gnu": "0c787eaf01b5779b5a0c12bd0573901cf1b58e5e484ad44c3530b7ed51754d15", - "rustc-1.38.0-src": "644263ca7c7106f8ee8fcde6bb16910d246b30668a74be20b8c7e0e9f4a52d80", "rustc-1.38.0-x86_64-apple-darwin": "ac34aee5a5f67003b8f7f857ddb1fa68f89a32680a591ab77561282721b75256", "rustc-1.38.0-x86_64-pc-windows-msvc": "6e00ee5f34c552c1b9fafec3b7a1330140c820a2ae4bd4213d2c4f135341a88d", "rustc-1.38.0-x86_64-unknown-freebsd": "1d99318bbdc947c6dc375215f0eddcd767348c309811cd141e5d18e17d5aaaa4", "rustc-1.38.0-x86_64-unknown-linux-gnu": "790a611695fabd12c3a141efa58b3dc5913d749947c1a95d3f5b6eb5476ee612", "rustc-1.39.0-aarch64-unknown-linux-gnu": "c64fc482404277fdb160a4b593b0be5a1b0c32d985464595015295321d111621", - "rustc-1.39.0-src": "b4a1f6b6a93931f270691aba4fc85eee032fecda973e6b9c774cd06857609357", "rustc-1.39.0-x86_64-apple-darwin": "9347ffb47e936fb44666ada525f8bfb86758a719e7c0330e93e17bbd5f3623be", "rustc-1.39.0-x86_64-pc-windows-msvc": "9a94785fdb473079d02f32bded6691322688001dcc16f5bfb582c1d181d3ef67", "rustc-1.39.0-x86_64-unknown-freebsd": "3714bf7bd4163a3bfe18291d49acaeda02f4bf2beb9fe36c520d2ecdc29ca031", "rustc-1.39.0-x86_64-unknown-linux-gnu": "333399dbf96dd6b8a9dc9cc56b1cb5d8aac2296b4e4aa857bd59d906d6df6fa1", "rustc-1.40.0-aarch64-unknown-linux-gnu": "8981d500261ecfec93c4b52e8f96a81c705b56ff9317d63e0363d11a72ee09a0", - "rustc-1.40.0-src": "dd97005578defc10a482bff3e4e728350d2099c60ffcf1f5e189540c39a549ad", "rustc-1.40.0-x86_64-apple-darwin": "f45bb00a9a59ca819a8266e9de77f7232f4b704d64f1c45d3870e2db4f646a77", "rustc-1.40.0-x86_64-pc-windows-msvc": "16299638792b7bffb63ca20674a7196a33d1fb25e91083b90f8015be010eec19", "rustc-1.40.0-x86_64-unknown-freebsd": "65810804d3e4cf8f845978c6226f8e23d77a7ccf35ebafdd5f8dac027627f396", "rustc-1.40.0-x86_64-unknown-linux-gnu": "5085a26abdc932fd9339aab2078084f9ab654f8298ad9f301611ac41ba8eca19", "rustc-1.41.0-aarch64-unknown-linux-gnu": "9d994935f92088c968f520f558a88b140bb7d60e917fc4ad69019e2b830b1db7", - "rustc-1.41.0-src": "5546822c09944c4d847968e9b7b3d0e299f143f307c00fa40e84a99fabf8d74b", "rustc-1.41.0-x86_64-apple-darwin": "25ee8865e21007c282cd1f3457c3bf932591337c3044e55ba574fc988bead3ad", "rustc-1.41.0-x86_64-pc-windows-msvc": "b338afb534be113f179252f8de29195e201dcd8bf4053b1d5e8eef928c457ca3", "rustc-1.41.0-x86_64-unknown-freebsd": "de3386f79a0e261b8f6133dc0d5a7d51b70ad73dba5a14dd30204ac285d04f3a", "rustc-1.41.0-x86_64-unknown-linux-gnu": "531b4cc77cc25e960aafa2ebaee073c137fceb0004447c6b7274557281c62a6d", "rustc-1.42.0-aarch64-unknown-linux-gnu": "612c10793852fd0c2e52b30f3d50dd6aef6f8181032b820eddefc93e3bf4d97b", - "rustc-1.42.0-src": "d2e8f931d16a0539faaaacd801e0d92c58df190269014b2360c6ab2a90ee3475", "rustc-1.42.0-x86_64-apple-darwin": "778dea93d7e46261e2c06cadec35b68f9857604f279ce6fbd1b37c1a89634625", "rustc-1.42.0-x86_64-pc-windows-msvc": "d132f99df49cb0d421f6d8948a268d4eddb1ae23e0af2641272438998503708b", "rustc-1.42.0-x86_64-unknown-freebsd": "e6e36a7df9886b18cce32752f5ac7a8da6977c6a1878fae696340f3843176fe5", "rustc-1.42.0-x86_64-unknown-linux-gnu": "4242a728b850bf6e74db9a95c68e8ed316fa4813b38e6b8bc296396b5f47ea5a", "rustc-1.43.0-aarch64-unknown-linux-gnu": "99f26a2b4376fc08203d129d65e15f01b2630db40dd2d4d6a7b917df8d512e72", - "rustc-1.43.0-src": "75f6ac6c9da9f897f4634d5a07be4084692f7ccc2d2bb89337be86cfc18453a1", "rustc-1.43.0-x86_64-apple-darwin": "3723b8194e38d7238262b4cc49762a22037f53f58ab1df199c1d710dad5728a5", "rustc-1.43.0-x86_64-pc-windows-msvc": "c6d1aa60cf2056c4fb35a5a197fb4e1a42887eb4ad1615b00398524ff78ce74c", "rustc-1.43.0-x86_64-unknown-freebsd": "69d572e80e13da85599557f662ce71909823194c874eea0fe91f82da0958fa68", "rustc-1.43.0-x86_64-unknown-linux-gnu": "950b323044ae9a7932b697a2e4f4f62b59248f58faa320e22dc20f8ad9521f6b", "rustc-1.44.0-aarch64-unknown-linux-gnu": "b0fc4cee7119c10f79fe2701ca0d19ab738bd20954352ae5b1dcc4c6f432779a", - "rustc-1.44.0-src": "bf2df62317e533e84167c5bc7d4351a99fdab1f9cd6e6ba09f51996ad8561100", "rustc-1.44.0-x86_64-apple-darwin": "4fd09afcae85f656d4a545ee415e19546e03e34f1ca23be5eaa68c489e3186ab", "rustc-1.44.0-x86_64-pc-windows-msvc": "0b3aec27d86034cbadf4adbaf36308bcf98d97c0979d162ffccf4328fb4f96cd", "rustc-1.44.0-x86_64-unknown-freebsd": "6f3c4e16bbda8719e5c07dc687e84a7236e097da55c4fabea13ef1cbd6a30c40", "rustc-1.44.0-x86_64-unknown-linux-gnu": "52671652e7045df0702d8f2e8af60bf6f20da3e3a5db1aa6022bf9545e914449", "rustc-1.45.0-aarch64-unknown-linux-gnu": "b1ef2ea19142d851f2ee6936cd46a30ec8f157ba53048bc2748279d1e9e0ad17", - "rustc-1.45.0-src": "ba0495f12c7d4e8735f3fa9e036bfafd1ae58c26910393201e95b9d13c80cd7c", "rustc-1.45.0-x86_64-apple-darwin": "fd17d99c3e827f0b4f01b9122d4bf2fca0f1144827300a1eda93718d8642b39f", "rustc-1.45.0-x86_64-pc-windows-msvc": "f65fb383f2c6f979a19acbd4e099e6eea8addc0e76f1fd988582dfc0daa4a121", "rustc-1.45.0-x86_64-unknown-freebsd": "b5d263c53320f8a5dd5daceac1e60da172fd21614ada67f584565430d9d1c9c6", "rustc-1.45.0-x86_64-unknown-linux-gnu": "3ef2fcf818c133c3e9957441917b23ea536805efd0ff9ac6ee0bea349d703a90", "rustc-1.46.0-aarch64-unknown-linux-gnu": "41239ece19c79250a205e5b2fae60b242bba4bf72b687bccc88f011e66a872b6", - "rustc-1.46.0-src": "2d6a3b7196db474ba3f37b8f5d50a1ecedff00738d7846840605b42bfc922728", "rustc-1.46.0-x86_64-apple-darwin": "f690b375df7b1399e5baa69b64932e3e4a3f2b651e5ef2ebc85509bee777a9d9", "rustc-1.46.0-x86_64-pc-windows-msvc": "56badce580b65f59d676b20b4e5f138969e5039182b7f6052ac7da9d38bd0aca", "rustc-1.46.0-x86_64-unknown-freebsd": "e76d3e18d1826753395d881bc37be3d43e9ff8d2d34d49d7ed6105f228d56284", "rustc-1.46.0-x86_64-unknown-linux-gnu": "4c0c740cfb86047ae8131019597f26382a9b8c289eab2f21069f74a5a4976a26", "rustc-1.47.0-aarch64-unknown-linux-gnu": "2e143bfa59eca5c3f3e995c5997ae55c7defe824fb4dbe7e77896e132f42c24b", - "rustc-1.47.0-src": "3185df064c4747f2c8b9bb8c4468edd58ff4ad6d07880c879ac1b173b768d81d", "rustc-1.47.0-x86_64-apple-darwin": "4773ad46b912c859984f1e4466e506dd8102603d1ffcd8b63cfe7522f49e5987", "rustc-1.47.0-x86_64-pc-windows-msvc": "f2010e4500602d0efc431c0853692733415bedb58652376023d7d6ac204f8c7c", "rustc-1.47.0-x86_64-unknown-freebsd": "811f298c07fb32a6a01f9960f2d7dc403f6f288a3f475ed9806648e2cc5938ca", diff --git a/aspects.bzl b/rust/private/rust_analyzer.bzl similarity index 100% rename from aspects.bzl rename to rust/private/rust_analyzer.bzl diff --git a/util/fetch_shas.sh b/util/fetch_shas.sh index 8c938436f5..30cf15e228 100755 --- a/util/fetch_shas.sh +++ b/util/fetch_shas.sh @@ -14,13 +14,6 @@ BETA_ISO_DATES="$(cat ./util/fetch_shas_BETA_ISO_DATES.txt)" NIGHTLY_ISO_DATES="$(cat ./util/fetch_shas_NIGHTLY_ISO_DATES.txt)" RUSTFMT_VERSIONS="$(cat ./util/fetch_shas_RUSTFMT_VERSIONS.txt)" -enumerate_rust_src_keys() { - for VERSION in $VERSIONS - do - echo "rustc-$VERSION-src" - done -} - enumerate_keys() { for TOOL in $TOOLS do From 536cf28672118ac15a408079f5ddaea2609f1be7 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Wed, 25 Nov 2020 23:34:37 +0000 Subject: [PATCH 17/49] Refactor generation code --- rust/private/rust_analyzer.bzl | 135 +++++++++++++-------------------- rust/private/rustc.bzl | 2 +- rust/rust.bzl | 11 +++ 3 files changed, 64 insertions(+), 84 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index bedf908166..34010de07d 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -20,7 +20,7 @@ given targets. This file can be consumed by rust-analyzer as an alternative to Cargo.toml files. """ -load("@io_bazel_rules_rust//rust:private/rustc.bzl", "BuildInfo") +load("@io_bazel_rules_rust//rust:private/rustc.bzl", "BuildInfo", "CrateInfo") load("@io_bazel_rules_rust//rust:private/utils.bzl", "find_toolchain") # We support only these rule kinds. @@ -29,61 +29,23 @@ _rust_rules = [ "rust_binary", ] -RustTargetInfo = provider( - "RustTargetInfo holds rust crate metadata for targets", +RustAnalyzerInfo = provider( + "RustAnalyzerInfo holds rust crate metadata for targets", fields = { - "name": "target name", - "root": "crate root", - "edition": "edition", - "deps": "dependencies", - "transitive_deps": "closure of all transitive dependencies", - "cfgs": "compilation cfgs", - "env": "Environment variables, used for the `env!` macro", + "crate": "CrateInfo", + "deps": "List[RustAnalyzerInfo]: direct dependencies", + "transitive_deps": "List[RustAnalyzerInfo]: transitive closure of dependencies", + "cfgs": "List[String]: features or other compilation --cfg= settings", + "env": "Dict{String: String}: Environment variables, used for the `env!` macro", }, ) -# Gets the crate_root file from the context. -# If the file is not specified, find lib.rs or main.rs -# in a library or binary rule respectively. -def fetch_crate_root_file(ctx): - crate_root = ctx.rule.attr.crate_root - if not crate_root: - if len(ctx.rule.attr.srcs) == 1: - crate_root = ctx.rule.attr.srcs[0] - else: - for src in ctx.rule.attr.srcs: - file_name = src.label.name - crate_type = ctx.rule.attr.crate_type - if crate_type == "bin": - if file_name.endswith("main.rs"): - crate_root = src - break - elif crate_type in ("rlib", "dylib", "cdylib", "staticlib", "proc-macro"): - if file_name.endswith("lib.rs"): - crate_root = src - break - else: - print("MISSED CRATE TYPE: ", crate_type) - - # The rules are structured such that the crate_root path will always be - # the first element in the in the depset - return crate_root.files.to_list()[0].path - -def _rust_project_aspect_impl(target, ctx): - if ctx.rule.kind not in _rust_rules: +def _rust_analyzer_aspect_impl(target, ctx): + if CrateInfo not in target: return [] toolchain = find_toolchain(ctx) - # extract the crate_root path - edition = ctx.rule.attr.edition - if not edition: - edition = toolchain.default_edition - - crate_name = ctx.rule.attr.name - - crate_root = fetch_crate_root_file(ctx) - cfgs = [] for feature in ctx.rule.attr.crate_features: cfgs.append("feature=\"" + feature + "\"") @@ -94,80 +56,87 @@ def _rust_project_aspect_impl(target, ctx): cfgs.append(flag[6:]) env = {} + + # If one of our deps is a cargo_build_script, set OUT_DIR. for dep in ctx.rule.attr.deps: if BuildInfo in dep: env.update({ "OUT_DIR": "../" + dep[BuildInfo].out_dir.path, }) + + # Add rest of rustc_env env.update(ctx.rule.attr.rustc_env) - deps = [dep[RustTargetInfo] for dep in ctx.rule.attr.deps if RustTargetInfo in dep] - deps += [dep[RustTargetInfo] for dep in ctx.rule.attr.proc_macro_deps if RustTargetInfo in dep] - transitive_deps = depset( - direct = deps, - order = "postorder", - transitive = [dep.transitive_deps for dep in deps], - ) - - return [RustTargetInfo( - name = crate_name, - edition = edition, + deps = [dep[RustAnalyzerInfo] for dep in (ctx.rule.attr.deps + ctx.rule.attr.proc_macro_deps) if RustAnalyzerInfo in dep] + transitive_deps = depset(direct = deps, order = "postorder", transitive = [dep.transitive_deps for dep in deps]) + + return [RustAnalyzerInfo( + crate = target[CrateInfo], cfgs = cfgs, - root = crate_root, env = env, deps = deps, transitive_deps = transitive_deps, )] -rust_project_aspect = aspect( +rust_analyzer_aspect = aspect( attr_aspects = ["deps", "proc_macro_deps"], - implementation = _rust_project_aspect_impl, + implementation = _rust_analyzer_aspect_impl, toolchains = ["@io_bazel_rules_rust//rust:toolchain"], ) -def create_crate(ctx, target, crate_mapping): +def create_crate(ctx, info, crate_mapping): crate = dict() - crate["name"] = target.name - crate["edition"] = target.edition - if target.root.startswith("external"): - crate["root_module"] = ctx.attr.exec_root + "/" + target.root + crate["name"] = info.crate.name + crate["edition"] = info.crate.edition + if info.crate.root.path.startswith("external"): + crate["root_module"] = ctx.attr.exec_root + "/" + info.crate.root.path crate["is_workspace_member"] = False else: - crate["root_module"] = "../" + target.root + crate["root_module"] = "../" + info.crate.root.path crate["is_workspace_member"] = True deps = [] - for dep in target.deps: + for dep in info.deps: deps.append({ - "name": dep.name, - "crate": crate_mapping["ID-" + dep.root], + "name": dep.crate.name, + "crate": crate_mapping["ID-" + dep.crate.root.path], }) crate["deps"] = deps - crate["cfg"] = target.cfgs - crate["env"] = target.env - return "ID-" + target.root, crate - + crate["cfg"] = info.cfgs + crate["env"] = info.env + return "ID-" + info.crate.root.path, crate + +# This implementation is incomplete because in order to get rustc env vars we +# would need to actually execute the build graph and gather the output of +# cargo_build_script rules. This would require a genrule to actually construct +# the JSON, rather than being able to build it completly in starlark. +# TODO(djmarcin): Run the cargo_build_scripts to gather env vars correctly. def _rust_project_impl(ctx): - output = dict() rust_toolchain = find_toolchain(ctx) + crate_mapping = dict() + + output = dict() output["sysroot_src"] = ctx.attr.exec_root + "/" + rust_toolchain.rust_lib.label.workspace_root + "/library" output["crates"] = [] - crate_mapping = dict() - + # Gather all crates and their dependencies into an array. + # Dependencies are referenced by index, so leaves should come first. idx = 0 for target in ctx.attr.targets: - # Add our transitive dependencies - for dep in target[RustTargetInfo].transitive_deps.to_list(): - crate_id, crate = create_crate(ctx, dep, crate_mapping) + if RustAnalyzerInfo not in target: + continue + + # Add this crate's transitive deps to the crate mapping and output. + for dep_info in target[RustAnalyzerInfo].transitive_deps.to_list(): + crate_id, crate = create_crate(ctx, dep_info, crate_mapping) if crate_id not in crate_mapping: crate_mapping[crate_id] = idx idx += 1 output["crates"].append(crate) # Add this crate to the crate mapping and output. - crate_id, crate = create_crate(ctx, target[RustTargetInfo], crate_mapping) + crate_id, crate = create_crate(ctx, target[RustAnalyzerInfo], crate_mapping) if crate_id not in crate_mapping: crate_mapping[crate_id] = idx idx += 1 @@ -178,7 +147,7 @@ def _rust_project_impl(ctx): rust_analyzer = rule( attrs = { "targets": attr.label_list( - aspects = [rust_project_aspect], + aspects = [rust_analyzer_aspect], doc = "List of all targets to be included in the index", ), "exec_root": attr.string( diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 9284122dfb..8ae25ccaa2 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -65,7 +65,7 @@ AliasableDepInfo = provider( ) DepInfo = provider( - doc = "A provider contianing information about a Crate's dependencies.", + doc = "A provider containing information about a Crate's dependencies.", fields = { "direct_crates": "depset[CrateInfo]", "transitive_crates": "depset[CrateInfo]", diff --git a/rust/rust.bzl b/rust/rust.bzl index 862344c659..58e3582039 100644 --- a/rust/rust.bzl +++ b/rust/rust.bzl @@ -34,6 +34,11 @@ load( _rust_clippy = "rust_clippy", _rust_clippy_aspect = "rust_clippy_aspect", ) +load( + "@io_bazel_rules_rust//rust:private/rust_analyzer.bzl", + _rust_analyzer = "rust_analyzer", + _rust_analyzer_aspect = "rust_analyzer_aspect", +) rust_library = _rust_library # See @io_bazel_rules_rust//rust:private/rust.bzl for a complete description. @@ -61,3 +66,9 @@ rust_clippy_aspect = _rust_clippy_aspect rust_clippy = _rust_clippy # See @io_bazel_rules_rust//rust:private/clippy.bzl for a complete description. + +rust_analyzer_aspect = _rust_analyzer_aspect +# See @io_bazel_rules_rust//rust:private/rust_analyzer.bzl for a complete description. + +rust_analyzer = _rust_analyzer +# See @io_bazel_rules_rust//rust:private/rust_analyzer.bzl for a complete description. From 7ebab90e738d5961d1dafb47ffe9d2cb1d8ada15 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Thu, 26 Nov 2020 01:40:42 +0000 Subject: [PATCH 18/49] Keep rustc-src in a subdirectory --- rust/private/rust_analyzer.bzl | 12 +++++++++++- rust/repositories.bzl | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 34010de07d..77bb9a6077 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -85,6 +85,16 @@ rust_analyzer_aspect = aspect( ) def create_crate(ctx, info, crate_mapping): + """Creates a crate in the rust-project.json format + + Args: + ctx: The rule context from which the exec_root can be retrieved + info: The crate RustAnalyzerInfo for the current crate + crate_mapping: The mapping of crates to ids for dependency memoization + + Returns: + Tuple containing this crate's ID and the crate rust-project representation + """ crate = dict() crate["name"] = info.crate.name crate["edition"] = info.crate.edition @@ -117,7 +127,7 @@ def _rust_project_impl(ctx): crate_mapping = dict() output = dict() - output["sysroot_src"] = ctx.attr.exec_root + "/" + rust_toolchain.rust_lib.label.workspace_root + "/library" + output["sysroot_src"] = ctx.attr.exec_root + "/" + rust_toolchain.rust_lib.label.workspace_root + "/rustc-src/library" output["crates"] = [] # Gather all crates and their dependencies into an array. diff --git a/rust/repositories.bzl b/rust/repositories.bzl index 6bdaa9698d..f424389189 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -273,7 +273,7 @@ filegroup( name = "rustc_src", srcs = glob( [ - "**/*.rs", + "rustc-src/**/*.rs", ], ), visibility = ["//visibility:public"], @@ -532,7 +532,7 @@ def _load_rust_src(ctx): ) ctx.extract( archive_path, - output = "", + output = "rustc-src", stripPrefix = tool_path, ) return BUILD_for_rustc_src() From a5e2f9bc3244788ba83c80261e9ce72a6fe28bee Mon Sep 17 00:00:00 2001 From: David Marcin Date: Thu, 26 Nov 2020 08:24:59 +0000 Subject: [PATCH 19/49] Proc macro support and more standard src location --- rust/private/rust_analyzer.bzl | 38 +++++++++++++++++++++++++++------- rust/repositories.bzl | 4 ++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 77bb9a6077..e398b31cbc 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -22,6 +22,7 @@ to Cargo.toml files. load("@io_bazel_rules_rust//rust:private/rustc.bzl", "BuildInfo", "CrateInfo") load("@io_bazel_rules_rust//rust:private/utils.bzl", "find_toolchain") +load("//rust/platform:triple_mappings.bzl", "system_to_dylib_ext", "triple_to_system") # We support only these rule kinds. _rust_rules = [ @@ -37,6 +38,8 @@ RustAnalyzerInfo = provider( "transitive_deps": "List[RustAnalyzerInfo]: transitive closure of dependencies", "cfgs": "List[String]: features or other compilation --cfg= settings", "env": "Dict{String: String}: Environment variables, used for the `env!` macro", + "proc_macro_dylib_path": "File: compiled shared library output of proc-macro rule", + "build_info": "BuildInfo: build info for this crate if present" }, ) @@ -58,11 +61,10 @@ def _rust_analyzer_aspect_impl(target, ctx): env = {} # If one of our deps is a cargo_build_script, set OUT_DIR. + build_info = None for dep in ctx.rule.attr.deps: if BuildInfo in dep: - env.update({ - "OUT_DIR": "../" + dep[BuildInfo].out_dir.path, - }) + build_info = dep[BuildInfo] # Add rest of rustc_env env.update(ctx.rule.attr.rustc_env) @@ -70,12 +72,23 @@ def _rust_analyzer_aspect_impl(target, ctx): deps = [dep[RustAnalyzerInfo] for dep in (ctx.rule.attr.deps + ctx.rule.attr.proc_macro_deps) if RustAnalyzerInfo in dep] transitive_deps = depset(direct = deps, order = "postorder", transitive = [dep.transitive_deps for dep in deps]) + crate_info = target[CrateInfo] + proc_macro_dylib_path = None + if crate_info.type == "proc-macro": + dylib_ext = system_to_dylib_ext(triple_to_system(toolchain.target_triple)) + for action in target.actions: + for output in action.outputs.to_list(): + if '.' + output.extension == dylib_ext: + proc_macro_dylib_path = output.path + return [RustAnalyzerInfo( - crate = target[CrateInfo], + crate = crate_info, cfgs = cfgs, env = env, deps = deps, transitive_deps = transitive_deps, + proc_macro_dylib_path = proc_macro_dylib_path, + build_info = build_info, )] rust_analyzer_aspect = aspect( @@ -98,12 +111,19 @@ def create_crate(ctx, info, crate_mapping): crate = dict() crate["name"] = info.crate.name crate["edition"] = info.crate.edition + crate["env"] = {} + if info.crate.root.path.startswith("external"): - crate["root_module"] = ctx.attr.exec_root + "/" + info.crate.root.path crate["is_workspace_member"] = False + crate["root_module"] = ctx.attr.exec_root + "/" + info.crate.root.path else: - crate["root_module"] = "../" + info.crate.root.path crate["is_workspace_member"] = True + crate["root_module"] = "/home/vagrant/metawork/" + info.crate.root.path + # Set CARGO_MANIFEST_DIR for local workspace crates + crate["env"].update({ "CARGO_MANIFEST_DIR": "/home/vagrant/metawork/" + info.crate.root.dirname + "/../" }) + if info.build_info != None: + crate["env"].update({ "OUT_DIR": ctx.attr.exec_root + "/" + info.build_info.out_dir.path }) + crate["env"].update(info.env) deps = [] for dep in info.deps: @@ -114,7 +134,9 @@ def create_crate(ctx, info, crate_mapping): crate["deps"] = deps crate["cfg"] = info.cfgs - crate["env"] = info.env + crate["target"] = find_toolchain(ctx).target_triple + if info.proc_macro_dylib_path != None: + crate["proc_macro_dylib_path"] = ctx.attr.exec_root + "/" + info.proc_macro_dylib_path return "ID-" + info.crate.root.path, crate # This implementation is incomplete because in order to get rustc env vars we @@ -127,7 +149,7 @@ def _rust_project_impl(ctx): crate_mapping = dict() output = dict() - output["sysroot_src"] = ctx.attr.exec_root + "/" + rust_toolchain.rust_lib.label.workspace_root + "/rustc-src/library" + output["sysroot_src"] = ctx.attr.exec_root + "/" + rust_toolchain.rust_lib.label.workspace_root + "/lib/rustlib/src/library" output["crates"] = [] # Gather all crates and their dependencies into an array. diff --git a/rust/repositories.bzl b/rust/repositories.bzl index f424389189..941f941521 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -273,7 +273,7 @@ filegroup( name = "rustc_src", srcs = glob( [ - "rustc-src/**/*.rs", + "lib/rustlib/src/**/*.rs", ], ), visibility = ["//visibility:public"], @@ -532,7 +532,7 @@ def _load_rust_src(ctx): ) ctx.extract( archive_path, - output = "rustc-src", + output = "lib/rustlib/src", stripPrefix = tool_path, ) return BUILD_for_rustc_src() From 77f8c845b0be4509224606cd1d583d3562916aa7 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Thu, 26 Nov 2020 11:28:24 +0000 Subject: [PATCH 20/49] Fix include! macros --- rust/private/rust_analyzer.bzl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index e398b31cbc..8f57b3f3c7 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -39,7 +39,7 @@ RustAnalyzerInfo = provider( "cfgs": "List[String]: features or other compilation --cfg= settings", "env": "Dict{String: String}: Environment variables, used for the `env!` macro", "proc_macro_dylib_path": "File: compiled shared library output of proc-macro rule", - "build_info": "BuildInfo: build info for this crate if present" + "build_info": "BuildInfo: build info for this crate if present", }, ) @@ -78,7 +78,7 @@ def _rust_analyzer_aspect_impl(target, ctx): dylib_ext = system_to_dylib_ext(triple_to_system(toolchain.target_triple)) for action in target.actions: for output in action.outputs.to_list(): - if '.' + output.extension == dylib_ext: + if "." + output.extension == dylib_ext: proc_macro_dylib_path = output.path return [RustAnalyzerInfo( @@ -113,16 +113,26 @@ def create_crate(ctx, info, crate_mapping): crate["edition"] = info.crate.edition crate["env"] = {} - if info.crate.root.path.startswith("external"): + # Switch on external/ to determine if crates are in the workspace or remote. + # TODO: Some folks may want to override this for vendored dependencies. + if info.crate.root.path.startswith("external/"): crate["is_workspace_member"] = False crate["root_module"] = ctx.attr.exec_root + "/" + info.crate.root.path + crate_root = ctx.attr.exec_root + "/" + info.crate.root.dirname + "/../" else: crate["is_workspace_member"] = True - crate["root_module"] = "/home/vagrant/metawork/" + info.crate.root.path + crate["root_module"] = "../" + info.crate.root.path + crate_root = "../" + info.crate.root.dirname + "/../" + # Set CARGO_MANIFEST_DIR for local workspace crates - crate["env"].update({ "CARGO_MANIFEST_DIR": "/home/vagrant/metawork/" + info.crate.root.dirname + "/../" }) + crate["env"].update({"CARGO_MANIFEST_DIR": crate_root}) if info.build_info != None: - crate["env"].update({ "OUT_DIR": ctx.attr.exec_root + "/" + info.build_info.out_dir.path }) + crate["env"].update({"OUT_DIR": ctx.attr.exec_root + "/" + info.build_info.out_dir.path}) + crate["source"] = { + # We have to tell rust-analyzer about our out_dir since it's not under the crate root. + "include_dirs": [crate_root, ctx.attr.exec_root + "/" + info.build_info.out_dir.path], + "exclude_dirs": [], + } crate["env"].update(info.env) deps = [] From 1530692e01cd74296217ae95cdb43e8a2a07aad8 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Thu, 26 Nov 2020 11:58:07 +0000 Subject: [PATCH 21/49] revert extraneous clippy change --- rust/private/clippy.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/private/clippy.bzl b/rust/private/clippy.bzl index 4be8b30d87..7ce28119eb 100644 --- a/rust/private/clippy.bzl +++ b/rust/private/clippy.bzl @@ -87,7 +87,7 @@ def _clippy_aspect_impl(target, ctx): crate_info, dep_info, output_hash = determine_output_hash(root), - rust_flags = ["--error-format=json"], + rust_flags = [], out_dir = out_dir, build_env_file = build_env_file, build_flags_files = build_flags_files, From 8ab7fb3da598c6e82afdf447e2d6d5c606bde4b9 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Thu, 26 Nov 2020 11:58:29 +0000 Subject: [PATCH 22/49] Handle the rule at any depth in the workspace --- rust/private/rust_analyzer.bzl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 8f57b3f3c7..d74e89f6d7 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -120,9 +120,11 @@ def create_crate(ctx, info, crate_mapping): crate["root_module"] = ctx.attr.exec_root + "/" + info.crate.root.path crate_root = ctx.attr.exec_root + "/" + info.crate.root.dirname + "/../" else: + # Compute the number of ../ we need for relative paths. + rule_depth = ctx.build_file_path.count('/') + 1 crate["is_workspace_member"] = True - crate["root_module"] = "../" + info.crate.root.path - crate_root = "../" + info.crate.root.dirname + "/../" + crate["root_module"] = "../" * rule_depth + info.crate.root.path + crate_root = "../" * rule_depth + info.crate.root.dirname + "/../" # Set CARGO_MANIFEST_DIR for local workspace crates crate["env"].update({"CARGO_MANIFEST_DIR": crate_root}) From 9703cbbfdc0f0f7197e919e8d78d730ba1116adb Mon Sep 17 00:00:00 2001 From: David Marcin Date: Thu, 26 Nov 2020 11:59:50 +0000 Subject: [PATCH 23/49] revert extraneous changes --- rust/private/rustc.bzl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 8ae25ccaa2..e14705f078 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -750,16 +750,12 @@ def _create_extra_input_args(ctx, file, build_info, dep_info): build_flags_files = [] if build_info: - # print("BUILD INFO: ", build_info) out_dir = build_info.out_dir.path - # print("out_dir: ", out_dir) build_env_file = build_info.rustc_env.path - # print("build_env_file: ", build_env_file) build_flags_files.append(build_info.flags.path) build_flags_files.append(build_info.link_flags.path) input_files.append(build_info.out_dir) input_files.append(build_info.link_flags) - return input_files, out_dir, build_env_file, build_flags_files From a522e5de744031cd7845094948de9877a14fe5cd Mon Sep 17 00:00:00 2001 From: David Marcin Date: Thu, 26 Nov 2020 12:07:47 +0000 Subject: [PATCH 24/49] Remove CARGO_MANIFEST_DIR since it doesn't appear to work --- rust/private/rust_analyzer.bzl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index d74e89f6d7..3ff38602c9 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -121,13 +121,11 @@ def create_crate(ctx, info, crate_mapping): crate_root = ctx.attr.exec_root + "/" + info.crate.root.dirname + "/../" else: # Compute the number of ../ we need for relative paths. - rule_depth = ctx.build_file_path.count('/') + 1 + rule_depth = ctx.build_file_path.count("/") + 1 crate["is_workspace_member"] = True crate["root_module"] = "../" * rule_depth + info.crate.root.path crate_root = "../" * rule_depth + info.crate.root.dirname + "/../" - # Set CARGO_MANIFEST_DIR for local workspace crates - crate["env"].update({"CARGO_MANIFEST_DIR": crate_root}) if info.build_info != None: crate["env"].update({"OUT_DIR": ctx.attr.exec_root + "/" + info.build_info.out_dir.path}) crate["source"] = { From 0f487c97930fa814a4cf4b077409faeb34eb067a Mon Sep 17 00:00:00 2001 From: David Marcin Date: Thu, 26 Nov 2020 12:13:13 +0000 Subject: [PATCH 25/49] Fix example --- examples/hello_lib/BUILD | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/hello_lib/BUILD b/examples/hello_lib/BUILD index cafeb60279..acf6a6e17b 100644 --- a/examples/hello_lib/BUILD +++ b/examples/hello_lib/BUILD @@ -1,11 +1,11 @@ load( "@io_bazel_rules_rust//rust:rust.bzl", + "rust_analyzer", "rust_doc", "rust_doc_test", "rust_library", "rust_test", ) -load("@io_bazel_rules_rust//:aspects.bzl", "rust_analyzer") package(default_visibility = ["//visibility:public"]) @@ -89,6 +89,6 @@ rust_doc_test( rust_analyzer( name = "hello_rust_analyzer", - targets = [ ":hello_lib" ], - exec_root = "bazel-rules_rust" + exec_root = "bazel-rules_rust", + targets = [":hello_lib"], ) From 005d389dc8ed2d6b927dcc5c9419e18a448149b5 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Thu, 26 Nov 2020 18:14:50 +0000 Subject: [PATCH 26/49] update shas --- rust/known_shas.bzl | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/rust/known_shas.bzl b/rust/known_shas.bzl index ca7a1a2b2d..21f99086d9 100644 --- a/rust/known_shas.bzl +++ b/rust/known_shas.bzl @@ -18,6 +18,7 @@ FILE_KEY_TO_SHA = { "2018-10-30/rust-std-beta-x86_64-unknown-freebsd": "5aef62464a5580ab6b38c9e54203db12f90ad42de538b7a5eefc7778b55b6497", "2018-10-30/rust-std-beta-x86_64-unknown-linux-gnu": "34996a688d6a4c3587f873b0a8c86fe1d2fee2a269b6e669b1cb8c6908fb77b8", "2018-10-30/rustc-beta-aarch64-unknown-linux-gnu": "e6bb89261baa494ef98239bde9821b66671de5cd78352a9c100abce3a18ca250", + "2018-10-30/rustc-beta-src": "4dfc6db5f3cbe760c089d498b4190e49e778ac677c72f6bfc9325fc140f12483", "2018-10-30/rustc-beta-x86_64-apple-darwin": "22153f359b8b98341aa0349233112fff2b9f092988f9d678626207ba29666b5b", "2018-10-30/rustc-beta-x86_64-pc-windows-msvc": "9cd8225f1307aab95b439dbecd70aaa35e03c913ba0897dc7fe3a04755fc15b1", "2018-10-30/rustc-beta-x86_64-unknown-freebsd": "e207562cd5e3a17497e029bcb1cab56d9fa474d788906f13e389a3cb804ea4d6", @@ -44,6 +45,7 @@ FILE_KEY_TO_SHA = { "2018-11-01/rust-std-beta-x86_64-unknown-freebsd": "eed13a5c36c0731b01b8926f26be5b054c341a0487628fca688e8e99f33b200b", "2018-11-01/rust-std-beta-x86_64-unknown-linux-gnu": "f38a224bccfc89bd0d598764363271985d0b2696123ea10de6399c4cc7dd8adb", "2018-11-01/rustc-beta-aarch64-unknown-linux-gnu": "acf359a4cecfc827f5ca4255c0492d46223d09d535444f0b303678918944c87c", + "2018-11-01/rustc-beta-src": "b2723ad2ca3c643b60a7ea1f1f1184aa8af9f7c2570f199ff5971d47791b4145", "2018-11-01/rustc-beta-x86_64-apple-darwin": "64b5a5fc8b3dc348395137df2c422adbf483168c58af5cd9acc8522dd9b4392b", "2018-11-01/rustc-beta-x86_64-pc-windows-msvc": "71cbfd2793f6b55653f5ef4bdf0350dfe6d9b0952d518a3a355044ec7caa03c2", "2018-11-01/rustc-beta-x86_64-unknown-freebsd": "51a5370f1776229bede506e5ab05da7cfeb5bd21a5374561acb4b7138c75d508", @@ -70,6 +72,7 @@ FILE_KEY_TO_SHA = { "2018-11-02/rust-std-beta-x86_64-unknown-freebsd": "4661fdd15b5cee0fafd4c9cb085d0614abab0b2b1d62a55540b3d4d2634c4ba7", "2018-11-02/rust-std-beta-x86_64-unknown-linux-gnu": "3e2f68697620e501a9439bb7923f5676c82f7a4b4aaf822a141188c92619fe13", "2018-11-02/rustc-beta-aarch64-unknown-linux-gnu": "d703f1cdecd77aba85024db5e94f13e50c74e66af21091107c7cd67a3179da15", + "2018-11-02/rustc-beta-src": "a0610ac06b0d9655e5d46794cc9b5e6479e2f2f8a8aeb86472760b66b81b0366", "2018-11-02/rustc-beta-x86_64-apple-darwin": "199a0776ad4f1406b8b6f477d12c58858816f07246d52842384e1084d8c9000e", "2018-11-02/rustc-beta-x86_64-pc-windows-msvc": "a4fd3838f4459a151e83d540784953cd80c5a1a68fe3bf965399c1f07f6476bb", "2018-11-02/rustc-beta-x86_64-unknown-freebsd": "f931cb44b892dc3899c9379238d8f51d35c9503db9e93ce5700f3121712c9b62", @@ -96,6 +99,7 @@ FILE_KEY_TO_SHA = { "2018-11-07/rust-std-nightly-x86_64-unknown-freebsd": "ca648e7eb243cec32dc5a1b4e2fe6d67c2a00be56326e4d7aec9f2bbeb4dc138", "2018-11-07/rust-std-nightly-x86_64-unknown-linux-gnu": "bd8daba5c2d36e261da6f0ea8b5893e7fe94252eca7478d581c036fc1acb7c36", "2018-11-07/rustc-nightly-aarch64-unknown-linux-gnu": "11caf45fef229d85efb36cdbcf955d95fae648c27ca4ffd153bad316eb58793a", + "2018-11-07/rustc-nightly-src": "0b048ce086ce939964333aef3917de0f51a6dfb81b3b4ce846f98b439651f129", "2018-11-07/rustc-nightly-x86_64-apple-darwin": "cddecdb0d595cb8b944bf70b2284f557743f5637536f2181ad0036806cf56217", "2018-11-07/rustc-nightly-x86_64-pc-windows-msvc": "479f58f34616b83c003fa29e68ee84c91ee5521038f255a7cd3b597a2f5082d0", "2018-11-07/rustc-nightly-x86_64-unknown-freebsd": "47f81ec8c4ebbcd4e948033b5db72c1e9bec6f284fdaa5bdf59bcc92b075333f", @@ -122,6 +126,7 @@ FILE_KEY_TO_SHA = { "2018-11-08/rust-std-nightly-x86_64-unknown-freebsd": "64aabfec15a2b773c27892e58514161cb05ab370e3291beb1cafc7d270772389", "2018-11-08/rust-std-nightly-x86_64-unknown-linux-gnu": "efb8f6f6aa2c5a3f1c069e05b74fde6a85985837054faf3bc565d839902efedc", "2018-11-08/rustc-nightly-aarch64-unknown-linux-gnu": "494173aa705efeef4df2d88278608bd71b477183d85a670a577051c76c5ee99c", + "2018-11-08/rustc-nightly-src": "e95ffea78eb6e37a420ac14c50b5d6877af7005b181f5a05cca3d8c642325c64", "2018-11-08/rustc-nightly-x86_64-apple-darwin": "316e7727a136a82a20832a69b18f74add335e9b659fa7e0d8c7d12c0d11224b7", "2018-11-08/rustc-nightly-x86_64-pc-windows-msvc": "489cb54446374eccc78eca18aa86b4159d47fdfa7bab0ea9a20cb68fa4d80071", "2018-11-08/rustc-nightly-x86_64-unknown-freebsd": "874b7055e0cb609ce34d38456bda888865c63fcbc7abac5aad147f2a21a7d147", @@ -148,6 +153,7 @@ FILE_KEY_TO_SHA = { "2018-11-09/rust-std-nightly-x86_64-unknown-freebsd": "ab8a32d8efb0ab4686526c6cf1380161e87a89015464f5d5f5438c99723675c7", "2018-11-09/rust-std-nightly-x86_64-unknown-linux-gnu": "1418ba09f97c6ba91e2df5ba0b11cf1c53498710bc6a147fe8f4be455a96c4d8", "2018-11-09/rustc-nightly-aarch64-unknown-linux-gnu": "167fec713804d8af1fa4f543e79ca5cee259f1b966b8e04c99efba75901f4c8e", + "2018-11-09/rustc-nightly-src": "9341a72e1616ed0c7b81036f388cf4e87d49f748a09467f9366ab8d7e6d3e664", "2018-11-09/rustc-nightly-x86_64-apple-darwin": "55ca5ad85b0afd61a419e374f8e6320b4f4fe30f8092005cdec9e63103812ea7", "2018-11-09/rustc-nightly-x86_64-pc-windows-msvc": "dd19c5a4b209a9f46dd2f99eb7ec0898bd00accf1c6e8a97222c580bcf62e32a", "2018-11-09/rustc-nightly-x86_64-unknown-freebsd": "bd6bb0228aeab01f425cb2ad55b2e0409b43e79450c2830183a6878cc2d2bdc4", @@ -175,6 +181,7 @@ FILE_KEY_TO_SHA = { "2020-02-16/rust-std-nightly-x86_64-unknown-freebsd": "6575eabdfaed4b0490cdfffcbb5860036dcc36bebdabc58d839c088ff5556a6f", "2020-02-16/rust-std-nightly-x86_64-unknown-linux-gnu": "28a169e9b0f0986a50254caf14be863cf6f1ed3aec8342a7fa756dc1af76f38b", "2020-02-16/rustc-nightly-aarch64-unknown-linux-gnu": "e9cf265820f69331abc9a7c4da0c26febffd4017cf4e6d0840d4ed22b3dd332b", + "2020-02-16/rustc-nightly-src": "605e6753e606a23ce85bbf44566e9c66e8de5df492e3bab1029ea3c4c3c11c10", "2020-02-16/rustc-nightly-x86_64-apple-darwin": "db0338b3e1934147dce0bf6420d9c147caa6aef2db1aca44ca8fef47b7247615", "2020-02-16/rustc-nightly-x86_64-pc-windows-msvc": "d51440d4004e49670c5cf803f96aa222c68f09348bfca46f6e0d4c8728908065", "2020-02-16/rustc-nightly-x86_64-unknown-freebsd": "c76fa125e6d17b16a96b01a875d826f20849b09970b49ed1183601a0e7803f6f", @@ -206,6 +213,7 @@ FILE_KEY_TO_SHA = { "2020-11-10/rust-std-nightly-x86_64-unknown-linux-gnu": "367c14b7fbe98e264b0e4b5a9ddaf3f78ce3ce09bbef4c7be33a3f2abade9ad9", "2020-11-10/rustc-nightly-aarch64-apple-darwin": "a461f2486013b5cec450c8f79230e83878689b803a38df7304adea27b025ef1b", "2020-11-10/rustc-nightly-aarch64-unknown-linux-gnu": "900170006c4c2d88cadc0d915d410588cb80150817e53aa7fca41a459a5ec500", + "2020-11-10/rustc-nightly-src": "c8fb001c1e44e40cae30b7f098b069b7a65343dfa0159a224dc5329266bc59fd", "2020-11-10/rustc-nightly-x86_64-apple-darwin": "7a443dfb068bb7e3854dd6475564da33a57d3f225ce03ad8bc973e8900960b69", "2020-11-10/rustc-nightly-x86_64-pc-windows-msvc": "e7b325e55d372aaf4be400273673711fe78271b655c0b710d62a972b8044b9ef", "2020-11-10/rustc-nightly-x86_64-unknown-freebsd": "3ef55f82aefad5eac4398977d34b1963feb05b1cd654005d385da26624cb2f7e", @@ -619,151 +627,181 @@ FILE_KEY_TO_SHA = { "rust-std-1.47.0-x86_64-unknown-freebsd": "80f5dee782bd74b41c55a676c624ce2260ab54c834102c90ea54e0c5e7e513c6", "rust-std-1.47.0-x86_64-unknown-linux-gnu": "17ecad27d96b331608e4a96dfa3cad05ccb2ccecb888894ed35054e0d1f5207f", "rustc-1.26.0-aarch64-unknown-linux-gnu": "ddddaddb585b95d81854171ac4e02d07790505853cee3034f199c8b7897f32e2", + "rustc-1.26.0-src": "4fb09bc4e233b71dcbe08a37a3f38cabc32219745ec6a628b18a55a1232281dd", "rustc-1.26.0-x86_64-apple-darwin": "5cb67314656d16cf2a1bdc84213aaaf6afdb5811825c7afba916e2d42d3d641f", "rustc-1.26.0-x86_64-pc-windows-msvc": "427ae4a43a901be288ff3a4dc85d3a14f7e95108cfdaae63e8dbb4a227e07cdd", "rustc-1.26.0-x86_64-unknown-freebsd": "9499ce5b68d631f8345c387e1f59b21892d97e0acb5650deb61a34719310bd38", "rustc-1.26.0-x86_64-unknown-linux-gnu": "7ca9a30010602aaf2244c376a3cc5baa89429d54da17b8ba1cb0cdfdc846cc61", "rustc-1.26.1-aarch64-unknown-linux-gnu": "7a06bd5312cbe8bb19e526b4c9ab04de1628019815a566ce0ff9401515bc2c04", + "rustc-1.26.1-src": "70a7961bd8ec43b2c01e9896e90b0a06804a7fbe0a5c05acc7fd6fed19500df0", "rustc-1.26.1-x86_64-apple-darwin": "e5f4291c3709b170fbeb17fab7fae50fe0c626dbdc5c42ddb1f342ea03acbad4", "rustc-1.26.1-x86_64-pc-windows-msvc": "e84dca395837aa24b4ea87d46d06a333c2e87d0be5fc5259476a95fbcb05accc", "rustc-1.26.1-x86_64-unknown-freebsd": "dc3dc36010d73349152e6158522e82830fda173007b9299b0a947c90769c54ff", "rustc-1.26.1-x86_64-unknown-linux-gnu": "45bc1c30e0c473c42889f22b182ec6f0b0fc3be0825e1607c64933592486eb2a", "rustc-1.26.2-aarch64-unknown-linux-gnu": "b09fea72e259811fcbc6aade942329bc4588356470765987ee37d6108a82f7b6", + "rustc-1.26.2-src": "fb9ecf304488c9b56600ab20cfd1937482057f7e5db7899fddb86e0774548700", "rustc-1.26.2-x86_64-apple-darwin": "5b0a3d94a4fa76ed28859123e35c09a91d7eb8ff65f40ec4c50dfa56ffed8ae5", "rustc-1.26.2-x86_64-pc-windows-msvc": "15eb657747a86a4481501bb21e2dbcf56a06c0beea00e8677c86ef74b8812576", "rustc-1.26.2-x86_64-unknown-freebsd": "48f20a8dc6bc54c90aae685d0c3fa2caf3677f1c4a4d0c53aee9d15588bd0735", "rustc-1.26.2-x86_64-unknown-linux-gnu": "1ebdafe52b581a63cea217a036fd6e77706d2715ae9cfe10a8c715d753326004", "rustc-1.27.0-aarch64-unknown-linux-gnu": "b58c0373df43623adcc990d36190ee157f46f6fba650d0242632f3df2dfbc425", + "rustc-1.27.0-src": "2cb9803f690349c9fd429564d909ddd4676c68dc48b670b8ddf797c2613e2d21", "rustc-1.27.0-x86_64-apple-darwin": "0b00c6971ef524f68b911f621d199e60c339c390b18e12700d55e012b62aa90c", "rustc-1.27.0-x86_64-pc-windows-msvc": "22eeac4f4b4d91c28cf18c6a4a8b477091e6661e3e827c0b32355d52e634a517", "rustc-1.27.0-x86_64-unknown-freebsd": "24c193213450ffacffebdd1413d77fc3c1ed00049cf1ede2d0f3f370dd86b462", "rustc-1.27.0-x86_64-unknown-linux-gnu": "29f399a1a208ea3f27f21e57f2d832e9d801c397a986aaea17e3a2ddeded6c3c", "rustc-1.27.1-aarch64-unknown-linux-gnu": "c48d19ff5474ce75ebbb97e1b26ca8dc23d38f635ae7a3e21b8a4139df5cfb8e", + "rustc-1.27.1-src": "2133beb01ddc3aa09eebc769dd884533c6cfb08ce684f042497e097068d733d1", "rustc-1.27.1-x86_64-apple-darwin": "747f616e07e5da9323a21c1cf9d76b53bb46094a68223d461a7333f26c714f19", "rustc-1.27.1-x86_64-pc-windows-msvc": "76abfd523f876516e589f62a83eaaa6e55496745e32f2e9f3f87aca55da3e8b8", "rustc-1.27.1-x86_64-unknown-freebsd": "9b199c21094f996fd9d4b620a5ff2c4bc5b8dab13e96bdf7c113291f601ec944", "rustc-1.27.1-x86_64-unknown-linux-gnu": "a6bf6205b345b854d705d0028a4e7161a0f5b209e464130e7d135fa01a296dc1", "rustc-1.27.2-aarch64-unknown-linux-gnu": "c1a5ddc6e40be5eef7afad8c126c6f426d07eb1a297902c7ef871279fdbeea49", + "rustc-1.27.2-src": "9a818c50cdb7880abeaa68b3d97792711e6c64c1cdfb6efdc23f75b8ced0e15d", "rustc-1.27.2-x86_64-apple-darwin": "b5c5edd2094afd0a92ad776dbd12cb6ee37800b940437dece10229ccacd1f561", "rustc-1.27.2-x86_64-pc-windows-msvc": "c00dde7df7475340f5574b09c86d0e19f6707f838bf95d2ff463a8f4d4d76d33", "rustc-1.27.2-x86_64-unknown-freebsd": "66d739632574fa52e82b40aca0eb4cef7a38047ed67cd6a240d8798a3cf9b6a6", "rustc-1.27.2-x86_64-unknown-linux-gnu": "ec3efc17ddbe6625840957049e15ebae960f447c8e8feb7da40c28dd6adf655f", "rustc-1.28.0-aarch64-unknown-linux-gnu": "09d1fa08d7403495ca07565eaabfcbe6703e842b765a68d5110cf4e64e988476", + "rustc-1.28.0-src": "1d5a81729c6f23a0a23b584dd249e35abe9c6f7569cee967cc42b1758ecd6486", "rustc-1.28.0-x86_64-apple-darwin": "10a5bf35177508c72050149663ff679a770eafa8557c6be0052603ca1267ae4d", "rustc-1.28.0-x86_64-pc-windows-msvc": "39871017768fe779dbffaaff8696baf0788bb9c4d6c4caa3d2564e1153ab2199", "rustc-1.28.0-x86_64-unknown-freebsd": "5eeaa17844f87e59aab821dc98dd15a920df0d1d7da3ef5808d2c586331c92a7", "rustc-1.28.0-x86_64-unknown-linux-gnu": "008bb3d714544bc991594b29a98a154441914c4771007130361bbadfb54143d0", "rustc-1.29.0-aarch64-unknown-linux-gnu": "c7480c0b98ae84151ffa8cadcb06d1ed2a11a755b6619ac1b89e7c886e98b7ff", + "rustc-1.29.0-src": "a4eb34ffd47f76afe2abd813f398512d5a19ef00989d37306217c9c9ec2f61e9", "rustc-1.29.0-x86_64-apple-darwin": "3462ba7e841485f93251762ce0b36a3922830a1249e5d79d6d010ceb43e4ee3f", "rustc-1.29.0-x86_64-pc-windows-msvc": "b27c38cb60092e9cac8afc4ad760349821e6b068d986e13ad46233b9676ab35e", "rustc-1.29.0-x86_64-unknown-freebsd": "38f30c96f0fa7ebfe94cd2db57e9b99961feca0a09045dbc1e955404b5d7f40a", "rustc-1.29.0-x86_64-unknown-linux-gnu": "229c51d51efc239e6eb9b428795bb7f57309f11287705dcba4877d5e220102a0", "rustc-1.29.1-aarch64-unknown-linux-gnu": "784ea61ff852225be622141600c79621456f1ad9f9becdf7070eb0217b8635aa", + "rustc-1.29.1-src": "f1b0728b66ce6bce6d72bbe5ea9e3a24ea22a045665da2ed8fcdfad14f61a349", "rustc-1.29.1-x86_64-apple-darwin": "64b86c923786dfafe8bbb5fcbef0d854132f29f0bf635830cd2d95ff225d2317", "rustc-1.29.1-x86_64-pc-windows-msvc": "2675bf444df8fe900b84098917db3e765c87ad3c812ef2a818c7e622d77db457", "rustc-1.29.1-x86_64-unknown-freebsd": "ed9b2ccbfc6028ce2c73105cebebdb9f2e2332018c687951639176358bfed9a2", "rustc-1.29.1-x86_64-unknown-linux-gnu": "b99324394ba20bd12efa9d30dad72b10747bd075f97c7a9fd0ce3f9394383fa7", "rustc-1.29.2-aarch64-unknown-linux-gnu": "54a8c54f04dec72d7f8655ce1c3037dc23ded2f9ada26e7ea77aa45fc8b0d0c5", + "rustc-1.29.2-src": "5088e796aa2e47478cdf41e7243fc5443fafab0a7c70a11423e57c80c04167c9", "rustc-1.29.2-x86_64-apple-darwin": "d9c0dd8127ed632e27d751f051bca933578317ffe891e39155ae721bc1d3ec05", "rustc-1.29.2-x86_64-pc-windows-msvc": "53dcf97ed9461784d713c5a413df7e8e5aa4c9158a4d5921a038b77b17120a17", "rustc-1.29.2-x86_64-unknown-freebsd": "94fba7a7b88ca86c037a48376b7e09bb4ca66e1268fc8d664796cdbdee97c0fa", "rustc-1.29.2-x86_64-unknown-linux-gnu": "b04146b09edc4bad0de7c8fa1a5a2aa4416d365c03c5962b8a5b26c7047b7cc9", "rustc-1.30.0-aarch64-unknown-linux-gnu": "ccff6c6d8386655955265f586862314dd3b646bbeccd1369877f4343b1960a53", + "rustc-1.30.0-src": "cd0ba83fcca55b64c0c9f23130fe731dfc1882b73ae21bef96be8f2362c108ee", "rustc-1.30.0-x86_64-apple-darwin": "d4fcbc61c7323e6fa1001ae268c5db1693ff07e5ef1ac25907138a2ee7bd8faf", "rustc-1.30.0-x86_64-pc-windows-msvc": "2d2d1a51bb15794920a2f0cccf7fd2c8bfb037d00975e799ff4a4ac3b83032ce", "rustc-1.30.0-x86_64-unknown-freebsd": "68a74949e34118406673cf8cc0098b011907c840890e0640aa3b145ce91c521d", "rustc-1.30.0-x86_64-unknown-linux-gnu": "cc45058e9963d33ca28220e752d9e360b7e05f17e34284f5f8197738c3a88444", "rustc-1.30.1-aarch64-unknown-linux-gnu": "f3569c0a74f07aa2e56bf93c9f2aaddf7434ce17f85d6d6ff854fb9245888bcf", + "rustc-1.30.1-src": "36a38902dbd9a3e1240d46ab0f2ca40d2fd07c2ab6508ed7970c6c4c036b5b29", "rustc-1.30.1-x86_64-apple-darwin": "fd8ca09595e9d686aef9e3b94259500b482cf7a01de167a8c72a4f8d19a604f3", "rustc-1.30.1-x86_64-pc-windows-msvc": "8ad1551132de8c766d2d7c66d9bb93a959ebbfa7d86c47f196227fea914583dd", "rustc-1.30.1-x86_64-unknown-freebsd": "2f79e386bed201eb9b6ffa58240742617ec6006accb559dab7b6424f33b65b5f", "rustc-1.30.1-x86_64-unknown-linux-gnu": "d84de208499b59e4a3c074f9f3f2fcbb26fb20d6bfd19262e6d5f4181ddbe34d", "rustc-1.31.0-aarch64-unknown-linux-gnu": "1e480d8cadceff39ad39d30fe874bfd485386c98842f16423310cb2ada1923c0", + "rustc-1.31.0-src": "9ad54dc0baf1db5fc6a79d54e71c439c82aff85cd96778978456f2958211ef06", "rustc-1.31.0-x86_64-apple-darwin": "250fd3f3aba7d38c4af9682a12a37c733dbd6dde127665b0f493551e6c4aea8b", "rustc-1.31.0-x86_64-pc-windows-msvc": "418abc285870ab4d85d53769eac229cd66b7fc7cdaa6e73699530e88ee5dfaf4", "rustc-1.31.0-x86_64-unknown-freebsd": "9ec40454e22e3494b9859c03e37e8851077f897845bcf838d69d4393900e7b33", "rustc-1.31.0-x86_64-unknown-linux-gnu": "5c4581f0fc05f0f5076db6231b0c1a4d27eb61c0b36bfb42d97243ad8f4e43a0", "rustc-1.31.1-aarch64-unknown-linux-gnu": "315ea9c981e4320a557f6c75b58242c0598a90316f610b4dfef5d06e82b927f2", + "rustc-1.31.1-src": "91d2fc22f08d986adab7a54eb3a6a9b99e490f677d2d092e5b9e4e069c23686a", "rustc-1.31.1-x86_64-apple-darwin": "e3f9c5ccd0e6e09da8012f30ee9a1880efebc0c039cc1f3866cf50c984be16a7", "rustc-1.31.1-x86_64-pc-windows-msvc": "0320b7544de463d4444c6445fd2e23044e28fde1173f614145a72a4bcfc6ccd9", "rustc-1.31.1-x86_64-unknown-freebsd": "fb38ad94976c273c0fb95d0b5ba2d1ce90684e58fa06fafc9f8050ba00559f50", "rustc-1.31.1-x86_64-unknown-linux-gnu": "77d47ce7e27a146e4301f11befd43f3fc5ac195ace0dfc07ac8154f130b057ea", "rustc-1.32.0-aarch64-unknown-linux-gnu": "193cbe67161e20a0bf4eeb8bafeb302f3e61a59ca939a0454fc3fbc76e9524cc", + "rustc-1.32.0-src": "4c594c7712a0e7e8eae6526c464bf6ea1d82f77b4f61717c3fc28fb27ba2224a", "rustc-1.32.0-x86_64-apple-darwin": "0334c4568f09cae984e53e4a3f4ff207e2bcc50fce13ad32b8eca89f014e5e61", "rustc-1.32.0-x86_64-pc-windows-msvc": "a7799495d3032c5ad6b5f712f7d7a9538f695c6d8d2e5258c0f7aadac8cea1d4", "rustc-1.32.0-x86_64-unknown-freebsd": "a14a0e288be8ce894a85810151a2eb70fc86afa36e4a5fae4e903c744b888687", "rustc-1.32.0-x86_64-unknown-linux-gnu": "75c31f32e19548c1608611d08b82b87560e02f15caac7b2663a8189a4609977c", "rustc-1.33.0-aarch64-unknown-linux-gnu": "e23141cc65d1d8e3957a96f3a601bdb7a9d09026ac20396aeaebd2613ea0d08e", + "rustc-1.33.0-src": "5a01a8d7e65126f6079042831385e77485fa5c014bf217e9f3e4aff36a485d94", "rustc-1.33.0-x86_64-apple-darwin": "ea1f0a95015bbefba9eac5890b12ee2887f464822ab579c8bbc2db3023c6dd08", "rustc-1.33.0-x86_64-pc-windows-msvc": "b935a78d072b9ae91ff8ddf9155df95d77fd8a1c6293e39df3c65b18d860320e", "rustc-1.33.0-x86_64-unknown-freebsd": "8bfc7fc50c50294cf4ded35360b41b590180401a0d2e84256f5931c7c1ff35cd", "rustc-1.33.0-x86_64-unknown-linux-gnu": "54a342f718b712d8a17fd7878ebd37d22a82ebc70b59c421168cd4153fd04c2b", "rustc-1.34.0-aarch64-unknown-linux-gnu": "364328a40c7aa5749be80b13a14466149a559205e34aef3d8823dc2580f55921", + "rustc-1.34.0-src": "7ac85acffd79dd3a7c44305d9eaabd1f1e7116e2e6e11e770e4bf5f92c0f1f59", "rustc-1.34.0-x86_64-apple-darwin": "2044d44f01a8aa7fb3382f35fc839facfde4fc1eb6f951ead42aef954e317088", "rustc-1.34.0-x86_64-pc-windows-msvc": "371f9abd2bc615b339dfd606d93e6b4892594fd86084d513e07a9f80ff21a828", "rustc-1.34.0-x86_64-unknown-freebsd": "522662f147d0550e4f4f49026b4ebcc5e05a0935fa88acc9b99da5d7435755aa", "rustc-1.34.0-x86_64-unknown-linux-gnu": "5852e84dd30e4a552a7cd4d7c0172648d7ffb4d9ac7078871adbb902c183ffc2", "rustc-1.35.0-aarch64-unknown-linux-gnu": "dc06d77e6cdc06693d3b87ce473f151c96bda2c1e5dbba8c0354c54990c64fc2", + "rustc-1.35.0-src": "5a4d637a716bac18d085f44dd87ef48b32195f71b967d872d80280b38cff712d", "rustc-1.35.0-x86_64-apple-darwin": "5b2fb7581332f349c041860479ffdbfec0eebf87fc3016146836b8868afc3ae5", "rustc-1.35.0-x86_64-pc-windows-msvc": "df4f94d29d10fde2486d9fac3247a566d99a2b7f97fa6ebd416f308b804f7693", "rustc-1.35.0-x86_64-unknown-freebsd": "d3b5a6cfa41264e1873287bdb89892a7edc40333d581f468890c68336f50a601", "rustc-1.35.0-x86_64-unknown-linux-gnu": "bb3a07a1f2fdc3eeeee25fc40131d3f05494e3838dfd4e9275475ffc500d7a9e", "rustc-1.36.0-aarch64-unknown-linux-gnu": "62e40e0677032ae0cd91a7f8b4450dbaaf5223050a05b28a9174802d09691da6", + "rustc-1.36.0-src": "04c4e4d7213d036d6aaed392841496d272146312c0290f728b7400fccd15bb1b", "rustc-1.36.0-x86_64-apple-darwin": "97568272717ffa62dbf4459dff6086e69c808df252a912146e28468412667013", "rustc-1.36.0-x86_64-pc-windows-msvc": "4c131f68eac74bc20315eda097578c43de2b695445739462a4b273f90a131ffc", "rustc-1.36.0-x86_64-unknown-freebsd": "c2dd0cec49b054ed9439762fb31555b8df9a3d81747b194f7d3afbc6d8adb8de", "rustc-1.36.0-x86_64-unknown-linux-gnu": "7c149fa1695b41e8e1edcb95dca199522889f119be99f922741084d50470a9e5", "rustc-1.37.0-aarch64-unknown-linux-gnu": "721ba21dbe9b350a8c50a4c783c76ba3f6926525480518851dd6ba92ecdb042c", + "rustc-1.37.0-src": "120e7020d065499cc6b28759ff04153bfdc2ac9b5adeb252331a4eb87cbe38c3", "rustc-1.37.0-x86_64-apple-darwin": "00d4d15b4d9a4d188e0db8bbc17cd5f0c3c3a87ad681e80ef15580c0d5bd4ff3", "rustc-1.37.0-x86_64-pc-windows-msvc": "790bdb5b57f397d7481151ad8715f7ac3f32b343efaf2922650f4fc6e374d7d7", "rustc-1.37.0-x86_64-unknown-freebsd": "a4dd357a0b39abf1ebbe8a0f64973c3b0c5bc527e374c12afe51266279fc1ca6", "rustc-1.37.0-x86_64-unknown-linux-gnu": "c759b318f333639a45f29c1551ca7ce55b1bf64e0fc3a3357d6b9356885d1626", "rustc-1.38.0-aarch64-unknown-linux-gnu": "0c787eaf01b5779b5a0c12bd0573901cf1b58e5e484ad44c3530b7ed51754d15", + "rustc-1.38.0-src": "644263ca7c7106f8ee8fcde6bb16910d246b30668a74be20b8c7e0e9f4a52d80", "rustc-1.38.0-x86_64-apple-darwin": "ac34aee5a5f67003b8f7f857ddb1fa68f89a32680a591ab77561282721b75256", "rustc-1.38.0-x86_64-pc-windows-msvc": "6e00ee5f34c552c1b9fafec3b7a1330140c820a2ae4bd4213d2c4f135341a88d", "rustc-1.38.0-x86_64-unknown-freebsd": "1d99318bbdc947c6dc375215f0eddcd767348c309811cd141e5d18e17d5aaaa4", "rustc-1.38.0-x86_64-unknown-linux-gnu": "790a611695fabd12c3a141efa58b3dc5913d749947c1a95d3f5b6eb5476ee612", "rustc-1.39.0-aarch64-unknown-linux-gnu": "c64fc482404277fdb160a4b593b0be5a1b0c32d985464595015295321d111621", + "rustc-1.39.0-src": "b4a1f6b6a93931f270691aba4fc85eee032fecda973e6b9c774cd06857609357", "rustc-1.39.0-x86_64-apple-darwin": "9347ffb47e936fb44666ada525f8bfb86758a719e7c0330e93e17bbd5f3623be", "rustc-1.39.0-x86_64-pc-windows-msvc": "9a94785fdb473079d02f32bded6691322688001dcc16f5bfb582c1d181d3ef67", "rustc-1.39.0-x86_64-unknown-freebsd": "3714bf7bd4163a3bfe18291d49acaeda02f4bf2beb9fe36c520d2ecdc29ca031", "rustc-1.39.0-x86_64-unknown-linux-gnu": "333399dbf96dd6b8a9dc9cc56b1cb5d8aac2296b4e4aa857bd59d906d6df6fa1", "rustc-1.40.0-aarch64-unknown-linux-gnu": "8981d500261ecfec93c4b52e8f96a81c705b56ff9317d63e0363d11a72ee09a0", + "rustc-1.40.0-src": "dd97005578defc10a482bff3e4e728350d2099c60ffcf1f5e189540c39a549ad", "rustc-1.40.0-x86_64-apple-darwin": "f45bb00a9a59ca819a8266e9de77f7232f4b704d64f1c45d3870e2db4f646a77", "rustc-1.40.0-x86_64-pc-windows-msvc": "16299638792b7bffb63ca20674a7196a33d1fb25e91083b90f8015be010eec19", "rustc-1.40.0-x86_64-unknown-freebsd": "65810804d3e4cf8f845978c6226f8e23d77a7ccf35ebafdd5f8dac027627f396", "rustc-1.40.0-x86_64-unknown-linux-gnu": "5085a26abdc932fd9339aab2078084f9ab654f8298ad9f301611ac41ba8eca19", "rustc-1.41.0-aarch64-unknown-linux-gnu": "9d994935f92088c968f520f558a88b140bb7d60e917fc4ad69019e2b830b1db7", + "rustc-1.41.0-src": "5546822c09944c4d847968e9b7b3d0e299f143f307c00fa40e84a99fabf8d74b", "rustc-1.41.0-x86_64-apple-darwin": "25ee8865e21007c282cd1f3457c3bf932591337c3044e55ba574fc988bead3ad", "rustc-1.41.0-x86_64-pc-windows-msvc": "b338afb534be113f179252f8de29195e201dcd8bf4053b1d5e8eef928c457ca3", "rustc-1.41.0-x86_64-unknown-freebsd": "de3386f79a0e261b8f6133dc0d5a7d51b70ad73dba5a14dd30204ac285d04f3a", "rustc-1.41.0-x86_64-unknown-linux-gnu": "531b4cc77cc25e960aafa2ebaee073c137fceb0004447c6b7274557281c62a6d", "rustc-1.42.0-aarch64-unknown-linux-gnu": "612c10793852fd0c2e52b30f3d50dd6aef6f8181032b820eddefc93e3bf4d97b", + "rustc-1.42.0-src": "d2e8f931d16a0539faaaacd801e0d92c58df190269014b2360c6ab2a90ee3475", "rustc-1.42.0-x86_64-apple-darwin": "778dea93d7e46261e2c06cadec35b68f9857604f279ce6fbd1b37c1a89634625", "rustc-1.42.0-x86_64-pc-windows-msvc": "d132f99df49cb0d421f6d8948a268d4eddb1ae23e0af2641272438998503708b", "rustc-1.42.0-x86_64-unknown-freebsd": "e6e36a7df9886b18cce32752f5ac7a8da6977c6a1878fae696340f3843176fe5", "rustc-1.42.0-x86_64-unknown-linux-gnu": "4242a728b850bf6e74db9a95c68e8ed316fa4813b38e6b8bc296396b5f47ea5a", "rustc-1.43.0-aarch64-unknown-linux-gnu": "99f26a2b4376fc08203d129d65e15f01b2630db40dd2d4d6a7b917df8d512e72", + "rustc-1.43.0-src": "75f6ac6c9da9f897f4634d5a07be4084692f7ccc2d2bb89337be86cfc18453a1", "rustc-1.43.0-x86_64-apple-darwin": "3723b8194e38d7238262b4cc49762a22037f53f58ab1df199c1d710dad5728a5", "rustc-1.43.0-x86_64-pc-windows-msvc": "c6d1aa60cf2056c4fb35a5a197fb4e1a42887eb4ad1615b00398524ff78ce74c", "rustc-1.43.0-x86_64-unknown-freebsd": "69d572e80e13da85599557f662ce71909823194c874eea0fe91f82da0958fa68", "rustc-1.43.0-x86_64-unknown-linux-gnu": "950b323044ae9a7932b697a2e4f4f62b59248f58faa320e22dc20f8ad9521f6b", "rustc-1.44.0-aarch64-unknown-linux-gnu": "b0fc4cee7119c10f79fe2701ca0d19ab738bd20954352ae5b1dcc4c6f432779a", + "rustc-1.44.0-src": "bf2df62317e533e84167c5bc7d4351a99fdab1f9cd6e6ba09f51996ad8561100", "rustc-1.44.0-x86_64-apple-darwin": "4fd09afcae85f656d4a545ee415e19546e03e34f1ca23be5eaa68c489e3186ab", "rustc-1.44.0-x86_64-pc-windows-msvc": "0b3aec27d86034cbadf4adbaf36308bcf98d97c0979d162ffccf4328fb4f96cd", "rustc-1.44.0-x86_64-unknown-freebsd": "6f3c4e16bbda8719e5c07dc687e84a7236e097da55c4fabea13ef1cbd6a30c40", "rustc-1.44.0-x86_64-unknown-linux-gnu": "52671652e7045df0702d8f2e8af60bf6f20da3e3a5db1aa6022bf9545e914449", "rustc-1.45.0-aarch64-unknown-linux-gnu": "b1ef2ea19142d851f2ee6936cd46a30ec8f157ba53048bc2748279d1e9e0ad17", + "rustc-1.45.0-src": "ba0495f12c7d4e8735f3fa9e036bfafd1ae58c26910393201e95b9d13c80cd7c", "rustc-1.45.0-x86_64-apple-darwin": "fd17d99c3e827f0b4f01b9122d4bf2fca0f1144827300a1eda93718d8642b39f", "rustc-1.45.0-x86_64-pc-windows-msvc": "f65fb383f2c6f979a19acbd4e099e6eea8addc0e76f1fd988582dfc0daa4a121", "rustc-1.45.0-x86_64-unknown-freebsd": "b5d263c53320f8a5dd5daceac1e60da172fd21614ada67f584565430d9d1c9c6", "rustc-1.45.0-x86_64-unknown-linux-gnu": "3ef2fcf818c133c3e9957441917b23ea536805efd0ff9ac6ee0bea349d703a90", "rustc-1.46.0-aarch64-unknown-linux-gnu": "41239ece19c79250a205e5b2fae60b242bba4bf72b687bccc88f011e66a872b6", + "rustc-1.46.0-src": "2d6a3b7196db474ba3f37b8f5d50a1ecedff00738d7846840605b42bfc922728", "rustc-1.46.0-x86_64-apple-darwin": "f690b375df7b1399e5baa69b64932e3e4a3f2b651e5ef2ebc85509bee777a9d9", "rustc-1.46.0-x86_64-pc-windows-msvc": "56badce580b65f59d676b20b4e5f138969e5039182b7f6052ac7da9d38bd0aca", "rustc-1.46.0-x86_64-unknown-freebsd": "e76d3e18d1826753395d881bc37be3d43e9ff8d2d34d49d7ed6105f228d56284", "rustc-1.46.0-x86_64-unknown-linux-gnu": "4c0c740cfb86047ae8131019597f26382a9b8c289eab2f21069f74a5a4976a26", "rustc-1.47.0-aarch64-unknown-linux-gnu": "2e143bfa59eca5c3f3e995c5997ae55c7defe824fb4dbe7e77896e132f42c24b", + "rustc-1.47.0-src": "3185df064c4747f2c8b9bb8c4468edd58ff4ad6d07880c879ac1b173b768d81d", "rustc-1.47.0-x86_64-apple-darwin": "4773ad46b912c859984f1e4466e506dd8102603d1ffcd8b63cfe7522f49e5987", "rustc-1.47.0-x86_64-pc-windows-msvc": "f2010e4500602d0efc431c0853692733415bedb58652376023d7d6ac204f8c7c", "rustc-1.47.0-x86_64-unknown-freebsd": "811f298c07fb32a6a01f9960f2d7dc403f6f288a3f475ed9806648e2cc5938ca", From d1d8bef694b04638c0c862eb4444bbe6b50a93ac Mon Sep 17 00:00:00 2001 From: David Marcin Date: Fri, 27 Nov 2020 19:43:33 +0000 Subject: [PATCH 27/49] Update documentation --- docs/BUILD | 8 ++++++++ docs/all.bzl | 6 ++++++ rust/private/rust_analyzer.bzl | 15 +++++++++------ rust/repositories.bzl | 4 ++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/docs/BUILD b/docs/BUILD index ee56918102..741944fadb 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -63,6 +63,14 @@ PAGES = { "rust_workspace": [ "rust_workspace", ], + "rust_clippy": [ + "rust_clippy", + "rust_clippy_aspect", + ], + "rust_analyzer": [ + "rust_analyzer", + "rust_analyzer_aspect", + ] } [ diff --git a/docs/all.bzl b/docs/all.bzl index c0e3f20cf0..ea304d7bb4 100644 --- a/docs/all.bzl +++ b/docs/all.bzl @@ -40,6 +40,8 @@ load( _rust_doc_test = "rust_doc_test", _rust_library = "rust_library", _rust_test = "rust_test", + _rust_clippy = "rust_clippy", + _rust_analyzer = "rust_analyzer", ) load( "@io_bazel_rules_rust//rust:toolchain.bzl", @@ -86,3 +88,7 @@ rust_toolchain_repository = _rust_toolchain_repository rust_toolchain_repository_proxy = _rust_toolchain_repository_proxy rust_workspace = _rust_workspace + +rust_clippy = _rust_clippy +rust_analyzer = _rust_analyzer + diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 3ff38602c9..1c2c09f728 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -31,12 +31,12 @@ _rust_rules = [ ] RustAnalyzerInfo = provider( - "RustAnalyzerInfo holds rust crate metadata for targets", + doc = "RustAnalyzerInfo holds rust crate metadata for targets", fields = { "crate": "CrateInfo", "deps": "List[RustAnalyzerInfo]: direct dependencies", "transitive_deps": "List[RustAnalyzerInfo]: transitive closure of dependencies", - "cfgs": "List[String]: features or other compilation --cfg= settings", + "cfgs": "List[String]: features or other compilation --cfg settings", "env": "Dict{String: String}: Environment variables, used for the `env!` macro", "proc_macro_dylib_path": "File: compiled shared library output of proc-macro rule", "build_info": "BuildInfo: build info for this crate if present", @@ -55,7 +55,7 @@ def _rust_analyzer_aspect_impl(target, ctx): for flag in ctx.rule.attr.rustc_flags: # --cfg flags should be passed as well but as an atomic # config, not key/value - if flag.startswith("--cfg"): + if flag.startswith("--cfg ") or flag.startswith("--cfg="): cfgs.append(flag[6:]) env = {} @@ -95,15 +95,16 @@ rust_analyzer_aspect = aspect( attr_aspects = ["deps", "proc_macro_deps"], implementation = _rust_analyzer_aspect_impl, toolchains = ["@io_bazel_rules_rust//rust:toolchain"], + doc = "Annotates rust rules with RustAnalyzerInfo later used to build a rust-project.json" ) def create_crate(ctx, info, crate_mapping): """Creates a crate in the rust-project.json format Args: - ctx: The rule context from which the exec_root can be retrieved - info: The crate RustAnalyzerInfo for the current crate - crate_mapping: The mapping of crates to ids for dependency memoization + ctx (ctx): The rule context from which the exec_root can be retrieved + info (RustAnalyzerInfo): The crate RustAnalyzerInfo for the current crate + crate_mapping (dict): A dict of {String:Int} that memoizes crates for deps. Returns: Tuple containing this crate's ID and the crate rust-project representation @@ -184,6 +185,7 @@ def _rust_project_impl(ctx): idx += 1 output["crates"].append(crate) + # TODO(djmarcin): Use json module once bazel 4.0 is released. ctx.actions.write(output = ctx.outputs.filename, content = struct(**output).to_json()) rust_analyzer = rule( @@ -202,4 +204,5 @@ rust_analyzer = rule( }, implementation = _rust_project_impl, toolchains = ["@io_bazel_rules_rust//rust:toolchain"], + doc = "Produces a rust-project.json for the given targets. Configure rust-analyzer to load the generated file via the linked projects mechanism." ) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index 941f941521..fd3f0289bd 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -515,9 +515,9 @@ def _load_rust_src(ctx): """Loads the rust source code. Used by the rust-analyzer rust-project.json generator. Args: - ctx: A repository_ctx. + ctx: A repository_ctx. Returns: - The BUILD file contents for this compiler and compiler library + The BUILD file contents for this compiler and compiler library """ tool_suburl = produce_tool_suburl("rustc", "src", ctx.attr.version, ctx.attr.iso_date) static_rust = ctx.os.environ["STATIC_RUST_URL"] if "STATIC_RUST_URL" in ctx.os.environ else "https://static.rust-lang.org" From dfcabb621668fc06aad6d3fabf1a6dd48ae2d4e7 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Fri, 27 Nov 2020 20:00:23 +0000 Subject: [PATCH 28/49] Regenerate documentation --- docs/cargo_build_script.md | 2 +- docs/flatten.md | 83 +++++++++++++++++++++++++++++++++++++- docs/rust_analyzer.md | 24 +++++++++++ docs/rust_clippy.md | 58 ++++++++++++++++++++++++++ docs/rust_repositories.md | 3 +- 5 files changed, 166 insertions(+), 4 deletions(-) create mode 100644 docs/rust_analyzer.md create mode 100644 docs/rust_clippy.md diff --git a/docs/cargo_build_script.md b/docs/cargo_build_script.md index 2032918747..7918d8341a 100644 --- a/docs/cargo_build_script.md +++ b/docs/cargo_build_script.md @@ -80,7 +80,7 @@ The `hello_lib` target will be build with the flags and the environment variable | deps | The dependencies of the crate defined by crate_name. | [] | | build_script_env | Environment variables for build scripts. | {} | | data | Files or tools needed by the build script. | [] | -| links |

-

| None | +| links | Name of the native library this crate links against. | None | | kwargs | Forwards to the underlying rust_binary rule. | none | diff --git a/docs/flatten.md b/docs/flatten.md index 3bb0c4e4ab..d10ff8324a 100644 --- a/docs/flatten.md +++ b/docs/flatten.md @@ -1,11 +1,15 @@ # Rust rules * [cargo_build_script](#cargo_build_script) +* [rust_analyzer](#rust_analyzer) +* [rust_analyzer_aspect](#rust_analyzer_aspect) * [rust_benchmark](#rust_benchmark) * [rust_binary](#rust_binary) * [rust_bindgen](#rust_bindgen) * [rust_bindgen_library](#rust_bindgen_library) * [rust_bindgen_toolchain](#rust_bindgen_toolchain) +* [rust_clippy](#rust_clippy) +* [rust_clippy_aspect](#rust_clippy_aspect) * [rust_doc](#rust_doc) * [rust_doc_test](#rust_doc_test) * [rust_grpc_library](#rust_grpc_library) @@ -23,6 +27,26 @@ * [rust_workspace](#rust_workspace) + + +## rust_analyzer + +
+rust_analyzer(name, exec_root, targets)
+
+ +Produces a rust-project.json for the given targets. Configure rust-analyzer to load the generated file via the linked projects mechanism. + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| exec_root | Execution root of Bazel as returned by 'bazel info execution_root'. | String | required | | +| targets | List of all targets to be included in the index | List of labels | optional | [] | + + ## rust_benchmark @@ -290,6 +314,60 @@ The tools required for the `rust_bindgen` rule. | rustfmt | The label of a rustfmt executable. If this is provided, generated sources will be formatted. | Label | optional | None | + + +## rust_clippy + +
+rust_clippy(name, deps)
+
+ +Executes the clippy checker on a specific target. + +Similar to `rust_clippy_aspect`, but allows specifying a list of dependencies within the build system. + +For example, given the following example targets: + +```python +package(default_visibility = ["//visibility:public"]) + +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library", "rust_test") + +rust_library( + name = "hello_lib", + srcs = ["src/lib.rs"], +) + +rust_test( + name = "greeting_test", + srcs = ["tests/greeting.rs"], + deps = [":hello_lib"], +) +``` + +Rust clippy can be set as a build target with the following: + +```python +rust_clippy( + name = "hello_library_clippy", + testonly = True, + deps = [ + ":hello_lib", + ":greeting_test", + ], +) +``` + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| deps | - | List of labels | optional | [] | + + ## rust_doc @@ -804,7 +882,7 @@ Run the test with `bazel build //hello_lib:hello_lib_test`.
 rust_toolchain(name, binary_ext, cargo, clippy_driver, debug_info, default_edition, dylib_ext,
-               exec_triple, opt_level, os, rust_doc, rust_lib, rustc, rustc_lib, rustfmt,
+               exec_triple, opt_level, os, rust_doc, rust_lib, rustc, rustc_lib, rustc_src, rustfmt,
                staticlib_ext, stdlib_linkflags, target_triple)
 
@@ -868,6 +946,7 @@ See @io_bazel_rules_rust//rust:repositories.bzl for examples of defining the @ru | rust_lib | The rust standard library. | Label | optional | None | | rustc | The location of the rustc binary. Can be a direct source or a filegroup containing one item. | Label | optional | None | | rustc_lib | The libraries used by rustc during compilation. | Label | optional | None | +| rustc_src | The source code of rustc. | Label | optional | None | | rustfmt | The location of the rustfmt binary. Can be a direct source or a filegroup containing one item. | Label | optional | None | | staticlib_ext | The extension for static libraries created from rustc. | String | required | | | stdlib_linkflags | Additional linker libs used when std lib is linked, see https://github.com/rust-lang/rust/blob/master/src/libstd/build.rs | List of strings | required | | @@ -1045,7 +1124,7 @@ The `hello_lib` target will be build with the flags and the environment variable | deps | The dependencies of the crate defined by crate_name. | [] | | build_script_env | Environment variables for build scripts. | {} | | data | Files or tools needed by the build script. | [] | -| links |

-

| None | +| links | Name of the native library this crate links against. | None | | kwargs | Forwards to the underlying rust_binary rule. | none | diff --git a/docs/rust_analyzer.md b/docs/rust_analyzer.md new file mode 100644 index 0000000000..94a99246c9 --- /dev/null +++ b/docs/rust_analyzer.md @@ -0,0 +1,24 @@ +# Rust rules +* [rust_analyzer](#rust_analyzer) +* [rust_analyzer_aspect](#rust_analyzer_aspect) + + + +## rust_analyzer + +
+rust_analyzer(name, exec_root, targets)
+
+ +Produces a rust-project.json for the given targets. Configure rust-analyzer to load the generated file via the linked projects mechanism. + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| exec_root | Execution root of Bazel as returned by 'bazel info execution_root'. | String | required | | +| targets | List of all targets to be included in the index | List of labels | optional | [] | + + diff --git a/docs/rust_clippy.md b/docs/rust_clippy.md new file mode 100644 index 0000000000..5d6b9127ed --- /dev/null +++ b/docs/rust_clippy.md @@ -0,0 +1,58 @@ +# Rust rules +* [rust_clippy](#rust_clippy) +* [rust_clippy_aspect](#rust_clippy_aspect) + + + +## rust_clippy + +
+rust_clippy(name, deps)
+
+ +Executes the clippy checker on a specific target. + +Similar to `rust_clippy_aspect`, but allows specifying a list of dependencies within the build system. + +For example, given the following example targets: + +```python +package(default_visibility = ["//visibility:public"]) + +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library", "rust_test") + +rust_library( + name = "hello_lib", + srcs = ["src/lib.rs"], +) + +rust_test( + name = "greeting_test", + srcs = ["tests/greeting.rs"], + deps = [":hello_lib"], +) +``` + +Rust clippy can be set as a build target with the following: + +```python +rust_clippy( + name = "hello_library_clippy", + testonly = True, + deps = [ + ":hello_lib", + ":greeting_test", + ], +) +``` + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| deps | - | List of labels | optional | [] | + + diff --git a/docs/rust_repositories.md b/docs/rust_repositories.md index d38d5e8b12..7c28b0ecbf 100644 --- a/docs/rust_repositories.md +++ b/docs/rust_repositories.md @@ -11,7 +11,7 @@
 rust_toolchain(name, binary_ext, cargo, clippy_driver, debug_info, default_edition, dylib_ext,
-               exec_triple, opt_level, os, rust_doc, rust_lib, rustc, rustc_lib, rustfmt,
+               exec_triple, opt_level, os, rust_doc, rust_lib, rustc, rustc_lib, rustc_src, rustfmt,
                staticlib_ext, stdlib_linkflags, target_triple)
 
@@ -75,6 +75,7 @@ See @io_bazel_rules_rust//rust:repositories.bzl for examples of defining the @ru | rust_lib | The rust standard library. | Label | optional | None | | rustc | The location of the rustc binary. Can be a direct source or a filegroup containing one item. | Label | optional | None | | rustc_lib | The libraries used by rustc during compilation. | Label | optional | None | +| rustc_src | The source code of rustc. | Label | optional | None | | rustfmt | The location of the rustfmt binary. Can be a direct source or a filegroup containing one item. | Label | optional | None | | staticlib_ext | The extension for static libraries created from rustc. | String | required | | | stdlib_linkflags | Additional linker libs used when std lib is linked, see https://github.com/rust-lang/rust/blob/master/src/libstd/build.rs | List of strings | required | | From 28fd0b08a269f3142eb08082d82b5c20278fc88e Mon Sep 17 00:00:00 2001 From: David Marcin Date: Wed, 2 Dec 2020 20:47:21 +0000 Subject: [PATCH 29/49] Provide a utility binary to fill exec-root automatically --- examples/hello_lib/BUILD | 1 - rust/private/rust_analyzer.bzl | 24 +++++------ tools/analyzer/BUILD | 10 +++++ tools/analyzer/main.rs | 73 ++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 16 deletions(-) create mode 100644 tools/analyzer/BUILD create mode 100644 tools/analyzer/main.rs diff --git a/examples/hello_lib/BUILD b/examples/hello_lib/BUILD index acf6a6e17b..3e3d323e94 100644 --- a/examples/hello_lib/BUILD +++ b/examples/hello_lib/BUILD @@ -89,6 +89,5 @@ rust_doc_test( rust_analyzer( name = "hello_rust_analyzer", - exec_root = "bazel-rules_rust", targets = [":hello_lib"], ) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 1c2c09f728..2f2b96333a 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -102,7 +102,7 @@ def create_crate(ctx, info, crate_mapping): """Creates a crate in the rust-project.json format Args: - ctx (ctx): The rule context from which the exec_root can be retrieved + ctx (ctx): The rule context info (RustAnalyzerInfo): The crate RustAnalyzerInfo for the current crate crate_mapping (dict): A dict of {String:Int} that memoizes crates for deps. @@ -118,20 +118,18 @@ def create_crate(ctx, info, crate_mapping): # TODO: Some folks may want to override this for vendored dependencies. if info.crate.root.path.startswith("external/"): crate["is_workspace_member"] = False - crate["root_module"] = ctx.attr.exec_root + "/" + info.crate.root.path - crate_root = ctx.attr.exec_root + "/" + info.crate.root.dirname + "/../" + crate["root_module"] = "__EXEC_ROOT__/" + info.crate.root.path + crate_root = "__EXEC_ROOT__/" + info.crate.root.dirname + "/../" else: - # Compute the number of ../ we need for relative paths. - rule_depth = ctx.build_file_path.count("/") + 1 crate["is_workspace_member"] = True - crate["root_module"] = "../" * rule_depth + info.crate.root.path - crate_root = "../" * rule_depth + info.crate.root.dirname + "/../" + crate["root_module"] = info.crate.root.path + crate_root = info.crate.root.dirname + "/../" if info.build_info != None: - crate["env"].update({"OUT_DIR": ctx.attr.exec_root + "/" + info.build_info.out_dir.path}) + crate["env"].update({"OUT_DIR": "__EXEC_ROOT__/" + info.build_info.out_dir.path}) crate["source"] = { # We have to tell rust-analyzer about our out_dir since it's not under the crate root. - "include_dirs": [crate_root, ctx.attr.exec_root + "/" + info.build_info.out_dir.path], + "include_dirs": [crate_root, "__EXEC_ROOT__/" + info.build_info.out_dir.path], "exclude_dirs": [], } crate["env"].update(info.env) @@ -147,7 +145,7 @@ def create_crate(ctx, info, crate_mapping): crate["cfg"] = info.cfgs crate["target"] = find_toolchain(ctx).target_triple if info.proc_macro_dylib_path != None: - crate["proc_macro_dylib_path"] = ctx.attr.exec_root + "/" + info.proc_macro_dylib_path + crate["proc_macro_dylib_path"] = "__EXEC_ROOT__/" + info.proc_macro_dylib_path return "ID-" + info.crate.root.path, crate # This implementation is incomplete because in order to get rustc env vars we @@ -160,7 +158,7 @@ def _rust_project_impl(ctx): crate_mapping = dict() output = dict() - output["sysroot_src"] = ctx.attr.exec_root + "/" + rust_toolchain.rust_lib.label.workspace_root + "/lib/rustlib/src/library" + output["sysroot_src"] = "__EXEC_ROOT__/" + rust_toolchain.rust_lib.label.workspace_root + "/lib/rustlib/src/library" output["crates"] = [] # Gather all crates and their dependencies into an array. @@ -194,10 +192,6 @@ rust_analyzer = rule( aspects = [rust_analyzer_aspect], doc = "List of all targets to be included in the index", ), - "exec_root": attr.string( - mandatory = True, - doc = "Execution root of Bazel as returned by 'bazel info execution_root'.", - ), }, outputs = { "filename": "rust-project.json", diff --git a/tools/analyzer/BUILD b/tools/analyzer/BUILD new file mode 100644 index 0000000000..f76fe13a25 --- /dev/null +++ b/tools/analyzer/BUILD @@ -0,0 +1,10 @@ +load( + "@io_bazel_rules_rust//rust:rust.bzl", + "rust_binary", +) + +rust_binary( + name = "analyzer", + srcs = ["main.rs"], + visibility = ["//visibility:public"], +) diff --git a/tools/analyzer/main.rs b/tools/analyzer/main.rs new file mode 100644 index 0000000000..0acdf3ded7 --- /dev/null +++ b/tools/analyzer/main.rs @@ -0,0 +1,73 @@ +use std::env; +use std::fs; +use std::path::PathBuf; +use std::process::Command; + +// TODO(david): This shells out to an expected rule in the workspace root //:rust_analyzer that the user must define. +// It would be more convenient if it could automatically discover all the rust code in the workspace if this target does not exist. +fn main() { + let repo_root = workspace_dir().expect( + "Could not determine workspace, are you running inside a directory with WORKSPACE?", + ); + let bazel_command = env::var("BAZEL_COMMAND").unwrap_or_else(|_| "bazel".into()); + let analyzer_target = + env::var("BAZEL_ANALYZER_TARGET").unwrap_or_else(|_| "//:rust_analyzer".into()); + + env::set_current_dir(&repo_root).expect( + format!( + "could not access workspace directory: {}", + repo_root.to_string_lossy() + ) + .as_str(), + ); + let output = Command::new(bazel_command) + .arg("build") + .arg(&analyzer_target) + .output() + .expect("failed to execute bazel process"); + if !output.status.success() { + panic!( + "bazel build failed:({}) of {}:\n{}", + output.status, + analyzer_target, + std::str::from_utf8(&output.stderr).unwrap() + ); + } + + let generated_rust_project = repo_root.join("bazel-bin/rust-project.json"); + let workspace_rust_project = repo_root.join("rust-project.json"); + let canonical_exec_root = fs::canonicalize(repo_root.join(format!( + "bazel-{}", + repo_root.file_name().unwrap().to_string_lossy() + ))) + .expect("could not canonicalize exec_root"); + + // The generated_rust_project has a template string we must replace with the workspace name. + let generated_json = fs::read_to_string(&generated_rust_project) + .expect("failed to read generated rust-project.json"); + + // It's OK if the file doesn't exist. + let _ = fs::remove_file(&workspace_rust_project); + fs::write( + workspace_rust_project, + generated_json.replace("__EXEC_ROOT__", &canonical_exec_root.to_string_lossy()), + ) + .expect("failed to write workspace rust-project.json"); +} + +fn workspace_dir() -> Option { + if let Ok(ws_dir) = env::var("BUILD_WORKSPACE_DIRECTORY") { + Some(PathBuf::from(ws_dir)) + } else { + let mut maybe_cwd = env::current_dir().ok(); + while let Some(cwd) = maybe_cwd { + let mut workspace_path = cwd.clone(); + workspace_path.push("WORKSPACE"); + if workspace_path.is_file() { + return Some(PathBuf::from(cwd)); + } + maybe_cwd = cwd.parent().map(PathBuf::from); + } + None + } +} From eca1cd94d8fe3aff68e1f35f67e09ec501ea8b34 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Wed, 2 Dec 2020 23:03:30 +0000 Subject: [PATCH 30/49] Add type annotations and fix comment --- rust/repositories.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index fd3f0289bd..d3655a2ef9 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -515,9 +515,9 @@ def _load_rust_src(ctx): """Loads the rust source code. Used by the rust-analyzer rust-project.json generator. Args: - ctx: A repository_ctx. + ctx (ctx): A repository_ctx. Returns: - The BUILD file contents for this compiler and compiler library + string: The BUILD file contents for the rust source code """ tool_suburl = produce_tool_suburl("rustc", "src", ctx.attr.version, ctx.attr.iso_date) static_rust = ctx.os.environ["STATIC_RUST_URL"] if "STATIC_RUST_URL" in ctx.os.environ else "https://static.rust-lang.org" From 4926725d8070b634010658dd38024c13e3a19ca3 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Fri, 4 Dec 2020 01:18:13 +0000 Subject: [PATCH 31/49] Regenerate documentation --- docs/flatten.md | 4 ++-- docs/rust_analyzer.md | 3 +-- docs/rust_workspace.md | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 docs/rust_workspace.md diff --git a/docs/flatten.md b/docs/flatten.md index e34fe5b9df..a3abe1b57f 100644 --- a/docs/flatten.md +++ b/docs/flatten.md @@ -24,6 +24,7 @@ * [rust_toolchain_repository_proxy](#rust_toolchain_repository_proxy) * [rust_wasm_bindgen](#rust_wasm_bindgen) * [rust_wasm_bindgen_toolchain](#rust_wasm_bindgen_toolchain) +* [rust_workspace](#rust_workspace) @@ -31,7 +32,7 @@ ## rust_analyzer
-rust_analyzer(name, exec_root, targets)
+rust_analyzer(name, targets)
 
Produces a rust-project.json for the given targets. Configure rust-analyzer to load the generated file via the linked projects mechanism. @@ -42,7 +43,6 @@ Produces a rust-project.json for the given targets. Configure rust-analyzer to l | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | -| exec_root | Execution root of Bazel as returned by 'bazel info execution_root'. | String | required | | | targets | List of all targets to be included in the index | List of labels | optional | [] | diff --git a/docs/rust_analyzer.md b/docs/rust_analyzer.md index 94a99246c9..c632956bdb 100644 --- a/docs/rust_analyzer.md +++ b/docs/rust_analyzer.md @@ -7,7 +7,7 @@ ## rust_analyzer
-rust_analyzer(name, exec_root, targets)
+rust_analyzer(name, targets)
 
Produces a rust-project.json for the given targets. Configure rust-analyzer to load the generated file via the linked projects mechanism. @@ -18,7 +18,6 @@ Produces a rust-project.json for the given targets. Configure rust-analyzer to l | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | -| exec_root | Execution root of Bazel as returned by 'bazel info execution_root'. | String | required | | | targets | List of all targets to be included in the index | List of labels | optional | [] | diff --git a/docs/rust_workspace.md b/docs/rust_workspace.md new file mode 100644 index 0000000000..8030da4ff8 --- /dev/null +++ b/docs/rust_workspace.md @@ -0,0 +1,3 @@ +# Rust rules +* [rust_workspace](#rust_workspace) + From fa42c63c47f58227e5e1bcbf2160ca558b503242 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Mon, 7 Dec 2020 19:37:57 +0000 Subject: [PATCH 32/49] review comments --- rust/private/rust_analyzer.bzl | 87 +++++++++++++++++----------------- rust/repositories.bzl | 4 +- tools/analyzer/main.rs | 7 ++- 3 files changed, 51 insertions(+), 47 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 2f2b96333a..ca0419c9f4 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -49,26 +49,17 @@ def _rust_analyzer_aspect_impl(target, ctx): toolchain = find_toolchain(ctx) - cfgs = [] - for feature in ctx.rule.attr.crate_features: - cfgs.append("feature=\"" + feature + "\"") - for flag in ctx.rule.attr.rustc_flags: - # --cfg flags should be passed as well but as an atomic - # config, not key/value - if flag.startswith("--cfg ") or flag.startswith("--cfg="): - cfgs.append(flag[6:]) - - env = {} - - # If one of our deps is a cargo_build_script, set OUT_DIR. + cfgs = ['feature="{}"'.format(f) for f in ctx.rule.attr.crate_features] + + # --cfg flags should be passed as well but as an atomic config, not key/value + cfgs += [f[6:] for f in ctx.rule.attr.rustc_flags if f.startswith("--cfg ") or f.startswith("--cfg=")] + + # Save BuildInfo if we find any (for build script output) build_info = None for dep in ctx.rule.attr.deps: if BuildInfo in dep: build_info = dep[BuildInfo] - # Add rest of rustc_env - env.update(ctx.rule.attr.rustc_env) - deps = [dep[RustAnalyzerInfo] for dep in (ctx.rule.attr.deps + ctx.rule.attr.proc_macro_deps) if RustAnalyzerInfo in dep] transitive_deps = depset(direct = deps, order = "postorder", transitive = [dep.transitive_deps for dep in deps]) @@ -78,13 +69,13 @@ def _rust_analyzer_aspect_impl(target, ctx): dylib_ext = system_to_dylib_ext(triple_to_system(toolchain.target_triple)) for action in target.actions: for output in action.outputs.to_list(): - if "." + output.extension == dylib_ext: + if output.extension == dylib_ext[1:]: proc_macro_dylib_path = output.path return [RustAnalyzerInfo( crate = crate_info, cfgs = cfgs, - env = env, + env = ctx.rule.attr.rustc_env, deps = deps, transitive_deps = transitive_deps, proc_macro_dylib_path = proc_macro_dylib_path, @@ -95,9 +86,19 @@ rust_analyzer_aspect = aspect( attr_aspects = ["deps", "proc_macro_deps"], implementation = _rust_analyzer_aspect_impl, toolchains = ["@io_bazel_rules_rust//rust:toolchain"], - doc = "Annotates rust rules with RustAnalyzerInfo later used to build a rust-project.json" + doc = "Annotates rust rules with RustAnalyzerInfo later used to build a rust-project.json", ) +_exec_root_tmpl = '__EXEC_ROOT__/' + +def _crate_id(crate_info): + '''Returns a unique stable identifier for a crate + + Returns: + (string): This crate's unique stable id. + ''' + return "ID-" + crate_info.root.path + def create_crate(ctx, info, crate_mapping): """Creates a crate in the rust-project.json format @@ -107,10 +108,10 @@ def create_crate(ctx, info, crate_mapping): crate_mapping (dict): A dict of {String:Int} that memoizes crates for deps. Returns: - Tuple containing this crate's ID and the crate rust-project representation + (dict) The crate rust-project.json representation """ crate = dict() - crate["name"] = info.crate.name + crate["display_name"] = info.crate.name crate["edition"] = info.crate.edition crate["env"] = {} @@ -118,35 +119,32 @@ def create_crate(ctx, info, crate_mapping): # TODO: Some folks may want to override this for vendored dependencies. if info.crate.root.path.startswith("external/"): crate["is_workspace_member"] = False - crate["root_module"] = "__EXEC_ROOT__/" + info.crate.root.path - crate_root = "__EXEC_ROOT__/" + info.crate.root.dirname + "/../" + crate["root_module"] = _exec_root_tmpl + info.crate.root.path + crate_root = _exec_root_tmpl + info.crate.root.dirname + "/../" else: crate["is_workspace_member"] = True crate["root_module"] = info.crate.root.path crate_root = info.crate.root.dirname + "/../" if info.build_info != None: - crate["env"].update({"OUT_DIR": "__EXEC_ROOT__/" + info.build_info.out_dir.path}) + crate["env"].update({"OUT_DIR": _exec_root_tmpl + info.build_info.out_dir.path}) crate["source"] = { # We have to tell rust-analyzer about our out_dir since it's not under the crate root. - "include_dirs": [crate_root, "__EXEC_ROOT__/" + info.build_info.out_dir.path], + "include_dirs": [crate_root, _exec_root_tmpl + info.build_info.out_dir.path], "exclude_dirs": [], } crate["env"].update(info.env) - deps = [] - for dep in info.deps: - deps.append({ - "name": dep.crate.name, - "crate": crate_mapping["ID-" + dep.crate.root.path], - }) - + deps = [ + {"name": d.crate.name, "crate": crate_mapping[_crate_id(info.crate)]} + for d in info.deps + ] crate["deps"] = deps crate["cfg"] = info.cfgs crate["target"] = find_toolchain(ctx).target_triple if info.proc_macro_dylib_path != None: - crate["proc_macro_dylib_path"] = "__EXEC_ROOT__/" + info.proc_macro_dylib_path - return "ID-" + info.crate.root.path, crate + crate["proc_macro_dylib_path"] = _exec_root_tmpl + info.proc_macro_dylib_path + return crate # This implementation is incomplete because in order to get rustc env vars we # would need to actually execute the build graph and gather the output of @@ -155,14 +153,12 @@ def create_crate(ctx, info, crate_mapping): # TODO(djmarcin): Run the cargo_build_scripts to gather env vars correctly. def _rust_project_impl(ctx): rust_toolchain = find_toolchain(ctx) - crate_mapping = dict() - - output = dict() - output["sysroot_src"] = "__EXEC_ROOT__/" + rust_toolchain.rust_lib.label.workspace_root + "/lib/rustlib/src/library" - output["crates"] = [] + sysroot_src = _exec_root_tmpl + rust_toolchain.rust_lib.label.workspace_root + "/lib/rustlib/src/library" # Gather all crates and their dependencies into an array. # Dependencies are referenced by index, so leaves should come first. + crates = [] + crate_mapping = dict() idx = 0 for target in ctx.attr.targets: if RustAnalyzerInfo not in target: @@ -170,21 +166,24 @@ def _rust_project_impl(ctx): # Add this crate's transitive deps to the crate mapping and output. for dep_info in target[RustAnalyzerInfo].transitive_deps.to_list(): - crate_id, crate = create_crate(ctx, dep_info, crate_mapping) + crate_id = _crate_id(dep_info.crate) if crate_id not in crate_mapping: crate_mapping[crate_id] = idx idx += 1 - output["crates"].append(crate) + crates.append(create_crate(ctx, dep_info, crate_mapping)) # Add this crate to the crate mapping and output. - crate_id, crate = create_crate(ctx, target[RustAnalyzerInfo], crate_mapping) + crate_id = _crate_id(target[RustAnalyzerInfo].crate) if crate_id not in crate_mapping: crate_mapping[crate_id] = idx idx += 1 - output["crates"].append(crate) + crates.append(create_crate(ctx, target[RustAnalyzerInfo], crate_mapping)) # TODO(djmarcin): Use json module once bazel 4.0 is released. - ctx.actions.write(output = ctx.outputs.filename, content = struct(**output).to_json()) + ctx.actions.write(output = ctx.outputs.filename, content = struct( + sysroot_src = sysroot_src, + crates = crates, + ).to_json()) rust_analyzer = rule( attrs = { @@ -198,5 +197,5 @@ rust_analyzer = rule( }, implementation = _rust_project_impl, toolchains = ["@io_bazel_rules_rust//rust:toolchain"], - doc = "Produces a rust-project.json for the given targets. Configure rust-analyzer to load the generated file via the linked projects mechanism." + doc = "Produces a rust-project.json for the given targets. Configure rust-analyzer to load the generated file via the linked projects mechanism.", ) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index d3655a2ef9..ae4e9f35f5 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -452,7 +452,7 @@ def load_arbitrary_tool(ctx, tool_name, tool_subdirectories, version, iso_date, # N.B. See https://static.rust-lang.org/dist/index.html to find the tool_suburl for a given # tool. tool_suburl = produce_tool_suburl(tool_name, target_triple, version, iso_date) - static_rust = ctx.os.environ["STATIC_RUST_URL"] if "STATIC_RUST_URL" in ctx.os.environ else "https://static.rust-lang.org" + static_rust = ctx.os.environ.get("STATIC_RUST_URL", "https://static.rust-lang.org") url = "{}/dist/{}.tar.gz".format(static_rust, tool_suburl) tool_path = produce_tool_path(tool_name, target_triple, version) @@ -520,7 +520,7 @@ def _load_rust_src(ctx): string: The BUILD file contents for the rust source code """ tool_suburl = produce_tool_suburl("rustc", "src", ctx.attr.version, ctx.attr.iso_date) - static_rust = ctx.os.environ["STATIC_RUST_URL"] if "STATIC_RUST_URL" in ctx.os.environ else "https://static.rust-lang.org" + static_rust = ctx.os.environ.get("STATIC_RUST_URL", "https://static.rust-lang.org") url = "{}/dist/{}.tar.gz".format(static_rust, tool_suburl) tool_path = produce_tool_path("rustc", "src", ctx.attr.version) diff --git a/tools/analyzer/main.rs b/tools/analyzer/main.rs index 0acdf3ded7..0bbf644b57 100644 --- a/tools/analyzer/main.rs +++ b/tools/analyzer/main.rs @@ -1,5 +1,6 @@ use std::env; use std::fs; +use std::io::ErrorKind; use std::path::PathBuf; use std::process::Command; @@ -47,7 +48,11 @@ fn main() { .expect("failed to read generated rust-project.json"); // It's OK if the file doesn't exist. - let _ = fs::remove_file(&workspace_rust_project); + match fs::remove_file(&workspace_rust_project) { + Ok(_) => {} + Err(err) if err.kind() == ErrorKind::NotFound => {}, + Err(_) => panic!("Unexpected error removing old rust-project.json"), + } fs::write( workspace_rust_project, generated_json.replace("__EXEC_ROOT__", &canonical_exec_root.to_string_lossy()), From b573ffb7fdbd7dd77a764dc38ae022abcb150bd8 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Mon, 7 Dec 2020 23:16:16 +0000 Subject: [PATCH 33/49] Update shas --- rust/known_shas.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/known_shas.bzl b/rust/known_shas.bzl index 8e9b85d8c7..aa1b729157 100644 --- a/rust/known_shas.bzl +++ b/rust/known_shas.bzl @@ -824,6 +824,7 @@ FILE_KEY_TO_SHA = { "rustc-1.47.0-x86_64-unknown-freebsd": "811f298c07fb32a6a01f9960f2d7dc403f6f288a3f475ed9806648e2cc5938ca", "rustc-1.47.0-x86_64-unknown-linux-gnu": "d96be0ae1deada01f41372ab2c2f485a9f8625069aeaff33c5b513061e9706d4", "rustc-1.48.0-aarch64-unknown-linux-gnu": "9c83a5d18f6ca913eeffd78c53913da288b171ff245137b646a8fd280fe72340", + "rustc-1.48.0-src": "0e763e6db47d5d6f91583284d2f989eacc49b84794d1443355b85c58d67ae43b", "rustc-1.48.0-x86_64-apple-darwin": "846f45f9bd6676e9d1f6758279b48e32564ba23773e69aa89692dbc123dbea5a", "rustc-1.48.0-x86_64-pc-windows-msvc": "395b2a8e6824b3e56a8a9b4598273be5410b4ea64e92c8aeaf900d9ff21f470f", "rustc-1.48.0-x86_64-unknown-freebsd": "fbaff313c2423f1ababc9792332560ca0e3749abf3749e7eb5289bc6515d9424", From 049ee0c879ca089ac6e00e7908c72f81a35ebc66 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Tue, 8 Dec 2020 00:07:05 +0000 Subject: [PATCH 34/49] Fix typo --- rust/private/rust_analyzer.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index ca0419c9f4..e67dfe7ccb 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -136,7 +136,7 @@ def create_crate(ctx, info, crate_mapping): crate["env"].update(info.env) deps = [ - {"name": d.crate.name, "crate": crate_mapping[_crate_id(info.crate)]} + {"name": d.crate.name, "crate": crate_mapping[_crate_id(d.crate)]} for d in info.deps ] crate["deps"] = deps From 226cc95f5d2cf6cd624fa3b37b124b2fbd9beb76 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Tue, 8 Dec 2020 02:33:29 +0000 Subject: [PATCH 35/49] Always add test and debug_assertions cfg values --- rust/private/rust_analyzer.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index e67dfe7ccb..f11d6c76d8 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -49,9 +49,9 @@ def _rust_analyzer_aspect_impl(target, ctx): toolchain = find_toolchain(ctx) - cfgs = ['feature="{}"'.format(f) for f in ctx.rule.attr.crate_features] - - # --cfg flags should be passed as well but as an atomic config, not key/value + # Always add test & debug_assertions (like here: https://github.com/rust-analyzer/rust-analyzer/blob/505ff4070a3de962dbde66f08b6550cda2eb4eab/crates/project_model/src/lib.rs#L379-L381) + cfgs = ["test", "debug_assertions"] + cfgs += ['feature="{}"'.format(f) for f in ctx.rule.attr.crate_features] cfgs += [f[6:] for f in ctx.rule.attr.rustc_flags if f.startswith("--cfg ") or f.startswith("--cfg=")] # Save BuildInfo if we find any (for build script output) From dd6e2fba28997af67f6b43ce40de0466bbbb465c Mon Sep 17 00:00:00 2001 From: David Marcin Date: Tue, 8 Dec 2020 10:08:54 +0000 Subject: [PATCH 36/49] Handle missing attrs (e.g. rust_proto_library rules) --- rust/private/rust_analyzer.bzl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index f11d6c76d8..e951f498b0 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -51,8 +51,10 @@ def _rust_analyzer_aspect_impl(target, ctx): # Always add test & debug_assertions (like here: https://github.com/rust-analyzer/rust-analyzer/blob/505ff4070a3de962dbde66f08b6550cda2eb4eab/crates/project_model/src/lib.rs#L379-L381) cfgs = ["test", "debug_assertions"] - cfgs += ['feature="{}"'.format(f) for f in ctx.rule.attr.crate_features] - cfgs += [f[6:] for f in ctx.rule.attr.rustc_flags if f.startswith("--cfg ") or f.startswith("--cfg=")] + if hasattr(ctx.rule.attr, "crate_features"): + cfgs += ['feature="{}"'.format(f) for f in ctx.rule.attr.crate_features] + if hasattr(ctx.rule.attr, "rustc_flags"): + cfgs += [f[6:] for f in ctx.rule.attr.rustc_flags if f.startswith("--cfg ") or f.startswith("--cfg=")] # Save BuildInfo if we find any (for build script output) build_info = None @@ -60,7 +62,9 @@ def _rust_analyzer_aspect_impl(target, ctx): if BuildInfo in dep: build_info = dep[BuildInfo] - deps = [dep[RustAnalyzerInfo] for dep in (ctx.rule.attr.deps + ctx.rule.attr.proc_macro_deps) if RustAnalyzerInfo in dep] + deps = [dep[RustAnalyzerInfo] for dep in ctx.rule.attr.deps if RustAnalyzerInfo in dep] + if hasattr(ctx.rule.attr, "proc_macro_deps"): + deps += [dep[RustAnalyzerInfo] for dep in ctx.rule.attr.proc_macro_deps if RustAnalyzerInfo in dep] transitive_deps = depset(direct = deps, order = "postorder", transitive = [dep.transitive_deps for dep in deps]) crate_info = target[CrateInfo] @@ -75,7 +79,7 @@ def _rust_analyzer_aspect_impl(target, ctx): return [RustAnalyzerInfo( crate = crate_info, cfgs = cfgs, - env = ctx.rule.attr.rustc_env, + env = ctx.rule.attr.rustc_env if hasattr(ctx.rule.attr, "rustc_env") else {}, deps = deps, transitive_deps = transitive_deps, proc_macro_dylib_path = proc_macro_dylib_path, From d4668d0d5a557f2776f4d81a2fe822000cd797c1 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Fri, 11 Dec 2020 22:38:24 +0000 Subject: [PATCH 37/49] Handle when sha256 is not passed for rustc-src --- rust/repositories.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index b3b32150a2..16de5b7c9b 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -528,7 +528,7 @@ def _load_rust_src(ctx): ctx.download( url, output = archive_path, - sha256 = ctx.attr.sha256s.get(tool_suburl) or FILE_KEY_TO_SHA.get(tool_suburl), + sha256 = ctx.attr.sha256s.get(tool_suburl) or FILE_KEY_TO_SHA.get(tool_suburl) or "", ) ctx.extract( archive_path, From 73b02871cd90f530549271cd6fafbb015a16748b Mon Sep 17 00:00:00 2001 From: David Marcin Date: Sun, 31 Jan 2021 23:11:54 +0000 Subject: [PATCH 38/49] Update for review comments --- rust/private/rust_analyzer.bzl | 52 +++++++++++++-------- rust/repositories.bzl | 25 +++++----- rust/rust.bzl | 2 +- tools/analyzer/BUILD | 2 +- tools/analyzer/main.rs | 83 ++++++++++++++++++++++------------ 5 files changed, 102 insertions(+), 62 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index e951f498b0..72e2138d66 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -20,8 +20,8 @@ given targets. This file can be consumed by rust-analyzer as an alternative to Cargo.toml files. """ -load("@io_bazel_rules_rust//rust:private/rustc.bzl", "BuildInfo", "CrateInfo") -load("@io_bazel_rules_rust//rust:private/utils.bzl", "find_toolchain") +load("//rust:private/rustc.bzl", "BuildInfo", "CrateInfo") +load("//rust:private/utils.bzl", "find_toolchain") load("//rust/platform:triple_mappings.bzl", "system_to_dylib_ext", "triple_to_system") # We support only these rule kinds. @@ -62,45 +62,59 @@ def _rust_analyzer_aspect_impl(target, ctx): if BuildInfo in dep: build_info = dep[BuildInfo] - deps = [dep[RustAnalyzerInfo] for dep in ctx.rule.attr.deps if RustAnalyzerInfo in dep] + dep_infos = [dep[RustAnalyzerInfo] for dep in ctx.rule.attr.deps if RustAnalyzerInfo in dep] if hasattr(ctx.rule.attr, "proc_macro_deps"): - deps += [dep[RustAnalyzerInfo] for dep in ctx.rule.attr.proc_macro_deps if RustAnalyzerInfo in dep] - transitive_deps = depset(direct = deps, order = "postorder", transitive = [dep.transitive_deps for dep in deps]) + dep_infos += [dep[RustAnalyzerInfo] for dep in ctx.rule.attr.proc_macro_deps if RustAnalyzerInfo in dep] + transitive_deps = depset(direct = dep_infos, order = "postorder", transitive = [dep.transitive_deps for dep in dep_infos]) crate_info = target[CrateInfo] - proc_macro_dylib_path = None - if crate_info.type == "proc-macro": - dylib_ext = system_to_dylib_ext(triple_to_system(toolchain.target_triple)) - for action in target.actions: - for output in action.outputs.to_list(): - if output.extension == dylib_ext[1:]: - proc_macro_dylib_path = output.path - return [RustAnalyzerInfo( crate = crate_info, cfgs = cfgs, env = ctx.rule.attr.rustc_env if hasattr(ctx.rule.attr, "rustc_env") else {}, - deps = deps, + deps = dep_infos, transitive_deps = transitive_deps, - proc_macro_dylib_path = proc_macro_dylib_path, + proc_macro_dylib_path = find_proc_macro_dylib_path(crate_info, toolchain), build_info = build_info, )] +def find_proc_macro_dylib_path(toolchain, target): + """Find the proc_macro_dylib_path of target. Returns None if target crate is not type proc-macro. + + Args: + toolchain: The current rust toolchain. + target: The current target. + Returns: + (path): The path to the proc macro dylib, or None if this crate is not a proc-macro. + """ + if target[CrateInfo].type != "proc-macro": + return None + + dylib_ext = system_to_dylib_ext(triple_to_system(toolchain.target_triple)) + for action in target.actions: + for output in action.outputs.to_list(): + if output.extension == dylib_ext[1:]: + return output.path + + # Failed to find the dylib path inside a proc-macro crate. + # TODO: Should this be an error? + return None + rust_analyzer_aspect = aspect( attr_aspects = ["deps", "proc_macro_deps"], implementation = _rust_analyzer_aspect_impl, - toolchains = ["@io_bazel_rules_rust//rust:toolchain"], + toolchains = [str(Label("//rust:toolchain"))], doc = "Annotates rust rules with RustAnalyzerInfo later used to build a rust-project.json", ) _exec_root_tmpl = '__EXEC_ROOT__/' def _crate_id(crate_info): - '''Returns a unique stable identifier for a crate + """Returns a unique stable identifier for a crate Returns: (string): This crate's unique stable id. - ''' + """ return "ID-" + crate_info.root.path def create_crate(ctx, info, crate_mapping): @@ -200,6 +214,6 @@ rust_analyzer = rule( "filename": "rust-project.json", }, implementation = _rust_project_impl, - toolchains = ["@io_bazel_rules_rust//rust:toolchain"], + toolchains = [str(Label("//rust:toolchain"))], doc = "Produces a rust-project.json for the given targets. Configure rust-analyzer to load the generated file via the linked projects mechanism.", ) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index 1315beaa95..7b5d72aaf7 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -265,12 +265,16 @@ def BUILD_for_rustfmt(target_triple): binary_ext = system_to_binary_ext(system), ) -_build_file_for_clippy_template = """\ +_build_file_for_rustc_src = """\ load("@rules_rust//rust:toolchain.bzl", "rust_toolchain") filegroup( - name = "clippy_driver_bin", - srcs = ["bin/clippy-driver{binary_ext}"], + name = "rustc_src", + srcs = glob( + [ + "lib/rustlib/src/**/*.rs", + ], + ), visibility = ["//visibility:public"], ) """ @@ -278,16 +282,15 @@ filegroup( def BUILD_for_rustc_src(): """Emits a BUILD file for the rustc src extracted files.""" - return """ -load("@io_bazel_rules_rust//rust:toolchain.bzl", "rust_toolchain") + return _build_file_for_rustc_src + + +_build_file_for_clippy_template = """\ +load("@rules_rust//rust:toolchain.bzl", "rust_toolchain") filegroup( - name = "rustc_src", - srcs = glob( - [ - "lib/rustlib/src/**/*.rs", - ], - ), + name = "clippy_driver_bin", + srcs = ["bin/clippy-driver{binary_ext}"], visibility = ["//visibility:public"], ) """ diff --git a/rust/rust.bzl b/rust/rust.bzl index 5324e8f142..de5e0bb18e 100644 --- a/rust/rust.bzl +++ b/rust/rust.bzl @@ -35,7 +35,7 @@ load( _rust_clippy_aspect = "rust_clippy_aspect", ) load( - "@io_bazel_rules_rust//rust:private/rust_analyzer.bzl", + "//rust:private/rust_analyzer.bzl", _rust_analyzer = "rust_analyzer", _rust_analyzer_aspect = "rust_analyzer_aspect", ) diff --git a/tools/analyzer/BUILD b/tools/analyzer/BUILD index f76fe13a25..ef15a93308 100644 --- a/tools/analyzer/BUILD +++ b/tools/analyzer/BUILD @@ -1,5 +1,5 @@ load( - "@io_bazel_rules_rust//rust:rust.bzl", + "//rust:rust.bzl", "rust_binary", ) diff --git a/tools/analyzer/main.rs b/tools/analyzer/main.rs index 0bbf644b57..498c63c46f 100644 --- a/tools/analyzer/main.rs +++ b/tools/analyzer/main.rs @@ -1,4 +1,5 @@ use std::env; +use std::ffi::OsString; use std::fs; use std::io::ErrorKind; use std::path::PathBuf; @@ -10,10 +11,6 @@ fn main() { let repo_root = workspace_dir().expect( "Could not determine workspace, are you running inside a directory with WORKSPACE?", ); - let bazel_command = env::var("BAZEL_COMMAND").unwrap_or_else(|_| "bazel".into()); - let analyzer_target = - env::var("BAZEL_ANALYZER_TARGET").unwrap_or_else(|_| "//:rust_analyzer".into()); - env::set_current_dir(&repo_root).expect( format!( "could not access workspace directory: {}", @@ -21,27 +18,13 @@ fn main() { ) .as_str(), ); - let output = Command::new(bazel_command) - .arg("build") - .arg(&analyzer_target) - .output() - .expect("failed to execute bazel process"); - if !output.status.success() { - panic!( - "bazel build failed:({}) of {}:\n{}", - output.status, - analyzer_target, - std::str::from_utf8(&output.stderr).unwrap() - ); - } - let generated_rust_project = repo_root.join("bazel-bin/rust-project.json"); + let bazel_command = env::var_os("BAZEL_COMMAND").unwrap_or_else(|| "bazel".into()); + let exec_root = find_exec_root(&bazel_command); + + build_rust_project_target(&bazel_command); + let generated_rust_project = repo_root.join("bazel-bin").join("rust-project.json"); let workspace_rust_project = repo_root.join("rust-project.json"); - let canonical_exec_root = fs::canonicalize(repo_root.join(format!( - "bazel-{}", - repo_root.file_name().unwrap().to_string_lossy() - ))) - .expect("could not canonicalize exec_root"); // The generated_rust_project has a template string we must replace with the workspace name. let generated_json = fs::read_to_string(&generated_rust_project) @@ -51,28 +34,68 @@ fn main() { match fs::remove_file(&workspace_rust_project) { Ok(_) => {} Err(err) if err.kind() == ErrorKind::NotFound => {}, - Err(_) => panic!("Unexpected error removing old rust-project.json"), + Err(err) => panic!("Unexpected error removing old rust-project.json: {}", err), } fs::write( workspace_rust_project, - generated_json.replace("__EXEC_ROOT__", &canonical_exec_root.to_string_lossy()), + generated_json.replace("__EXEC_ROOT__", &exec_root.to_string_lossy()), ) .expect("failed to write workspace rust-project.json"); } fn workspace_dir() -> Option { - if let Ok(ws_dir) = env::var("BUILD_WORKSPACE_DIRECTORY") { + if let Some(ws_dir) = env::var_os("BUILD_WORKSPACE_DIRECTORY") { Some(PathBuf::from(ws_dir)) } else { let mut maybe_cwd = env::current_dir().ok(); while let Some(cwd) = maybe_cwd { - let mut workspace_path = cwd.clone(); - workspace_path.push("WORKSPACE"); - if workspace_path.is_file() { - return Some(PathBuf::from(cwd)); + for workspace_filename in &["WORKSPACE", "WORKSPACE.bazel"] { + let mut workspace_path = cwd.clone(); + workspace_path.push(workspace_filename); + if workspace_path.is_file() { + return Some(PathBuf::from(cwd)); + } } maybe_cwd = cwd.parent().map(PathBuf::from); } None } } + +fn build_rust_project_target(bazel_command: &OsString) { + let analyzer_target = + env::var_os("BAZEL_ANALYZER_TARGET").unwrap_or_else(|| "//:rust_analyzer".into()); + + let output = Command::new(bazel_command) + .arg("build") + .arg(&analyzer_target) + .output() + .expect("failed to execute bazel process"); + if !output.status.success() { + panic!( + "bazel build failed:({}) of {:?}:\n{}", + output.status, + analyzer_target, + String::from_utf8_lossy(&output.stderr) + ); + } +} + +fn find_exec_root(bazel_command: &OsString) -> PathBuf { + let output = Command::new(bazel_command) + .arg("info") + .arg("execution_root") + .output() + .expect("failed to execute bazel process"); + if !output.status.success() { + panic!( + "Failed to find execution_root:({}):\n{}", + output.status, + String::from_utf8_lossy(&output.stderr) + ); + } + + // TODO: This only works with UTF8 filenames. Esoteric directory name handling + // would would require platform specific code. + PathBuf::from(String::from_utf8_lossy(output.stdout.as_slice()).into_owned()) +} \ No newline at end of file From d408804d4020f9058e4102c1c989f5dd7f6f6601 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Mon, 1 Feb 2021 03:49:30 +0000 Subject: [PATCH 39/49] Fix args to find_proc_macro_dylib_path --- rust/private/rust_analyzer.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 72e2138d66..556d4cdb36 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -74,7 +74,7 @@ def _rust_analyzer_aspect_impl(target, ctx): env = ctx.rule.attr.rustc_env if hasattr(ctx.rule.attr, "rustc_env") else {}, deps = dep_infos, transitive_deps = transitive_deps, - proc_macro_dylib_path = find_proc_macro_dylib_path(crate_info, toolchain), + proc_macro_dylib_path = find_proc_macro_dylib_path(toolchain, target), build_info = build_info, )] From acd6c70b543edfc12485f23ed9368ebe93be25ec Mon Sep 17 00:00:00 2001 From: David Marcin Date: Mon, 1 Feb 2021 21:59:44 +0000 Subject: [PATCH 40/49] simplify with getattr --- rust/private/rust_analyzer.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 556d4cdb36..d477460306 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -71,7 +71,7 @@ def _rust_analyzer_aspect_impl(target, ctx): return [RustAnalyzerInfo( crate = crate_info, cfgs = cfgs, - env = ctx.rule.attr.rustc_env if hasattr(ctx.rule.attr, "rustc_env") else {}, + env = getattr(ctx.rule.attr, "rustc_env", {}), deps = dep_infos, transitive_deps = transitive_deps, proc_macro_dylib_path = find_proc_macro_dylib_path(toolchain, target), From a00d1a0f1ec67401457831ae989b6ba8a53e4d3f Mon Sep 17 00:00:00 2001 From: David Marcin Date: Wed, 3 Feb 2021 22:36:06 +0000 Subject: [PATCH 41/49] trim command output --- tools/analyzer/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/analyzer/main.rs b/tools/analyzer/main.rs index 498c63c46f..42a4c58865 100644 --- a/tools/analyzer/main.rs +++ b/tools/analyzer/main.rs @@ -97,5 +97,5 @@ fn find_exec_root(bazel_command: &OsString) -> PathBuf { // TODO: This only works with UTF8 filenames. Esoteric directory name handling // would would require platform specific code. - PathBuf::from(String::from_utf8_lossy(output.stdout.as_slice()).into_owned()) + PathBuf::from(String::from_utf8_lossy(output.stdout.as_slice()).trim()) } \ No newline at end of file From 87024311e6030b1387cf22cb3a9aa52583b748f7 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Sun, 14 Feb 2021 08:23:41 +0000 Subject: [PATCH 42/49] fix merge --- rust/private/rust_analyzer.bzl | 5 +++-- rust/rust.bzl | 2 +- rust/toolchain.bzl | 15 +++------------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index d477460306..b0157d2c6e 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -20,8 +20,9 @@ given targets. This file can be consumed by rust-analyzer as an alternative to Cargo.toml files. """ -load("//rust:private/rustc.bzl", "BuildInfo", "CrateInfo") -load("//rust:private/utils.bzl", "find_toolchain") +load("//rust:rust_common.bzl", "CrateInfo") +load("//rust/private:rustc.bzl", "BuildInfo") +load("//rust/private:utils.bzl", "find_toolchain") load("//rust/platform:triple_mappings.bzl", "system_to_dylib_ext", "triple_to_system") # We support only these rule kinds. diff --git a/rust/rust.bzl b/rust/rust.bzl index 634ab02539..ac6bb7a41b 100644 --- a/rust/rust.bzl +++ b/rust/rust.bzl @@ -41,7 +41,7 @@ load( _rust_doc_test = "rust_doc_test", ) load( - "//rust:private/rust_analyzer.bzl", + "//rust/private:rust_analyzer.bzl", _rust_analyzer = "rust_analyzer", _rust_analyzer_aspect = "rust_analyzer_aspect", ) diff --git a/rust/toolchain.bzl b/rust/toolchain.bzl index fc7b9689d4..359d0fb74c 100644 --- a/rust/toolchain.bzl +++ b/rust/toolchain.bzl @@ -56,18 +56,6 @@ rust_toolchain = rule( doc = "The location of the `clippy-driver` binary. Can be a direct source or a filegroup containing one item.", allow_single_file = True, ), - "rustc_lib": attr.label( - doc = "The libraries used by rustc during compilation.", - ), - "rustc_src": attr.label( - doc = "The source code of rustc.", - ), - "rust_lib": attr.label( - doc = "The rust standard library.", - ), - "binary_ext": attr.string( - doc = "The extension for binaries created from rustc.", - mandatory = True, "debug_info": attr.string_dict( doc = "Rustc debug info levels per opt level", default = { @@ -116,6 +104,9 @@ rust_toolchain = rule( "rustc_lib": attr.label( doc = "The libraries used by rustc during compilation.", ), + "rustc_src": attr.label( + doc = "The source code of rustc.", + ), "rustfmt": attr.label( doc = "The location of the `rustfmt` binary. Can be a direct source or a filegroup containing one item.", allow_single_file = True, From a3a1ddb7aff02a683e22e89b3a8902543fd14db8 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Sun, 14 Feb 2021 09:16:44 +0000 Subject: [PATCH 43/49] Refactor to use command line flags and bazel info to determine workspace --- WORKSPACE | 4 + tools/analyzer/BUILD | 10 - tools/analyzer/main.rs | 101 ------- tools/rust_analyzer/BUILD | 15 + tools/rust_analyzer/deps.bzl | 8 + tools/rust_analyzer/main.rs | 134 +++++++++ tools/rust_analyzer/raze/BUILD.bazel | 39 +++ tools/rust_analyzer/raze/Cargo.raze.lock | 230 +++++++++++++++ tools/rust_analyzer/raze/Cargo.toml | 19 ++ tools/rust_analyzer/raze/crates.bzl | 272 ++++++++++++++++++ .../raze/remote/BUILD.ansi_term-0.11.0.bazel | 66 +++++ .../raze/remote/BUILD.anyhow-1.0.38.bazel | 112 ++++++++ .../raze/remote/BUILD.atty-0.2.14.bazel | 89 ++++++ tools/rust_analyzer/raze/remote/BUILD.bazel | 0 .../raze/remote/BUILD.bitflags-1.2.1.bazel | 84 ++++++ .../raze/remote/BUILD.clap-2.33.3.bazel | 93 ++++++ .../raze/remote/BUILD.heck-0.3.2.bazel | 54 ++++ .../raze/remote/BUILD.hermit-abi-0.1.18.bazel | 55 ++++ .../raze/remote/BUILD.lazy_static-1.4.0.bazel | 57 ++++ .../raze/remote/BUILD.libc-0.2.86.bazel | 84 ++++++ .../remote/BUILD.proc-macro-error-1.0.4.bazel | 101 +++++++ .../BUILD.proc-macro-error-attr-1.0.4.bazel | 85 ++++++ .../remote/BUILD.proc-macro2-1.0.24.bazel | 97 +++++++ .../raze/remote/BUILD.quote-1.0.9.bazel | 60 ++++ .../raze/remote/BUILD.strsim-0.8.0.bazel | 57 ++++ .../raze/remote/BUILD.structopt-0.3.21.bazel | 151 ++++++++++ .../BUILD.structopt-derive-0.4.14.bazel | 58 ++++ .../raze/remote/BUILD.syn-1.0.60.bazel | 157 ++++++++++ .../raze/remote/BUILD.textwrap-0.11.0.bazel | 62 ++++ .../BUILD.unicode-segmentation-1.7.1.bazel | 55 ++++ .../remote/BUILD.unicode-width-0.1.8.bazel | 54 ++++ .../raze/remote/BUILD.unicode-xid-0.2.1.bazel | 56 ++++ .../raze/remote/BUILD.vec_map-0.8.2.bazel | 53 ++++ .../remote/BUILD.version_check-0.9.2.bazel | 53 ++++ .../raze/remote/BUILD.winapi-0.3.9.bazel | 94 ++++++ ...ILD.winapi-i686-pc-windows-gnu-0.4.0.bazel | 82 ++++++ ...D.winapi-x86_64-pc-windows-gnu-0.4.0.bazel | 82 ++++++ 37 files changed, 2772 insertions(+), 111 deletions(-) delete mode 100644 tools/analyzer/BUILD delete mode 100644 tools/analyzer/main.rs create mode 100644 tools/rust_analyzer/BUILD create mode 100644 tools/rust_analyzer/deps.bzl create mode 100644 tools/rust_analyzer/main.rs create mode 100644 tools/rust_analyzer/raze/BUILD.bazel create mode 100644 tools/rust_analyzer/raze/Cargo.raze.lock create mode 100644 tools/rust_analyzer/raze/Cargo.toml create mode 100644 tools/rust_analyzer/raze/crates.bzl create mode 100644 tools/rust_analyzer/raze/remote/BUILD.ansi_term-0.11.0.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.anyhow-1.0.38.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.atty-0.2.14.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.bitflags-1.2.1.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.clap-2.33.3.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.heck-0.3.2.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.hermit-abi-0.1.18.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.lazy_static-1.4.0.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.libc-0.2.86.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.proc-macro-error-1.0.4.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.proc-macro-error-attr-1.0.4.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.proc-macro2-1.0.24.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.quote-1.0.9.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.strsim-0.8.0.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.structopt-0.3.21.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.structopt-derive-0.4.14.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.syn-1.0.60.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.textwrap-0.11.0.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.unicode-segmentation-1.7.1.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.unicode-width-0.1.8.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.unicode-xid-0.2.1.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.vec_map-0.8.2.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.version_check-0.9.2.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.winapi-0.3.9.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel create mode 100644 tools/rust_analyzer/raze/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel diff --git a/WORKSPACE b/WORKSPACE index 92ffdee023..67c7f5117c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -12,6 +12,10 @@ load("@rules_rust//bindgen:repositories.bzl", "rust_bindgen_repositories") rust_bindgen_repositories() +load("@rules_rust//tools/rust_analyzer/raze:crates.bzl", "rules_rust_tools_rust_analyzer_fetch_remote_crates") + +rules_rust_tools_rust_analyzer_fetch_remote_crates() + load("@rules_rust//wasm_bindgen:repositories.bzl", "rust_wasm_bindgen_repositories") rust_wasm_bindgen_repositories() diff --git a/tools/analyzer/BUILD b/tools/analyzer/BUILD deleted file mode 100644 index ef15a93308..0000000000 --- a/tools/analyzer/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -load( - "//rust:rust.bzl", - "rust_binary", -) - -rust_binary( - name = "analyzer", - srcs = ["main.rs"], - visibility = ["//visibility:public"], -) diff --git a/tools/analyzer/main.rs b/tools/analyzer/main.rs deleted file mode 100644 index 42a4c58865..0000000000 --- a/tools/analyzer/main.rs +++ /dev/null @@ -1,101 +0,0 @@ -use std::env; -use std::ffi::OsString; -use std::fs; -use std::io::ErrorKind; -use std::path::PathBuf; -use std::process::Command; - -// TODO(david): This shells out to an expected rule in the workspace root //:rust_analyzer that the user must define. -// It would be more convenient if it could automatically discover all the rust code in the workspace if this target does not exist. -fn main() { - let repo_root = workspace_dir().expect( - "Could not determine workspace, are you running inside a directory with WORKSPACE?", - ); - env::set_current_dir(&repo_root).expect( - format!( - "could not access workspace directory: {}", - repo_root.to_string_lossy() - ) - .as_str(), - ); - - let bazel_command = env::var_os("BAZEL_COMMAND").unwrap_or_else(|| "bazel".into()); - let exec_root = find_exec_root(&bazel_command); - - build_rust_project_target(&bazel_command); - let generated_rust_project = repo_root.join("bazel-bin").join("rust-project.json"); - let workspace_rust_project = repo_root.join("rust-project.json"); - - // The generated_rust_project has a template string we must replace with the workspace name. - let generated_json = fs::read_to_string(&generated_rust_project) - .expect("failed to read generated rust-project.json"); - - // It's OK if the file doesn't exist. - match fs::remove_file(&workspace_rust_project) { - Ok(_) => {} - Err(err) if err.kind() == ErrorKind::NotFound => {}, - Err(err) => panic!("Unexpected error removing old rust-project.json: {}", err), - } - fs::write( - workspace_rust_project, - generated_json.replace("__EXEC_ROOT__", &exec_root.to_string_lossy()), - ) - .expect("failed to write workspace rust-project.json"); -} - -fn workspace_dir() -> Option { - if let Some(ws_dir) = env::var_os("BUILD_WORKSPACE_DIRECTORY") { - Some(PathBuf::from(ws_dir)) - } else { - let mut maybe_cwd = env::current_dir().ok(); - while let Some(cwd) = maybe_cwd { - for workspace_filename in &["WORKSPACE", "WORKSPACE.bazel"] { - let mut workspace_path = cwd.clone(); - workspace_path.push(workspace_filename); - if workspace_path.is_file() { - return Some(PathBuf::from(cwd)); - } - } - maybe_cwd = cwd.parent().map(PathBuf::from); - } - None - } -} - -fn build_rust_project_target(bazel_command: &OsString) { - let analyzer_target = - env::var_os("BAZEL_ANALYZER_TARGET").unwrap_or_else(|| "//:rust_analyzer".into()); - - let output = Command::new(bazel_command) - .arg("build") - .arg(&analyzer_target) - .output() - .expect("failed to execute bazel process"); - if !output.status.success() { - panic!( - "bazel build failed:({}) of {:?}:\n{}", - output.status, - analyzer_target, - String::from_utf8_lossy(&output.stderr) - ); - } -} - -fn find_exec_root(bazel_command: &OsString) -> PathBuf { - let output = Command::new(bazel_command) - .arg("info") - .arg("execution_root") - .output() - .expect("failed to execute bazel process"); - if !output.status.success() { - panic!( - "Failed to find execution_root:({}):\n{}", - output.status, - String::from_utf8_lossy(&output.stderr) - ); - } - - // TODO: This only works with UTF8 filenames. Esoteric directory name handling - // would would require platform specific code. - PathBuf::from(String::from_utf8_lossy(output.stdout.as_slice()).trim()) -} \ No newline at end of file diff --git a/tools/rust_analyzer/BUILD b/tools/rust_analyzer/BUILD new file mode 100644 index 0000000000..0e0fe9f3f0 --- /dev/null +++ b/tools/rust_analyzer/BUILD @@ -0,0 +1,15 @@ +load( + "//rust:rust.bzl", + "rust_binary", +) + +rust_binary( + name = "gen_rust_project", + srcs = ["main.rs"], + edition = "2018", + visibility = ["//visibility:public"], + deps = [ + "//tools/rust_analyzer/raze:anyhow", + "//tools/rust_analyzer/raze:structopt", + ], +) diff --git a/tools/rust_analyzer/deps.bzl b/tools/rust_analyzer/deps.bzl new file mode 100644 index 0000000000..322588488b --- /dev/null +++ b/tools/rust_analyzer/deps.bzl @@ -0,0 +1,8 @@ +""" +The dependencies for running the gen_rust_project binary. +""" + +load("//tools/rust_analyzer/raze:crates.bzl", "rules_rust_tools_rust_analyzer_fetch_remote_crates") + +def gen_rust_project_dependencies(): + rules_rust_tools_rust_analyzer_fetch_remote_crates() \ No newline at end of file diff --git a/tools/rust_analyzer/main.rs b/tools/rust_analyzer/main.rs new file mode 100644 index 0000000000..7643f86fd5 --- /dev/null +++ b/tools/rust_analyzer/main.rs @@ -0,0 +1,134 @@ +use anyhow::anyhow; +use std::collections::HashMap; +use std::env; +use std::fs; +use std::io::ErrorKind; +use std::path::PathBuf; +use std::process::Command; +use structopt::StructOpt; + +// TODO(david): This shells out to an expected rule in the workspace root //:rust_analyzer that the user must define. +// It would be more convenient if it could automatically discover all the rust code in the workspace if this target does not exist. +fn main() -> anyhow::Result<()> { + let config = parse_config()?; + + let workspace_root = config + .workspace + .as_ref() + .expect("failed to find workspace root, set with --workspace"); + let execution_root = config + .execution_root + .as_ref() + .expect("failed to find execution root, is --workspace set correctly?"); + + build_rust_project_target(&config); + let generated_rust_project = workspace_root.join("bazel-bin").join("rust-project.json"); + let workspace_rust_project = workspace_root.join("rust-project.json"); + + // The generated_rust_project has a template string we must replace with the workspace name. + let generated_json = fs::read_to_string(&generated_rust_project) + .expect("failed to read generated rust-project.json"); + + // Try to remove the existing rust-project.json. It's OK if the file doesn't exist. + match fs::remove_file(&workspace_rust_project) { + Ok(_) => {} + Err(err) if err.kind() == ErrorKind::NotFound => {} + Err(err) => panic!("Unexpected error removing old rust-project.json: {}", err), + } + + // Write the new rust-project.json file. + fs::write( + workspace_rust_project, + generated_json.replace("__EXEC_ROOT__", &execution_root.to_string_lossy()), + ) + .expect("failed to write workspace rust-project.json"); + + Ok(()) +} + +fn build_rust_project_target(config: &Config) { + let output = Command::new(&config.bazel) + .current_dir(config.workspace.as_ref().unwrap()) + .arg("build") + .arg(&config.bazel_analyzer_target) + .output() + .expect("failed to execute bazel process"); + if !output.status.success() { + panic!( + "bazel build failed:({}) of {:?}:\n{}", + output.status, + &config.bazel_analyzer_target, + String::from_utf8_lossy(&output.stderr) + ); + } +} + +// Parse the configuration flags and supplement with bazel info as needed. +fn parse_config() -> anyhow::Result { + let mut config = Config::from_args(); + println!("Config = {:?}", config); + + // Ensure we know the workspace. If we are under `bazel run`, the + // BUILD_WORKSPACE_DIR environment variable will be present. + if config.workspace.is_none() { + if let Some(ws_dir) = env::var_os("BUILD_WORKSPACE_DIRECTORY") { + config.workspace = Some(PathBuf::from(ws_dir)); + } + } + + if config.workspace.is_some() && config.execution_root.is_some() { + return Ok(config); + } + + // We need some info from `bazel info`. Fetch it now. + let mut bazel_info_command = Command::new(&config.bazel); + bazel_info_command.arg("info"); + if let Some(workspace) = &config.workspace { + bazel_info_command.current_dir(workspace); + } + + // Execute bazel info. + let output = bazel_info_command.output()?; + if !output.status.success() { + return Err(anyhow!( + "Failed to run `bazel info` ({:?}): {}", + output.status, + String::from_utf8_lossy(&output.stderr) + )); + } + + // Extract the output. + let output = String::from_utf8_lossy(&output.stdout.as_slice()); + let bazel_info = output + .trim() + .split("\n") + .map(|line| line.split_at(line.find(":").expect("missing `:` in bazel info output"))) + .map(|(k, v)| (k, (&v[1..]).trim())) + .collect::>(); + + if config.workspace.is_none() { + config.workspace = bazel_info.get("workspace").map(Into::into); + } + if config.execution_root.is_none() { + config.execution_root = bazel_info.get("execution_root").map(Into::into); + } + + Ok(config) +} + +#[derive(Debug, StructOpt)] +struct Config { + // If not specified, uses the result of `bazel info workspace`. + #[structopt(long)] + workspace: Option, + + // If not specified, uses the result of `bazel info execution_root`. + #[structopt(long)] + execution_root: Option, + + #[structopt(long, default_value = "bazel")] + bazel: PathBuf, + + #[structopt(long, default_value = "//:rust_analyzer")] + bazel_analyzer_target: String, +} diff --git a/tools/rust_analyzer/raze/BUILD.bazel b/tools/rust_analyzer/raze/BUILD.bazel new file mode 100644 index 0000000000..b071f0c294 --- /dev/null +++ b/tools/rust_analyzer/raze/BUILD.bazel @@ -0,0 +1,39 @@ +""" +@generated +cargo-raze generated Bazel file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +package(default_visibility = ["//visibility:public"]) + +licenses([ + "notice", # See individual crates for specific licenses +]) + +# Aliased targets +alias( + name = "anyhow", + actual = "@rules_rust_tools_rust_analyzer__anyhow__1_0_38//:anyhow", + tags = [ + "cargo-raze", + "manual", + ], +) + +alias( + name = "structopt", + actual = "@rules_rust_tools_rust_analyzer__structopt__0_3_21//:structopt", + tags = [ + "cargo-raze", + "manual", + ], +) + +# Export file for Stardoc support +exports_files( + [ + "crates.bzl", + ], + visibility = ["//visibility:public"], +) diff --git a/tools/rust_analyzer/raze/Cargo.raze.lock b/tools/rust_analyzer/raze/Cargo.raze.lock new file mode 100644 index 0000000000..1f42f80163 --- /dev/null +++ b/tools/rust_analyzer/raze/Cargo.raze.lock @@ -0,0 +1,230 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "compile_with_bazel" +version = "0.0.0" +dependencies = [ + "anyhow", + "structopt", +] + +[[package]] +name = "heck" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "unicode-segmentation" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/tools/rust_analyzer/raze/Cargo.toml b/tools/rust_analyzer/raze/Cargo.toml new file mode 100644 index 0000000000..8f3fb7ef27 --- /dev/null +++ b/tools/rust_analyzer/raze/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "compile_with_bazel" +version = "0.0.0" +edition="2018" + +[lib] +path = "fake_lib.rs" + +[dependencies] +anyhow = "1.0" +structopt = "0.3" + +[package.metadata.raze] +genmode = "Remote" +workspace_path = "//tools/rust_analyzer/raze" +gen_workspace_prefix = "rules_rust_tools_rust_analyzer" +rust_rules_workspace_name = "rules_rust" +package_aliases_dir = "." +default_gen_buildrs = true diff --git a/tools/rust_analyzer/raze/crates.bzl b/tools/rust_analyzer/raze/crates.bzl new file mode 100644 index 0000000000..5088704270 --- /dev/null +++ b/tools/rust_analyzer/raze/crates.bzl @@ -0,0 +1,272 @@ +""" +@generated +cargo-raze generated Bazel file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # buildifier: disable=load +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load + +def rules_rust_tools_rust_analyzer_fetch_remote_crates(): + """This function defines a collection of repos and should be called in a WORKSPACE file""" + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__ansi_term__0_11_0", + url = "https://crates.io/api/v1/crates/ansi_term/0.11.0/download", + type = "tar.gz", + sha256 = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b", + strip_prefix = "ansi_term-0.11.0", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.ansi_term-0.11.0.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__anyhow__1_0_38", + url = "https://crates.io/api/v1/crates/anyhow/1.0.38/download", + type = "tar.gz", + sha256 = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1", + strip_prefix = "anyhow-1.0.38", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.anyhow-1.0.38.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__atty__0_2_14", + url = "https://crates.io/api/v1/crates/atty/0.2.14/download", + type = "tar.gz", + sha256 = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8", + strip_prefix = "atty-0.2.14", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.atty-0.2.14.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__bitflags__1_2_1", + url = "https://crates.io/api/v1/crates/bitflags/1.2.1/download", + type = "tar.gz", + sha256 = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693", + strip_prefix = "bitflags-1.2.1", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.bitflags-1.2.1.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__clap__2_33_3", + url = "https://crates.io/api/v1/crates/clap/2.33.3/download", + type = "tar.gz", + sha256 = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002", + strip_prefix = "clap-2.33.3", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.clap-2.33.3.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__heck__0_3_2", + url = "https://crates.io/api/v1/crates/heck/0.3.2/download", + type = "tar.gz", + sha256 = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac", + strip_prefix = "heck-0.3.2", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.heck-0.3.2.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__hermit_abi__0_1_18", + url = "https://crates.io/api/v1/crates/hermit-abi/0.1.18/download", + type = "tar.gz", + sha256 = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c", + strip_prefix = "hermit-abi-0.1.18", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.hermit-abi-0.1.18.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__lazy_static__1_4_0", + url = "https://crates.io/api/v1/crates/lazy_static/1.4.0/download", + type = "tar.gz", + sha256 = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646", + strip_prefix = "lazy_static-1.4.0", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.lazy_static-1.4.0.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__libc__0_2_86", + url = "https://crates.io/api/v1/crates/libc/0.2.86/download", + type = "tar.gz", + sha256 = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c", + strip_prefix = "libc-0.2.86", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.libc-0.2.86.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__proc_macro_error__1_0_4", + url = "https://crates.io/api/v1/crates/proc-macro-error/1.0.4/download", + type = "tar.gz", + sha256 = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c", + strip_prefix = "proc-macro-error-1.0.4", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.proc-macro-error-1.0.4.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__proc_macro_error_attr__1_0_4", + url = "https://crates.io/api/v1/crates/proc-macro-error-attr/1.0.4/download", + type = "tar.gz", + sha256 = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869", + strip_prefix = "proc-macro-error-attr-1.0.4", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.proc-macro-error-attr-1.0.4.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__proc_macro2__1_0_24", + url = "https://crates.io/api/v1/crates/proc-macro2/1.0.24/download", + type = "tar.gz", + sha256 = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71", + strip_prefix = "proc-macro2-1.0.24", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.proc-macro2-1.0.24.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__quote__1_0_9", + url = "https://crates.io/api/v1/crates/quote/1.0.9/download", + type = "tar.gz", + sha256 = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7", + strip_prefix = "quote-1.0.9", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.quote-1.0.9.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__strsim__0_8_0", + url = "https://crates.io/api/v1/crates/strsim/0.8.0/download", + type = "tar.gz", + sha256 = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a", + strip_prefix = "strsim-0.8.0", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.strsim-0.8.0.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__structopt__0_3_21", + url = "https://crates.io/api/v1/crates/structopt/0.3.21/download", + type = "tar.gz", + sha256 = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c", + strip_prefix = "structopt-0.3.21", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.structopt-0.3.21.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__structopt_derive__0_4_14", + url = "https://crates.io/api/v1/crates/structopt-derive/0.4.14/download", + type = "tar.gz", + sha256 = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90", + strip_prefix = "structopt-derive-0.4.14", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.structopt-derive-0.4.14.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__syn__1_0_60", + url = "https://crates.io/api/v1/crates/syn/1.0.60/download", + type = "tar.gz", + sha256 = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081", + strip_prefix = "syn-1.0.60", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.syn-1.0.60.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__textwrap__0_11_0", + url = "https://crates.io/api/v1/crates/textwrap/0.11.0/download", + type = "tar.gz", + sha256 = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060", + strip_prefix = "textwrap-0.11.0", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.textwrap-0.11.0.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__unicode_segmentation__1_7_1", + url = "https://crates.io/api/v1/crates/unicode-segmentation/1.7.1/download", + type = "tar.gz", + sha256 = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796", + strip_prefix = "unicode-segmentation-1.7.1", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.unicode-segmentation-1.7.1.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__unicode_width__0_1_8", + url = "https://crates.io/api/v1/crates/unicode-width/0.1.8/download", + type = "tar.gz", + sha256 = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3", + strip_prefix = "unicode-width-0.1.8", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.unicode-width-0.1.8.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__unicode_xid__0_2_1", + url = "https://crates.io/api/v1/crates/unicode-xid/0.2.1/download", + type = "tar.gz", + sha256 = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564", + strip_prefix = "unicode-xid-0.2.1", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.unicode-xid-0.2.1.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__vec_map__0_8_2", + url = "https://crates.io/api/v1/crates/vec_map/0.8.2/download", + type = "tar.gz", + sha256 = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191", + strip_prefix = "vec_map-0.8.2", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.vec_map-0.8.2.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__version_check__0_9_2", + url = "https://crates.io/api/v1/crates/version_check/0.9.2/download", + type = "tar.gz", + sha256 = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed", + strip_prefix = "version_check-0.9.2", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.version_check-0.9.2.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__winapi__0_3_9", + url = "https://crates.io/api/v1/crates/winapi/0.3.9/download", + type = "tar.gz", + sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419", + strip_prefix = "winapi-0.3.9", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.winapi-0.3.9.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__winapi_i686_pc_windows_gnu__0_4_0", + url = "https://crates.io/api/v1/crates/winapi-i686-pc-windows-gnu/0.4.0/download", + type = "tar.gz", + sha256 = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6", + strip_prefix = "winapi-i686-pc-windows-gnu-0.4.0", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel"), + ) + + maybe( + http_archive, + name = "rules_rust_tools_rust_analyzer__winapi_x86_64_pc_windows_gnu__0_4_0", + url = "https://crates.io/api/v1/crates/winapi-x86_64-pc-windows-gnu/0.4.0/download", + type = "tar.gz", + sha256 = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f", + strip_prefix = "winapi-x86_64-pc-windows-gnu-0.4.0", + build_file = Label("//tools/rust_analyzer/raze/remote:BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel"), + ) diff --git a/tools/rust_analyzer/raze/remote/BUILD.ansi_term-0.11.0.bazel b/tools/rust_analyzer/raze/remote/BUILD.ansi_term-0.11.0.bazel new file mode 100644 index 0000000000..f491d8ad4e --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.ansi_term-0.11.0.bazel @@ -0,0 +1,66 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +# Unsupported target "colours" with type "example" omitted + +rust_library( + name = "ansi_term", + srcs = glob(["**/*.rs"]), + aliases = { + }, + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.11.0", + # buildifier: leave-alone + deps = [ + ] + selects.with_or({ + # cfg(target_os = "windows") + ( + "@rules_rust//rust/platform:i686-pc-windows-msvc", + "@rules_rust//rust/platform:x86_64-pc-windows-msvc", + ): [ + "@rules_rust_tools_rust_analyzer__winapi__0_3_9//:winapi", + ], + "//conditions:default": [], + }), +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.anyhow-1.0.38.bazel b/tools/rust_analyzer/raze/remote/BUILD.anyhow-1.0.38.bazel new file mode 100644 index 0000000000..d40717d2bf --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.anyhow-1.0.38.bazel @@ -0,0 +1,112 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "anyhow_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + "default", + "std", + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.38", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "anyhow", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.38", + # buildifier: leave-alone + deps = [ + ":anyhow_build_script", + ], +) + +# Unsupported target "compiletest" with type "test" omitted + +# Unsupported target "test_autotrait" with type "test" omitted + +# Unsupported target "test_backtrace" with type "test" omitted + +# Unsupported target "test_boxed" with type "test" omitted + +# Unsupported target "test_chain" with type "test" omitted + +# Unsupported target "test_context" with type "test" omitted + +# Unsupported target "test_convert" with type "test" omitted + +# Unsupported target "test_downcast" with type "test" omitted + +# Unsupported target "test_ffi" with type "test" omitted + +# Unsupported target "test_fmt" with type "test" omitted + +# Unsupported target "test_macros" with type "test" omitted + +# Unsupported target "test_repr" with type "test" omitted + +# Unsupported target "test_source" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.atty-0.2.14.bazel b/tools/rust_analyzer/raze/remote/BUILD.atty-0.2.14.bazel new file mode 100644 index 0000000000..01f65c43d0 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.atty-0.2.14.bazel @@ -0,0 +1,89 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +# Unsupported target "atty" with type "example" omitted + +rust_library( + name = "atty", + srcs = glob(["**/*.rs"]), + aliases = { + }, + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.2.14", + # buildifier: leave-alone + deps = [ + ] + selects.with_or({ + # cfg(unix) + ( + "@rules_rust//rust/platform:aarch64-apple-darwin", + "@rules_rust//rust/platform:aarch64-apple-ios", + "@rules_rust//rust/platform:aarch64-linux-android", + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", + "@rules_rust//rust/platform:i686-apple-darwin", + "@rules_rust//rust/platform:i686-linux-android", + "@rules_rust//rust/platform:i686-unknown-freebsd", + "@rules_rust//rust/platform:i686-unknown-linux-gnu", + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", + "@rules_rust//rust/platform:s390x-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-darwin", + "@rules_rust//rust/platform:x86_64-apple-ios", + "@rules_rust//rust/platform:x86_64-linux-android", + "@rules_rust//rust/platform:x86_64-unknown-freebsd", + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", + ): [ + "@rules_rust_tools_rust_analyzer__libc__0_2_86//:libc", + ], + "//conditions:default": [], + }) + selects.with_or({ + # cfg(windows) + ( + "@rules_rust//rust/platform:i686-pc-windows-msvc", + "@rules_rust//rust/platform:x86_64-pc-windows-msvc", + ): [ + "@rules_rust_tools_rust_analyzer__winapi__0_3_9//:winapi", + ], + "//conditions:default": [], + }), +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.bazel b/tools/rust_analyzer/raze/remote/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/rust_analyzer/raze/remote/BUILD.bitflags-1.2.1.bazel b/tools/rust_analyzer/raze/remote/BUILD.bitflags-1.2.1.bazel new file mode 100644 index 0000000000..d60959397b --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.bitflags-1.2.1.bazel @@ -0,0 +1,84 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "bitflags_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + "default", + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.2.1", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "bitflags", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.2.1", + # buildifier: leave-alone + deps = [ + ":bitflags_build_script", + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.clap-2.33.3.bazel b/tools/rust_analyzer/raze/remote/BUILD.clap-2.33.3.bazel new file mode 100644 index 0000000000..569965fdf0 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.clap-2.33.3.bazel @@ -0,0 +1,93 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +rust_library( + name = "clap", + srcs = glob(["**/*.rs"]), + aliases = { + }, + crate_features = [ + "ansi_term", + "atty", + "color", + "default", + "strsim", + "suggestions", + "vec_map", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "2.33.3", + # buildifier: leave-alone + deps = [ + "@rules_rust_tools_rust_analyzer__atty__0_2_14//:atty", + "@rules_rust_tools_rust_analyzer__bitflags__1_2_1//:bitflags", + "@rules_rust_tools_rust_analyzer__strsim__0_8_0//:strsim", + "@rules_rust_tools_rust_analyzer__textwrap__0_11_0//:textwrap", + "@rules_rust_tools_rust_analyzer__unicode_width__0_1_8//:unicode_width", + "@rules_rust_tools_rust_analyzer__vec_map__0_8_2//:vec_map", + ] + selects.with_or({ + # cfg(not(windows)) + ( + "@rules_rust//rust/platform:aarch64-apple-darwin", + "@rules_rust//rust/platform:aarch64-apple-ios", + "@rules_rust//rust/platform:aarch64-linux-android", + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", + "@rules_rust//rust/platform:i686-apple-darwin", + "@rules_rust//rust/platform:i686-linux-android", + "@rules_rust//rust/platform:i686-unknown-freebsd", + "@rules_rust//rust/platform:i686-unknown-linux-gnu", + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", + "@rules_rust//rust/platform:s390x-unknown-linux-gnu", + "@rules_rust//rust/platform:wasm32-unknown-unknown", + "@rules_rust//rust/platform:wasm32-wasi", + "@rules_rust//rust/platform:x86_64-apple-darwin", + "@rules_rust//rust/platform:x86_64-apple-ios", + "@rules_rust//rust/platform:x86_64-linux-android", + "@rules_rust//rust/platform:x86_64-unknown-freebsd", + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", + ): [ + "@rules_rust_tools_rust_analyzer__ansi_term__0_11_0//:ansi_term", + ], + "//conditions:default": [], + }), +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.heck-0.3.2.bazel b/tools/rust_analyzer/raze/remote/BUILD.heck-0.3.2.bazel new file mode 100644 index 0000000000..5526ff36c7 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.heck-0.3.2.bazel @@ -0,0 +1,54 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "heck", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.3.2", + # buildifier: leave-alone + deps = [ + "@rules_rust_tools_rust_analyzer__unicode_segmentation__1_7_1//:unicode_segmentation", + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.hermit-abi-0.1.18.bazel b/tools/rust_analyzer/raze/remote/BUILD.hermit-abi-0.1.18.bazel new file mode 100644 index 0000000000..c9123ef065 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.hermit-abi-0.1.18.bazel @@ -0,0 +1,55 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "hermit_abi", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.1.18", + # buildifier: leave-alone + deps = [ + "@rules_rust_tools_rust_analyzer__libc__0_2_86//:libc", + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.lazy_static-1.4.0.bazel b/tools/rust_analyzer/raze/remote/BUILD.lazy_static-1.4.0.bazel new file mode 100644 index 0000000000..7fd9b6586f --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.lazy_static-1.4.0.bazel @@ -0,0 +1,57 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "lazy_static", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.4.0", + # buildifier: leave-alone + deps = [ + ], +) + +# Unsupported target "no_std" with type "test" omitted + +# Unsupported target "test" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.libc-0.2.86.bazel b/tools/rust_analyzer/raze/remote/BUILD.libc-0.2.86.bazel new file mode 100644 index 0000000000..8200c0f190 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.libc-0.2.86.bazel @@ -0,0 +1,84 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "libc_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.2.86", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "libc", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.2.86", + # buildifier: leave-alone + deps = [ + ":libc_build_script", + ], +) + +# Unsupported target "const_fn" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.proc-macro-error-1.0.4.bazel b/tools/rust_analyzer/raze/remote/BUILD.proc-macro-error-1.0.4.bazel new file mode 100644 index 0000000000..8db102c667 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.proc-macro-error-1.0.4.bazel @@ -0,0 +1,101 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "proc_macro_error_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + "default", + "syn", + "syn-error", + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.4", + visibility = ["//visibility:private"], + deps = [ + "@rules_rust_tools_rust_analyzer__version_check__0_9_2//:version_check", + ], +) + +rust_library( + name = "proc_macro_error", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + "syn", + "syn-error", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + proc_macro_deps = [ + "@rules_rust_tools_rust_analyzer__proc_macro_error_attr__1_0_4//:proc_macro_error_attr", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.4", + # buildifier: leave-alone + deps = [ + ":proc_macro_error_build_script", + "@rules_rust_tools_rust_analyzer__proc_macro2__1_0_24//:proc_macro2", + "@rules_rust_tools_rust_analyzer__quote__1_0_9//:quote", + "@rules_rust_tools_rust_analyzer__syn__1_0_60//:syn", + ], +) + +# Unsupported target "macro-errors" with type "test" omitted + +# Unsupported target "ok" with type "test" omitted + +# Unsupported target "runtime-errors" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.proc-macro-error-attr-1.0.4.bazel b/tools/rust_analyzer/raze/remote/BUILD.proc-macro-error-attr-1.0.4.bazel new file mode 100644 index 0000000000..eb3834dfdb --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.proc-macro-error-attr-1.0.4.bazel @@ -0,0 +1,85 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "proc_macro_error_attr_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.4", + visibility = ["//visibility:private"], + deps = [ + "@rules_rust_tools_rust_analyzer__version_check__0_9_2//:version_check", + ], +) + +rust_library( + name = "proc_macro_error_attr", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "proc-macro", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.4", + # buildifier: leave-alone + deps = [ + ":proc_macro_error_attr_build_script", + "@rules_rust_tools_rust_analyzer__proc_macro2__1_0_24//:proc_macro2", + "@rules_rust_tools_rust_analyzer__quote__1_0_9//:quote", + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.proc-macro2-1.0.24.bazel b/tools/rust_analyzer/raze/remote/BUILD.proc-macro2-1.0.24.bazel new file mode 100644 index 0000000000..c7ec2d701b --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.proc-macro2-1.0.24.bazel @@ -0,0 +1,97 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "proc_macro2_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + "default", + "proc-macro", + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.24", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "proc_macro2", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + "proc-macro", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.24", + # buildifier: leave-alone + deps = [ + ":proc_macro2_build_script", + "@rules_rust_tools_rust_analyzer__unicode_xid__0_2_1//:unicode_xid", + ], +) + +# Unsupported target "comments" with type "test" omitted + +# Unsupported target "features" with type "test" omitted + +# Unsupported target "marker" with type "test" omitted + +# Unsupported target "test" with type "test" omitted + +# Unsupported target "test_fmt" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.quote-1.0.9.bazel b/tools/rust_analyzer/raze/remote/BUILD.quote-1.0.9.bazel new file mode 100644 index 0000000000..2fd419e14f --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.quote-1.0.9.bazel @@ -0,0 +1,60 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "quote", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + "proc-macro", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.9", + # buildifier: leave-alone + deps = [ + "@rules_rust_tools_rust_analyzer__proc_macro2__1_0_24//:proc_macro2", + ], +) + +# Unsupported target "compiletest" with type "test" omitted + +# Unsupported target "test" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.strsim-0.8.0.bazel b/tools/rust_analyzer/raze/remote/BUILD.strsim-0.8.0.bazel new file mode 100644 index 0000000000..7ee8a5c454 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.strsim-0.8.0.bazel @@ -0,0 +1,57 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +# Unsupported target "benches" with type "bench" omitted + +rust_library( + name = "strsim", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.8.0", + # buildifier: leave-alone + deps = [ + ], +) + +# Unsupported target "lib" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.structopt-0.3.21.bazel b/tools/rust_analyzer/raze/remote/BUILD.structopt-0.3.21.bazel new file mode 100644 index 0000000000..85c4bbaba4 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.structopt-0.3.21.bazel @@ -0,0 +1,151 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # Apache-2.0 from expression "Apache-2.0 OR MIT" +]) + +# Generated Targets + +# Unsupported target "after_help" with type "example" omitted + +# Unsupported target "at_least_two" with type "example" omitted + +# Unsupported target "basic" with type "example" omitted + +# Unsupported target "deny_missing_docs" with type "example" omitted + +# Unsupported target "doc_comments" with type "example" omitted + +# Unsupported target "enum_in_args" with type "example" omitted + +# Unsupported target "enum_tuple" with type "example" omitted + +# Unsupported target "env" with type "example" omitted + +# Unsupported target "example" with type "example" omitted + +# Unsupported target "flatten" with type "example" omitted + +# Unsupported target "gen_completions" with type "example" omitted + +# Unsupported target "git" with type "example" omitted + +# Unsupported target "group" with type "example" omitted + +# Unsupported target "keyvalue" with type "example" omitted + +# Unsupported target "negative_flag" with type "example" omitted + +# Unsupported target "no_version" with type "example" omitted + +# Unsupported target "rename_all" with type "example" omitted + +# Unsupported target "required_if" with type "example" omitted + +# Unsupported target "skip" with type "example" omitted + +# Unsupported target "subcommand_aliases" with type "example" omitted + +# Unsupported target "true_or_false" with type "example" omitted + +rust_library( + name = "structopt", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + proc_macro_deps = [ + "@rules_rust_tools_rust_analyzer__structopt_derive__0_4_14//:structopt_derive", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.3.21", + # buildifier: leave-alone + deps = [ + "@rules_rust_tools_rust_analyzer__clap__2_33_3//:clap", + "@rules_rust_tools_rust_analyzer__lazy_static__1_4_0//:lazy_static", + ], +) + +# Unsupported target "argument_naming" with type "test" omitted + +# Unsupported target "arguments" with type "test" omitted + +# Unsupported target "author_version_about" with type "test" omitted + +# Unsupported target "custom-string-parsers" with type "test" omitted + +# Unsupported target "default_value" with type "test" omitted + +# Unsupported target "deny-warnings" with type "test" omitted + +# Unsupported target "doc-comments-help" with type "test" omitted + +# Unsupported target "explicit_name_no_renaming" with type "test" omitted + +# Unsupported target "flags" with type "test" omitted + +# Unsupported target "flatten" with type "test" omitted + +# Unsupported target "issues" with type "test" omitted + +# Unsupported target "macro-errors" with type "test" omitted + +# Unsupported target "nested-subcommands" with type "test" omitted + +# Unsupported target "non_literal_attributes" with type "test" omitted + +# Unsupported target "options" with type "test" omitted + +# Unsupported target "privacy" with type "test" omitted + +# Unsupported target "raw_bool_literal" with type "test" omitted + +# Unsupported target "raw_idents" with type "test" omitted + +# Unsupported target "regressions" with type "test" omitted + +# Unsupported target "rename_all_env" with type "test" omitted + +# Unsupported target "skip" with type "test" omitted + +# Unsupported target "special_types" with type "test" omitted + +# Unsupported target "subcommands" with type "test" omitted + +# Unsupported target "utils" with type "test" omitted + +# Unsupported target "we_need_syn_full" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.structopt-derive-0.4.14.bazel b/tools/rust_analyzer/raze/remote/BUILD.structopt-derive-0.4.14.bazel new file mode 100644 index 0000000000..3de6f7ff68 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.structopt-derive-0.4.14.bazel @@ -0,0 +1,58 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # Apache-2.0 from expression "Apache-2.0 OR MIT" +]) + +# Generated Targets + +rust_library( + name = "structopt_derive", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "proc-macro", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.4.14", + # buildifier: leave-alone + deps = [ + "@rules_rust_tools_rust_analyzer__heck__0_3_2//:heck", + "@rules_rust_tools_rust_analyzer__proc_macro2__1_0_24//:proc_macro2", + "@rules_rust_tools_rust_analyzer__proc_macro_error__1_0_4//:proc_macro_error", + "@rules_rust_tools_rust_analyzer__quote__1_0_9//:quote", + "@rules_rust_tools_rust_analyzer__syn__1_0_60//:syn", + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.syn-1.0.60.bazel b/tools/rust_analyzer/raze/remote/BUILD.syn-1.0.60.bazel new file mode 100644 index 0000000000..581a6ab1c1 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.syn-1.0.60.bazel @@ -0,0 +1,157 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "syn_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + "clone-impls", + "default", + "derive", + "full", + "parsing", + "printing", + "proc-macro", + "quote", + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.60", + visibility = ["//visibility:private"], + deps = [ + ], +) + +# Unsupported target "file" with type "bench" omitted + +# Unsupported target "rust" with type "bench" omitted + +rust_library( + name = "syn", + srcs = glob(["**/*.rs"]), + crate_features = [ + "clone-impls", + "default", + "derive", + "full", + "parsing", + "printing", + "proc-macro", + "quote", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.0.60", + # buildifier: leave-alone + deps = [ + ":syn_build_script", + "@rules_rust_tools_rust_analyzer__proc_macro2__1_0_24//:proc_macro2", + "@rules_rust_tools_rust_analyzer__quote__1_0_9//:quote", + "@rules_rust_tools_rust_analyzer__unicode_xid__0_2_1//:unicode_xid", + ], +) + +# Unsupported target "test_asyncness" with type "test" omitted + +# Unsupported target "test_attribute" with type "test" omitted + +# Unsupported target "test_derive_input" with type "test" omitted + +# Unsupported target "test_expr" with type "test" omitted + +# Unsupported target "test_generics" with type "test" omitted + +# Unsupported target "test_grouping" with type "test" omitted + +# Unsupported target "test_ident" with type "test" omitted + +# Unsupported target "test_item" with type "test" omitted + +# Unsupported target "test_iterators" with type "test" omitted + +# Unsupported target "test_lit" with type "test" omitted + +# Unsupported target "test_meta" with type "test" omitted + +# Unsupported target "test_parse_buffer" with type "test" omitted + +# Unsupported target "test_parse_stream" with type "test" omitted + +# Unsupported target "test_pat" with type "test" omitted + +# Unsupported target "test_path" with type "test" omitted + +# Unsupported target "test_precedence" with type "test" omitted + +# Unsupported target "test_receiver" with type "test" omitted + +# Unsupported target "test_round_trip" with type "test" omitted + +# Unsupported target "test_shebang" with type "test" omitted + +# Unsupported target "test_should_parse" with type "test" omitted + +# Unsupported target "test_size" with type "test" omitted + +# Unsupported target "test_stmt" with type "test" omitted + +# Unsupported target "test_token_trees" with type "test" omitted + +# Unsupported target "test_ty" with type "test" omitted + +# Unsupported target "test_visibility" with type "test" omitted + +# Unsupported target "zzz_stable" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.textwrap-0.11.0.bazel b/tools/rust_analyzer/raze/remote/BUILD.textwrap-0.11.0.bazel new file mode 100644 index 0000000000..d63ad5a1ce --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.textwrap-0.11.0.bazel @@ -0,0 +1,62 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +# Unsupported target "linear" with type "bench" omitted + +# Unsupported target "layout" with type "example" omitted + +# Unsupported target "termwidth" with type "example" omitted + +rust_library( + name = "textwrap", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.11.0", + # buildifier: leave-alone + deps = [ + "@rules_rust_tools_rust_analyzer__unicode_width__0_1_8//:unicode_width", + ], +) + +# Unsupported target "version-numbers" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.unicode-segmentation-1.7.1.bazel b/tools/rust_analyzer/raze/remote/BUILD.unicode-segmentation-1.7.1.bazel new file mode 100644 index 0000000000..2b761bdd2d --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.unicode-segmentation-1.7.1.bazel @@ -0,0 +1,55 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +# Unsupported target "graphemes" with type "bench" omitted + +rust_library( + name = "unicode_segmentation", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.7.1", + # buildifier: leave-alone + deps = [ + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.unicode-width-0.1.8.bazel b/tools/rust_analyzer/raze/remote/BUILD.unicode-width-0.1.8.bazel new file mode 100644 index 0000000000..d981d0bbb3 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.unicode-width-0.1.8.bazel @@ -0,0 +1,54 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "unicode_width", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.1.8", + # buildifier: leave-alone + deps = [ + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.unicode-xid-0.2.1.bazel b/tools/rust_analyzer/raze/remote/BUILD.unicode-xid-0.2.1.bazel new file mode 100644 index 0000000000..c5185455cd --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.unicode-xid-0.2.1.bazel @@ -0,0 +1,56 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "unicode_xid", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.2.1", + # buildifier: leave-alone + deps = [ + ], +) + +# Unsupported target "exhaustive_tests" with type "test" omitted diff --git a/tools/rust_analyzer/raze/remote/BUILD.vec_map-0.8.2.bazel b/tools/rust_analyzer/raze/remote/BUILD.vec_map-0.8.2.bazel new file mode 100644 index 0000000000..274966f06a --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.vec_map-0.8.2.bazel @@ -0,0 +1,53 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "vec_map", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.8.2", + # buildifier: leave-alone + deps = [ + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.version_check-0.9.2.bazel b/tools/rust_analyzer/raze/remote/BUILD.version_check-0.9.2.bazel new file mode 100644 index 0000000000..d1f1747268 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.version_check-0.9.2.bazel @@ -0,0 +1,53 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "version_check", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.9.2", + # buildifier: leave-alone + deps = [ + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.winapi-0.3.9.bazel b/tools/rust_analyzer/raze/remote/BUILD.winapi-0.3.9.bazel new file mode 100644 index 0000000000..b64b7bdbcb --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.winapi-0.3.9.bazel @@ -0,0 +1,94 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "winapi_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + "consoleapi", + "errhandlingapi", + "minwinbase", + "minwindef", + "processenv", + "winbase", + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.3.9", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "winapi", + srcs = glob(["**/*.rs"]), + crate_features = [ + "consoleapi", + "errhandlingapi", + "minwinbase", + "minwindef", + "processenv", + "winbase", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.3.9", + # buildifier: leave-alone + deps = [ + ":winapi_build_script", + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel b/tools/rust_analyzer/raze/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel new file mode 100644 index 0000000000..2d0f24a9e8 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel @@ -0,0 +1,82 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "winapi_i686_pc_windows_gnu_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.4.0", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "winapi_i686_pc_windows_gnu", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.4.0", + # buildifier: leave-alone + deps = [ + ":winapi_i686_pc_windows_gnu_build_script", + ], +) diff --git a/tools/rust_analyzer/raze/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel b/tools/rust_analyzer/raze/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel new file mode 100644 index 0000000000..08ff48c5d4 --- /dev/null +++ b/tools/rust_analyzer/raze/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel @@ -0,0 +1,82 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//tools/rust_analyzer/raze", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "winapi_x86_64_pc_windows_gnu_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.4.0", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "winapi_x86_64_pc_windows_gnu", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.4.0", + # buildifier: leave-alone + deps = [ + ":winapi_x86_64_pc_windows_gnu_build_script", + ], +) From 2b0d3e3cd3caaebd86cdb95c257131b110a2a121 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Sun, 14 Feb 2021 09:49:07 +0000 Subject: [PATCH 44/49] Use the new rust_common.crate_info, but now this OOMs... --- rust/private/rust_analyzer.bzl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index b0157d2c6e..42cac4727d 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -20,7 +20,7 @@ given targets. This file can be consumed by rust-analyzer as an alternative to Cargo.toml files. """ -load("//rust:rust_common.bzl", "CrateInfo") +load("//rust/private:common.bzl", "rust_common") load("//rust/private:rustc.bzl", "BuildInfo") load("//rust/private:utils.bzl", "find_toolchain") load("//rust/platform:triple_mappings.bzl", "system_to_dylib_ext", "triple_to_system") @@ -34,7 +34,7 @@ _rust_rules = [ RustAnalyzerInfo = provider( doc = "RustAnalyzerInfo holds rust crate metadata for targets", fields = { - "crate": "CrateInfo", + "crate": "rust_common.crate_info", "deps": "List[RustAnalyzerInfo]: direct dependencies", "transitive_deps": "List[RustAnalyzerInfo]: transitive closure of dependencies", "cfgs": "List[String]: features or other compilation --cfg settings", @@ -45,7 +45,7 @@ RustAnalyzerInfo = provider( ) def _rust_analyzer_aspect_impl(target, ctx): - if CrateInfo not in target: + if rust_common.crate_info not in target: return [] toolchain = find_toolchain(ctx) @@ -68,7 +68,7 @@ def _rust_analyzer_aspect_impl(target, ctx): dep_infos += [dep[RustAnalyzerInfo] for dep in ctx.rule.attr.proc_macro_deps if RustAnalyzerInfo in dep] transitive_deps = depset(direct = dep_infos, order = "postorder", transitive = [dep.transitive_deps for dep in dep_infos]) - crate_info = target[CrateInfo] + crate_info = target[rust_common.crate_info] return [RustAnalyzerInfo( crate = crate_info, cfgs = cfgs, @@ -88,7 +88,7 @@ def find_proc_macro_dylib_path(toolchain, target): Returns: (path): The path to the proc macro dylib, or None if this crate is not a proc-macro. """ - if target[CrateInfo].type != "proc-macro": + if target[rust_common.crate_info].type != "proc-macro": return None dylib_ext = system_to_dylib_ext(triple_to_system(toolchain.target_triple)) From 4a55fb8246c9bf4959257f6bf02ac6855a33bbac Mon Sep 17 00:00:00 2001 From: David Marcin Date: Sun, 14 Feb 2021 10:12:20 +0000 Subject: [PATCH 45/49] Make buildifier happy --- docs/BUILD | 19 ++++++++----------- docs/all.bzl | 4 ++-- rust/private/rust_analyzer.bzl | 18 +++++++++--------- rust/rust.bzl | 10 +++++----- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/docs/BUILD b/docs/BUILD index 7f5c442c27..945d56605b 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -37,12 +37,20 @@ PAGES = { "rust_benchmark", "rust_test", ], + "rust_analyzer": [ + "rust_analyzer", + "rust_analyzer_aspect", + ], "rust_bindgen": [ "rust_bindgen_library", "rust_bindgen_repositories", "rust_bindgen_toolchain", "rust_bindgen", ], + "rust_clippy": [ + "rust_clippy", + "rust_clippy_aspect", + ], "rust_doc": [ "rust_doc", "rust_doc_test", @@ -60,17 +68,6 @@ PAGES = { "rust_toolchain_repository", "rust_toolchain_repository_proxy", ], - "rust_workspace": [ - "rust_workspace", - ], - "rust_clippy": [ - "rust_clippy", - "rust_clippy_aspect", - ], - "rust_analyzer": [ - "rust_analyzer", - "rust_analyzer_aspect", - ] "rust_wasm_bindgen": [ "rust_wasm_bindgen_repositories", "rust_wasm_bindgen_toolchain", diff --git a/docs/all.bzl b/docs/all.bzl index d040112b7e..15b2569988 100644 --- a/docs/all.bzl +++ b/docs/all.bzl @@ -38,14 +38,14 @@ load( ) load( "@rules_rust//rust:rust.bzl", + _rust_analyzer = "rust_analyzer", _rust_benchmark = "rust_benchmark", _rust_binary = "rust_binary", + _rust_clippy = "rust_clippy", _rust_doc = "rust_doc", _rust_doc_test = "rust_doc_test", _rust_library = "rust_library", _rust_test = "rust_test", - _rust_clippy = "rust_clippy", - _rust_analyzer = "rust_analyzer", ) load( "@rules_rust//rust:toolchain.bzl", diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 42cac4727d..6da3504c87 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -20,10 +20,10 @@ given targets. This file can be consumed by rust-analyzer as an alternative to Cargo.toml files. """ +load("//rust/platform:triple_mappings.bzl", "system_to_dylib_ext", "triple_to_system") load("//rust/private:common.bzl", "rust_common") load("//rust/private:rustc.bzl", "BuildInfo") load("//rust/private:utils.bzl", "find_toolchain") -load("//rust/platform:triple_mappings.bzl", "system_to_dylib_ext", "triple_to_system") # We support only these rule kinds. _rust_rules = [ @@ -34,13 +34,13 @@ _rust_rules = [ RustAnalyzerInfo = provider( doc = "RustAnalyzerInfo holds rust crate metadata for targets", fields = { + "build_info": "BuildInfo: build info for this crate if present", + "cfgs": "List[String]: features or other compilation --cfg settings", "crate": "rust_common.crate_info", "deps": "List[RustAnalyzerInfo]: direct dependencies", - "transitive_deps": "List[RustAnalyzerInfo]: transitive closure of dependencies", - "cfgs": "List[String]: features or other compilation --cfg settings", "env": "Dict{String: String}: Environment variables, used for the `env!` macro", "proc_macro_dylib_path": "File: compiled shared library output of proc-macro rule", - "build_info": "BuildInfo: build info for this crate if present", + "transitive_deps": "List[RustAnalyzerInfo]: transitive closure of dependencies", }, ) @@ -81,7 +81,7 @@ def _rust_analyzer_aspect_impl(target, ctx): def find_proc_macro_dylib_path(toolchain, target): """Find the proc_macro_dylib_path of target. Returns None if target crate is not type proc-macro. - + Args: toolchain: The current rust toolchain. target: The current target. @@ -108,11 +108,11 @@ rust_analyzer_aspect = aspect( doc = "Annotates rust rules with RustAnalyzerInfo later used to build a rust-project.json", ) -_exec_root_tmpl = '__EXEC_ROOT__/' +_exec_root_tmpl = "__EXEC_ROOT__/" def _crate_id(crate_info): """Returns a unique stable identifier for a crate - + Returns: (string): This crate's unique stable id. """ @@ -149,13 +149,13 @@ def create_crate(ctx, info, crate_mapping): crate["env"].update({"OUT_DIR": _exec_root_tmpl + info.build_info.out_dir.path}) crate["source"] = { # We have to tell rust-analyzer about our out_dir since it's not under the crate root. - "include_dirs": [crate_root, _exec_root_tmpl + info.build_info.out_dir.path], "exclude_dirs": [], + "include_dirs": [crate_root, _exec_root_tmpl + info.build_info.out_dir.path], } crate["env"].update(info.env) deps = [ - {"name": d.crate.name, "crate": crate_mapping[_crate_id(d.crate)]} + {"crate": crate_mapping[_crate_id(d.crate)], "name": d.crate.name} for d in info.deps ] crate["deps"] = deps diff --git a/rust/rust.bzl b/rust/rust.bzl index ac6bb7a41b..1562635820 100644 --- a/rust/rust.bzl +++ b/rust/rust.bzl @@ -28,6 +28,11 @@ load( _rust_test = "rust_test", _rust_test_binary = "rust_test_binary", ) +load( + "//rust/private:rust_analyzer.bzl", + _rust_analyzer = "rust_analyzer", + _rust_analyzer_aspect = "rust_analyzer_aspect", +) load( "//rust/private:rustc.bzl", _error_format = "error_format", @@ -40,11 +45,6 @@ load( "//rust/private:rustdoc_test.bzl", _rust_doc_test = "rust_doc_test", ) -load( - "//rust/private:rust_analyzer.bzl", - _rust_analyzer = "rust_analyzer", - _rust_analyzer_aspect = "rust_analyzer_aspect", -) rust_library = _rust_library # See @rules_rust//rust/private:rust.bzl for a complete description. From 5a1d449fd3d4bd8310ae322745786a5605da9a9e Mon Sep 17 00:00:00 2001 From: David Marcin Date: Sun, 14 Feb 2021 10:18:34 +0000 Subject: [PATCH 46/49] Regenerate documentation --- docs/flatten.md | 3 +-- docs/rust_clippy.md | 2 +- docs/rust_workspace.md | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 docs/rust_workspace.md diff --git a/docs/flatten.md b/docs/flatten.md index 6a2cebad95..20509d9722 100644 --- a/docs/flatten.md +++ b/docs/flatten.md @@ -27,7 +27,6 @@ * [rust_wasm_bindgen](#rust_wasm_bindgen) * [rust_wasm_bindgen_repositories](#rust_wasm_bindgen_repositories) * [rust_wasm_bindgen_toolchain](#rust_wasm_bindgen_toolchain) -* [rust_workspace](#rust_workspace) @@ -335,7 +334,7 @@ For example, given the following example targets: ```python package(default_visibility = ["//visibility:public"]) -load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library", "rust_test") +load("@rules_rust//rust:rust.bzl", "rust_library", "rust_test") rust_library( name = "hello_lib", diff --git a/docs/rust_clippy.md b/docs/rust_clippy.md index 5d6b9127ed..8841f0c799 100644 --- a/docs/rust_clippy.md +++ b/docs/rust_clippy.md @@ -19,7 +19,7 @@ For example, given the following example targets: ```python package(default_visibility = ["//visibility:public"]) -load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library", "rust_test") +load("@rules_rust//rust:rust.bzl", "rust_library", "rust_test") rust_library( name = "hello_lib", diff --git a/docs/rust_workspace.md b/docs/rust_workspace.md deleted file mode 100644 index 8030da4ff8..0000000000 --- a/docs/rust_workspace.md +++ /dev/null @@ -1,3 +0,0 @@ -# Rust rules -* [rust_workspace](#rust_workspace) - From d5d58a0825245a45e93da3cfe26999f01b1caf13 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Sun, 14 Feb 2021 10:22:01 +0000 Subject: [PATCH 47/49] Regenerate known_shas --- rust/known_shas.bzl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rust/known_shas.bzl b/rust/known_shas.bzl index 9ac3cbc51d..d571603970 100644 --- a/rust/known_shas.bzl +++ b/rust/known_shas.bzl @@ -269,12 +269,14 @@ FILE_KEY_TO_SHA = { "2020-12-30/rust-std-nightly-x86_64-unknown-linux-gnu": "5b1bd5fa31b9190c66b3446629c155d4896cffc8fb1f9f603a2e949162b7f791", "2020-12-30/rustc-beta-aarch64-apple-darwin": "20107f4541be8822d428c402e010333f2f00aaf086d03b4e35ce8d1bd5c33d5a", "2020-12-30/rustc-beta-aarch64-unknown-linux-gnu": "29e2808cadf8da481a0ace30bf107372dd108b0475706cbe2b9cdd4ff27e2315", + "2020-12-30/rustc-beta-src": "1da2252009705f728e5ff62329b9500884368a3805e3d75079aa45ba0bd42892", "2020-12-30/rustc-beta-x86_64-apple-darwin": "d65df5791d79e13037672d22055ec24583195554cdf7c3c2992cbcafa497e98f", "2020-12-30/rustc-beta-x86_64-pc-windows-msvc": "7f934dd412207c0d776fb4e8ec4c5f4426e92b2a1854416a8ce7bbc2dc7f5908", "2020-12-30/rustc-beta-x86_64-unknown-freebsd": "19818ab53bbd94c6d1723a52809bf1c3a271e258664ea2b3b7d00161965e058c", "2020-12-30/rustc-beta-x86_64-unknown-linux-gnu": "4f5ac3311c913b79dca1a02cf42fd7326c63d53ee252447b61f113c043a82b5f", "2020-12-30/rustc-nightly-aarch64-apple-darwin": "4610961ab77e1bb54bda95474b1c1f25f1fc5c1c103bc4f54758e5b2a5454d8b", "2020-12-30/rustc-nightly-aarch64-unknown-linux-gnu": "c9997c01769a6371200e20639fcae99e6dec3d9062f65b2928429e04d4cb7930", + "2020-12-30/rustc-nightly-src": "e5e00eb7c58ad1a94dbb67b07f400a73faf8bf852bb2a31bd118155bf24a9f6d", "2020-12-30/rustc-nightly-x86_64-apple-darwin": "cf2f06d6c8d784a469561f6323b8b923fb6ad3a7c55c7ac90d5619b9d443ae9f", "2020-12-30/rustc-nightly-x86_64-pc-windows-msvc": "8df3729f3b09cb39fc4b0ecfd90551625941d508f7e776ae4e16fcf02b0af4f3", "2020-12-30/rustc-nightly-x86_64-unknown-freebsd": "f3818645265c3a08cb9fa04d1c2d42be72116974c9c34515feb7d5788e86ac41", @@ -938,12 +940,14 @@ FILE_KEY_TO_SHA = { "rustc-1.48.0-x86_64-unknown-linux-gnu": "aa4a96b010e0d4573e6a1fec230beaadaae6cdce2bb4befeee7b1c081ee9ef8c", "rustc-1.49.0-aarch64-apple-darwin": "3e8c0c9101f27623f7607f2d8acef5f28dcb2bdfcded56f210d9d370cf9a9c06", "rustc-1.49.0-aarch64-unknown-linux-gnu": "b72699cdf74c03ccc0aabab937a69807f2ceb5861f3508593e1c222190c4efc7", + "rustc-1.49.0-src": "b50aefa8df1fdfc9bccafdbf37aee611c8dfe81bf5648d5f43699c50289dc779", "rustc-1.49.0-x86_64-apple-darwin": "09333f9aacb9c5959e2a2798d7e283cae674255f063a35ea28f91595caa0a78b", "rustc-1.49.0-x86_64-pc-windows-msvc": "800b7571438850074aeb0fb9a0e7d890c6785f9f4823b3052b9b0b098bb9ddd4", "rustc-1.49.0-x86_64-unknown-freebsd": "66427837606aba2cda99d4f52161bee1086e98b226a5cb99be8e9a7bf896495f", "rustc-1.49.0-x86_64-unknown-linux-gnu": "42300556b987934e5e4677972c1dfc57eb07731dc62fa9f4f561935a1c84ed0e", "rustc-1.50.0-aarch64-apple-darwin": "3abc090591fb7fd0a292eeff4cc6a029841d39b0a768eaf1f0b9e4e06cba8ed7", "rustc-1.50.0-aarch64-unknown-linux-gnu": "9afe0e968da845981b463beb75f91d6da0d4de5443d1abb6002b75a8cf066ea7", + "rustc-1.50.0-src": "95978f8d02bb6175ae3238930baf03563c240aedf9a70bebdc3eaa2a8c3c5a5e", "rustc-1.50.0-x86_64-apple-darwin": "3637ee8d8bc0f8e922b1f9ec7b6fc00b6efcceae97c337d205a3bc472be7b936", "rustc-1.50.0-x86_64-pc-windows-msvc": "d7f7607c9cd3e137a335904e1186345f4328a971588ee8a54838e32a35a38e3a", "rustc-1.50.0-x86_64-unknown-freebsd": "916e616188638738ff217a047b3fbe372d9ad3734bb466d0e56d2fcefd1da5c6", From 227ece91af033c61768c3cee19b18b9a82d99066 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Sun, 14 Feb 2021 10:39:01 +0000 Subject: [PATCH 48/49] Remove extra /../ that isn't actually necessary --- rust/private/rust_analyzer.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 6da3504c87..545f248236 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -139,11 +139,11 @@ def create_crate(ctx, info, crate_mapping): if info.crate.root.path.startswith("external/"): crate["is_workspace_member"] = False crate["root_module"] = _exec_root_tmpl + info.crate.root.path - crate_root = _exec_root_tmpl + info.crate.root.dirname + "/../" + crate_root = _exec_root_tmpl + info.crate.root.dirname else: crate["is_workspace_member"] = True crate["root_module"] = info.crate.root.path - crate_root = info.crate.root.dirname + "/../" + crate_root = info.crate.root.dirname if info.build_info != None: crate["env"].update({"OUT_DIR": _exec_root_tmpl + info.build_info.out_dir.path}) From 1aa7f8ef2912ab16f88c0bcba37bd78e34aa7ecb Mon Sep 17 00:00:00 2001 From: David Marcin Date: Sun, 14 Feb 2021 10:41:33 +0000 Subject: [PATCH 49/49] Remove debugging statement --- tools/rust_analyzer/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/rust_analyzer/main.rs b/tools/rust_analyzer/main.rs index 7643f86fd5..73d64440e2 100644 --- a/tools/rust_analyzer/main.rs +++ b/tools/rust_analyzer/main.rs @@ -66,7 +66,6 @@ fn build_rust_project_target(config: &Config) { // Parse the configuration flags and supplement with bazel info as needed. fn parse_config() -> anyhow::Result { let mut config = Config::from_args(); - println!("Config = {:?}", config); // Ensure we know the workspace. If we are under `bazel run`, the // BUILD_WORKSPACE_DIR environment variable will be present.