Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Nov 11 20:59:50 2016 +0000
Revision:
0:5c4d7b2438d3
Initial commit

Who changed what in which revision?

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