From 5150e8d5b9bce6ef7095d54aa26b64292dc81262 Mon Sep 17 00:00:00 2001 From: Robert Sayre Date: Wed, 17 Apr 2019 12:47:02 -0700 Subject: [PATCH] Add proc-macro support from https://github.com/bazelbuild/rules_rust/issues/205 --- rust/private/rust.bzl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index 2cdcf98ff6..9e29466469 100644 --- a/rust/private/rust.bzl +++ b/rust/private/rust.bzl @@ -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"],