forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBUILD.bazel
More file actions
105 lines (96 loc) · 2.23 KB
/
BUILD.bazel
File metadata and controls
105 lines (96 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//third_party:substitution.bzl", "header_template_rule")
load("//tools/config:defs.bzl", "if_cuda")
# The bool_flag targets allow configuring the build from the
# command-line, e.g. --//c10:use_gflags or --no//c10:use_gflags to
# disable.
bool_flag(
name = "use_gflags",
build_setting_default = True,
)
bool_flag(
name = "use_glog",
build_setting_default = True,
)
config_setting(
name = "using_gflags",
flag_values = {":use_gflags": "true"},
)
config_setting(
name = "using_glog",
flag_values = {":use_glog": "true"},
)
header_template_rule(
name = "cuda_cmake_macros_h",
src = "cuda/impl/cuda_cmake_macros.h.in",
out = "cuda/impl/cuda_cmake_macros.h",
substitutions = {
"cmakedefine": "define",
},
)
cc_library(
name = "headers",
hdrs = glob([
"core/*.h",
"core/impl/*.h",
"cuda/*.h",
"cuda/impl/*.h",
"mobile/*.h",
"util/*.h",
"util/*.hpp",
]),
deps = [
":cuda_cmake_macros_h",
"//c10/macros",
] + select({
":using_gflags": ["@com_github_gflags_gflags//:gflags"],
"//conditions:default": [],
}) + select({
":using_glog": ["@com_github_glog//:glog"],
"//conditions:default": [],
}),
visibility = ["//:__pkg__"],
)
cc_library(
name = "c10",
srcs = glob([
"core/*.cpp",
"core/impl/*.cpp",
"mobile/*.cpp",
"util/*.cpp",
]) + if_cuda(
glob([
"cuda/*.cpp",
"cuda/impl/*.cpp",
]),
[],
),
local_defines = ["C10_BUILD_MAIN_LIB"],
deps = [
":headers",
"@fmt",
] + if_cuda(
["@cuda"],
[],
),
alwayslink = True,
visibility = ["//:__pkg__"],
)
cc_test(
name = "tests",
size = "small",
srcs = glob([
"test/util/*.cpp",
"test/util/*.h",
"test/core/*.cpp",
"test/core/impl/*.cpp",
]),
copts = ["-Wno-deprecated-declarations"],
deps = [
":c10",
":headers",
"@com_google_googletest//:gtest_main",
],
visibility = ["//:__pkg__"],
)