[workspace_tools] project.py adding 2 cmdline options

- Adding an option to print a matrix similar to build.py -S with targets
and supported IDEs
- Adding an option to write README.md in workspace_tools/export
pull/819/head
ohagendorf 2014-12-30 19:26:43 +01:00
parent ab46ea6cee
commit b57fefbd0c
2 changed files with 88 additions and 2 deletions

View File

@ -21,7 +21,7 @@ from shutil import copytree, rmtree
from workspace_tools.utils import mkdir
from workspace_tools.export import uvision4, codesourcery, codered, gccarm, ds5_5, iar, emblocks, coide, kds
from workspace_tools.export.exporters import zip_working_directory_and_clean_up, OldLibrariesException
from workspace_tools.targets import EXPORT_MAP
from workspace_tools.targets import TARGET_NAMES, EXPORT_MAP
EXPORTERS = {
'uvision': uvision4.Uvision4,
@ -118,3 +118,59 @@ def setup_user_prj(user_dir, prj_path, lib_paths=None):
if lib_paths is not None:
for lib_path in lib_paths:
copy_tree(lib_path, join(user_lib, basename(lib_path)))
def get_unique_supported_ides():
""" Get list of all unique IDEs supported by targets """
unique_supported_ides = []
for key in EXPORTERS.iterkeys():
unique_supported_ides.append(key)
return unique_supported_ides
def mcu_ide_matrix(verbose_html=False, platform_filter=None):
""" Shows target map using prettytable """
supported_ides = []
for key in EXPORTERS.iterkeys():
supported_ides.append(key)
supported_ides.sort()
from prettytable import PrettyTable, ALL # Only use it in this function so building works without extra modules
# All tests status table print
columns = ["Platform"] + supported_ides
pt = PrettyTable(columns)
# Align table
for col in columns:
pt.align[col] = "c"
pt.align["Platform"] = "l"
perm_counter = 0
target_counter = 0
for target in sorted(TARGET_NAMES):
target_counter += 1
row = [target] # First column is platform name
for ide in supported_ides:
text = "-"
if target in EXPORTERS[ide].TARGETS:
if verbose_html:
text = "✓"
else:
text = "x"
perm_counter += 1
row.append(text)
pt.add_row(row)
pt.border = True
pt.vrules = ALL
pt.hrules = ALL
# creates a html page suitable for a browser
# result = pt.get_html_string(format=True) if verbose_html else pt.get_string()
# creates a html page in a shorter format suitable for readme.md
result = pt.get_html_string() if verbose_html else pt.get_string()
result += "\n"
result += "Total IDEs: %d\n"% (len(supported_ides))
if verbose_html: result += "<br>"
result += "Total platforms: %d\n"% (target_counter)
if verbose_html: result += "<br>"
result += "Total permutations: %d"% (perm_counter)
if verbose_html: result = result.replace("&amp;", "&")
return result

View File

@ -8,7 +8,7 @@ from optparse import OptionParser
from workspace_tools.paths import EXPORT_DIR, EXPORT_WORKSPACE, EXPORT_TMP
from workspace_tools.paths import MBED_BASE, MBED_LIBRARIES
from workspace_tools.export import export, setup_user_prj, EXPORTERS
from workspace_tools.export import export, setup_user_prj, EXPORTERS, mcu_ide_matrix
from workspace_tools.utils import args_error
from workspace_tools.tests import TESTS, Test, TEST_MAP
from workspace_tools.targets import TARGET_NAMES
@ -65,6 +65,18 @@ if __name__ == '__main__':
default=False,
help="list available programs in order and exit")
parser.add_option("-S", "--list-matrix",
action="store_true",
dest="supported_ides",
default=False,
help="displays supported matrix of MCUs and IDEs")
parser.add_option("-E",
action="store_true",
dest="supported_ides_html",
default=False,
help="writes workspace_tools/export/README.md")
(options, args) = parser.parse_args()
# Print available tests in order and exit
@ -72,6 +84,24 @@ if __name__ == '__main__':
print '\n'.join(map(str, sorted(TEST_MAP.values())))
sys.exit()
# Only prints matrix of supported IDEs
if options.supported_ides:
print mcu_ide_matrix()
exit(0)
# Only prints matrix of supported IDEs
if options.supported_ides_html:
html = mcu_ide_matrix(verbose_html=True)
f = open("./export/README.md","w")
try:
f.write("Exporter IDE/Platform Support\n")
f.write("-----------------------------------\n")
f.write("\n");
f.write(html)
finally:
f.close()
exit(0)
# Clean Export Directory
if options.clean:
if exists(EXPORT_DIR):