forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathovrsource_defs.bzl
More file actions
148 lines (140 loc) · 4.34 KB
/
ovrsource_defs.bzl
File metadata and controls
148 lines (140 loc) · 4.34 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
load("//arvr/tools/build_defs:genrule_utils.bzl", "gen_cmake_header")
load("//arvr/tools/build_defs:oxx.bzl", "oxx_static_library")
cpu_supported_platforms = [
"ovr_config//os:android",
"ovr_config//os:iphoneos",
"ovr_config//os:linux-x86_64",
"ovr_config//os:macos",
"ovr_config//os:windows-x86_64",
"ovr_config//runtime:arm64-linux-ubuntu-neon",
"ovr_config//os:linux-arm64",
]
cuda_supported_platforms = [
"ovr_config//os:linux-cuda",
"ovr_config//os:windows-cuda",
]
def define_c10_ovrsource(name, is_mobile):
if is_mobile:
pp_flags = ["-DC10_MOBILE=1"]
else:
pp_flags = []
oxx_static_library(
name = name,
srcs = native.glob([
"core/*.cpp",
"core/impl/*.cpp",
"mobile/*.cpp",
"util/*.cpp",
]),
compatible_with = cpu_supported_platforms,
compiler_flags = select({
"DEFAULT": [],
"ovr_config//compiler:cl": [
"/w",
],
"ovr_config//toolchain/clang:win": [
"-Wno-error",
"-Wno-shadow",
"-Wno-undef",
"-Wno-unused-variable",
],
}),
include_directories = [".."],
preprocessor_flags = [
"-DNO_EXPORT",
"-DC10_BUILD_MAIN_LIB=1",
"-DSUPPORTS_BACKTRACE=0",
],
fbobjc_compiler_flags = ["-Wno-error=global-constructors", "-Wno-error=missing-prototypes"],
public_include_directories = [".."],
public_preprocessor_flags = pp_flags,
public_raw_headers = native.glob([
"core/*.h",
"macros/*.h",
"mobile/*.h",
"test/util/*.h", # some external tests use this
"util/*.h",
]),
raw_headers = native.glob([
"core/impl/*.h",
]),
reexport_all_header_dependencies = False,
visibility = [
"//xplat/caffe2/c10:c10_ovrsource",
],
deps = select({
"DEFAULT": [],
"ovr_config//os:linux": [
"//third-party/numactl:numactl",
],
}),
exported_deps = [
"//xplat/caffe2/torch/headeronly:torch_headeronly_ovrsource",
"//arvr/third-party/gflags:gflags",
"//third-party/cpuinfo:cpuinfo",
"//third-party/fmt:fmt",
"//third-party/glog:glog",
],
)
def define_ovrsource_targets():
c10_cuda_macros = gen_cmake_header(
src = "cuda/impl/cuda_cmake_macros.h.in",
defines = [
("#cmakedefine C10_CUDA_BUILD_SHARED_LIBS", ""),
],
header = "c10/cuda/impl/cuda_cmake_macros.h",
prefix = "ovrsource",
)
oxx_static_library(
name = "c10_ovrsource",
compatible_with = cpu_supported_platforms,
exported_deps = select({
"DEFAULT": [":c10_full_ovrsource"],
"ovr_config//os:android": [":c10_mobile_ovrsource"],
"ovr_config//os:iphoneos": [":c10_mobile_ovrsource"],
}),
visibility = ["PUBLIC"],
)
"""
Most users should use c10_ovrsource, not these targets directly.
"""
define_c10_ovrsource("c10_mobile_ovrsource", True)
define_c10_ovrsource("c10_full_ovrsource", False)
oxx_static_library(
name = "c10_cuda_ovrsource",
srcs = native.glob([
"cuda/*.cpp",
"cuda/impl/*.cpp",
]),
compatible_with = cuda_supported_platforms,
compiler_flags = select({
"DEFAULT": [],
"ovr_config//compiler:cl": [
"/w",
],
"ovr_config//toolchain/clang:win": [
"-Wno-error",
"-Wno-shadow",
"-Wno-undef",
"-Wno-unused-variable",
],
}),
link_whole = True,
preprocessor_flags = [
"-DNO_EXPORT",
"-DC10_CUDA_BUILD_MAIN_LIB=1",
],
raw_headers = native.glob([
"cuda/*.h",
"cuda/impl/*.h",
]),
reexport_all_header_dependencies = False,
visibility = ["PUBLIC"],
deps = [
"//third-party/cuda:libcuda",
"//third-party/cuda:libcudart",
],
exported_deps = c10_cuda_macros + [
":c10_ovrsource",
],
)