42
42
parser = argparse .ArgumentParser ()
43
43
parser .add_argument ('--tbbroot' , default = '.' , help = 'Take Intel TBB from here' )
44
44
parser .add_argument ('--prefix' , default = default_prefix , help = 'Prefix' )
45
+ parser .add_argument ('--prebuilt' , default = [], action = 'append' , help = 'Directories to find prebuilt files' )
45
46
parser .add_argument ('--no-rebuild' , default = False , action = 'store_true' , help = 'do not rebuild' )
46
47
parser .add_argument ('--install' , default = False , action = 'store_true' , help = 'install all' )
47
48
parser .add_argument ('--install-libs' , default = False , action = 'store_true' , help = 'install libs' )
@@ -92,75 +93,79 @@ def custom_cp(src, dst):
92
93
93
94
##############################################################
94
95
96
+ def run_make (arg ):
97
+ if os .system ('%s -j %s' % (args .make_tool , arg )) != 0 :
98
+ print ("\n Bummer. Running serial build in order to recover the log and have a chance to fix the build" )
99
+ assert os .system ('%s %s' % (args .make_tool , arg )) == 0
100
+
95
101
os .chdir (args .tbbroot )
96
- if is_win and args .msbuild :
97
- preview_release_dir = release_dir = jp (args .tbbroot , 'build' , 'vs' + args .vs , args .vs_platform , 'Release' )
98
- if not args .no_rebuild or not os .path .isdir (release_dir ):
99
- assert os .system ('msbuild /m /p:Platform=%s /p:Configuration=Release %s build/vs%s/makefile.sln' % \
100
- (args .vs_platform , args .build_args , args .vs )) == 0
101
- preview_debug_dir = debug_dir = jp (args .tbbroot , 'build' , 'vs' + args .vs , args .vs_platform , 'Debug' )
102
- if not args .no_rebuild or not os .path .isdir (debug_dir ):
103
- assert os .system ('msbuild /m /p:Platform=%s /p:Configuration=Debug %s build/vs%s/makefile.sln' % \
104
- (args .vs_platform , args .build_args , args .vs )) == 0
102
+ if args .prebuilt :
103
+ release_dirs = sum ([glob (d ) for d in args .prebuilt ], [])
104
+ print ("Using pre-built files from " , release_dirs )
105
105
else :
106
- release_dir = jp (args .tbbroot , 'build' , args .build_prefix + '_release' )
107
- debug_dir = jp (args .tbbroot , 'build' , args .build_prefix + '_debug' )
108
- if not args .no_rebuild or not (os .path .isdir (release_dir ) and os .path .isdir (debug_dir )):
109
- assert os .system ('%s -j tbb_build_prefix=%s %s' % \
110
- (args .make_tool , args .build_prefix , args .build_args )) == 0
111
- preview_release_dir = jp (args .tbbroot , 'build' , args .build_prefix + '_preview_release' )
112
- preview_debug_dir = jp (args .tbbroot , 'build' , args .build_prefix + '_preview_debug' )
113
- if not args .no_rebuild or not (os .path .isdir (preview_release_dir ) and os .path .isdir (preview_debug_dir )):
114
- assert os .system ('%s -j tbb_build_prefix=%s_preview %s tbb_cpf=1 tbb' % \
115
- (args .make_tool , args .build_prefix , args .build_args )) == 0
116
-
106
+ if is_win and args .msbuild :
107
+ preview_release_dir = release_dir = jp (args .tbbroot , 'build' , 'vs' + args .vs , args .vs_platform , 'Release' )
108
+ if not args .no_rebuild or not os .path .isdir (release_dir ):
109
+ assert os .system ('msbuild /m /p:Platform=%s /p:Configuration=Release %s build/vs%s/makefile.sln' % \
110
+ (args .vs_platform , args .build_args , args .vs )) == 0
111
+ preview_debug_dir = debug_dir = jp (args .tbbroot , 'build' , 'vs' + args .vs , args .vs_platform , 'Debug' )
112
+ if not args .no_rebuild or not os .path .isdir (debug_dir ):
113
+ assert os .system ('msbuild /m /p:Platform=%s /p:Configuration=Debug %s build/vs%s/makefile.sln' % \
114
+ (args .vs_platform , args .build_args , args .vs )) == 0
115
+ else :
116
+ release_dir = jp (args .tbbroot , 'build' , args .build_prefix + '_release' )
117
+ debug_dir = jp (args .tbbroot , 'build' , args .build_prefix + '_debug' )
118
+ if not args .no_rebuild or not (os .path .isdir (release_dir ) and os .path .isdir (debug_dir )):
119
+ run_make ('tbb_build_prefix=%s %s' % (args .build_prefix , args .build_args ))
120
+ preview_release_dir = jp (args .tbbroot , 'build' , args .build_prefix + '_preview_release' )
121
+ preview_debug_dir = jp (args .tbbroot , 'build' , args .build_prefix + '_preview_debug' )
122
+ if not args .no_rebuild or not (os .path .isdir (preview_release_dir ) and os .path .isdir (preview_debug_dir )):
123
+ run_make ('tbb_build_prefix=%s_preview %s tbb_cpf=1 tbb' % (args .build_prefix , args .build_args ))
124
+ release_dirs = [release_dir , debug_dir , preview_release_dir , preview_debug_dir ]
117
125
118
126
filemap = OrderedDict ()
119
- def append_files (files , dst ):
127
+ def append_files (names , dst , paths = release_dirs ):
120
128
global filemap
129
+ files = sum ([glob (jp (d , f )) for d in paths for f in names ], [])
121
130
filemap .update (dict (zip (files , [dst ]* len (files ))))
122
131
132
+
123
133
if args .install_libs :
124
- files = [jp (release_dir , libpref + f + libext ) for f in tbb_names ]
125
- append_files (files , dll_dir )
134
+ append_files ([libpref + f + libext for f in tbb_names ], dll_dir )
126
135
127
136
if args .install_devel :
128
- dll_files = [jp ( debug_dir , libpref + f + '_debug' + libext ) for f in tbb_names ] # adding debug libraries
137
+ dll_files = [libpref + f + '_debug' + libext for f in tbb_names ] # adding debug libraries
129
138
if not is_win or not args .msbuild :
130
- dll_files += [jp (preview_release_dir , libpref + "tbb_preview" + libext ),
131
- jp (preview_debug_dir , libpref + "tbb_preview_debug" + libext )]
139
+ dll_files += [libpref + "tbb_preview" + libext , libpref + "tbb_preview_debug" + libext ]
132
140
if is_win :
133
- dll_files += sum ( [glob (jp (d , 'tbb*.pdb' )) for d in # copying debug info
134
- (release_dir , debug_dir , preview_release_dir , preview_debug_dir )], [])
141
+ dll_files += ['tbb*.pdb' ] # copying debug info
135
142
if is_lin :
136
- dll_files += sum ( [glob (jp (d , 'libtbb*.so' )) for d in # copying linker scripts
137
- (release_dir , debug_dir , preview_release_dir , preview_debug_dir )], [])
143
+ dll_files += ['libtbb*.so' ] # copying linker scripts
138
144
# symlinks .so -> .so.2 should not be created instead
139
145
# since linking with -ltbb when using links can result in
140
146
# incorrect dependence upon unversioned .so files
141
147
append_files (dll_files , dll_dir )
142
148
if is_win :
143
- lib_files = sum ([glob (jp (d ,e )) for d in (release_dir , debug_dir ) for e in ('*.lib' , '*.def' )], [])
144
- append_files (lib_files , lib_dir ) # copying linker libs and defs
149
+ append_files (['*.lib' , '*.def' ], lib_dir ) # copying linker libs and defs
145
150
for rootdir , dirnames , filenames in os .walk (jp (args .tbbroot ,'include' )):
146
- files = [jp ( rootdir , f ) for f in filenames if not '.html' in f ]
147
- append_files (files , jp (inc_dir , rootdir .split ('include' )[1 ][1 :]))
151
+ files = [f for f in filenames if not '.html' in f ]
152
+ append_files (files , jp (inc_dir , rootdir .split ('include' )[1 ][1 :]), paths = ( rootdir ,) )
148
153
149
- if args .install_python :
150
- assert os . system ( '%s -j tbb_build_prefix=%s %s python' % \
151
- (args .make_tool , args . build_prefix , args .build_args )) == 0
154
+ if args .install_python : # RML part
155
+ irml_dir = jp ( args . tbbroot , 'build' , args . build_prefix + '_release' )
156
+ run_make ( '-C src tbb_build_prefix=%s %s python_rml' % (args .build_prefix , args .build_args ))
152
157
if is_lin :
153
- append_files ([jp ( release_dir , 'libirml.so.1' ) ], dll_dir )
158
+ append_files (['libirml.so.1' ], dll_dir , paths = [ irml_dir ] )
154
159
155
160
if args .install_docs :
156
- files = [jp ( args . tbbroot , * f ) for f in (
157
- ( 'CHANGES' ,) ,
158
- ( 'LICENSE' ,) ,
159
- ( 'README' ,) ,
160
- ( 'README.md' ,) ,
161
- ( 'doc' , ' Release_Notes.txt') ,
162
- ) ]
163
- append_files (files , doc_dir )
161
+ files = [
162
+ 'CHANGES' ,
163
+ 'LICENSE' ,
164
+ 'README' ,
165
+ 'README.md' ,
166
+ ' Release_Notes.txt' ,
167
+ ]
168
+ append_files (files , doc_dir , paths = release_dirs + [ jp ( args . tbbroot , d ) for d in ( '.' , 'doc' )] )
164
169
165
170
for f in filemap .keys ():
166
171
assert os .path .exists (f )
@@ -174,4 +179,11 @@ def append_files(files, dst):
174
179
print ("+ %s to $prefix%s" % (f ,dest .replace (args .prefix , '' )))
175
180
install_cp (f , dest )
176
181
182
+ if args .install_python : # Python part
183
+ paths = [os .path .abspath (d ) for d in (args .prefix , irml_dir , lib_dir , inc_dir )]
184
+ os .environ ["TBBROOT" ] = paths [0 ]
185
+ # all the paths must be relative to python/ directory or be absolute
186
+ assert os .system ('python python/setup.py build -b%s build_ext -L%s:%s -I%s install -f' % \
187
+ (paths [1 ], paths [2 ], paths [1 ], paths [3 ])) == 0 # add install location? windows needs pythnon/Library location separation
188
+
177
189
print ("done" )
0 commit comments