From 5a3ddf1f0e82bab3a3013b7f0a574e3598c0014c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 25 Sep 2020 20:11:54 -0400 Subject: [PATCH 1/2] Switch from genrule to run_binary for Bazel --- tools/bazel/rust_cxx_bridge.bzl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/bazel/rust_cxx_bridge.bzl b/tools/bazel/rust_cxx_bridge.bzl index 7f3f95846..6b31b15a0 100644 --- a/tools/bazel/rust_cxx_bridge.bzl +++ b/tools/bazel/rust_cxx_bridge.bzl @@ -1,3 +1,4 @@ +load("@bazel_skylib//rules:run_binary.bzl", "run_binary") load("@rules_cc//cc:defs.bzl", "cc_library") def rust_cxx_bridge( @@ -6,20 +7,20 @@ def rust_cxx_bridge( include_prefix = None, strip_include_prefix = None, deps = []): - native.genrule( + run_binary( name = "%s/header" % name, srcs = [src], outs = [src + ".h"], - cmd = "$(location //:codegen) --header $< > $@", - tools = ["//:codegen"], + args = ["$(location %s)" % src, "-o", "$(location %s.h)" % src, "--header"], + tool = "//:codegen", ) - native.genrule( + run_binary( name = "%s/source" % name, srcs = [src], outs = [src + ".cc"], - cmd = "$(location //:codegen) $< > $@", - tools = ["//:codegen"], + args = ["$(location %s)" % src, "-o", "$(location %s.cc)" % src], + tool = "//:codegen", ) cc_library( From 73d129dfd983c31e86dde30282bdc76e15b06b9c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 25 Sep 2020 20:26:25 -0400 Subject: [PATCH 2/2] Wrap run_binary args --- tools/bazel/rust_cxx_bridge.bzl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/bazel/rust_cxx_bridge.bzl b/tools/bazel/rust_cxx_bridge.bzl index 6b31b15a0..497061d21 100644 --- a/tools/bazel/rust_cxx_bridge.bzl +++ b/tools/bazel/rust_cxx_bridge.bzl @@ -11,7 +11,12 @@ def rust_cxx_bridge( name = "%s/header" % name, srcs = [src], outs = [src + ".h"], - args = ["$(location %s)" % src, "-o", "$(location %s.h)" % src, "--header"], + args = [ + "$(location %s)" % src, + "-o", + "$(location %s.h)" % src, + "--header", + ], tool = "//:codegen", ) @@ -19,7 +24,11 @@ def rust_cxx_bridge( name = "%s/source" % name, srcs = [src], outs = [src + ".cc"], - args = ["$(location %s)" % src, "-o", "$(location %s.cc)" % src], + args = [ + "$(location %s)" % src, + "-o", + "$(location %s.cc)" % src, + ], tool = "//:codegen", )