1
- from conan .tools .microsoft import msvc_runtime_flag
2
- from conans import ConanFile , tools
3
- from conans .errors import ConanInvalidConfiguration , ConanException
1
+ from conan import ConanFile
2
+ from conan .tools .microsoft import msvc_runtime_flag , is_msvc
3
+ from conan .tools .build import cross_building
4
+ from conan .tools .files import get , replace_in_file , save , chdir , copy
5
+ from conan .tools .scm import Version
6
+ from conan .errors import ConanInvalidConfiguration , ConanException
7
+ from conans import tools
4
8
import os
5
9
import textwrap
6
10
7
- required_conan_version = ">=1.43 .0"
11
+ required_conan_version = ">=1.47 .0"
8
12
9
13
10
14
class OneTBBConan (ConanFile ):
@@ -41,10 +45,6 @@ def _source_subfolder(self):
41
45
def _settings_build (self ):
42
46
return getattr (self , "settings_build" , self .settings )
43
47
44
- @property
45
- def _is_msvc (self ):
46
- return str (self .settings .compiler ) in ["Visual Studio" , "msvc" ]
47
-
48
48
@property
49
49
def _is_clanglc (self ):
50
50
return self .settings .os == "Windows" and self .settings .compiler == "clang"
@@ -66,10 +66,10 @@ def configure(self):
66
66
67
67
def validate (self ):
68
68
if self .settings .os == "Macos" :
69
- if hasattr (self , "settings_build" ) and tools . cross_building (self ):
69
+ if hasattr (self , "settings_build" ) and cross_building (self ):
70
70
# See logs from https://github.com/conan-io/conan-center-index/pull/8454
71
71
raise ConanInvalidConfiguration ("Cross building on Macos is not yet supported. Contributions are welcome" )
72
- if self .settings .compiler == "apple-clang" and tools . Version (self .settings .compiler .version ) < "8.0" :
72
+ if self .settings .compiler == "apple-clang" and Version (self .settings .compiler .version ) < "8.0" :
73
73
raise ConanInvalidConfiguration ("%s %s couldn't be built by apple-clang < 8.0" % (self .name , self .version ))
74
74
if not self .options .shared :
75
75
self .output .warn ("oneTBB strongly discourages usage of static linkage" )
@@ -88,7 +88,7 @@ def build_requirements(self):
88
88
self .build_requires ("make/4.2.1" )
89
89
90
90
def source (self ):
91
- tools . get (** self .conan_data ["sources" ][self .version ],
91
+ get (self , ** self .conan_data ["sources" ][self .version ],
92
92
strip_root = True , destination = self ._source_subfolder )
93
93
94
94
def build (self ):
@@ -100,14 +100,14 @@ def add_flag(name, value):
100
100
101
101
# Get the version of the current compiler instead of gcc
102
102
linux_include = os .path .join (self ._source_subfolder , "build" , "linux.inc" )
103
- tools . replace_in_file (linux_include , "shell gcc" , "shell $(CC)" )
104
- tools . replace_in_file (linux_include , "= gcc" , "= $(CC)" )
103
+ replace_in_file (self , linux_include , "shell gcc" , "shell $(CC)" )
104
+ replace_in_file (self , linux_include , "= gcc" , "= $(CC)" )
105
105
106
106
if self .version != "2019_u9" and self .settings .build_type == "Debug" :
107
- tools . replace_in_file (os .path .join (self ._source_subfolder , "Makefile" ), "release" , "debug" )
107
+ replace_in_file (self , os .path .join (self ._source_subfolder , "Makefile" ), "release" , "debug" )
108
108
109
109
if str (self ._base_compiler ) in ["Visual Studio" , "msvc" ]:
110
- tools . save (
110
+ save (self ,
111
111
os .path .join (self ._source_subfolder , "build" , "big_iron_msvc.inc" ),
112
112
# copy of big_iron.inc adapted for MSVC
113
113
textwrap .dedent ("""\
@@ -211,7 +211,7 @@ def add_flag(name, value):
211
211
if not make :
212
212
raise ConanException ("This package needs 'make' in the path to build" )
213
213
214
- with tools . chdir (self ._source_subfolder ):
214
+ with chdir (self , self ._source_subfolder ):
215
215
# intentionally not using AutoToolsBuildEnvironment for now - it's broken for clang-cl
216
216
if self ._is_clanglc :
217
217
add_flag ("CFLAGS" , "-mrtm" )
@@ -221,36 +221,35 @@ def add_flag(name, value):
221
221
context = tools .no_op ()
222
222
if self .settings .compiler == "intel" :
223
223
context = tools .intel_compilervars (self )
224
- elif self . _is_msvc :
224
+ elif is_msvc ( self ) :
225
225
# intentionally not using vcvars for clang-cl yet
226
226
context = tools .vcvars (self )
227
227
with context :
228
228
self .run ("%s %s %s" % (make , extra , " " .join (targets )))
229
229
230
230
def package (self ):
231
- self . copy ("LICENSE" , dst = "licenses" , src = self ._source_subfolder )
232
- self . copy (pattern = "*.h" , dst = "include" , src = "%s/include" % self ._source_subfolder )
233
- self . copy (pattern = "*" , dst = "include/ tbb/ compat" , src = "%s/ include/ tbb/compat" % self . _source_subfolder )
234
- build_folder = "%s/build/" % self ._source_subfolder
231
+ copy (self , "LICENSE" , dst = os . path . join ( self . package_folder , "licenses" ) , src = self ._source_subfolder )
232
+ copy (self , pattern = "*.h" , dst = os . path . join ( self . package_folder , "include" ) , src = os . path . join ( self ._source_subfolder , "include" ) )
233
+ copy (self , pattern = "*" , dst = os . path . join ( self . package_folder , "include" , " tbb" , " compat") , src = os . path . join ( self . _source_subfolder , " include" , " tbb" , "compat" ) )
234
+ build_folder = os . path . join ( self ._source_subfolder , "build" )
235
235
build_type = "debug" if self .settings .build_type == "Debug" else "release"
236
- self . copy (pattern = "*%s *.lib" % build_type , dst = "lib" , src = build_folder , keep_path = False )
237
- self . copy (pattern = "*%s *.a" % build_type , dst = "lib" , src = build_folder , keep_path = False )
238
- self . copy (pattern = "*%s *.dll" % build_type , dst = "bin" , src = build_folder , keep_path = False )
239
- self . copy (pattern = "*%s *.dylib" % build_type , dst = "lib" , src = build_folder , keep_path = False )
236
+ copy (self , pattern = f"* { build_type } *.lib" , dst = os . path . join ( self . package_folder , "lib" ) , src = build_folder , keep_path = False )
237
+ copy (self , pattern = f"* { build_type } *.a" , dst = os . path . join ( self . package_folder , "lib" ) , src = build_folder , keep_path = False )
238
+ copy (self , pattern = f"* { build_type } *.dll" , dst = os . path . join ( self . package_folder , "bin" ) , src = build_folder , keep_path = False )
239
+ copy (self , pattern = f"* { build_type } *.dylib" , dst = os . path . join ( self . package_folder , "lib" ) , src = build_folder , keep_path = False )
240
240
# Copy also .dlls to lib folder so consumers can link against them directly when using MinGW
241
241
if self .settings .os == "Windows" and self .settings .compiler == "gcc" :
242
- self . copy ("*%s *.dll" % build_type , dst = "lib" , src = build_folder , keep_path = False )
242
+ copy (self , f"* { build_type } *.dll" , dst = os . path . join ( self . package_folder , "lib" ) , src = build_folder , keep_path = False )
243
243
244
244
if self .settings .os == "Linux" :
245
245
extension = "so"
246
246
if self .options .shared :
247
- self .copy ("*%s*.%s.*" % (build_type , extension ), "lib" , build_folder ,
248
- keep_path = False )
247
+ copy (self , f"*{ build_type } *.{ extension } .*" , dst = os .path .join (self .package_folder , "lib" ), src = build_folder , keep_path = False )
249
248
outputlibdir = os .path .join (self .package_folder , "lib" )
250
- os . chdir (outputlibdir )
251
- for fpath in os .listdir (outputlibdir ):
252
- self . run ( "ln -s \" %s \" \" %s \" " %
253
- ( fpath , fpath [ 0 : fpath . rfind ( "." + extension ) + len ( extension ) + 1 ]) )
249
+ with chdir (self , outputlibdir ):
250
+ for fpath in os .listdir (outputlibdir ):
251
+ filepath = fpath [ 0 : fpath . rfind ( "." + extension ) + len ( extension ) + 1 ]
252
+ self . run ( f'ln -s " { fpath } " " { filepath } "' , run_environment = True )
254
253
255
254
def package_info (self ):
256
255
self .cpp_info .set_property ("cmake_file_name" , "TBB" )
0 commit comments