Skip to content

Commit

Permalink
extract //c10 to common build system (pytorch#71411)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#71411

This library is mostly the same now externally and internally, though
internal to Meta we never include cuda in this library, so our select
resolves internally unconditionally to false.
ghstack-source-id: 150235103

Test Plan: This ought to be a no-op, rely on CI.

Reviewed By: malfet

Differential Revision: D33635739

fbshipit-source-id: a4d3c7e30995c0e43ecd4c69ad0abb23498ee098
(cherry picked from commit c574a12)
  • Loading branch information
mikey dagitses authored and pytorchmergebot committed Mar 2, 2022
1 parent 81437e6 commit e9dfc61
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
29 changes: 4 additions & 25 deletions c10/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tools/config:defs.bzl", "if_cuda")
load("//:tools/bazel.bzl", "rules")
load(":build.bzl", "define_targets")

define_targets(rules = rules)

# The bool_flag targets allow configuring the build from the
# command-line, e.g. --//c10:use_gflags or --no//c10:use_gflags to
Expand Down Expand Up @@ -47,27 +50,3 @@ cc_library(
}),
visibility = ["//:__pkg__"],
)

cc_library(
name = "c10",
deps = [
"//c10/core:CPUAllocator",
"//c10/core:ScalarType",
"//c10/core:alignment",
"//c10/core:alloc_cpu",
"//c10/core:base",
"//c10/macros",
"//c10/mobile:CPUCachingAllocator",
"//c10/mobile:CPUProfilingAllocator",
"//c10/util:TypeCast",
"//c10/util:base",
"//c10/util:typeid",
] + if_cuda(
[
"//c10/cuda",
"//c10/cuda:Macros",
],
[],
),
visibility = ["//:__pkg__"],
)
24 changes: 24 additions & 0 deletions c10/build.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def define_targets(rules):
rules.cc_library(
name = "c10",
deps = [
"//c10/core:CPUAllocator",
"//c10/core:ScalarType",
"//c10/core:alignment",
"//c10/core:alloc_cpu",
"//c10/core:base",
"//c10/macros",
"//c10/mobile:CPUCachingAllocator",
"//c10/mobile:CPUProfilingAllocator",
"//c10/util:TypeCast",
"//c10/util:base",
"//c10/util:typeid",
] + rules.if_cuda(
[
"//c10/cuda",
"//c10/cuda:Macros",
],
[],
),
visibility = ["//visibility:public"],
)
2 changes: 2 additions & 0 deletions tools/bazel.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@rules_cc//cc:defs.bzl", "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")

# Rules implementation for the Bazel build system. Since the common
# build structure aims to replicate Bazel as much as possible, most of
Expand All @@ -11,6 +12,7 @@ rules = struct(
cmake_configure_file = cmake_configure_file,
filegroup = native.filegroup,
glob = native.glob,
if_cuda = if_cuda,
requires_cuda_enabled = requires_cuda_enabled,
select = select,
)

0 comments on commit e9dfc61

Please sign in to comment.