1
+ from __future__ import print_function
1
2
import collections
2
3
import itertools
3
4
import json
@@ -29,7 +30,7 @@ def merged_with( self, build_desc ):
29
30
def env ( self ):
30
31
environ = os .environ .copy ()
31
32
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 () ):
33
34
var = var .upper ()
34
35
if type (value ) is unicode :
35
36
value = value .encode ( sys .getdefaultencoding () )
@@ -62,27 +63,27 @@ def __init__( self, desc, work_dir, source_dir ):
62
63
self .build_succeeded = False
63
64
64
65
def execute_build (self ):
65
- print 'Build %s' % self .desc
66
+ print ( 'Build %s' % self .desc )
66
67
self ._make_new_work_dir ( )
67
68
self .cmake_succeeded = self ._generate_makefiles ( )
68
69
if self .cmake_succeeded :
69
70
self .build_succeeded = self ._build_using_makefiles ( )
70
71
return self .build_succeeded
71
72
72
73
def _generate_makefiles (self ):
73
- print ' Generating makefiles: ' ,
74
+ print ( ' Generating makefiles: ' , end = ' ' )
74
75
cmd = ['cmake' ] + self .desc .cmake_args ( ) + [os .path .abspath ( self .source_dir )]
75
76
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' )
77
78
return succeeded
78
79
79
80
def _build_using_makefiles (self ):
80
- print ' Building:' ,
81
+ print ( ' Building:' , end = ' ' )
81
82
cmd = ['cmake' , '--build' , self .work_dir ]
82
83
if self .desc .build_type :
83
84
cmd += ['--config' , self .desc .build_type ]
84
85
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' )
86
87
return succeeded
87
88
88
89
def _execute_build_subprocess (self , cmd , env , log_path ):
@@ -97,7 +98,7 @@ def _execute_build_subprocess(self, cmd, env, log_path):
97
98
98
99
def _make_new_work_dir (self ):
99
100
if os .path .isdir ( self .work_dir ):
100
- print ' Removing work directory' , self .work_dir
101
+ print ( ' Removing work directory' , self .work_dir )
101
102
shutil .rmtree ( self .work_dir , ignore_errors = True )
102
103
if not os .path .isdir ( self .work_dir ):
103
104
os .makedirs ( self .work_dir )
@@ -134,9 +135,9 @@ def load_build_variants_from_config( config_path ):
134
135
135
136
def generate_build_variants ( build_descs_by_axis ):
136
137
"""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 () )
138
139
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 () ):
140
141
if len (build_descs ):
141
142
# for each existing build_desc and each axis build desc, create a new build_desc
142
143
new_build_descs = []
@@ -227,7 +228,7 @@ def generate_html_report( html_report_path, builds ):
227
228
tr_builds = '\n ' .join ( tr_builds ) )
228
229
with open ( html_report_path , 'wt' ) as fhtml :
229
230
fhtml .write ( html )
230
- print 'HTML report generated in:' , html_report_path
231
+ print ( 'HTML report generated in:' , html_report_path )
231
232
232
233
def main ():
233
234
usage = r"""%prog WORK_DIR SOURCE_DIR CONFIG_JSON_PATH [CONFIG2_JSON_PATH...]
@@ -258,7 +259,7 @@ def main():
258
259
for config_path in config_paths :
259
260
build_descs_by_axis = load_build_variants_from_config ( config_path )
260
261
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 ) )
262
263
# assign build directory for each variant
263
264
if not os .path .isdir ( work_dir ):
264
265
os .makedirs ( work_dir )
@@ -272,7 +273,7 @@ def main():
272
273
build .execute_build ()
273
274
html_report_path = os .path .join ( work_dir , 'batchbuild-report.html' )
274
275
generate_html_report ( html_report_path , builds )
275
- print 'Done'
276
+ print ( 'Done' )
276
277
277
278
278
279
if __name__ == '__main__' :
0 commit comments