Skip to content

Preventing a traceback when a library is not built during export #1868

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

Closed
Closed
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
34 changes: 25 additions & 9 deletions workspace_tools/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ def export(project_path, project_name, ide, target, destination='/tmp/',
# Generate project folders following the online conventions
###############################################################################
def copy_tree(src, dst, clean=True):
"""
Copies the 'src' directory recursively to 'dst' directory
"""
if exists(dst):
if clean:
rmtree(dst)
Expand All @@ -151,23 +154,36 @@ def copy_tree(src, dst, clean=True):

copytree(src, dst)


def setup_user_prj(user_dir, prj_path, lib_paths=None):
"""
Setup a project with the same directory structure of the mbed online IDE
"""
report = {'success': True, 'errormsg':''}

mkdir(user_dir)

# Project Path
copy_tree(prj_path, join(user_dir, "src"))

# Project Libraries
user_lib = join(user_dir, "lib")
mkdir(user_lib)
if exists(prj_path):
copy_tree(prj_path, join(user_dir, "src"))

# Project Libraries
user_lib = join(user_dir, "lib")
mkdir(user_lib)

if lib_paths is not None:
for lib_path in lib_paths:
if exists(lib_path):
copy_tree(lib_path, join(user_lib, basename(lib_path)))
else:
report['success'] = False
report['errormsg'] = "Library path '%s' does not exist. Ensure that the library is built." % (lib_path)
break
else:
report['success'] = False
report['errormsg'] = "Project path '%s' does not exist" % (prj_path)

return report

if lib_paths is not None:
for lib_path in lib_paths:
copy_tree(lib_path, join(user_lib, basename(lib_path)))

def mcu_ide_matrix(verbose_html=False, platform_filter=None):
""" Shows target map using prettytable """
Expand Down
22 changes: 13 additions & 9 deletions workspace_tools/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,20 @@

# Build the project with the same directory structure of the mbed online IDE
project_dir = join(EXPORT_WORKSPACE, test.id)
setup_user_prj(project_dir, test.source_dir, test.dependencies)

# Export to selected toolchain
tmp_path, report = export(project_dir, test.id, ide, mcu, EXPORT_WORKSPACE, EXPORT_TMP, extra_symbols=lib_symbols)
if report['success']:
zip_path = join(EXPORT_DIR, "%s_%s_%s.zip" % (test.id, ide, mcu))
move(tmp_path, zip_path)
successes.append("%s::%s\t%s"% (mcu, ide, zip_path))
else:

report = setup_user_prj(project_dir, test.source_dir, test.dependencies)

if not report['success']:
failures.append("%s::%s\t%s"% (mcu, ide, report['errormsg']))
else:
# Export to selected toolchain
tmp_path, report = export(project_dir, test.id, ide, mcu, EXPORT_WORKSPACE, EXPORT_TMP, extra_symbols=lib_symbols)
if report['success']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this true always here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean? This bit of code was here before, it's checking to see if the export was successful.

zip_path = join(EXPORT_DIR, "%s_%s_%s.zip" % (test.id, ide, mcu))
move(tmp_path, zip_path)
successes.append("%s::%s\t%s"% (mcu, ide, zip_path))
else:
failures.append("%s::%s\t%s"% (mcu, ide, report['errormsg']))

# Prints export results
print
Expand Down