Skip to content

Correct syntax for mbed export in Py3 #6192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tools/export/cmake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
from __future__ import print_function, absolute_import
from builtins import str

import re
import shutil
from os import remove, getcwd, chdir, mkdir
Expand Down Expand Up @@ -162,7 +165,7 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
else:
out_string += "FAILURE"

print out_string
print(out_string)

if log_name:
# Write the output to the log file
Expand Down
52 changes: 4 additions & 48 deletions tools/export/gnuarmeclipse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

Author: Liviu Ionescu <[email protected]>
"""
from __future__ import print_function, absolute_import
from builtins import str

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

libraries = []
# print 'libraries'
# print self.resources.libraries
for lib in self.resources.libraries:
l, _ = splitext(basename(lib))
libraries.append(l[3:])
Expand All @@ -158,28 +158,22 @@ def create_jinja_ctx(self):
# TODO: get the list from existing .cproject
build_folders = [s.capitalize() for s in profile_ids]
build_folders.append('BUILD')
# print build_folders

objects = [self.filter_dot(s) for s in self.resources.objects]
for bf in build_folders:
objects = [o for o in objects if not o.startswith(bf + '/')]
# print 'objects'
# print objects

self.compute_exclusions()

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

self.as_defines = self.toolchain.get_symbols(True)
self.c_defines = self.toolchain.get_symbols()
self.cpp_defines = self.c_defines
print 'Symbols: {0}'.format(len(self.c_defines))

self.ld_script = self.filter_dot(
self.resources.linker_script)
print 'Linker script: {0}'.format(self.ld_script)

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

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

profile = profiles[id]

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

flags = self.toolchain_flags(toolchain)

print 'Common flags:', ' '.join(flags['common_flags'])
print 'C++ flags:', ' '.join(flags['cxx_flags'])
print 'C flags:', ' '.join(flags['c_flags'])
print 'ASM flags:', ' '.join(flags['asm_flags'])
print 'Linker flags:', ' '.join(flags['ld_flags'])

# Most GNU ARM Eclipse options have a parent,
# either debug or release.
if '-O0' in flags['common_flags'] or '-Og' in flags['common_flags']:
Expand Down Expand Up @@ -281,11 +267,6 @@ def generate(self):
"""
jinja_ctx = self.create_jinja_ctx()

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

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

print
print 'Done. Import the \'{0}\' project in Eclipse.'.format(self.project_name)
print('Done. Import the \'{0}\' project in Eclipse.'.format(self.project_name))

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

print "%s\n%s\n%s\n%s" % (stdout_string, out, err_string, ret_string)
print("%s\n%s\n%s\n%s" % (stdout_string, out, err_string, ret_string))

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

# print file_names

profile_names = [basename(fn).replace(".json", "")
for fn in file_names]
# print profile_names

profiles = {}

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

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


# -------------------------------------------------------------------------
Expand All @@ -460,7 +437,6 @@ def dump_tree(self, nodes, depth=0):
node = nodes[k]
parent_name = node['parent'][
'name'] if 'parent' in node.keys() else ''
print ' ' * depth, node['name'], node['is_used'], parent_name
if len(node['children'].keys()) != 0:
self.dump_tree(node['children'], depth + 1)

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

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

if False:
print
print 'common_flags', flags['common_flags']
print 'asm_flags', flags['asm_flags']
print 'c_flags', flags['c_flags']
print 'cxx_flags', flags['cxx_flags']
print 'ld_flags', flags['ld_flags']

# Initialise the 'last resort' options where all unrecognised
# options will be collected.
opts['as']['other'] = ''
Expand Down Expand Up @@ -944,17 +911,6 @@ def process_options(self, opts, flags_in):
opts['cpp']['other'] = opts['cpp']['other'].strip()
opts['ld']['other'] = opts['ld']['other'].strip()

if False:
print
print opts

print
print 'common_flags', flags['common_flags']
print 'asm_flags', flags['asm_flags']
print 'c_flags', flags['c_flags']
print 'cxx_flags', flags['cxx_flags']
print 'ld_flags', flags['ld_flags']

@staticmethod
def find_options(lst, option):
tmp = [str for str in lst if str.startswith(option)]
Expand Down
5 changes: 4 additions & 1 deletion tools/export/iar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import print_function, absolute_import
from builtins import str

import os
from os.path import sep, join, exists
from collections import namedtuple
Expand Down Expand Up @@ -181,7 +184,7 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
else:
out_string += "FAILURE"

print out_string
print(out_string)

if log_name:
# Write the output to the log file
Expand Down
5 changes: 4 additions & 1 deletion tools/export/makefile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
from __future__ import print_function, absolute_import
from builtins import str

from os.path import splitext, basename, relpath, join, abspath, dirname,\
exists
from os import remove
Expand Down Expand Up @@ -178,7 +181,7 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
else:
out_string += "FAILURE"

print out_string
print(out_string)

if log_name:
# Write the output to the log file
Expand Down
47 changes: 5 additions & 42 deletions tools/export/mcuxpresso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
Based on GNU ARM Eclipse Exporter from Liviu Ionescu <[email protected]>
modified for MCUXpresso by Johannes Stratmann <[email protected]>
"""
from __future__ import print_function, absolute_import
from builtins import str

import copy
import tempfile
Expand All @@ -39,9 +41,6 @@
from tools.build_api import prepare_toolchain


# =============================================================================


POST_BINARY_WHITELIST = set([
"TEENSY3_1Code.binary_hook",
"MCU_NRF51Code.binary_hook",
Expand Down Expand Up @@ -73,12 +72,6 @@ def generate(self):
if not self.resources.linker_script:
raise NotSupportedException("No linker script found.")

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

self.resources.win_to_unix()

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

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

self.as_defines = self.toolchain.get_symbols(True)
self.c_defines = self.toolchain.get_symbols()
self.cpp_defines = self.c_defines
print 'Symbols: {0}'.format(len(self.c_defines))

self.ld_script = self.filter_dot(
self.resources.linker_script)
print 'Linker script: {0}'.format(self.ld_script)

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

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

profile = profiles[id]

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

flags = self.toolchain_flags(toolchain)

print 'Common flags:', ' '.join(flags['common_flags'])
print 'C++ flags:', ' '.join(flags['cxx_flags'])
print 'C flags:', ' '.join(flags['c_flags'])
print 'ASM flags:', ' '.join(flags['asm_flags'])
print 'Linker flags:', ' '.join(flags['ld_flags'])

# Most GNU ARM Eclipse options have a parent,
# either debug or release.
if '-O0' in flags['common_flags'] or '-Og' in flags['common_flags']:
Expand Down Expand Up @@ -227,8 +210,8 @@ def generate(self):
self.gen_file_nonoverwrite('mcuxpresso/mbedignore.tmpl', jinja_ctx,
'.mbedignore')

print
print 'Done. Import the \'{0}\' project in Eclipse.'.format(self.project_name)
print('Done. Import the \'{0}\' project in MCUXpresso.'.format(
self.project_name))

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

print "%s\n%s\n%s\n%s" % (stdout_string, out, err_string, ret_string)
print("%s\n%s\n%s\n%s" % (stdout_string, out, err_string, ret_string))

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

if False:
print
print 'common_flags', flags['common_flags']
print 'asm_flags', flags['asm_flags']
print 'c_flags', flags['c_flags']
print 'cxx_flags', flags['cxx_flags']
print 'ld_flags', flags['ld_flags']

# Initialise the 'last resort' options where all unrecognised
# options will be collected.
opts['as']['other'] = ''
Expand Down Expand Up @@ -733,15 +708,3 @@ def process_options(self, opts, flags_in):
opts['c']['other'] = opts['c']['other'].strip()
opts['cpp']['other'] = opts['cpp']['other'].strip()
opts['ld']['other'] = opts['ld']['other'].strip()

if False:
print
print opts

print
print 'common_flags', flags['common_flags']
print 'asm_flags', flags['asm_flags']
print 'c_flags', flags['c_flags']
print 'cxx_flags', flags['cxx_flags']
print 'ld_flags', flags['ld_flags']

Loading