Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce edition on all Bazel targets #1034

Merged
merged 1 commit into from Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions BUILD
Expand Up @@ -8,6 +8,7 @@ rust_library(
"alloc",
"std",
],
edition = "2018",
proc_macro_deps = [
":cxxbridge-macro",
],
Expand All @@ -19,6 +20,7 @@ rust_binary(
name = "codegen",
srcs = glob(["gen/cmd/src/**/*.rs"]),
data = ["gen/cmd/src/gen/include/cxx.h"],
edition = "2018",
visibility = ["//visibility:public"],
deps = [
"//third-party:clap",
Expand Down Expand Up @@ -46,6 +48,7 @@ cc_library(
rust_proc_macro(
name = "cxxbridge-macro",
srcs = glob(["macro/src/**"]),
edition = "2018",
deps = [
"//third-party:proc-macro2",
"//third-party:quote",
Expand All @@ -57,6 +60,7 @@ rust_library(
name = "build",
srcs = glob(["gen/build/src/**/*.rs"]),
data = ["gen/build/src/gen/include/cxx.h"],
edition = "2018",
visibility = ["//visibility:public"],
deps = [
"//third-party:cc",
Expand All @@ -73,6 +77,7 @@ rust_library(
name = "lib",
srcs = glob(["gen/lib/src/**/*.rs"]),
data = ["gen/lib/src/gen/include/cxx.h"],
edition = "2018",
visibility = ["//visibility:public"],
deps = [
"//third-party:cc",
Expand Down
5 changes: 1 addition & 4 deletions WORKSPACE
Expand Up @@ -16,10 +16,7 @@ load("@rules_rust//rust:repositories.bzl", "rust_repositories")

RUST_VERSION = "1.57.0"

rust_repositories(
edition = "2018",
version = RUST_VERSION,
)
rust_repositories(version = RUST_VERSION)

load("//tools/bazel:vendor.bzl", "vendor")

Expand Down
1 change: 1 addition & 0 deletions demo/BUILD
Expand Up @@ -5,6 +5,7 @@ load("//tools/bazel:rust_cxx_bridge.bzl", "rust_cxx_bridge")
rust_binary(
name = "demo",
srcs = glob(["src/**/*.rs"]),
edition = "2018",
deps = [
":blobstore-sys",
":bridge",
Expand Down
2 changes: 2 additions & 0 deletions tests/BUILD
Expand Up @@ -6,6 +6,7 @@ rust_test(
name = "test",
size = "small",
srcs = ["test.rs"],
edition = "2018",
deps = [
":cxx_test_suite",
"//:cxx",
Expand All @@ -19,6 +20,7 @@ rust_library(
"ffi/lib.rs",
"ffi/module.rs",
],
edition = "2018",
deps = [
":impl",
"//:cxx",
Expand Down
19 changes: 19 additions & 0 deletions third-party/BUILD
Expand Up @@ -8,18 +8,21 @@ load(
rust_library(
name = "bitflags",
srcs = glob(["vendor/bitflags-1.3.2/src/**"]),
edition = "2018",
)

rust_library(
name = "cc",
srcs = glob(["vendor/cc-1.0.73/src/**"]),
edition = "2018",
visibility = ["//visibility:public"],
)

rust_library(
name = "clap",
srcs = glob(["vendor/clap-3.1.6/src/**"]),
crate_features = ["std"],
edition = "2018",
visibility = ["//visibility:public"],
deps = [
":bitflags",
Expand All @@ -32,6 +35,7 @@ rust_library(
rust_library(
name = "codespan-reporting",
srcs = glob(["vendor/codespan-reporting-0.11.1/src/**"]),
edition = "2018",
visibility = ["//visibility:public"],
deps = [
":termcolor",
Expand All @@ -43,12 +47,14 @@ rust_library(
name = "hashbrown",
srcs = glob(["vendor/hashbrown-0.11.2/src/**"]),
crate_features = ["raw"],
edition = "2018",
)

rust_library(
name = "indexmap",
srcs = glob(["vendor/indexmap-1.8.0/src/**"]),
crate_features = ["std"],
edition = "2018",
rustc_flags = ["--cfg=has_std"],
deps = [":hashbrown"],
)
Expand All @@ -57,6 +63,7 @@ rust_library(
name = "memchr",
srcs = glob(["vendor/memchr-2.4.1/src/**/*.rs"]),
crate_features = ["std"],
edition = "2018",
)

rust_library(
Expand All @@ -66,6 +73,7 @@ rust_library(
"alloc",
"std",
],
edition = "2018",
visibility = ["//visibility:public"],
)

Expand All @@ -76,6 +84,7 @@ rust_library(
"memchr",
"raw_os_str",
],
edition = "2018",
deps = [":memchr"],
)

Expand All @@ -86,6 +95,7 @@ rust_library(
"proc-macro",
"span-locations",
],
edition = "2018",
visibility = ["//visibility:public"],
deps = [
":proc-macro2@build",
Expand All @@ -101,19 +111,22 @@ cargo_build_script(
"span-locations",
],
crate_name = "build",
edition = "2018",
)

rust_library(
name = "quote",
srcs = glob(["vendor/quote-1.0.15/src/**"]),
crate_features = ["proc-macro"],
edition = "2018",
visibility = ["//visibility:public"],
deps = [":proc-macro2"],
)

rust_library(
name = "scratch",
srcs = glob(["vendor/scratch-1.0.1/src/**"]),
edition = "2018",
rustc_env = {"OUT_DIR": ""},
visibility = ["//visibility:public"],
)
Expand All @@ -129,6 +142,7 @@ rust_library(
"printing",
"proc-macro",
],
edition = "2018",
visibility = ["//visibility:public"],
deps = [
":proc-macro2",
Expand All @@ -150,25 +164,30 @@ cargo_build_script(
"proc-macro",
],
crate_name = "build",
edition = "2018",
)

rust_library(
name = "termcolor",
srcs = glob(["vendor/termcolor-1.1.3/src/**"]),
edition = "2018",
)

rust_library(
name = "textwrap",
srcs = glob(["vendor/textwrap-0.15.0/src/**"]),
edition = "2018",
deps = [":unicode-width"],
)

rust_library(
name = "unicode-width",
srcs = glob(["vendor/unicode-width-0.1.9/src/**"]),
edition = "2018",
)

rust_library(
name = "unicode-xid",
srcs = glob(["vendor/unicode-xid-0.2.2/src/**"]),
edition = "2018",
)
12 changes: 6 additions & 6 deletions tools/bazel/third_party.bzl
Expand Up @@ -5,14 +5,14 @@ load("@third-party//:vendor.bzl", "vendored")
def third_party_glob(include):
return vendored and native.glob(include)

def third_party_cargo_build_script(rustc_flags = [], **kwargs):
def third_party_cargo_build_script(edition, rustc_flags = [], **kwargs):
rustc_flags = rustc_flags + ["--cap-lints=allow"]
cargo_build_script(rustc_flags = rustc_flags, **kwargs)
cargo_build_script(edition = edition, rustc_flags = rustc_flags, **kwargs)

def third_party_rust_binary(rustc_flags = [], **kwargs):
def third_party_rust_binary(edition, rustc_flags = [], **kwargs):
rustc_flags = rustc_flags + ["--cap-lints=allow"]
rust_binary(rustc_flags = rustc_flags, **kwargs)
rust_binary(edition = edition, rustc_flags = rustc_flags, **kwargs)

def third_party_rust_library(rustc_flags = [], **kwargs):
def third_party_rust_library(edition, rustc_flags = [], **kwargs):
rustc_flags = rustc_flags + ["--cap-lints=allow"]
rust_library(rustc_flags = rustc_flags, **kwargs)
rust_library(edition = edition, rustc_flags = rustc_flags, **kwargs)