Rizky Ardi Maulana / mbed-os
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.export.exporters import OldLibrariesException, FailedBuildException
00022 from tools.targets import TARGET_NAMES
00023 
00024 EXPORTERS = {
00025     'uvision5': uvision.Uvision,
00026     'uvision': uvision.Uvision,
00027     'lpcxpresso': codered.CodeRed,
00028     'gcc_arm': makefile.GccArm,
00029     'make_gcc_arm': makefile.GccArm,
00030     'make_armc5': makefile.Armc5,
00031     'make_iar': makefile.IAR,
00032     'ds5_5': ds5_5.DS5_5,
00033     'iar': iar.IAR,
00034     'emblocks' : emblocks.IntermediateFile,
00035     'coide' : coide.CoIDE,
00036     'kds' : kds.KDS,
00037     'simplicityv3' : simplicityv3.SimplicityV3,
00038     'atmelstudio' : atmelstudio.AtmelStudio,
00039     'sw4stm32'    : sw4stm32.Sw4STM32,
00040     'e2studio' : e2studio.E2Studio,
00041     'eclipse_gcc_arm'  : cdt.EclipseGcc,
00042     'eclipse_iar'      : cdt.EclipseIAR,
00043     'eclipse_armc5'    : cdt.EclipseArmc5,
00044     'zip' : zip.ZIP,
00045     'cmsis'    : cmsis.CMSIS
00046 }
00047 
00048 ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """
00049 Sorry, the target %s is not currently supported on the %s toolchain.
00050 Please refer to <a href='/handbook/Exporting-to-offline-toolchains' target='_blank'>Exporting to offline toolchains</a> for more information.
00051 """
00052 
00053 ERROR_MESSAGE_NOT_EXPORT_LIBS = """
00054 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>.
00055 """
00056 
00057 def mcu_ide_matrix (verbose_html=False):
00058     """Shows target map using prettytable
00059 
00060     Keyword argumets:
00061     verbose_html - print the matrix in html format
00062     """
00063     supported_ides = sorted(EXPORTERS.keys())
00064     # Only use it in this function so building works without extra modules
00065     from prettytable import PrettyTable, ALL
00066 
00067     # All tests status table print
00068     table_printer = PrettyTable(["Platform"] + supported_ides)
00069     # Align table
00070     for col in supported_ides:
00071         table_printer.align[col] = "c"
00072     table_printer.align["Platform"] = "l"
00073 
00074     perm_counter = 0
00075     for target in sorted(TARGET_NAMES):
00076         row = [target]  # First column is platform name
00077         for ide in supported_ides:
00078             text = "-"
00079             if target in EXPORTERS[ide].TARGETS:
00080                 if verbose_html:
00081                     text = "&#10003;"
00082                 else:
00083                     text = "x"
00084                 perm_counter += 1
00085             row.append(text)
00086         table_printer.add_row(row)
00087 
00088     table_printer.border = True
00089     table_printer.vrules = ALL
00090     table_printer.hrules = ALL
00091     # creates a html page in a shorter format suitable for readme.md
00092     if verbose_html:
00093         result = table_printer.get_html_string()
00094     else:
00095         result = table_printer.get_string()
00096     result += "\n"
00097     result += "Total IDEs: %d\n"% (len(supported_ides))
00098     if verbose_html:
00099         result += "<br>"
00100     result += "Total platforms: %d\n"% (len(TARGET_NAMES))
00101     if verbose_html:
00102         result += "<br>"
00103     result += "Total permutations: %d"% (perm_counter)
00104     if verbose_html:
00105         result = result.replace("&amp;", "&")
00106     return result