Skip to content

Commit 40d9b3e

Browse files
theotherjimmyadbridge
authored andcommitted
Correct syntax for mbed export in Py3
1 parent 2df7de2 commit 40d9b3e

File tree

11 files changed

+56
-149
lines changed

11 files changed

+56
-149
lines changed

tools/export/cmake/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17+
from __future__ import print_function, absolute_import
18+
from builtins import str
19+
1720
import re
1821
import shutil
1922
from os import remove, getcwd, chdir, mkdir
@@ -162,7 +165,7 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
162165
else:
163166
out_string += "FAILURE"
164167

165-
print out_string
168+
print(out_string)
166169

167170
if log_name:
168171
# Write the output to the log file

tools/export/gnuarmeclipse/__init__.py

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
2222
Author: Liviu Ionescu <[email protected]>
2323
"""
24+
from __future__ import print_function, absolute_import
25+
from builtins import str
2426

2527
import os
2628
import copy
@@ -139,8 +141,6 @@ def create_jinja_ctx(self):
139141
# TODO: use some logger to display additional info if verbose
140142

141143
libraries = []
142-
# print 'libraries'
143-
# print self.resources.libraries
144144
for lib in self.resources.libraries:
145145
l, _ = splitext(basename(lib))
146146
libraries.append(l[3:])
@@ -158,28 +158,22 @@ def create_jinja_ctx(self):
158158
# TODO: get the list from existing .cproject
159159
build_folders = [s.capitalize() for s in profile_ids]
160160
build_folders.append('BUILD')
161-
# print build_folders
162161

163162
objects = [self.filter_dot(s) for s in self.resources.objects]
164163
for bf in build_folders:
165164
objects = [o for o in objects if not o.startswith(bf + '/')]
166-
# print 'objects'
167-
# print objects
168165

169166
self.compute_exclusions()
170167

171168
self.include_path = [
172169
self.filter_dot(s) for s in self.resources.inc_dirs]
173-
print 'Include folders: {0}'.format(len(self.include_path))
174170

175171
self.as_defines = self.toolchain.get_symbols(True)
176172
self.c_defines = self.toolchain.get_symbols()
177173
self.cpp_defines = self.c_defines
178-
print 'Symbols: {0}'.format(len(self.c_defines))
179174

180175
self.ld_script = self.filter_dot(
181176
self.resources.linker_script)
182-
print 'Linker script: {0}'.format(self.ld_script)
183177

184178
self.options = {}
185179
for id in profile_ids:
@@ -196,8 +190,6 @@ def create_jinja_ctx(self):
196190
opts['id'] = id
197191
opts['name'] = opts['id'].capitalize()
198192

199-
print
200-
print 'Build configuration: {0}'.format(opts['name'])
201193

202194
profile = profiles[id]
203195

@@ -215,12 +207,6 @@ def create_jinja_ctx(self):
215207

216208
flags = self.toolchain_flags(toolchain)
217209

218-
print 'Common flags:', ' '.join(flags['common_flags'])
219-
print 'C++ flags:', ' '.join(flags['cxx_flags'])
220-
print 'C flags:', ' '.join(flags['c_flags'])
221-
print 'ASM flags:', ' '.join(flags['asm_flags'])
222-
print 'Linker flags:', ' '.join(flags['ld_flags'])
223-
224210
# Most GNU ARM Eclipse options have a parent,
225211
# either debug or release.
226212
if '-O0' in flags['common_flags'] or '-Og' in flags['common_flags']:
@@ -281,11 +267,6 @@ def generate(self):
281267
"""
282268
jinja_ctx = self.create_jinja_ctx()
283269

284-
print
285-
print 'Create a GNU ARM Eclipse C++ managed project'
286-
print 'Project name: {0}'.format(self.project_name)
287-
print 'Target: {0}'.format(self.toolchain.target.name)
288-
print 'Toolchain: {0}'.format(self.TOOLCHAIN)
289270

290271
self.gen_file('gnuarmeclipse/.project.tmpl', jinja_ctx,
291272
'.project', trim_blocks=True, lstrip_blocks=True)
@@ -296,8 +277,7 @@ def generate(self):
296277
self.gen_file_nonoverwrite('gnuarmeclipse/mbedignore.tmpl', jinja_ctx,
297278
'.mbedignore')
298279

299-
print
300-
print 'Done. Import the \'{0}\' project in Eclipse.'.format(self.project_name)
280+
print('Done. Import the \'{0}\' project in Eclipse.'.format(self.project_name))
301281

302282
@staticmethod
303283
def clean(_):
@@ -363,7 +343,7 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
363343
if ret_code != 0:
364344
ret_string += "FAILURE\n"
365345

366-
print "%s\n%s\n%s\n%s" % (stdout_string, out, err_string, ret_string)
346+
print("%s\n%s\n%s\n%s" % (stdout_string, out, err_string, ret_string))
367347

368348
if log_name:
369349
# Write the output to the log file
@@ -397,11 +377,9 @@ def get_all_profiles():
397377
file_names = [join(tools_path, "profiles", fn) for fn in os.listdir(
398378
join(tools_path, "profiles")) if fn.endswith(".json")]
399379

400-
# print file_names
401380

402381
profile_names = [basename(fn).replace(".json", "")
403382
for fn in file_names]
404-
# print profile_names
405383

406384
profiles = {}
407385

@@ -435,7 +413,6 @@ def compute_exclusions(self):
435413
src) for src in self.resources.c_sources + self.resources.cpp_sources + self.resources.s_sources)]
436414

437415
self.excluded_folders = set(self.resources.ignored_dirs) - set(self.resources.inc_dirs)
438-
print 'Source folders: {0}, with {1} exclusions'.format(len(source_folders), len(self.excluded_folders))
439416

440417

441418
# -------------------------------------------------------------------------
@@ -460,7 +437,6 @@ def dump_tree(self, nodes, depth=0):
460437
node = nodes[k]
461438
parent_name = node['parent'][
462439
'name'] if 'parent' in node.keys() else ''
463-
print ' ' * depth, node['name'], node['is_used'], parent_name
464440
if len(node['children'].keys()) != 0:
465441
self.dump_tree(node['children'], depth + 1)
466442

@@ -474,7 +450,6 @@ def dump_paths(self, nodes, depth=0):
474450
break
475451
node = node['parent']
476452
path = '/'.join(parts)
477-
print path, nodes[k]['is_used']
478453
self.dump_paths(nodes[k]['children'], depth + 1)
479454

480455
# -------------------------------------------------------------------------
@@ -504,14 +479,6 @@ def process_options(self, opts, flags_in):
504479
# Make a copy of the flags, to be one by one removed after processing.
505480
flags = copy.deepcopy(flags_in)
506481

507-
if False:
508-
print
509-
print 'common_flags', flags['common_flags']
510-
print 'asm_flags', flags['asm_flags']
511-
print 'c_flags', flags['c_flags']
512-
print 'cxx_flags', flags['cxx_flags']
513-
print 'ld_flags', flags['ld_flags']
514-
515482
# Initialise the 'last resort' options where all unrecognised
516483
# options will be collected.
517484
opts['as']['other'] = ''
@@ -944,17 +911,6 @@ def process_options(self, opts, flags_in):
944911
opts['cpp']['other'] = opts['cpp']['other'].strip()
945912
opts['ld']['other'] = opts['ld']['other'].strip()
946913

947-
if False:
948-
print
949-
print opts
950-
951-
print
952-
print 'common_flags', flags['common_flags']
953-
print 'asm_flags', flags['asm_flags']
954-
print 'c_flags', flags['c_flags']
955-
print 'cxx_flags', flags['cxx_flags']
956-
print 'ld_flags', flags['ld_flags']
957-
958914
@staticmethod
959915
def find_options(lst, option):
960916
tmp = [str for str in lst if str.startswith(option)]

tools/export/iar/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import print_function, absolute_import
2+
from builtins import str
3+
14
import os
25
from os.path import sep, join, exists
36
from collections import namedtuple
@@ -181,7 +184,7 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
181184
else:
182185
out_string += "FAILURE"
183186

184-
print out_string
187+
print(out_string)
185188

186189
if log_name:
187190
# Write the output to the log file

tools/export/makefile/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17+
from __future__ import print_function, absolute_import
18+
from builtins import str
19+
1720
from os.path import splitext, basename, relpath, join, abspath, dirname,\
1821
exists
1922
from os import remove
@@ -178,7 +181,7 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
178181
else:
179182
out_string += "FAILURE"
180183

181-
print out_string
184+
print(out_string)
182185

183186
if log_name:
184187
# Write the output to the log file

tools/export/mcuxpresso/__init__.py

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
Based on GNU ARM Eclipse Exporter from Liviu Ionescu <[email protected]>
2323
modified for MCUXpresso by Johannes Stratmann <[email protected]>
2424
"""
25+
from __future__ import print_function, absolute_import
26+
from builtins import str
2527

2628
import copy
2729
import tempfile
@@ -39,9 +41,6 @@
3941
from tools.build_api import prepare_toolchain
4042

4143

42-
# =============================================================================
43-
44-
4544
POST_BINARY_WHITELIST = set([
4645
"TEENSY3_1Code.binary_hook",
4746
"MCU_NRF51Code.binary_hook",
@@ -73,12 +72,6 @@ def generate(self):
7372
if not self.resources.linker_script:
7473
raise NotSupportedException("No linker script found.")
7574

76-
print
77-
print 'Create a GNU ARM Eclipse C++ managed project'
78-
print 'Project name: {0}'.format(self.project_name)
79-
print 'Target: {0}'.format(self.toolchain.target.name)
80-
print 'Toolchain: {0}'.format(self.TOOLCHAIN)
81-
8275
self.resources.win_to_unix()
8376

8477
# TODO: use some logger to display additional info if verbose
@@ -115,16 +108,13 @@ def generate(self):
115108

116109
self.include_path = [
117110
self.filter_dot(s) for s in self.resources.inc_dirs]
118-
print 'Include folders: {0}'.format(len(self.include_path))
119111

120112
self.as_defines = self.toolchain.get_symbols(True)
121113
self.c_defines = self.toolchain.get_symbols()
122114
self.cpp_defines = self.c_defines
123-
print 'Symbols: {0}'.format(len(self.c_defines))
124115

125116
self.ld_script = self.filter_dot(
126117
self.resources.linker_script)
127-
print 'Linker script: {0}'.format(self.ld_script)
128118

129119
self.options = {}
130120
profile_ids.remove('develop')
@@ -143,7 +133,6 @@ def generate(self):
143133
opts['name'] = opts['id'].capitalize()
144134

145135
print
146-
print 'Build configuration: {0}'.format(opts['name'])
147136

148137
profile = profiles[id]
149138

@@ -159,12 +148,6 @@ def generate(self):
159148

160149
flags = self.toolchain_flags(toolchain)
161150

162-
print 'Common flags:', ' '.join(flags['common_flags'])
163-
print 'C++ flags:', ' '.join(flags['cxx_flags'])
164-
print 'C flags:', ' '.join(flags['c_flags'])
165-
print 'ASM flags:', ' '.join(flags['asm_flags'])
166-
print 'Linker flags:', ' '.join(flags['ld_flags'])
167-
168151
# Most GNU ARM Eclipse options have a parent,
169152
# either debug or release.
170153
if '-O0' in flags['common_flags'] or '-Og' in flags['common_flags']:
@@ -227,8 +210,8 @@ def generate(self):
227210
self.gen_file_nonoverwrite('mcuxpresso/mbedignore.tmpl', jinja_ctx,
228211
'.mbedignore')
229212

230-
print
231-
print 'Done. Import the \'{0}\' project in Eclipse.'.format(self.project_name)
213+
print('Done. Import the \'{0}\' project in MCUXpresso.'.format(
214+
self.project_name))
232215

233216
@staticmethod
234217
def clean(_):
@@ -296,7 +279,7 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
296279
else:
297280
ret_string = "FAILURE: build returned %s \n" % ret_code
298281

299-
print "%s\n%s\n%s\n%s" % (stdout_string, out, err_string, ret_string)
282+
print("%s\n%s\n%s\n%s" % (stdout_string, out, err_string, ret_string))
300283

301284
if log_name:
302285
# Write the output to the log file
@@ -346,14 +329,6 @@ def process_options(self, opts, flags_in):
346329
# Make a copy of the flags, to be one by one removed after processing.
347330
flags = copy.deepcopy(flags_in)
348331

349-
if False:
350-
print
351-
print 'common_flags', flags['common_flags']
352-
print 'asm_flags', flags['asm_flags']
353-
print 'c_flags', flags['c_flags']
354-
print 'cxx_flags', flags['cxx_flags']
355-
print 'ld_flags', flags['ld_flags']
356-
357332
# Initialise the 'last resort' options where all unrecognised
358333
# options will be collected.
359334
opts['as']['other'] = ''
@@ -733,15 +708,3 @@ def process_options(self, opts, flags_in):
733708
opts['c']['other'] = opts['c']['other'].strip()
734709
opts['cpp']['other'] = opts['cpp']['other'].strip()
735710
opts['ld']['other'] = opts['ld']['other'].strip()
736-
737-
if False:
738-
print
739-
print opts
740-
741-
print
742-
print 'common_flags', flags['common_flags']
743-
print 'asm_flags', flags['asm_flags']
744-
print 'c_flags', flags['c_flags']
745-
print 'cxx_flags', flags['cxx_flags']
746-
print 'ld_flags', flags['ld_flags']
747-

0 commit comments

Comments
 (0)