1+ from __future__ import print_function
12import collections
23import itertools
34import json
@@ -29,7 +30,7 @@ def merged_with( self, build_desc ):
2930 def env ( self ):
3031 environ = os .environ .copy ()
3132 for values_by_name in self .prepend_envs :
32- for var , value in values_by_name .items ():
33+ for var , value in list ( values_by_name .items () ):
3334 var = var .upper ()
3435 if type (value ) is unicode :
3536 value = value .encode ( sys .getdefaultencoding () )
@@ -62,27 +63,27 @@ def __init__( self, desc, work_dir, source_dir ):
6263 self .build_succeeded = False
6364
6465 def execute_build (self ):
65- print 'Build %s' % self .desc
66+ print ( 'Build %s' % self .desc )
6667 self ._make_new_work_dir ( )
6768 self .cmake_succeeded = self ._generate_makefiles ( )
6869 if self .cmake_succeeded :
6970 self .build_succeeded = self ._build_using_makefiles ( )
7071 return self .build_succeeded
7172
7273 def _generate_makefiles (self ):
73- print ' Generating makefiles: ' ,
74+ print ( ' Generating makefiles: ' , end = ' ' )
7475 cmd = ['cmake' ] + self .desc .cmake_args ( ) + [os .path .abspath ( self .source_dir )]
7576 succeeded = self ._execute_build_subprocess ( cmd , self .desc .env (), self .cmake_log_path )
76- print 'done' if succeeded else 'FAILED'
77+ print ( 'done' if succeeded else 'FAILED' )
7778 return succeeded
7879
7980 def _build_using_makefiles (self ):
80- print ' Building:' ,
81+ print ( ' Building:' , end = ' ' )
8182 cmd = ['cmake' , '--build' , self .work_dir ]
8283 if self .desc .build_type :
8384 cmd += ['--config' , self .desc .build_type ]
8485 succeeded = self ._execute_build_subprocess ( cmd , self .desc .env (), self .build_log_path )
85- print 'done' if succeeded else 'FAILED'
86+ print ( 'done' if succeeded else 'FAILED' )
8687 return succeeded
8788
8889 def _execute_build_subprocess (self , cmd , env , log_path ):
@@ -97,7 +98,7 @@ def _execute_build_subprocess(self, cmd, env, log_path):
9798
9899 def _make_new_work_dir (self ):
99100 if os .path .isdir ( self .work_dir ):
100- print ' Removing work directory' , self .work_dir
101+ print ( ' Removing work directory' , self .work_dir )
101102 shutil .rmtree ( self .work_dir , ignore_errors = True )
102103 if not os .path .isdir ( self .work_dir ):
103104 os .makedirs ( self .work_dir )
@@ -134,9 +135,9 @@ def load_build_variants_from_config( config_path ):
134135
135136def generate_build_variants ( build_descs_by_axis ):
136137 """Returns a list of BuildDesc generated for the partial BuildDesc for each axis."""
137- axis_names = build_descs_by_axis .keys ()
138+ axis_names = list ( build_descs_by_axis .keys () )
138139 build_descs = []
139- for axis_name , axis_build_descs in build_descs_by_axis .items ():
140+ for axis_name , axis_build_descs in list ( build_descs_by_axis .items () ):
140141 if len (build_descs ):
141142 # for each existing build_desc and each axis build desc, create a new build_desc
142143 new_build_descs = []
@@ -227,7 +228,7 @@ def generate_html_report( html_report_path, builds ):
227228 tr_builds = '\n ' .join ( tr_builds ) )
228229 with open ( html_report_path , 'wt' ) as fhtml :
229230 fhtml .write ( html )
230- print 'HTML report generated in:' , html_report_path
231+ print ( 'HTML report generated in:' , html_report_path )
231232
232233def main ():
233234 usage = r"""%prog WORK_DIR SOURCE_DIR CONFIG_JSON_PATH [CONFIG2_JSON_PATH...]
@@ -258,7 +259,7 @@ def main():
258259 for config_path in config_paths :
259260 build_descs_by_axis = load_build_variants_from_config ( config_path )
260261 build_descs .extend ( generate_build_variants ( build_descs_by_axis ) )
261- print 'Build variants (%d):' % len (build_descs )
262+ print ( 'Build variants (%d):' % len (build_descs ) )
262263 # assign build directory for each variant
263264 if not os .path .isdir ( work_dir ):
264265 os .makedirs ( work_dir )
@@ -272,7 +273,7 @@ def main():
272273 build .execute_build ()
273274 html_report_path = os .path .join ( work_dir , 'batchbuild-report.html' )
274275 generate_html_report ( html_report_path , builds )
275- print 'Done'
276+ print ( 'Done' )
276277
277278
278279if __name__ == '__main__' :
0 commit comments