Skip to content

Commit

Permalink
Migrate rules_rust examples to defs.bzl and smaller rules (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
hlopko committed Oct 23, 2021
1 parent 3fff8df commit d974e0e
Show file tree
Hide file tree
Showing 52 changed files with 112 additions and 161 deletions.
2 changes: 1 addition & 1 deletion examples/bindgen/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_rust//bindgen:bindgen.bzl", "rust_bindgen_library")
load("@rules_rust//rust:rust.bzl", "rust_binary", "rust_test")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test")

cc_library(
name = "simple",
Expand Down
6 changes: 1 addition & 5 deletions examples/cargo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ load(
"@rules_rust//cargo:cargo_build_script.bzl",
"cargo_build_script",
)
load(
"@rules_rust//rust:rust.bzl",
"rust_library",
"rust_test",
)
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")

cargo_build_script(
name = "build_script",
Expand Down
2 changes: 1 addition & 1 deletion examples/cargo_manifest_dir/usage/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_rust//rust:rust.bzl", "rust_test")
load("@rules_rust//rust:defs.bzl", "rust_test")

rust_test(
name = "cargo_manifest_dir_usage",
Expand Down
5 changes: 1 addition & 4 deletions examples/env_locations/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
load(
"@rules_rust//rust:rust.bzl",
"rust_test",
)
load("@rules_rust//rust:defs.bzl", "rust_test")

# generate a file
genrule(
Expand Down
5 changes: 2 additions & 3 deletions examples/ffi/c_calling_rust/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("@rules_rust//rust:rust.bzl", "rust_library", "rust_test")
load("@rules_rust//rust:defs.bzl", "rust_static_library", "rust_test")

rust_library(
rust_static_library(
name = "rusty",
srcs = ["lib.rs"],
crate_type = "staticlib",
)

rust_test(
Expand Down
2 changes: 1 addition & 1 deletion examples/ffi/rust_calling_c/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_rust//rust:rust.bzl", "rust_doc", "rust_library", "rust_test")
load("@rules_rust//rust:defs.bzl", "rust_doc", "rust_library", "rust_test")

package(default_visibility = ["//ffi/rust_calling_c:__subpackages__"])

Expand Down
8 changes: 1 addition & 7 deletions examples/fibonacci/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
load(
"@rules_rust//rust:rust.bzl",
"rust_doc",
"rust_doc_test",
"rust_library",
"rust_test",
)
load("@rules_rust//rust:defs.bzl", "rust_doc", "rust_doc_test", "rust_library", "rust_test")

rust_library(
name = "fibonacci",
Expand Down
5 changes: 1 addition & 4 deletions examples/flag_locations/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
load(
"@rules_rust//rust:rust.bzl",
"rust_test",
)
load("@rules_rust//rust:defs.bzl", "rust_test")

# generate a file containing cfg flags
genrule(
Expand Down
30 changes: 5 additions & 25 deletions examples/hello_lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
load(
"@rules_rust//rust:rust.bzl",
"rust_analyzer",
"rust_doc",
"rust_doc_test",
"rust_library",
"rust_test",
)
load("@rules_rust//rust:defs.bzl", "rust_analyzer", "rust_doc", "rust_doc_test", "rust_library", "rust_shared_library", "rust_static_library", "rust_test")

package(default_visibility = ["//visibility:public"])

Expand All @@ -19,50 +12,37 @@ rust_library(
rustc_flags = ["--cap-lints=allow"],
)

rust_library(
name = "hello_dylib",
srcs = [
"src/greeter.rs",
"src/lib.rs",
],
crate_type = "dylib",
)

rust_library(
rust_shared_library(
name = "hello_cdylib",
srcs = [
"src/greeter.rs",
"src/lib.rs",
],
crate_type = "cdylib",
)

rust_library(
rust_static_library(
name = "hello_staticlib",
srcs = [
"src/greeter.rs",
"src/lib.rs",
],
crate_type = "staticlib",
)

# Regression test for #368: static lib with dependencies fail.
rust_library(
rust_static_library(
name = "hello_test_staticlib",
srcs = [
"tests/greeting.rs",
],
crate_type = "staticlib",
deps = [":hello_lib"],
)

# Regression test for #368: cdylib lib with dependencies fail.
rust_library(
rust_shared_library(
name = "hello_test_cdylib",
srcs = [
"tests/greeting.rs",
],
crate_type = "cdylib",
deps = [":hello_lib"],
)

Expand Down
2 changes: 1 addition & 1 deletion examples/hello_runfiles/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_rust//rust:rust.bzl", "rust_binary")
load("@rules_rust//rust:defs.bzl", "rust_binary")

package(default_visibility = ["//visibility:public"])

Expand Down
6 changes: 1 addition & 5 deletions examples/hello_world/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
load(
"@rules_rust//rust:rust.bzl",
"rust_binary",
"rust_doc",
)
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_doc")

package(default_visibility = ["//visibility:public"])

Expand Down
7 changes: 1 addition & 6 deletions examples/per_platform_printer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
load(
"@rules_rust//rust:rust.bzl",
"rust_binary",
"rust_library",
"rust_test",
)
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")

package(default_visibility = ["//visibility:public"])

Expand Down
2 changes: 1 addition & 1 deletion examples/proto/basic/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_rust//proto:proto.bzl", "rust_proto_library")
load("@rules_rust//rust:rust.bzl", "rust_binary", "rust_library")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")

package(default_visibility = ["//proto:__subpackages__"])

Expand Down
2 changes: 1 addition & 1 deletion examples/proto/helloworld/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_rust//proto:proto.bzl", "rust_grpc_library")
load("@rules_rust//rust:rust.bzl", "rust_test")
load("@rules_rust//rust:defs.bzl", "rust_test")

proto_library(
name = "helloworld",
Expand Down
2 changes: 1 addition & 1 deletion examples/proto/helloworld/greeter_client/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_rust//proto:toolchain.bzl", "GRPC_COMPILE_DEPS")
load("@rules_rust//rust:rust.bzl", "rust_binary")
load("@rules_rust//rust:defs.bzl", "rust_binary")

rust_binary(
name = "greeter_client",
Expand Down
2 changes: 1 addition & 1 deletion examples/proto/helloworld/greeter_server/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_rust//proto:toolchain.bzl", "GRPC_COMPILE_DEPS")
load("@rules_rust//rust:rust.bzl", "rust_binary")
load("@rules_rust//rust:defs.bzl", "rust_binary")

rust_binary(
name = "greeter_server",
Expand Down
2 changes: 1 addition & 1 deletion examples/sys/basic/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_rust//rust:rust.bzl", "rust_binary")
load("@rules_rust//rust:defs.bzl", "rust_binary")

package(default_visibility = ["//visibility:public"])

Expand Down
4 changes: 2 additions & 2 deletions examples/sys/basic/raze/remote/BUILD.bzip2-0.3.3.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:rust.bzl",
"@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_library",
"rust_proc_macro",
"rust_test",
)

Expand All @@ -36,7 +37,6 @@ rust_library(
crate_features = [
],
crate_root = "src/lib.rs",
crate_type = "lib",
data = [],
edition = "2015",
rustc_flags = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:rust.bzl",
"@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_library",
"rust_proc_macro",
"rust_test",
)

Expand Down Expand Up @@ -68,7 +69,6 @@ rust_library(
crate_features = [
],
crate_root = "lib.rs",
crate_type = "lib",
data = [],
edition = "2015",
rustc_flags = [
Expand Down
4 changes: 2 additions & 2 deletions examples/sys/basic/raze/remote/BUILD.cc-1.0.60.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:rust.bzl",
"@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_library",
"rust_proc_macro",
"rust_test",
)

Expand Down Expand Up @@ -60,7 +61,6 @@ rust_library(
crate_features = [
],
crate_root = "src/lib.rs",
crate_type = "lib",
data = [],
edition = "2018",
rustc_flags = [
Expand Down
4 changes: 2 additions & 2 deletions examples/sys/basic/raze/remote/BUILD.libc-0.2.77.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:rust.bzl",
"@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_library",
"rust_proc_macro",
"rust_test",
)

Expand Down Expand Up @@ -40,7 +41,6 @@ rust_library(
"std",
],
crate_root = "src/lib.rs",
crate_type = "lib",
data = [],
edition = "2015",
rustc_flags = [
Expand Down
4 changes: 2 additions & 2 deletions examples/sys/basic/raze/remote/BUILD.pkg-config-0.3.18.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:rust.bzl",
"@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_library",
"rust_proc_macro",
"rust_test",
)

Expand All @@ -36,7 +37,6 @@ rust_library(
crate_features = [
],
crate_root = "src/lib.rs",
crate_type = "lib",
data = [],
edition = "2015",
rustc_flags = [
Expand Down
2 changes: 1 addition & 1 deletion examples/sys/complex/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_rust//rust:rust.bzl", "rust_binary")
load("@rules_rust//rust:defs.bzl", "rust_binary")

package(default_visibility = ["//visibility:public"])

Expand Down
4 changes: 2 additions & 2 deletions examples/sys/complex/raze/remote/BUILD.autocfg-1.0.1.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:rust.bzl",
"@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_library",
"rust_proc_macro",
"rust_test",
)

Expand Down Expand Up @@ -44,7 +45,6 @@ rust_library(
crate_features = [
],
crate_root = "src/lib.rs",
crate_type = "lib",
data = [],
edition = "2015",
rustc_flags = [
Expand Down
4 changes: 2 additions & 2 deletions examples/sys/complex/raze/remote/BUILD.bitflags-1.2.1.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:rust.bzl",
"@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_library",
"rust_proc_macro",
"rust_test",
)

Expand Down Expand Up @@ -67,7 +68,6 @@ rust_library(
"default",
],
crate_root = "src/lib.rs",
crate_type = "lib",
data = [],
edition = "2015",
rustc_flags = [
Expand Down
4 changes: 2 additions & 2 deletions examples/sys/complex/raze/remote/BUILD.cc-1.0.69.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:rust.bzl",
"@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_library",
"rust_proc_macro",
"rust_test",
)

Expand Down Expand Up @@ -65,7 +66,6 @@ rust_library(
"parallel",
],
crate_root = "src/lib.rs",
crate_type = "lib",
data = [],
edition = "2018",
rustc_flags = [
Expand Down
Loading

0 comments on commit d974e0e

Please sign in to comment.