def test_export(toolchain, target, expected_error=None): if toolchain is None and target is None: base_dir = join(EXPORT_TMP, "zip") else: base_dir = join(EXPORT_TMP, toolchain, target) temp_dir = join(base_dir, "temp") mkdir(temp_dir) zip_path, report = export(USER_PRJ, USR_PRJ_NAME, toolchain, target, base_dir, temp_dir, False, None, fake_build_url_resolver) if report['success']: move(zip_path, join(EXPORT_DIR, "export_%s_%s.zip" % (toolchain, target))) print "[OK]" else: if expected_error is None: print '[ERRROR] %s' % report['errormsg'] else: if (zip_path is None) and (expected_error in report['errormsg']): print '[OK]' else: print '[ERROR]' print ' zip:', zip_path print ' msg:', report['errormsg']
def perform_export(dir, name, ide, mcu, temp, clean=False, zip=False, lib_symbols='', sources_relative=False, progen_build=False): tmp_path, report = export(dir, name, ide, mcu, dir[0], temp, clean=clean, make_zip=zip, extra_symbols=lib_symbols, sources_relative=sources_relative, progen_build=progen_build) return tmp_path, report
def test_export(toolchain, target, expected_error=None): if toolchain is None and target is None: base_dir = join(EXPORT_TMP, "zip") else: base_dir = join(EXPORT_TMP, toolchain, target) temp_dir = join(base_dir, "temp") mkdir(temp_dir) zip_path, report = export( USER_PRJ, USR_PRJ_NAME, toolchain, target, base_dir, temp_dir, False, None, fake_build_url_resolver ) if report["success"]: move(zip_path, join(EXPORT_DIR, "export_%s_%s.zip" % (toolchain, target))) print "[OK]" else: if expected_error is None: print "[ERRROR] %s" % report["errormsg"] else: if (zip_path is None) and (expected_error in report["errormsg"]): print "[OK]" else: print "[ERROR]" print " zip:", zip_path print " msg:", report["errormsg"]
if not options.build: # Substitute the library builds with the sources # TODO: Substitute also the other library build paths if MBED_LIBRARIES in test.dependencies: test.dependencies.remove(MBED_LIBRARIES) test.dependencies.append(MBED_BASE) # Build the project with the same directory structure of the mbed online IDE project_name = test.id project_dir = join(EXPORT_WORKSPACE, project_name) project_temp = EXPORT_TMP setup_user_prj(project_dir, test.source_dir, test.dependencies) # Export to selected toolchain tmp_path, report = export(project_dir, project_name, ide, mcu, project_dir, project_temp, clean=clean, zip=zip, extra_symbols=lib_symbols, relative=sources_relative) if report['success']: zip_path = join(EXPORT_DIR, "%s_%s_%s.zip" % (project_name, ide, mcu)) if zip: 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 if len(successes) > 0: print "Successful exports:" for success in successes: print " * %s"% success if len(failures) > 0:
failures = [] # source_dir = use relative paths, otherwise sources are copied sources_relative = True if options.source_dir else False for mcu in options.mcu: # Program Number or name p, src, ide = options.program, options.source_dir, options.ide try: project_dir, project_name, project_temp = setup_project(mcu, ide, p, src, options.build) zip = not bool(src) # create zip when no src_dir provided clean = not bool(src) # don't clean when source is provided, use acrual source tree for IDE files # Export to selected toolchain lib_symbols = get_lib_symbols(options.macros, src, p) tmp_path, report = export(project_dir, project_name, ide, mcu, project_dir[0], project_temp, clean=clean, make_zip=zip, extra_symbols=lib_symbols, sources_relative=sources_relative) except OSError as e: if e.errno == 2: report = dict(success=False, errormsg="Library path '%s' does not exist. Ensure that the library is built." % (e.filename)) else: report = dict(success=False, errormsg="An OS error occured: errno #{}".format(e.errno)) if report['success']: if not zip: zip_path = join(project_temp, project_name) else: zip_path = join(EXPORT_DIR, "%s_%s_%s.zip" % (project_name, 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']))