Greg Steiert / pegasus_dev

Dependents:   blinky_max32630fthr

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers __init__.py Source File

__init__.py

00001 """The generic interface for all exporters.
00002 """
00003 # mbed SDK
00004 # Copyright (c) 2011-2016 ARM Limited
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #     http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 
00018 from tools.export import codered, ds5_5, iar, makefile
00019 from tools.export import emblocks, coide, kds, simplicityv3, atmelstudio
00020 from tools.export import sw4stm32, e2studio, zip, cmsis, uvision, cdt
00021 from tools.targets import TARGET_NAMES
00022 
00023 EXPORTERS = {
00024     'uvision5': uvision.Uvision,
00025     'uvision': uvision.Uvision,
00026     'lpcxpresso': codered.CodeRed,
00027     'gcc_arm': makefile.GccArm,
00028     'make_gcc_arm': makefile.GccArm,
00029     'make_armc5': makefile.Armc5,
00030     'make_iar': makefile.IAR,
00031     'ds5_5': ds5_5.DS5_5,
00032     'iar': iar.IAR,
00033     'emblocks' : emblocks.IntermediateFile,
00034     'coide' : coide.CoIDE,
00035     'kds' : kds.KDS,
00036     'simplicityv3' : simplicityv3.SimplicityV3,
00037     'atmelstudio' : atmelstudio.AtmelStudio,
00038     'sw4stm32'    : sw4stm32.Sw4STM32,
00039     'e2studio' : e2studio.E2Studio,
00040     'eclipse_gcc_arm'  : cdt.EclipseGcc,
00041     'eclipse_iar'      : cdt.EclipseIAR,
00042     'eclipse_armc5'    : cdt.EclipseArmc5,
00043     'zip' : zip.ZIP,
00044     'cmsis'    : cmsis.CMSIS
00045 }
00046 
00047 ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """
00048 Sorry, the target %s is not currently supported on the %s toolchain.
00049 Please refer to <a href='/handbook/Exporting-to-offline-toolchains' target='_blank'>Exporting to offline toolchains</a> for more information.
00050 """
00051 
00052 ERROR_MESSAGE_NOT_EXPORT_LIBS = """
00053 To export this project please <a href='http://mbed.org/compiler/?import=http://mbed.org/users/mbed_official/code/mbed-export/k&mode=lib' target='_blank'>import the export version of the mbed library</a>.
00054 """
00055 
00056 def mcu_ide_matrix (verbose_html=False):
00057     """Shows target map using prettytable
00058 
00059     Keyword argumets:
00060     verbose_html - print the matrix in html format
00061     """
00062     supported_ides = sorted(EXPORTERS.keys())
00063     # Only use it in this function so building works without extra modules
00064     from prettytable import PrettyTable, ALL
00065 
00066     # All tests status table print
00067     table_printer = PrettyTable(["Platform"] + supported_ides)
00068     # Align table
00069     for col in supported_ides:
00070         table_printer.align[col] = "c"
00071     table_printer.align["Platform"] = "l"
00072 
00073     perm_counter = 0
00074     for target in sorted(TARGET_NAMES):
00075         row = [target]  # First column is platform name
00076         for ide in supported_ides:
00077             text = "-"
00078             if target in EXPORTERS[ide].TARGETS:
00079                 if verbose_html:
00080                     text = "&#10003;"
00081                 else:
00082                     text = "x"
00083                 perm_counter += 1
00084             row.append(text)
00085         table_printer.add_row(row)
00086 
00087     table_printer.border = True
00088     table_printer.vrules = ALL
00089     table_printer.hrules = ALL
00090     # creates a html page in a shorter format suitable for readme.md
00091     if verbose_html:
00092         result = table_printer.get_html_string()
00093     else:
00094         result = table_printer.get_string()
00095     result += "\n"
00096     result += "Total IDEs: %d\n"% (len(supported_ides))
00097     if verbose_html:
00098         result += "<br>"
00099     result += "Total platforms: %d\n"% (len(TARGET_NAMES))
00100     if verbose_html:
00101         result += "<br>"
00102     result += "Total permutations: %d"% (perm_counter)
00103     if verbose_html:
00104         result = result.replace("&amp;", "&")
00105     return result