mbed-os for GR-LYCHEE

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Committer:
dkato
Date:
Fri Feb 02 05:42:23 2018 +0000
Revision:
0:f782d9c66c49
mbed-os for GR-LYCHEE

Who changed what in which revision?

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