diff --git a/BUILD.bazel b/BUILD.bazel index 02bf37b6ec81..d04dca06c064 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1261,7 +1261,7 @@ cc_library( copts = CAFFE2_COPTS, visibility = ["//visibility:public"], deps = [ - ":caffe2_core_macros_h", + ":caffe2_core_macros", "//c10:headers", "//caffe2/proto:caffe2_pb", ], @@ -1292,41 +1292,46 @@ genrule( cc_library( name = "caffe2_headers", - hdrs = glob([ - "caffe2/contrib/aten/*.h", - "caffe2/contrib/gloo/*.h", - "caffe2/core/*.h", - "caffe2/core/nomnigraph/include/nomnigraph/Converters/*.h", - "caffe2/core/nomnigraph/include/nomnigraph/Generated/*.h", - "caffe2/core/nomnigraph/include/nomnigraph/Graph/*.h", - "caffe2/core/nomnigraph/include/nomnigraph/Representations/*.h", - "caffe2/core/nomnigraph/include/nomnigraph/Support/*.h", - "caffe2/core/nomnigraph/include/nomnigraph/Transformations/*.h", - "caffe2/core/nomnigraph/tests/*.h", - "caffe2/db/*.h", - "caffe2/distributed/*.h", - "caffe2/ideep/*.h", - "caffe2/ideep/operators/*.h", - "caffe2/ideep/operators/quantization/*.h", - "caffe2/ideep/utils/*.h", - "caffe2/onnx/*.h", - "caffe2/operators/*.h", - "caffe2/operators/rnn/*.h", - "caffe2/opt/*.h", - "caffe2/perfkernels/*.h", - "caffe2/predictor/*.h", - "caffe2/predictor/emulator/*.h", - "caffe2/quantization/server/*.h", - "caffe2/queue/*.h", - "caffe2/serialize/*.h", - "caffe2/sgd/*.h", - "caffe2/share/contrib/depthwise/*.h", - "caffe2/transforms/*.h", - "caffe2/utils/*.h", - "caffe2/utils/math/*.h", - "caffe2/utils/threadpool/*.h", - "modules/**/*.h", - ]) + if_cuda(glob([ + hdrs = glob( + [ + "caffe2/contrib/aten/*.h", + "caffe2/contrib/gloo/*.h", + "caffe2/core/*.h", + "caffe2/core/nomnigraph/include/nomnigraph/Converters/*.h", + "caffe2/core/nomnigraph/include/nomnigraph/Generated/*.h", + "caffe2/core/nomnigraph/include/nomnigraph/Graph/*.h", + "caffe2/core/nomnigraph/include/nomnigraph/Representations/*.h", + "caffe2/core/nomnigraph/include/nomnigraph/Support/*.h", + "caffe2/core/nomnigraph/include/nomnigraph/Transformations/*.h", + "caffe2/core/nomnigraph/tests/*.h", + "caffe2/db/*.h", + "caffe2/distributed/*.h", + "caffe2/ideep/*.h", + "caffe2/ideep/operators/*.h", + "caffe2/ideep/operators/quantization/*.h", + "caffe2/ideep/utils/*.h", + "caffe2/onnx/*.h", + "caffe2/operators/*.h", + "caffe2/operators/rnn/*.h", + "caffe2/opt/*.h", + "caffe2/perfkernels/*.h", + "caffe2/predictor/*.h", + "caffe2/predictor/emulator/*.h", + "caffe2/quantization/server/*.h", + "caffe2/queue/*.h", + "caffe2/serialize/*.h", + "caffe2/sgd/*.h", + "caffe2/share/contrib/depthwise/*.h", + "caffe2/transforms/*.h", + "caffe2/utils/*.h", + "caffe2/utils/math/*.h", + "caffe2/utils/threadpool/*.h", + "modules/**/*.h", + ], + exclude = [ + "caffe2/core/macros.h", + ], + ) + if_cuda(glob([ "caffe2/**/*.cuh", "caffe2/image/*.h", ])) + [":generated_caffe2_aten_op_headers"], @@ -1337,6 +1342,7 @@ cc_library( ], visibility = ["//visibility:public"], deps = [ + ":caffe2_core_macros", ":caffe2_for_aten_headers", "//caffe2/proto:caffe2_pb", "//caffe2/proto:cc_proto", @@ -1395,6 +1401,7 @@ cc_library( linkstatic = 1, visibility = ["//visibility:public"], deps = [ + ":caffe2_core_macros", ":caffe2_dnnlowp_avx2_ops", ":caffe2_headers", ":caffe2_perfkernels_avx", diff --git a/build.bzl b/build.bzl index 29dfe4e838ea..1324323bb2c4 100644 --- a/build.bzl +++ b/build.bzl @@ -6,6 +6,11 @@ load( ) def define_targets(rules): + rules.cc_library( + name = "caffe2_core_macros", + hdrs = [":caffe2_core_macros_h"], + ) + rules.cmake_configure_file( name = "caffe2_core_macros_h", src = "caffe2/core/macros.h.in",