From 5d3f36c8af4953df2e828a2ec866b4e47bf2cdf4 Mon Sep 17 00:00:00 2001 From: Andre Brisco Date: Wed, 27 Jan 2021 07:38:17 -0800 Subject: [PATCH] Updated Bazel Rust rules version --- WORKSPACE | 35 +++++++-------------------------- third-party/BUILD | 2 -- tools/bazel/BUILD | 7 +++++++ tools/bazel/rust.bzl | 4 +++- tools/bazel/rust_cxx_bridge.bzl | 8 ++++++++ tools/bazel/vendor.bzl | 11 ++++++++++- 6 files changed, 35 insertions(+), 32 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 039237b5..ce4e1acb 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -2,39 +2,18 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("//tools/bazel:vendor.bzl", "vendor") http_archive( - name = "io_bazel_rules_rust", - sha256 = "5ed804fcd10a506a5b8e9e59bc6b3b7f43bc30c87ce4670e6f78df43604894fd", - strip_prefix = "rules_rust-fdf9655ba95616e0314b4e0ebab40bb0c5fe005c", - # Master branch as of 2020-07-30 - url = "https://github.com/bazelbuild/rules_rust/archive/fdf9655ba95616e0314b4e0ebab40bb0c5fe005c.tar.gz", -) - -http_archive( - name = "bazel_skylib", - sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", + name = "rules_rust", + sha256 = "e6d835ee673f388aa5b62dc23d82db8fc76497e93fa47d8a4afe97abaf09b10d", + strip_prefix = "rules_rust-f37b9d6a552e9412285e627f30cb124e709f4f7a", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", + # Master branch as of 2021-01-27 + "https://github.com/bazelbuild/rules_rust/archive/f37b9d6a552e9412285e627f30cb124e709f4f7a.tar.gz", ], ) -load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version") +load("@rules_rust//rust:repositories.bzl", "rust_repositories") -bazel_version(name = "bazel_version") - -load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repository_set") - -rust_repository_set( - name = "rust_1_48_linux", - exec_triple = "x86_64-unknown-linux-gnu", - version = "1.48.0", -) - -rust_repository_set( - name = "rust_1_48_darwin", - exec_triple = "x86_64-apple-darwin", - version = "1.48.0", -) +rust_repositories() vendor( name = "third-party", diff --git a/third-party/BUILD b/third-party/BUILD index a8e5622a..6b9e7bba 100644 --- a/third-party/BUILD +++ b/third-party/BUILD @@ -1,10 +1,8 @@ load( "//tools/bazel:rust.bzl", glob = "third_party_glob", - rust_binary = "third_party_rust_binary", rust_library = "third_party_rust_library", ) -load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") rust_library( name = "bitflags", diff --git a/tools/bazel/BUILD b/tools/bazel/BUILD index e69de29b..d42fc71c 100644 --- a/tools/bazel/BUILD +++ b/tools/bazel/BUILD @@ -0,0 +1,7 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +bzl_library( + name = "bzl_srcs", + srcs = glob(["**/*.bzl"]), + visibility = ["//visibility:public"], +) diff --git a/tools/bazel/rust.bzl b/tools/bazel/rust.bzl index b7b23e55..9f71923a 100644 --- a/tools/bazel/rust.bzl +++ b/tools/bazel/rust.bzl @@ -1,5 +1,7 @@ +"""A module wrapping the core rules of `rules_rust`""" + load( - "@io_bazel_rules_rust//rust:rust.bzl", + "@rules_rust//rust:rust.bzl", _rust_binary = "rust_binary", _rust_library = "rust_library", _rust_test = "rust_test", diff --git a/tools/bazel/rust_cxx_bridge.bzl b/tools/bazel/rust_cxx_bridge.bzl index 534f6b5a..d026e0d8 100644 --- a/tools/bazel/rust_cxx_bridge.bzl +++ b/tools/bazel/rust_cxx_bridge.bzl @@ -1,7 +1,15 @@ +# buildifier: disable=module-docstring load("@bazel_skylib//rules:run_binary.bzl", "run_binary") load("@rules_cc//cc:defs.bzl", "cc_library") def rust_cxx_bridge(name, src, deps = []): + """A macro defining a cxx bridge library + + Args: + name (string): The name of the new target + src (string): The rust source file to generate a bridge for + deps (list, optional): A list of dependencies for the underlying cc_library. Defaults to []. + """ native.alias( name = "%s/header" % name, actual = src + ".h", diff --git a/tools/bazel/vendor.bzl b/tools/bazel/vendor.bzl index e9f10ac6..24678e8e 100644 --- a/tools/bazel/vendor.bzl +++ b/tools/bazel/vendor.bzl @@ -1,3 +1,7 @@ +"""A module defining a repository rule for vendoring the dependencies +of a crate in the current workspace. +""" + def _impl(repository_ctx): # Link cxx repository into @third-party. lockfile = repository_ctx.path(repository_ctx.attr.lockfile) @@ -48,7 +52,12 @@ def _log_cargo_vendor(repository_ctx, result): repository_ctx.execute(print, quiet = False) vendor = repository_rule( - attrs = {"lockfile": attr.label()}, + doc = "A rule used to vender the dependencies of a crate in the current workspace", + attrs = { + "lockfile": attr.label( + doc = "A lockfile providing the set of crates to vendor", + ), + }, local = True, implementation = _impl, )