|
| 1 | +# Copyright (c) 2021-2024 Intel Corporation |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# DISCLAIMER: Bazel support is community-based. The maintainers do not |
| 16 | +# use Bazel internally. The Bazel build can have security risks or |
| 17 | +# optimization gaps. |
| 18 | + |
| 19 | +package( |
| 20 | + default_visibility = ["//visibility:public"], |
| 21 | +) |
| 22 | + |
| 23 | +cc_library( |
| 24 | + name = "tbb", |
| 25 | + srcs = glob([ |
| 26 | + "src/tbb/*.cpp", |
| 27 | + "src/tbb/*.h", |
| 28 | + ]) + select({ |
| 29 | + "@platforms//cpu:x86_64": glob(["src/tbb/tools_api/**/*.h"]), |
| 30 | + "//conditions:default": [], |
| 31 | + }), |
| 32 | + hdrs = glob([ |
| 33 | + "include/tbb/*.h", |
| 34 | + "include/oneapi/*.h", |
| 35 | + "include/oneapi/tbb/*.h", |
| 36 | + "include/oneapi/tbb/detail/*.h", |
| 37 | + ]), |
| 38 | + copts = ["-w"] + select({ |
| 39 | + "@platforms//os:windows": [""], |
| 40 | + "//conditions:default": ["-mwaitpkg"], |
| 41 | + }), |
| 42 | + defines = |
| 43 | + select({ |
| 44 | + "@platforms//cpu:x86_64": ["__TBB_NO_IMPLICIT_LINKAGE"], |
| 45 | + "//conditions:default": [ |
| 46 | + "USE_PTHREAD", |
| 47 | + ], |
| 48 | + }) + |
| 49 | + select({ |
| 50 | + "@platforms//os:osx": ["_XOPEN_SOURCE"], |
| 51 | + "//conditions:default": [], |
| 52 | + }), |
| 53 | + includes = [ |
| 54 | + "include", |
| 55 | + ], |
| 56 | + linkopts = |
| 57 | + select({ |
| 58 | + "@platforms//os:windows": [], |
| 59 | + "@platforms//os:linux": [ |
| 60 | + "-ldl", |
| 61 | + "-pthread", |
| 62 | + "-lrt", |
| 63 | + ], |
| 64 | + "//conditions:default": ["-pthread"], |
| 65 | + }), |
| 66 | + local_defines = select({ |
| 67 | + "@platforms//cpu:x86_64": [ |
| 68 | + "__TBB_USE_ITT_NOTIFY", |
| 69 | + ], |
| 70 | + "//conditions:default": [], |
| 71 | + }) + [ |
| 72 | + "__TBB_BUILD", |
| 73 | + ], |
| 74 | + textual_hdrs = select({ |
| 75 | + "@platforms//cpu:x86_64": [ |
| 76 | + "src/tbb/tools_api/ittnotify_static.c", |
| 77 | + ], |
| 78 | + "//conditions:default": [], |
| 79 | + }), |
| 80 | +) |
| 81 | + |
| 82 | +cc_library( |
| 83 | + name = "tbbmalloc", |
| 84 | + srcs = |
| 85 | + glob([ |
| 86 | + "src/tbbmalloc/*.h", |
| 87 | + "src/tbb/*.h", |
| 88 | + "src/tbbmalloc_proxy/*.h", |
| 89 | + ]) + [ |
| 90 | + "src/tbbmalloc/backend.cpp", |
| 91 | + "src/tbbmalloc/backref.cpp", |
| 92 | + "src/tbbmalloc/frontend.cpp", |
| 93 | + "src/tbbmalloc/large_objects.cpp", |
| 94 | + "src/tbbmalloc/tbbmalloc.cpp", |
| 95 | + ], |
| 96 | + hdrs = glob([ |
| 97 | + "include/tbb/*.h", |
| 98 | + "include/oneapi/tbb/detail/*.h", |
| 99 | + "include/oneapi/tbb/*.h", |
| 100 | + ]), |
| 101 | + includes = [ |
| 102 | + "include", |
| 103 | + ], |
| 104 | + local_defines = [ |
| 105 | + "__TBBMALLOC_BUILD", |
| 106 | + ], |
| 107 | +) |
| 108 | + |
| 109 | +cc_library( |
| 110 | + name = "tbbmalloc_proxy", |
| 111 | + srcs = [ |
| 112 | + "src/tbbmalloc_proxy/function_replacement.cpp", |
| 113 | + "src/tbbmalloc_proxy/proxy.cpp", |
| 114 | + ], |
| 115 | + deps = [ |
| 116 | + ":tbbmalloc", |
| 117 | + ], |
| 118 | +) |
| 119 | + |
| 120 | +cc_test( |
| 121 | + name = "test_mutex", |
| 122 | + srcs = [ |
| 123 | + "test/tbb/test_mutex.cpp", |
| 124 | + "test/tbb/test_mutex.h" |
| 125 | + ] + glob([ |
| 126 | + "test/common/*.h", |
| 127 | + ]), |
| 128 | + includes = ["test"], |
| 129 | + deps = [ |
| 130 | + ":tbb", |
| 131 | + ], |
| 132 | +) |
| 133 | + |
| 134 | +cc_test( |
| 135 | + name = "test_parallel_for", |
| 136 | + srcs = [ |
| 137 | + "test/tbb/test_parallel_for.cpp", |
| 138 | + "test/tbb/test_partitioner.h" |
| 139 | + ] + glob([ |
| 140 | + "test/common/*.h", |
| 141 | + ]), |
| 142 | + includes = ["test"], |
| 143 | + deps = [ |
| 144 | + ":tbb", |
| 145 | + ], |
| 146 | +) |
| 147 | + |
| 148 | +cc_test( |
| 149 | + name = "test_parallel_reduce", |
| 150 | + srcs = [ |
| 151 | + "test/tbb/test_parallel_reduce.cpp", |
| 152 | + ] + glob([ |
| 153 | + "test/common/*.h", |
| 154 | + ]), |
| 155 | + includes = ["test"], |
| 156 | + deps = [ |
| 157 | + ":tbb", |
| 158 | + ], |
| 159 | +) |
| 160 | + |
| 161 | +cc_test( |
| 162 | + name = "test_task", |
| 163 | + srcs = [ |
| 164 | + "test/tbb/test_task.cpp", |
| 165 | + ] + glob([ |
| 166 | + "test/common/*.h", |
| 167 | + ]), |
| 168 | + includes = ["test"], |
| 169 | + deps = [ |
| 170 | + ":tbb", |
| 171 | + ], |
| 172 | +) |
0 commit comments