Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vertexwahn <julian.amann@tum.de>
- Loading branch information
1 parent
8e7f9e1
commit 6164044
Showing
6 changed files
with
212 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (c) 2021 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# DISCLAIMER: Bazel support is community-based. The maintainers do not | ||
# use Bazel internally. The Bazel build can have security risks or | ||
# optimization gaps. | ||
|
||
build --symlink_prefix=/ # Out of source build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
4.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# Copyright (c) 2021 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# DISCLAIMER: Bazel support is community-based. The maintainers do not | ||
# use Bazel internally. The Bazel build can have security risks or | ||
# optimization gaps. | ||
|
||
package( | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_library( | ||
name = "tbb", | ||
srcs = glob([ | ||
"src/tbb/*.cpp", | ||
"src/tbb/*.h", | ||
]) + select({ | ||
"@platforms//cpu:x86_64": glob(["src/tbb/tools_api/**/*.h"]), | ||
"//conditions:default": [], | ||
}), | ||
hdrs = glob([ | ||
"include/tbb/*.h", | ||
"include/oneapi/*.h", | ||
"include/oneapi/tbb/*.h", | ||
"include/oneapi/tbb/detail/*.h", | ||
]), | ||
copts = [ | ||
"-w", | ||
], | ||
defines = | ||
select({ | ||
"@platforms//cpu:x86_64": ["__TBB_NO_IMPLICIT_LINKAGE"], | ||
"//conditions:default": [ | ||
"USE_PTHREAD", | ||
], | ||
}), | ||
includes = [ | ||
"include", | ||
], | ||
linkopts = | ||
select({ | ||
"@bazel_tools//platforms:windows": [], | ||
"//conditions:default": [ | ||
"-ldl", | ||
"-pthread", | ||
"-lrt", | ||
], | ||
}), | ||
local_defines = select({ | ||
"@platforms//cpu:x86_64": [ | ||
"__TBB_USE_ITT_NOTIFY", | ||
], | ||
"//conditions:default": [], | ||
}) + [ | ||
"__TBB_BUILD", | ||
], | ||
textual_hdrs = select({ | ||
"@platforms//cpu:x86_64": [ | ||
"src/tbb/tools_api/ittnotify_static.c", | ||
], | ||
"//conditions:default": [], | ||
}), | ||
) | ||
|
||
cc_library( | ||
name = "tbbmalloc", | ||
srcs = | ||
glob([ | ||
"src/tbbmalloc/*.h", | ||
"src/tbb/*.h", | ||
"src/tbbmalloc_proxy/*.h", | ||
]) + [ | ||
"src/tbbmalloc/backend.cpp", | ||
"src/tbbmalloc/backref.cpp", | ||
"src/tbbmalloc/frontend.cpp", | ||
"src/tbbmalloc/large_objects.cpp", | ||
"src/tbbmalloc/tbbmalloc.cpp", | ||
], | ||
hdrs = glob([ | ||
"include/tbb/*.h", | ||
"include/oneapi/tbb/detail/*.h", | ||
"include/oneapi/tbb/*.h", | ||
]), | ||
includes = [ | ||
"include", | ||
], | ||
local_defines = [ | ||
"__TBBMALLOC_BUILD", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "tbbmalloc_proxy", | ||
srcs = [ | ||
"src/tbbmalloc_proxy/function_replacement.cpp", | ||
"src/tbbmalloc_proxy/proxy.cpp", | ||
], | ||
deps = [ | ||
":tbbmalloc", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Bazel build support | ||
|
||
The main build system of oneTBB is CMake. | ||
Bazel support is community-based. | ||
The maintainers do not use Bazel internally. | ||
The Bazel configuration may not include recommended compiler and linker flags used in official CMake configuration. | ||
|
||
The Bazel build of oneTBB currently only aims for a subset of oneTBB that suffices restricted use cases of the usage of oneTBB. | ||
Pull requests to improve the Bazel build experience are welcomed. | ||
|
||
The standard approach of how Bazel handles third-party libraries is static linking. | ||
Even this is not recommended by the oneTBB maintainers this is chosen since this is considered as the best practice in the Bazel ecosystem. | ||
|
||
## Example usage | ||
|
||
1. [Install Bazel](https://docs.bazel.build/versions/main/install.html). | ||
|
||
2. Create the following files in one folder (this folder will be considered as the workspace folder): | ||
|
||
_WORKSPACE.bazel_: | ||
``` | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
git_repository( | ||
name = "oneTBB", | ||
branch = "master", | ||
remote = "https://github.com/oneapi-src/oneTBB/", | ||
) | ||
``` | ||
|
||
_BUILD_: | ||
``` | ||
cc_binary( | ||
name = "Demo", | ||
srcs = ["main.cpp"], | ||
deps = ["@oneTBB//:tbb"], | ||
) | ||
``` | ||
|
||
_main.cpp_: | ||
``` | ||
#include "oneapi/tbb/version.h" | ||
#include <iostream> | ||
int main() { | ||
std::cout << "Hello from oneTBB " | ||
<< TBB_VERSION_MAJOR << "." | ||
<< TBB_VERSION_MINOR << "." | ||
<< TBB_VERSION_PATCH | ||
<< "!" << std::endl; | ||
return 0; | ||
} | ||
``` | ||
|
||
3. Switch to the folder where you create the files. | ||
|
||
4. Execute the command `bazel run //:Demo`. | ||
As an expected output, you should see the oneTBB version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (c) 2021 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# DISCLAIMER: Bazel support is community-based. The maintainers do not | ||
# use Bazel internally. The Bazel build can have security risks or | ||
# optimization gaps. | ||
|
||
workspace(name = "oneTBB") |