1load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") 2load("@rules_cuda//cuda:defs.bzl", "cuda_library", "requires_cuda_enabled") 3load("@rules_python//python:defs.bzl", "py_binary", "py_library") 4load("@pip_deps//:requirements.bzl", "requirement") 5load("@pytorch//c10/macros:cmake_configure_file.bzl", "cmake_configure_file") 6load("@pytorch//tools/config:defs.bzl", "if_cuda") 7 8def _genrule(**kwds): 9 if _enabled(**kwds): 10 native.genrule(**kwds) 11 12def _is_cpu_static_dispatch_build(): 13 return False 14 15# Rules implementation for the Bazel build system. Since the common 16# build structure aims to replicate Bazel as much as possible, most of 17# the rules simply forward to the Bazel definitions. 18rules = struct( 19 cc_binary = cc_binary, 20 cc_library = cc_library, 21 cc_test = cc_test, 22 cmake_configure_file = cmake_configure_file, 23 cuda_library = cuda_library, 24 filegroup = native.filegroup, 25 genrule = _genrule, 26 glob = native.glob, 27 if_cuda = if_cuda, 28 is_cpu_static_dispatch_build = _is_cpu_static_dispatch_build, 29 py_binary = py_binary, 30 py_library = py_library, 31 requirement = requirement, 32 requires_cuda_enabled = requires_cuda_enabled, 33 select = select, 34 test_suite = native.test_suite, 35) 36 37def _enabled(tags = [], **_kwds): 38 """Determines if the target is enabled.""" 39 return "-bazel" not in tags 40