Skip to content

Commit

Permalink
Add proc-macro support from bazelbuild#205
Browse files Browse the repository at this point in the history
  • Loading branch information
sayrer committed Apr 17, 2019
1 parent 2215277 commit 5150e8d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,27 @@ _rust_test_attrs = {
),
}

def _platform_to_host_transition(settings, attr):
if attr.crate_type == "proc-macro":
return {
"//command_line_option:platforms": "@bazel_tools//platforms:host_platform",
}
else:
return {
"//command_line_option:platforms": "@bazel_tools//platforms:target_platform",
}

platform_to_host_transition = transition(
implementation = _platform_to_host_transition,
inputs = [],
outputs = ["//command_line_option:platforms"],
)

rust_library = rule(
_rust_library_impl,
attrs = dict(_rust_common_attrs.items() +
_rust_library_attrs.items()),
cfg = platform_to_host_transition,
fragments = ["cpp"],
host_fragments = ["cpp"],
toolchains = ["@io_bazel_rules_rust//rust:toolchain"],
Expand Down

0 comments on commit 5150e8d

Please sign in to comment.