|
|
|
@ -2,7 +2,6 @@ |
|
|
|
|
|
|
|
|
|
load("@bazel_skylib//rules:common_settings.bzl", "string_flag") |
|
|
|
|
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix") |
|
|
|
|
load("@rules_pkg//pkg:tar.bzl", "pkg_tar") |
|
|
|
|
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test") |
|
|
|
|
load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain") |
|
|
|
|
load("//rust:dist.bzl", "pkg_cross_compiled_binaries") |
|
|
|
@ -261,20 +260,10 @@ config_setting( |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Note: strip_prefix.from_pkg() should work for this below, but has surprising behavior in bazel |
|
|
|
|
# with filegroups and so we only use strip_prefix.from_root() and this constant instead. |
|
|
|
|
SRC_ROOT = "rust" |
|
|
|
|
|
|
|
|
|
pkg_files( |
|
|
|
|
name = "rust_protobuf_src", |
|
|
|
|
srcs = ALL_RUST_SRCS, |
|
|
|
|
strip_prefix = strip_prefix.from_root(SRC_ROOT), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
pkg_files( |
|
|
|
|
name = "crate_root_files", |
|
|
|
|
srcs = ["//rust/cargo:srcs"], |
|
|
|
|
strip_prefix = strip_prefix.from_root(SRC_ROOT + "/cargo"), |
|
|
|
|
strip_prefix = strip_prefix.from_root("rust"), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
pkg_filegroup( |
|
|
|
@ -284,6 +273,7 @@ pkg_filegroup( |
|
|
|
|
"//rust/upb:rust_protobuf_upb_src", |
|
|
|
|
], |
|
|
|
|
prefix = "src", |
|
|
|
|
visibility = ["//rust/release_crates:__subpackages__"], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
pkg_files( |
|
|
|
@ -299,79 +289,7 @@ pkg_filegroup( |
|
|
|
|
"//upb/cmake:upb_cmake_dist", |
|
|
|
|
], |
|
|
|
|
prefix = "libupb", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
pkg_tar( |
|
|
|
|
name = "protobuf_crate_dist", |
|
|
|
|
srcs = [ |
|
|
|
|
":crate_root_files", |
|
|
|
|
":rust_protobuf_libupb_src", |
|
|
|
|
":rust_protobuf_src_dir", |
|
|
|
|
"//:LICENSE", |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
pkg_files( |
|
|
|
|
name = "protobuf_codegen_files", |
|
|
|
|
srcs = ["//rust/protobuf_codegen:srcs"], |
|
|
|
|
strip_prefix = strip_prefix.from_root(SRC_ROOT + "/protobuf_codegen"), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
pkg_tar( |
|
|
|
|
name = "codegen_crate_dist", |
|
|
|
|
srcs = [ |
|
|
|
|
":protobuf_codegen_files", |
|
|
|
|
":vendored_protocs_dist", |
|
|
|
|
"//:LICENSE", |
|
|
|
|
], |
|
|
|
|
tags = ["manual"], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
pkg_tar( |
|
|
|
|
name = "codegen_crate_test", |
|
|
|
|
srcs = [ |
|
|
|
|
":protobuf_codegen_files", |
|
|
|
|
":vendored_protocs_test", |
|
|
|
|
"//:LICENSE", |
|
|
|
|
], |
|
|
|
|
tags = ["manual"], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
pkg_files( |
|
|
|
|
name = "codegen_example_files", |
|
|
|
|
srcs = ["//rust/protobuf_codegen/example:srcs"], |
|
|
|
|
strip_prefix = strip_prefix.from_root(SRC_ROOT + "/protobuf_codegen/example"), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
pkg_tar( |
|
|
|
|
name = "codegen_example_test", |
|
|
|
|
srcs = [ |
|
|
|
|
":codegen_example_files", |
|
|
|
|
"//:LICENSE", |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Bundle all protoc binaries for all platforms. Requires the toolchains to be installed. |
|
|
|
|
pkg_cross_compiled_binaries( |
|
|
|
|
name = "vendored_protocs_dist", |
|
|
|
|
cpus = [ |
|
|
|
|
# TODO: Re-enable these platforms once the toolchains are available. |
|
|
|
|
# "osx-x86_64", |
|
|
|
|
# "osx-aarch_64", |
|
|
|
|
"linux-aarch_64", |
|
|
|
|
"linux-ppcle_64", |
|
|
|
|
# "linux-s390_64", |
|
|
|
|
"linux-x86_32", |
|
|
|
|
"linux-x86_64", |
|
|
|
|
"win32", |
|
|
|
|
"win64", |
|
|
|
|
], |
|
|
|
|
prefix = "bin", |
|
|
|
|
tags = ["manual"], |
|
|
|
|
targets = [ |
|
|
|
|
"//upb_generator/minitable:protoc-gen-upb_minitable", |
|
|
|
|
"//:protoc", |
|
|
|
|
], |
|
|
|
|
visibility = ["//rust/release_crates:__subpackages__"], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Bundle only the linux-x86_64 protoc for testing. |
|
|
|
@ -386,30 +304,5 @@ pkg_cross_compiled_binaries( |
|
|
|
|
"//upb_generator/minitable:protoc-gen-upb_minitable", |
|
|
|
|
"//:protoc", |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Run the cargo test with only a bundled linux-x86_64 protoc. |
|
|
|
|
sh_binary( |
|
|
|
|
name = "cargo_test", |
|
|
|
|
srcs = ["cargo_test.sh"], |
|
|
|
|
data = [ |
|
|
|
|
":codegen_crate_test", |
|
|
|
|
":codegen_example_test", |
|
|
|
|
":protobuf_crate_dist", |
|
|
|
|
], |
|
|
|
|
tags = ["manual"], |
|
|
|
|
deps = ["@bazel_tools//tools/bash/runfiles"], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Run the cargo test with all bundled protocs. |
|
|
|
|
sh_binary( |
|
|
|
|
name = "cargo_release_test", |
|
|
|
|
srcs = ["cargo_test.sh"], |
|
|
|
|
data = [ |
|
|
|
|
":codegen_crate_dist", |
|
|
|
|
":codegen_example_test", |
|
|
|
|
":protobuf_crate_dist", |
|
|
|
|
], |
|
|
|
|
tags = ["manual"], |
|
|
|
|
deps = ["@bazel_tools//tools/bash/runfiles"], |
|
|
|
|
visibility = ["//rust/release_crates:__subpackages__"], |
|
|
|
|
) |
|
|
|
|