extract out //c10/core:base library (#70857)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/70857
ghstack-source-id: 147302543
Test Plan: Relying on CI
Reviewed By: malfet
Differential Revision: D33329579
fbshipit-source-id: 961abdecabb7b2c6f090e00a6a670e5b70aa5bca
(cherry picked from commit 2b8c4bb0a4f6b22e028aa4cfbf06f09fb6873fa3)
diff --git a/c10/BUILD.bazel b/c10/BUILD.bazel
index 4c29b31..566b0f4 100644
--- a/c10/BUILD.bazel
+++ b/c10/BUILD.bazel
@@ -76,6 +76,7 @@
deps = [
":headers",
"//c10/core:ScalarType",
+ "//c10/core:base",
"//c10/util:TypeCast",
"//c10/util:base",
"//c10/util:typeid",
diff --git a/c10/core/build.bzl b/c10/core/build.bzl
index 209d70f..ebb59f3 100644
--- a/c10/core/build.bzl
+++ b/c10/core/build.bzl
@@ -8,6 +8,41 @@
deps = ["//c10/util:base"],
)
+ rules.cc_library(
+ name = "base",
+ srcs = rules.glob(
+ [
+ "*.cpp",
+ "impl/*.cpp",
+ ],
+ exclude = [
+ "CPUAllocator.cpp",
+ ],
+ ),
+ hdrs = rules.glob(
+ [
+ "*.h",
+ "impl/*.h",
+ ],
+ exclude = [
+ "CPUAllocator.h",
+ ],
+ ),
+ # This library uses flags and registration. Do not let the
+ # linker remove them.
+ alwayslink = True,
+ linkstatic = True,
+ local_defines = ["C10_BUILD_MAIN_LIB"],
+ visibility = ["//visibility:public"],
+ deps = [
+ ":ScalarType",
+ "//c10/macros",
+ "//c10/util:TypeCast",
+ "//c10/util:base",
+ "//c10/util:typeid",
+ ],
+ )
+
rules.filegroup(
name = "headers",
srcs = rules.glob(
@@ -23,13 +58,6 @@
rules.filegroup(
name = "sources",
- srcs = rules.glob(
- [
- "*.cpp",
- "impl/*.cpp",
- ],
- exclude = [
- ],
- ),
+ srcs = ["CPUAllocator.cpp"],
visibility = ["//c10:__pkg__"],
)