Esempio n. 1
0
def export(project_path, project_name, ide, target, destination='/tmp/', tempdir=None, clean=True, build_url_resolver=online_build_url_resolver):
    # Convention: we are using capitals for toolchain and target names
    if target is not None:
        target = target.upper()

    if tempdir is None:
        tempdir = tempfile.mkdtemp()

    if ide is None:
        # Simply copy everything, no project files to be generated
        for d in ['src', 'lib']:
            os.system("cp -r %s/* %s" % (join(project_path, d), tempdir))
        report = {'success': True}

    else:
        report = {'success': False}
        if ide not in EXPORTERS:
            report['errormsg'] = "Unsupported toolchain"
        else:
            Exporter = EXPORTERS[ide]
            target = EXPORT_MAP.get(target, target)
            if target not in Exporter.TARGETS:
                report['errormsg'] = ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN % (target, ide)
            else:
                try:
                    exporter = Exporter(target, tempdir, project_name, build_url_resolver)
                    exporter.scan_and_copy_resources(project_path, tempdir)
                    exporter.generate()
                    report['success'] = True
                except OldLibrariesException, e:
                    report['errormsg'] = ERROR_MESSAGE_NOT_EXPORT_LIBS
Esempio n. 2
0
def export(project_path,
           project_name,
           ide,
           target,
           destination='/tmp/',
           tempdir=None,
           clean=True,
           extra_symbols=None,
           build_url_resolver=online_build_url_resolver):
    # Convention: we are using capitals for toolchain and target names
    if target is not None:
        target = target.upper()

    if tempdir is None:
        tempdir = tempfile.mkdtemp()

    if ide is None:
        # Simply copy everything, no project files to be generated
        for d in ['src', 'lib']:
            os.system("cp -r %s/* %s" % (join(project_path, d), tempdir))
        report = {'success': True}

    else:
        report = {'success': False}
        if ide not in EXPORTERS:
            report['errormsg'] = "Unsupported toolchain"
        else:
            Exporter = EXPORTERS[ide]
            target = EXPORT_MAP.get(target, target)
            if target not in Exporter.TARGETS:
                report['errormsg'] = ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN % (
                    target, ide)
            else:
                try:
                    exporter = Exporter(target,
                                        tempdir,
                                        project_name,
                                        build_url_resolver,
                                        extra_symbols=extra_symbols)
                    exporter.scan_and_copy_resources(project_path, tempdir)
                    exporter.generate()
                    report['success'] = True
                except OldLibrariesException, e:
                    report['errormsg'] = ERROR_MESSAGE_NOT_EXPORT_LIBS
Esempio n. 3
0
    if ide is None or ide == "zip":
        # Simple ZIP exporter
        try:
            ide = "zip"
            exporter = zip.ZIP(target, tempdir, project_name, build_url_resolver, extra_symbols=extra_symbols)
            exporter.scan_and_copy_resources(project_path, tempdir)
            exporter.generate()
            report['success'] = True
        except OldLibrariesException, e:
            report['errormsg'] = ERROR_MESSAGE_NOT_EXPORT_LIBS
    else:
        if ide not in EXPORTERS:
            report['errormsg'] = ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN % (target, ide)
        else:
            Exporter = EXPORTERS[ide]
            target = EXPORT_MAP.get(target, target)
            # use progen targets or mbed exporters targets, check progen attribute
            use_progen = False
            supported = True
            try:
                if Exporter.PROGEN_ACTIVE:
                    use_progen = True
            except AttributeError:
                pass
            if use_progen:
                if not ProGenDef(ide).is_supported(TARGET_MAP[target].progen['target']):
                    supported = False
            else:
                if target not in Exporter.TARGETS:
                    supported = False
Esempio n. 4
0
    if ide is None or ide == "zip":
        # Simple ZIP exporter
        try:
            ide = "zip"
            exporter = zip.ZIP(target, tempdir, project_name, build_url_resolver, extra_symbols=extra_symbols)
            exporter.scan_and_copy_resources(project_path, tempdir)
            exporter.generate()
            report['success'] = True
        except OldLibrariesException, e:
            report['errormsg'] = ERROR_MESSAGE_NOT_EXPORT_LIBS
    else:
        if ide not in EXPORTERS:
            report['errormsg'] = "Unsupported toolchain"
        else:
            Exporter = EXPORTERS[ide]
            target = EXPORT_MAP.get(target, target)
            if target not in Exporter.TARGETS:
                report['errormsg'] = ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN % (target, ide)
            else:
                try:
                    exporter = Exporter(target, tempdir, project_name, build_url_resolver, extra_symbols=extra_symbols)
                    exporter.scan_and_copy_resources(project_path, tempdir)
                    exporter.generate()
                    report['success'] = True
                except OldLibrariesException, e:
                    report['errormsg'] = ERROR_MESSAGE_NOT_EXPORT_LIBS

    zip_path = None
    if report['success']:
        # add readme file to every offline export.
        open(os.path.join(tempdir, 'GettingStarted.htm'),'w').write('<meta http-equiv="refresh" content="0; url=http://mbed.org/handbook/Getting-Started-mbed-Exporters#%s"/>'% (ide))