Clone of official tools

Revision:
9:2d27d77ada5c
Parent:
0:66f3b5499f7f
Child:
13:ab47a20b66f0
--- a/make.py	Tue Jun 07 11:35:02 2016 +0100
+++ b/make.py	Tue Jun 14 11:07:30 2016 +0100
@@ -21,7 +21,7 @@
 import sys
 from time import sleep
 from shutil import copy
-from os.path import join, abspath, dirname
+from os.path import join, abspath, dirname, isfile, isdir
 
 # Be sure that the tools directory is in the search path
 ROOT = abspath(join(dirname(__file__), ".."))
@@ -41,12 +41,12 @@
 from tools.targets import TARGET_MAP
 from tools.options import get_default_options_parser
 from tools.build_api import build_project
+from tools.build_api import mcu_toolchain_matrix
 try:
     import tools.private_settings as ps
 except:
     ps = object()
 
-
 if __name__ == '__main__':
     # Parse Options
     parser = get_default_options_parser()
@@ -82,6 +82,17 @@
                       dest="macros",
                       help="Add a macro definition")
 
+    parser.add_option("-S", "--supported-toolchains",
+                      action="store_true",
+                      dest="supported_toolchains",
+                      default=False,
+                      help="Displays supported matrix of MCUs and toolchains")
+
+    parser.add_option('-f', '--filter',
+                      dest='general_filter_regex',
+                      default=None,
+                      help='For some commands you can use filter to filter out results')
+
     # Local run
     parser.add_option("--automated", action="store_true", dest="automated",
                       default=False, help="Automated test")
@@ -167,6 +178,17 @@
 
     (options, args) = parser.parse_args()
 
+    # Only prints matrix of supported toolchains
+    if options.supported_toolchains:
+        print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
+        exit(0)
+
+    if options.source_dir:
+        for path in options.source_dir :
+            if not isfile(path) and not isdir(path) :
+                args_error(parser, "[ERROR] you passed \"{}\" to --source, which does not exist".
+                           format(path))
+
     # Print available tests in order and exit
     if options.list_tests is True:
         print '\n'.join(map(str, sorted(TEST_MAP.values())))
@@ -243,13 +265,7 @@
             build_dir = options.build_dir
 
         try:
-            target = TARGET_MAP[mcu]
-        except KeyError:
-            print "[ERROR] Target %s not supported" % mcu
-            sys.exit(1)
-
-        try:
-            bin_file = build_project(test.source_dir, build_dir, target, toolchain, test.dependencies, options.options,
+            bin_file = build_project(test.source_dir, build_dir, mcu, toolchain, test.dependencies, options.options,
                                      linker_script=options.linker_script,
                                      clean=options.clean,
                                      verbose=options.verbose,
@@ -267,7 +283,7 @@
                 # Import pyserial: https://pypi.python.org/pypi/pyserial
                 from serial import Serial
 
-                sleep(target.program_cycle_s())
+                sleep(TARGET_MAP[mcu].program_cycle_s())
 
                 serial = Serial(options.serial, timeout = 1)
                 if options.baud: