forked from bazelbuild/rules_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cfg = proc_macro_host_transition to all rules (bazelbuild#301)
The rust_library rule specifies a cfg option. This performs transitions in order to support WASM. Other rules, such as rust_binary, do not have this configuration, which causes Bazel to build and link some libraries into the final binary twice, resulting in compilation errors. This is detailed in pull request bazelbuild#294 and issue bazelbuild#300. The issue was introduced in commit 7cde1e4. This adds the example from @colin353 in PR bazelbuild#294 as an example that would otherwise fail. Fixes bazelbuild#300
- Loading branch information
Showing
5 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,31 @@ | ||
load("@rules_proto//proto:defs.bzl", "proto_library") | ||
load("@io_bazel_rules_rust//proto:proto.bzl", "rust_proto_library") | ||
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") | ||
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_binary") | ||
|
||
package(default_visibility = ["//proto:__subpackages__"]) | ||
|
||
proto_library( | ||
name = "common", | ||
srcs = ["common.proto"], | ||
) | ||
|
||
rust_proto_library( | ||
name = "common_proto_rust", | ||
deps = [":common"], | ||
) | ||
|
||
rust_library( | ||
name = "common_lib", | ||
srcs = ["lib.rs"], | ||
deps = [":common_proto_rust"], | ||
) | ||
|
||
rust_binary( | ||
name = "common_bin", | ||
srcs = ["main.rs"], | ||
deps = [ | ||
":common_lib", | ||
":common_proto_rust", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extern crate common_proto_rust; | ||
|
||
pub fn do_something(x: &common_proto_rust::Config) -> bool { | ||
true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extern crate common_lib; | ||
extern crate common_proto_rust; | ||
|
||
pub fn main() { | ||
common_lib::do_something(&common_proto_rust::Config::new()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters