Skip to content

Commit

Permalink
Committing Intel(R) TBB 2018 Update 3 source code with updated build.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tbbdev committed Mar 30, 2018
1 parent d31fcc6 commit 633b01a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 47 deletions.
104 changes: 58 additions & 46 deletions build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
parser = argparse.ArgumentParser()
parser.add_argument('--tbbroot', default='.', help='Take Intel TBB from here')
parser.add_argument('--prefix', default=default_prefix, help='Prefix')
parser.add_argument('--prebuilt', default=[], action='append', help='Directories to find prebuilt files')
parser.add_argument('--no-rebuild', default=False, action='store_true', help='do not rebuild')
parser.add_argument('--install', default=False, action='store_true', help='install all')
parser.add_argument('--install-libs', default=False, action='store_true', help='install libs')
Expand Down Expand Up @@ -92,75 +93,79 @@ def custom_cp(src, dst):

##############################################################

def run_make(arg):
if os.system('%s -j %s'% (args.make_tool, arg)) != 0:
print("\nBummer. Running serial build in order to recover the log and have a chance to fix the build")
assert os.system('%s %s'% (args.make_tool, arg)) == 0

os.chdir(args.tbbroot)
if is_win and args.msbuild:
preview_release_dir = release_dir = jp(args.tbbroot, 'build', 'vs'+args.vs, args.vs_platform, 'Release')
if not args.no_rebuild or not os.path.isdir(release_dir):
assert os.system('msbuild /m /p:Platform=%s /p:Configuration=Release %s build/vs%s/makefile.sln'% \
(args.vs_platform, args.build_args, args.vs)) == 0
preview_debug_dir = debug_dir = jp(args.tbbroot, 'build', 'vs'+args.vs, args.vs_platform, 'Debug')
if not args.no_rebuild or not os.path.isdir(debug_dir):
assert os.system('msbuild /m /p:Platform=%s /p:Configuration=Debug %s build/vs%s/makefile.sln'% \
(args.vs_platform, args.build_args, args.vs)) == 0
if args.prebuilt:
release_dirs = sum([glob(d) for d in args.prebuilt], [])
print("Using pre-built files from ", release_dirs)
else:
release_dir = jp(args.tbbroot, 'build', args.build_prefix+'_release')
debug_dir = jp(args.tbbroot, 'build', args.build_prefix+'_debug')
if not args.no_rebuild or not (os.path.isdir(release_dir) and os.path.isdir(debug_dir)):
assert os.system('%s -j tbb_build_prefix=%s %s'% \
(args.make_tool, args.build_prefix, args.build_args)) == 0
preview_release_dir = jp(args.tbbroot, 'build', args.build_prefix+'_preview_release')
preview_debug_dir = jp(args.tbbroot, 'build', args.build_prefix+'_preview_debug')
if not args.no_rebuild or not (os.path.isdir(preview_release_dir) and os.path.isdir(preview_debug_dir)):
assert os.system('%s -j tbb_build_prefix=%s_preview %s tbb_cpf=1 tbb'% \
(args.make_tool, args.build_prefix, args.build_args)) == 0

if is_win and args.msbuild:
preview_release_dir = release_dir = jp(args.tbbroot, 'build', 'vs'+args.vs, args.vs_platform, 'Release')
if not args.no_rebuild or not os.path.isdir(release_dir):
assert os.system('msbuild /m /p:Platform=%s /p:Configuration=Release %s build/vs%s/makefile.sln'% \
(args.vs_platform, args.build_args, args.vs)) == 0
preview_debug_dir = debug_dir = jp(args.tbbroot, 'build', 'vs'+args.vs, args.vs_platform, 'Debug')
if not args.no_rebuild or not os.path.isdir(debug_dir):
assert os.system('msbuild /m /p:Platform=%s /p:Configuration=Debug %s build/vs%s/makefile.sln'% \
(args.vs_platform, args.build_args, args.vs)) == 0
else:
release_dir = jp(args.tbbroot, 'build', args.build_prefix+'_release')
debug_dir = jp(args.tbbroot, 'build', args.build_prefix+'_debug')
if not args.no_rebuild or not (os.path.isdir(release_dir) and os.path.isdir(debug_dir)):
run_make('tbb_build_prefix=%s %s'% (args.build_prefix, args.build_args))
preview_release_dir = jp(args.tbbroot, 'build', args.build_prefix+'_preview_release')
preview_debug_dir = jp(args.tbbroot, 'build', args.build_prefix+'_preview_debug')
if not args.no_rebuild or not (os.path.isdir(preview_release_dir) and os.path.isdir(preview_debug_dir)):
run_make('tbb_build_prefix=%s_preview %s tbb_cpf=1 tbb'% (args.build_prefix, args.build_args))
release_dirs = [release_dir, debug_dir, preview_release_dir, preview_debug_dir]

filemap = OrderedDict()
def append_files(files, dst):
def append_files(names, dst, paths=release_dirs):
global filemap
files = sum([glob(jp(d, f)) for d in paths for f in names], [])
filemap.update(dict(zip(files, [dst]*len(files))))


if args.install_libs:
files = [jp(release_dir, libpref+f+libext) for f in tbb_names]
append_files(files, dll_dir)
append_files([libpref+f+libext for f in tbb_names], dll_dir)

if args.install_devel:
dll_files = [jp(debug_dir, libpref+f+'_debug'+libext) for f in tbb_names] # adding debug libraries
dll_files = [libpref+f+'_debug'+libext for f in tbb_names] # adding debug libraries
if not is_win or not args.msbuild:
dll_files += [jp(preview_release_dir, libpref+"tbb_preview"+libext),
jp(preview_debug_dir, libpref+"tbb_preview_debug"+libext)]
dll_files += [libpref+"tbb_preview"+libext, libpref+"tbb_preview_debug"+libext]
if is_win:
dll_files += sum( [glob(jp(d, 'tbb*.pdb')) for d in # copying debug info
(release_dir, debug_dir, preview_release_dir, preview_debug_dir)], [])
dll_files += ['tbb*.pdb'] # copying debug info
if is_lin:
dll_files += sum( [glob(jp(d, 'libtbb*.so')) for d in # copying linker scripts
(release_dir, debug_dir, preview_release_dir, preview_debug_dir)], [])
dll_files += ['libtbb*.so'] # copying linker scripts
# symlinks .so -> .so.2 should not be created instead
# since linking with -ltbb when using links can result in
# incorrect dependence upon unversioned .so files
append_files(dll_files, dll_dir)
if is_win:
lib_files = sum([glob(jp(d,e)) for d in (release_dir, debug_dir) for e in ('*.lib', '*.def')], [])
append_files(lib_files, lib_dir) # copying linker libs and defs
append_files(['*.lib', '*.def'], lib_dir) # copying linker libs and defs
for rootdir, dirnames, filenames in os.walk(jp(args.tbbroot,'include')):
files = [jp(rootdir, f) for f in filenames if not '.html' in f]
append_files(files, jp(inc_dir, rootdir.split('include')[1][1:]))
files = [f for f in filenames if not '.html' in f]
append_files(files, jp(inc_dir, rootdir.split('include')[1][1:]), paths=(rootdir,))

if args.install_python:
assert os.system('%s -j tbb_build_prefix=%s %s python'% \
(args.make_tool, args.build_prefix, args.build_args)) == 0
if args.install_python: # RML part
irml_dir = jp(args.tbbroot, 'build', args.build_prefix+'_release')
run_make('-C src tbb_build_prefix=%s %s python_rml'% (args.build_prefix, args.build_args))
if is_lin:
append_files([jp(release_dir, 'libirml.so.1')], dll_dir)
append_files(['libirml.so.1'], dll_dir, paths=[irml_dir])

if args.install_docs:
files = [jp(args.tbbroot, *f) for f in (
('CHANGES',),
('LICENSE',),
('README',),
('README.md',),
('doc','Release_Notes.txt'),
)]
append_files(files, doc_dir)
files = [
'CHANGES',
'LICENSE',
'README',
'README.md',
'Release_Notes.txt',
]
append_files(files, doc_dir, paths=release_dirs+[jp(args.tbbroot, d) for d in ('.', 'doc')])

for f in filemap.keys():
assert os.path.exists(f)
Expand All @@ -174,4 +179,11 @@ def append_files(files, dst):
print("+ %s to $prefix%s"%(f,dest.replace(args.prefix, '')))
install_cp(f, dest)

if args.install_python: # Python part
paths = [os.path.abspath(d) for d in (args.prefix, irml_dir, lib_dir, inc_dir)]
os.environ["TBBROOT"] = paths[0]
# all the paths must be relative to python/ directory or be absolute
assert os.system('python python/setup.py build -b%s build_ext -L%s:%s -I%s install -f'% \
(paths[1], paths[2], paths[1], paths[3])) == 0 # add install location? windows needs pythnon/Library location separation

print("done")
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ else
@$(MAKE) -C "$(work_dir)_$(cfg)" -r -f $(tbb_root)/build/Makefile.test $@
endif

python_%:
python_%: mkdir_release
$(MAKE) -C "$(work_dir)_release" -rf $(tbb_root)/python/Makefile $(subst python_,,$@)

.PHONY: test_release test_debug test_release_no_depends test_debug_no_depends
Expand Down

0 comments on commit 633b01a

Please sign in to comment.