1
load("//arvr/tools/build_defs:genrule_utils.bzl", "gen_cmake_header")
2
load("//arvr/tools/build_defs:oxx.bzl", "oxx_static_library")
4
cpu_supported_platforms = [
5
"ovr_config//os:android",
6
"ovr_config//os:iphoneos",
7
"ovr_config//os:linux-x86_64",
8
"ovr_config//os:macos",
9
"ovr_config//os:windows-x86_64",
10
"ovr_config//runtime:arm64-linux-ubuntu-neon",
11
"ovr_config//os:linux-arm64",
14
cuda_supported_platforms = [
15
"ovr_config//os:linux-cuda",
16
"ovr_config//os:windows-cuda",
19
def define_c10_ovrsource(name, is_mobile):
21
pp_flags = ["-DC10_MOBILE=1"]
33
compatible_with = cpu_supported_platforms,
34
compiler_flags = select({
36
"ovr_config//compiler:cl": [
39
"ovr_config//toolchain/clang:win": [
43
"-Wno-unused-variable",
46
include_directories = [".."],
47
preprocessor_flags = [
49
"-DC10_BUILD_MAIN_LIB=1",
50
"-DSUPPORTS_BACKTRACE=0",
52
fbobjc_compiler_flags = ["-Wno-error=global-constructors", "-Wno-error=missing-prototypes"],
53
public_include_directories = [".."],
54
public_preprocessor_flags = pp_flags,
55
public_raw_headers = native.glob([
59
"test/util/*.h", # some external tests use this
62
raw_headers = native.glob([
65
reexport_all_header_dependencies = False,
66
# tests = C10_CPU_TEST_TARGETS,
68
"//xplat/caffe2/c10:c10_ovrsource",
72
"ovr_config//os:linux": [
73
"//third-party/numactl:numactl",
77
":ovrsource_c10_cmake_macros.h",
78
"//arvr/third-party/gflags:gflags",
79
"//third-party/cpuinfo:cpuinfo",
80
"//third-party/fmt:fmt",
81
"//third-party/glog:glog",
85
def define_ovrsource_targets():
86
# C10_CPU_TEST_FILES = native.glob([
91
# C10_GPU_TEST_FILES = native.glob([
92
# "cuda/test/**/*.cpp",
95
# C10_CPU_TEST_TARGETS = [
96
# ":" + paths.basename(test)[:-len(".cpp")] + "_ovrsource"
97
# for test in C10_CPU_TEST_FILES
100
# C10_GPU_TEST_TARGETS = [
101
# ":" + paths.basename(test)[:-len(".cpp")] + "_ovrsource"
102
# for test in C10_GPU_TEST_FILES
105
common_c10_cmake_defines = [
106
("#cmakedefine C10_BUILD_SHARED_LIBS", ""),
107
("#cmakedefine C10_USE_NUMA", ""),
108
("#cmakedefine C10_USE_MSVC_STATIC_RUNTIME", ""),
109
("#cmakedefine C10_USE_ROCM_KERNEL_ASSERT", ""),
112
mobile_c10_cmake_defines = [
113
("#cmakedefine C10_USE_GLOG", ""),
114
("#cmakedefine C10_USE_GFLAGS", ""),
117
non_mobile_c10_cmake_defines = [
118
("#cmakedefine C10_USE_GLOG", "#define C10_USE_GLOG 1"),
119
("#cmakedefine C10_USE_GFLAGS", "#define C10_USE_GFLAGS 1"),
123
src = "macros/cmake_macros.h.in",
124
defines = common_c10_cmake_defines + mobile_c10_cmake_defines,
125
header = "c10/macros/cmake_macros.h",
126
prefix = "ovrsource_c10_mobile_",
130
src = "macros/cmake_macros.h.in",
131
defines = common_c10_cmake_defines + non_mobile_c10_cmake_defines,
132
header = "c10/macros/cmake_macros.h",
133
prefix = "ovrsource_c10_non_mobile_",
137
name = "ovrsource_c10_cmake_macros.h",
139
"ovr_config//os:android",
140
"ovr_config//os:iphoneos",
141
"ovr_config//os:linux",
142
"ovr_config//os:macos",
143
"ovr_config//os:windows",
146
"ovr_config//os:android": [":ovrsource_c10_mobile_cmake_macros.h"],
147
"ovr_config//os:iphoneos": [":ovrsource_c10_mobile_cmake_macros.h"],
148
"ovr_config//os:linux": [":ovrsource_c10_non_mobile_cmake_macros.h"],
149
"ovr_config//os:macos": [":ovrsource_c10_non_mobile_cmake_macros.h"],
150
"ovr_config//os:windows": [":ovrsource_c10_non_mobile_cmake_macros.h"],
154
c10_cuda_macros = gen_cmake_header(
155
src = "cuda/impl/cuda_cmake_macros.h.in",
157
("#cmakedefine C10_CUDA_BUILD_SHARED_LIBS", ""),
159
header = "c10/cuda/impl/cuda_cmake_macros.h",
160
prefix = "ovrsource",
164
name = "c10_ovrsource",
165
compatible_with = cpu_supported_platforms,
166
exported_deps = select({
167
"DEFAULT": [":c10_full_ovrsource"],
168
"ovr_config//os:android": [":c10_mobile_ovrsource"],
169
"ovr_config//os:iphoneos": [":c10_mobile_ovrsource"],
171
visibility = ["PUBLIC"],
175
Most users should use c10_ovrsource, not these targets directly.
177
define_c10_ovrsource("c10_mobile_ovrsource", True)
178
define_c10_ovrsource("c10_full_ovrsource", False)
181
name = "c10_cuda_ovrsource",
186
compatible_with = cuda_supported_platforms,
187
compiler_flags = select({
189
"ovr_config//compiler:cl": [
192
"ovr_config//toolchain/clang:win": [
196
"-Wno-unused-variable",
200
preprocessor_flags = [
202
"-DC10_CUDA_BUILD_MAIN_LIB=1",
204
raw_headers = native.glob([
208
reexport_all_header_dependencies = False,
209
# tests = C10_GPU_TEST_TARGETS,
210
visibility = ["PUBLIC"],
212
"//third-party/cuda:libcuda",
213
"//third-party/cuda:libcudart",
215
exported_deps = c10_cuda_macros + [
222
# name = paths.basename(test)[:-len(".cpp")] + "_ovrsource",
224
# compatible_with = cpu_supported_platforms,
225
# compiler_flags = select({
227
# "ovr_config//compiler:cl": [
230
# "ovr_config//compiler:clang": [
232
# "-Wno-self-assign-overloaded",
236
# "-Wno-unused-function",
237
# "-Wno-unused-variable",
240
# framework = "gtest",
241
# oncall = "ovrsource_pytorch",
242
# raw_headers = native.glob([
249
# for test in C10_CPU_TEST_FILES
254
# name = paths.basename(test)[:-len(".cpp")] + "_ovrsource",
256
# compatible_with = cuda_supported_platforms,
257
# compiler_flags = select({
259
# "ovr_config//compiler:cl": [
262
# "ovr_config//compiler:clang": [
266
# framework = "gtest",
267
# oncall = "ovrsource_pytorch",
268
# raw_headers = native.glob([
271
# runtime_shared_libraries = [
272
# "//third-party/cuda:cudart",
275
# ":c10_cuda_ovrsource",
278
# for test in C10_GPU_TEST_FILES