init

Dependencies:   mbed

Committer:
Nathan Yonkee
Date:
Fri Mar 02 07:16:49 2018 -0700
Revision:
10:46a4cf51ee38
Parent:
9:d58e77ebd769
remove mbed-os

Who changed what in which revision?

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