Skip to content

Commit

Permalink
improve tbb detection (for OSX support)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmouret committed Jul 24, 2017
1 parent c17356b commit 6005a62
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
10 changes: 10 additions & 0 deletions waf_tools/sferes.py
Expand Up @@ -12,6 +12,16 @@

import glob

# check if a lib exists for both osx (darwin) and GNU/linux
def check_lib(self, name, path):
if self.env['DEST_OS']=='darwin':
libname = name + '.dylib'
else:
libname = name + '.so'
res = self.find_file(libname, path)
lib = res[:-len(libname)-1]
return res, lib

def create_variants(bld, source, use,
uselib, variants, includes=". ../ ../../",
cxxflags='',
Expand Down
40 changes: 14 additions & 26 deletions waf_tools/tbb.py
@@ -1,14 +1,12 @@
#! /usr/bin/env python
#!/usr/bin/env python
# encoding: utf-8
# JB Mouret - 2014

"""
Quick n dirty tbb detection
"""

import os
from waflib.Configure import conf
from waflib import Utils, Logs
import sferes

def options(opt):
opt.add_option('--tbb', type='string', help='path to Intel TBB', dest='tbb')
Expand All @@ -21,38 +19,28 @@ def check_tbb(self, *k, **kw):
libpath_tbb = [self.options.tbb + '/lib']
else:
includes_tbb = ['/usr/local/include', '/usr/include', '/opt/intel/tbb/include']
libpath_tbb = ['/usr/local/lib/', '/usr/lib', '/opt/intel/tbb/lib', '/usr/lib/x86_64-linux-gnu', '/usr/libx86_64-linux-gnu']
if 'CPPFLAGS' in os.environ:
includes_tbb += [path[2:] for path in os.environ['CPPFLAGS'].split() if path[0:2] == '-I']
if 'LD_LIBRARY_PATH' in os.environ:
libpath_tbb += os.environ['LD_LIBRARY_PATH'].split(":")
libpath_tbb = ['/usr/local/lib/', '/usr/lib', '/opt/intel/tbb/lib', '/usr/lib/x86_64-linux-gnu/']

self.start_msg('Checking Intel TBB includes (optional)')
incl = ''
lib = ''
try:
res = self.find_file('tbb/parallel_for.h', includes_tbb)
index = includes_tbb.index(res[:-len('tbb/parallel_for.h')-1])
includes_tbb = [includes_tbb[index]]
self.end_msg('ok')
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % includes_tbb[0])
incl = res[:-len('tbb/parallel_for.h')-1]
self.end_msg(incl)
except:
self.end_msg('not found', 'YELLOW')
self.end_msg('Not found in %s' % str(includes_tbb), 'YELLOW')
return

self.start_msg('Checking Intel TBB libs (optional)')
try:
res = self.find_file('libtbb.so', libpath_tbb)
index = libpath_tbb.index(res[:-len('libtbb.so')-1])
libpath_tbb = [libpath_tbb[index]]
self.end_msg('ok')
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % libpath_tbb[0])
Logs.pprint('CYAN', ' libs : [\'tbb\']')
res, lib = sferes.check_lib(self, 'libtbb', libpath_tbb)
self.end_msg(lib)
except:
self.end_msg('not found', 'YELLOW')
self.end_msg('Not found in %s' % str(libpath_tbb), 'YELLOW')
return

self.env.LIBPATH_TBB = libpath_tbb
self.env.LIBPATH_TBB = [lib]
self.env.LIB_TBB = ['tbb']
self.env.INCLUDES_TBB = includes_tbb
self.env['TBB_ENABLED'] = True
self.env.INCLUDES_TBB = [incl]
self.env.DEFINES_TBB = ['USE_TBB']

0 comments on commit 6005a62

Please sign in to comment.