3636from jinja2 .environment import Environment
3737from tools .config import Config
3838
39+ RELEASE_VERSIONS = ['2' , '5' ]
40+
3941def prep_report (report , target_name , toolchain_name , id_name ):
4042 # Setup report keys
4143 if not target_name in report :
@@ -116,9 +118,9 @@ def is_official_target(target_name, version):
116118 """ Returns True, None if a target is part of the official release for the
117119 given version. Return False, 'reason' if a target is not part of the
118120 official release for the given version.
119-
120- target_name: name if the target (ex. 'K64F')
121- version: string of the version (ex. '2' or '5')
121+
122+ target_name: Name if the target (ex. 'K64F')
123+ version: The release version string. Should be a string contained within RELEASE_VERSIONS
122124 """
123125
124126 result = True
@@ -154,6 +156,11 @@ def is_official_target(target_name, version):
154156 (("official release: %s" + linesep ) % ", " .join (required_toolchains_sorted )) + \
155157 ("Currently it is only configured to support the " ) + \
156158 ("following toolchains: %s" % ", " .join (supported_toolchains_sorted ))
159+ else :
160+ result = False
161+ reason = ("Target '%s' has set an invalid release version of '%s'" % version ) + \
162+ ("Please choose from the following release versions: %s" + ', ' .join (RELEASE_VERSIONS ))
163+
157164 else :
158165 result = False
159166 if not hasattr (target , 'release' ):
@@ -163,14 +170,35 @@ def is_official_target(target_name, version):
163170
164171 return result , reason
165172
173+ def transform_release_toolchains (toolchains , version ):
174+ """ Given a list of toolchains and a release version, return a list of
175+ only the supported toolchains for that release
176+
177+ toolchains: The list of toolchains
178+ version: The release version string. Should be a string contained within RELEASE_VERSIONS
179+ """
180+ toolchains_set = set (toolchains )
181+
182+ if version == '5' :
183+ return ['ARM' , 'GCC_ARM' , 'IAR' ]
184+ else :
185+ return toolchains
186+
166187
167188def get_mbed_official_release (version ):
189+ """ Given a release version string, return a tuple that contains a target
190+ and the supported toolchains for that release.
191+ Ex. Given '2', return (('LPC1768', ('ARM', 'GCC_ARM')), ('K64F', ('ARM', 'GCC_ARM')), ...)
192+
193+ version: The version string. Should be a string contained within RELEASE_VERSIONS
194+ """
195+
168196 MBED_OFFICIAL_RELEASE = (
169197 tuple (
170198 tuple (
171199 [
172200 TARGET_MAP [target ].name ,
173- tuple (TARGET_MAP [target ].supported_toolchains )
201+ tuple (transform_release_toolchains ( TARGET_MAP [target ].supported_toolchains , version ) )
174202 ]
175203 ) for target in TARGET_NAMES if (hasattr (TARGET_MAP [target ], 'release' ) and version in TARGET_MAP [target ].release )
176204 )
@@ -719,39 +747,88 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F
719747 raise e
720748
721749
722- def get_unique_supported_toolchains ():
723- """ Get list of all unique toolchains supported by targets """
750+ def get_unique_supported_toolchains (release_targets = None ):
751+ """ Get list of all unique toolchains supported by targets
752+ If release_targets is not specified, then it queries all known targets
753+ release_targets: tuple structure returned from get_mbed_official_release()
754+ """
724755 unique_supported_toolchains = []
725- for target in TARGET_NAMES :
726- for toolchain in TARGET_MAP [target ].supported_toolchains :
727- if toolchain not in unique_supported_toolchains :
728- unique_supported_toolchains .append (toolchain )
756+
757+ if not release_targets :
758+ for target in TARGET_NAMES :
759+ for toolchain in TARGET_MAP [target ].supported_toolchains :
760+ if toolchain not in unique_supported_toolchains :
761+ unique_supported_toolchains .append (toolchain )
762+ else :
763+ for target in release_targets :
764+ for toolchain in target [1 ]:
765+ if toolchain not in unique_supported_toolchains :
766+ unique_supported_toolchains .append (toolchain )
767+
729768 return unique_supported_toolchains
730769
731770
732- def mcu_toolchain_matrix (verbose_html = False , platform_filter = None ):
771+ def mcu_toolchain_matrix (verbose_html = False , platform_filter = None , release_version = '5' ):
733772 """ Shows target map using prettytable """
734- unique_supported_toolchains = get_unique_supported_toolchains ()
735773 from prettytable import PrettyTable # Only use it in this function so building works without extra modules
736774
775+ if isinstance (release_version , basestring ):
776+ # Force release_version to lowercase if it is a string
777+ release_version = release_version .lower ()
778+ else :
779+ # Otherwise default to printing all known targets and toolchains
780+ release_version = 'all'
781+
782+
783+ version_release_targets = {}
784+ version_release_target_names = {}
785+
786+ for version in RELEASE_VERSIONS :
787+ version_release_targets [version ] = get_mbed_official_release (version )
788+ version_release_target_names [version ] = [x [0 ] for x in version_release_targets [version ]]
789+
790+ if release_version in RELEASE_VERSIONS :
791+ release_targets = version_release_targets [release_version ]
792+ else :
793+ release_targets = None
794+
795+ unique_supported_toolchains = get_unique_supported_toolchains (release_targets )
796+ prepend_columns = ["Target" ] + ["mbed OS %s" % x for x in RELEASE_VERSIONS ]
797+
737798 # All tests status table print
738- columns = [ "Target" ] + unique_supported_toolchains
739- pt = PrettyTable ([ "Target" ] + unique_supported_toolchains )
799+ columns = prepend_columns + unique_supported_toolchains
800+ pt = PrettyTable (columns )
740801 # Align table
741802 for col in columns :
742803 pt .align [col ] = "c"
743804 pt .align ["Target" ] = "l"
744805
745806 perm_counter = 0
746807 target_counter = 0
747- for target in sorted (TARGET_NAMES ):
808+
809+ target_names = []
810+
811+ if release_targets :
812+ target_names = [x [0 ] for x in release_targets ]
813+ else :
814+ target_names = TARGET_NAMES
815+
816+ for target in sorted (target_names ):
748817 if platform_filter is not None :
749818 # FIlter out platforms using regex
750819 if re .search (platform_filter , target ) is None :
751820 continue
752821 target_counter += 1
753822
754823 row = [target ] # First column is platform name
824+
825+ for version in RELEASE_VERSIONS :
826+ if target in version_release_target_names [version ]:
827+ text = "Supported"
828+ else :
829+ text = "-"
830+ row .append (text )
831+
755832 for unique_toolchain in unique_supported_toolchains :
756833 if unique_toolchain in TARGET_MAP [target ].supported_toolchains :
757834 text = "Supported"
0 commit comments