diff --git a/workspace_tools/export/__init__.py b/workspace_tools/export/__init__.py index 1b4cd197ba3..93df7e62818 100755 --- a/workspace_tools/export/__init__.py +++ b/workspace_tools/export/__init__.py @@ -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) @@ -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 """ diff --git a/workspace_tools/project.py b/workspace_tools/project.py index 7bf165b0bd0..38e6cb0e181 100644 --- a/workspace_tools/project.py +++ b/workspace_tools/project.py @@ -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']: + 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