From 026c0af479e5ba74530c0abf65c12deecfda701e Mon Sep 17 00:00:00 2001 From: mikey dagitses Date: Wed, 2 Mar 2022 02:49:38 -0800 Subject: [PATCH] move intrusive_ptr benchmark to shared build structure (#71413) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/71413 ghstack-source-id: 150235101 Test Plan: Verified manually. Rely on CI to validate. Reviewed By: malfet Differential Revision: D33635740 fbshipit-source-id: 82c6798a20c01c16fb17547d4a0ba30e6ffc272d (cherry picked from commit d7a0b39f510f59fe16f138a712d380e0091b230a) --- c10/benchmark/BUILD.bazel | 13 +++---------- c10/benchmark/build.bzl | 10 ++++++++++ tools/bazel.bzl | 3 ++- 3 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 c10/benchmark/build.bzl diff --git a/c10/benchmark/BUILD.bazel b/c10/benchmark/BUILD.bazel index 82c92dd0e030..d1a0db360d23 100644 --- a/c10/benchmark/BUILD.bazel +++ b/c10/benchmark/BUILD.bazel @@ -1,11 +1,4 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") +load("//:tools/bazel.bzl", "rules") +load(":build.bzl", "define_targets") -cc_binary( - name = "intrusive_ptr", - srcs = ["intrusive_ptr_benchmark.cpp"], - tags = ["benchmark"], - deps = [ - "//c10/util:base", - "@google_benchmark//:benchmark", - ], -) +define_targets(rules = rules) diff --git a/c10/benchmark/build.bzl b/c10/benchmark/build.bzl new file mode 100644 index 000000000000..f9838e00cb4e --- /dev/null +++ b/c10/benchmark/build.bzl @@ -0,0 +1,10 @@ +def define_targets(rules): + rules.cc_binary( + name = "intrusive_ptr", + srcs = ["intrusive_ptr_benchmark.cpp"], + tags = ["benchmark"], + deps = [ + "//c10/util:base", + "@google_benchmark//:benchmark", + ], + ) diff --git a/tools/bazel.bzl b/tools/bazel.bzl index bb58b8aab534..a088024a6833 100644 --- a/tools/bazel.bzl +++ b/tools/bazel.bzl @@ -1,4 +1,4 @@ -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load("@rules_cuda//cuda:defs.bzl", "requires_cuda_enabled") load("//c10/macros:cmake_configure_file.bzl", "cmake_configure_file") load("//tools/config:defs.bzl", "if_cuda") @@ -7,6 +7,7 @@ load("//tools/config:defs.bzl", "if_cuda") # build structure aims to replicate Bazel as much as possible, most of # the rules simply forward to the Bazel definitions. rules = struct( + cc_binary = cc_binary, cc_library = cc_library, cc_test = cc_test, cmake_configure_file = cmake_configure_file,