Skip to content

Commit

Permalink
tbb: Add option to build tbb_preview lib
Browse files Browse the repository at this point in the history
This makes the resulting tbb package more interchangeable with the
official releases

Signed-off-by: Paul Molodowitch <paul@molodowitch.com>
  • Loading branch information
pmolodo authored and jfpanisset committed Jun 26, 2023
1 parent e1b8287 commit 5de30db
Showing 1 changed file with 38 additions and 31 deletions.
69 changes: 38 additions & 31 deletions packages/conan/recipes/tbb/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ class TBBConan(ConanFile):
"fPIC": [True, False],
"tbbmalloc": [True, False],
"tbbproxy": [True, False],
"tbbpreview": [True, False],
}
default_options = {
"shared": True,
"fPIC": True,
"tbbmalloc": True,
"tbbproxy": True,
"tbbpreview": False,
}

@property
Expand Down Expand Up @@ -81,21 +83,28 @@ def source(self):
)

def build(self):
self.build_base()
if self.options.tbbpreview:
self.build_base(preview=True)

def build_base(self, preview=False):
def add_flag(name, value):
if name in os.environ:
os.environ[name] += " " + value
else:
os.environ[name] = value

# Get the version of the current compiler instead of gcc
linux_include = os.path.join(self._source_subfolder, "build", "linux.inc")
tools.replace_in_file(linux_include, "shell gcc", "shell $(CC)")
tools.replace_in_file(linux_include, "= gcc", "= $(CC)")
# if we're doing a second build (ie, preview), then we the source replacements have already been done...
if not preview:
# Get the version of the current compiler instead of gcc
linux_include = os.path.join(self._source_subfolder, "build", "linux.inc")
tools.replace_in_file(linux_include, "shell gcc", "shell $(CC)")
tools.replace_in_file(linux_include, "= gcc", "= $(CC)")

if self.version != "2019_u9" and self.settings.build_type == "Debug":
tools.replace_in_file(
os.path.join(self._source_subfolder, "Makefile"), "release", "debug"
)
if self.version != "2019_u9" and self.settings.build_type == "Debug":
tools.replace_in_file(
os.path.join(self._source_subfolder, "Makefile"), "release", "debug"
)

if self._base_compiler == "Visual Studio":
tools.save(
Expand Down Expand Up @@ -139,6 +148,9 @@ def add_flag(name, value):
}[str(self.settings.arch)]
extra += " arch=%s" % arch

if preview:
extra += " tbb_build_prefix=local_preview tbb_cpf=1"

if str(self._base_compiler) in ("gcc", "clang", "apple-clang"):
if str(self._base_compiler.libcxx) in ("libstdc++", "libstdc++11"):
extra += " stdlib=libstdc++"
Expand Down Expand Up @@ -197,10 +209,11 @@ def add_flag(name, value):
add_flag("CXXFLAGS", "-mrtm")

targets = ["tbb"]
if self.options.tbbmalloc:
targets.append("tbbmalloc")
if self.options.tbbproxy:
targets.append("tbbproxy")
if not preview:
if self.options.tbbmalloc:
targets.append("tbbmalloc")
if self.options.tbbproxy:
targets.append("tbbproxy")
context = tools.no_op()
if self.settings.compiler == "intel":
context = tools.intel_compilervars(self)
Expand Down Expand Up @@ -275,39 +288,33 @@ def package_info(self):
self.cpp_info.names["cmake_find_package"] = "TBB"
self.cpp_info.names["cmake_find_package_multi"] = "TBB"
# tbb
self.cpp_info.components["libtbb"].names["cmake_find_package"] = "tbb"
self.cpp_info.components["libtbb"].names["cmake_find_package_multi"] = "tbb"
self.cpp_info.components["libtbb"].libs = [self._lib_name("tbb")]
self._add_component("libtbb", lib="tbb")
if self.settings.os == "Linux":
self.cpp_info.components["libtbb"].system_libs = ["dl", "rt", "pthread"]
# tbbmalloc
if self.options.tbbmalloc:
self.cpp_info.components["tbbmalloc"].names[
"cmake_find_package"
] = "tbbmalloc"
self.cpp_info.components["tbbmalloc"].names[
"cmake_find_package_multi"
] = "tbbmalloc"
self.cpp_info.components["tbbmalloc"].libs = [self._lib_name("tbbmalloc")]
self._add_component("tbbmalloc")
if self.settings.os == "Linux":
self.cpp_info.components["tbbmalloc"].system_libs = ["dl", "pthread"]
# tbbmalloc_proxy
if self.options.tbbproxy:
self.cpp_info.components["tbbmalloc_proxy"].names[
"cmake_find_package"
] = "tbbmalloc_proxy"
self.cpp_info.components["tbbmalloc_proxy"].names[
"cmake_find_package_multi"
] = "tbbmalloc_proxy"
self.cpp_info.components["tbbmalloc_proxy"].libs = [
self._lib_name("tbbmalloc_proxy")
]
self._add_component("tbbmalloc_proxy")
self.cpp_info.components["tbbmalloc_proxy"].requires = ["tbbmalloc"]
# tbbpreview
if self.options.tbbpreview:
self._add_component("tbb_preview")

def _lib_name(self, name):
if self.settings.build_type == "Debug":
return name + "_debug"
return name

def _add_component(self, component_name, lib=""):
if not lib:
lib = component_name
self.cpp_info.components[component_name].names["cmake_find_package"] = lib
self.cpp_info.components[component_name].names["cmake_find_package_multi"] = lib
self.cpp_info.components[component_name].libs = [self._lib_name(lib)]

def deploy(self):
self.copy("*")

0 comments on commit 5de30db

Please sign in to comment.