Clone of official tools

Committer:
The Other Jimmy
Date:
Thu Jul 13 15:26:26 2017 -0500
Revision:
38:399953da035d
Parent:
31:8ea194f6145b
Child:
40:7d3fa6b99b2b
Update to tools release 5.5.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 1 #! /usr/bin/env python2
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 2 """
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 3 mbed SDK
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 4 Copyright (c) 2011-2013 ARM Limited
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 5
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 6 Licensed under the Apache License, Version 2.0 (the "License");
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 7 you may not use this file except in compliance with the License.
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 8 You may obtain a copy of the License at
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 9
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 10 http://www.apache.org/licenses/LICENSE-2.0
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 11
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 12 Unless required by applicable law or agreed to in writing, software
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 13 distributed under the License is distributed on an "AS IS" BASIS,
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 15 See the License for the specific language governing permissions and
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 16 limitations under the License.
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 17
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 18 """
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 19 import sys
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 20 from os.path import isdir, abspath, dirname, join
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 21 from os import _exit
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 22
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 23 # Be sure that the tools directory is in the search path
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 24 ROOT = abspath(join(dirname(__file__), ".."))
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 25 sys.path.insert(0, ROOT)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 26
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 27 from tools.utils import args_error
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 28 from tools.options import get_default_options_parser
The Other Jimmy 38:399953da035d 29 from tools.options import extract_mcus
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 30 from tools.build_api import get_config
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 31 from config import Config
screamer 22:9e85236d8716 32 from utils import argparse_filestring_type
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 33 try:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 34 import tools.private_settings as ps
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 35 except:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 36 ps = object()
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 37
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 38 if __name__ == '__main__':
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 39 # Parse Options
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 40 parser = get_default_options_parser(add_clean=False, add_options=False)
The Other Jimmy 31:8ea194f6145b 41 parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type, required=True,
screamer 22:9e85236d8716 42 default=[], help="The source (input) directory", action="append")
screamer 22:9e85236d8716 43 parser.add_argument("--prefix", dest="prefix", action="append",
screamer 22:9e85236d8716 44 default=[], help="Restrict listing to parameters that have this prefix")
screamer 22:9e85236d8716 45 parser.add_argument("-v", "--verbose", action="store_true", dest="verbose",
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 46 default=False, help="Verbose diagnostic output")
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 47
screamer 22:9e85236d8716 48 options = parser.parse_args()
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 49
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 50 # Target
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 51 if options.mcu is None :
The Other Jimmy 31:8ea194f6145b 52 args_error(parser, "argument -m/--mcu is required")
The Other Jimmy 38:399953da035d 53 target = extract_mcus(parser, options)[0]
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 54
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 55 # Toolchain
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 56 if options.tool is None:
The Other Jimmy 31:8ea194f6145b 57 args_error(parser, "argument -t/--toolchain is required")
screamer 22:9e85236d8716 58 toolchain = options.tool[0]
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 59
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 60 options.prefix = options.prefix or [""]
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 61
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 62 try:
screamer 13:ab47a20b66f0 63 params, macros, features = get_config(options.source_dir, target, toolchain)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 64 if not params and not macros:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 65 print "No configuration data available."
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 66 _exit(0)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 67 if params:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 68 print "Configuration parameters"
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 69 print "------------------------"
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 70 for p in params:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 71 for s in options.prefix:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 72 if p.startswith(s):
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 73 print(str(params[p]) if not options.verbose else params[p].get_verbose_description())
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 74 break
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 75 print ""
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 76
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 77 print "Macros"
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 78 print "------"
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 79 if macros:
screamer 13:ab47a20b66f0 80 print 'Defined with "macros":', Config.config_macros_to_macros(macros)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 81 print "Generated from configuration parameters:", Config.parameters_to_macros(params)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 82
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 83 except KeyboardInterrupt, e:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 84 print "\n[CTRL+c] exit"
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 85 except Exception,e:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 86 if options.verbose:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 87 import traceback
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 88 traceback.print_exc(file=sys.stdout)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 89 else:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 90 print "[ERROR] %s" % str(e)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 91
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 92 sys.exit(1)