Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
get_config.py
00001 #! /usr/bin/env python2 00002 """ 00003 mbed SDK 00004 Copyright (c) 2011-2013 ARM Limited 00005 00006 Licensed under the Apache License, Version 2.0 (the "License"); 00007 you may not use this file except in compliance with the License. 00008 You may obtain a copy of the License at 00009 00010 http://www.apache.org/licenses/LICENSE-2.0 00011 00012 Unless required by applicable law or agreed to in writing, software 00013 distributed under the License is distributed on an "AS IS" BASIS, 00014 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 See the License for the specific language governing permissions and 00016 limitations under the License. 00017 00018 """ 00019 from __future__ import print_function 00020 import sys 00021 from os.path import abspath, dirname, join 00022 00023 # Be sure that the tools directory is in the search path 00024 ROOT = abspath(join(dirname(__file__), "..")) 00025 sys.path.insert(0, ROOT) 00026 00027 from tools.utils import args_error 00028 from tools.options import get_default_options_parser 00029 from tools.options import extract_mcus 00030 from tools.build_api import get_config 00031 from tools.config import Config 00032 from tools.utils import argparse_filestring_type 00033 00034 if __name__ == '__main__': 00035 # Parse Options 00036 parser = get_default_options_parser(add_clean=False, add_options=False, 00037 add_app_config=True) 00038 parser.add_argument( 00039 "--source", dest="source_dir", type=argparse_filestring_type, 00040 required=True, default=[], help="The source (input) directory", 00041 action="append") 00042 parser.add_argument( 00043 "--prefix", dest="prefix", action="append", default=[], 00044 help="Restrict listing to parameters that have this prefix") 00045 parser.add_argument( 00046 "-v", "--verbose", action="store_true", dest="verbose", default=False, 00047 help="Verbose diagnostic output") 00048 00049 options = parser.parse_args() 00050 00051 # Target 00052 if options.mcu is None : 00053 args_error(parser, "argument -m/--mcu is required") 00054 target = extract_mcus(parser, options)[0] 00055 00056 # Toolchain 00057 if options.tool is None: 00058 args_error(parser, "argument -t/--toolchain is required") 00059 toolchain = options.tool[0] 00060 00061 options.prefix = options.prefix or [""] 00062 00063 try: 00064 params, macros, features = get_config( 00065 options.source_dir, target, toolchain, app_config=options.app_config) 00066 if not params and not macros: 00067 print("No configuration data available.") 00068 sys.exit(0) 00069 if params: 00070 print("Configuration parameters") 00071 print("------------------------") 00072 for p in sorted(list(params.keys())): 00073 if any(p.startswith(s) for s in options.prefix): 00074 if options.verbose: 00075 print(params[p].get_verbose_description()) 00076 else: 00077 print(str(params[p])) 00078 print("") 00079 00080 print("Macros") 00081 print("------") 00082 for m in Config.config_macros_to_macros(macros): 00083 if any(m.startswith(s) for s in options.prefix): 00084 print(m) 00085 00086 except KeyboardInterrupt as e: 00087 print("\n[CTRL+c] exit") 00088 except Exception as e: 00089 if options.verbose: 00090 import traceback 00091 traceback.print_exc(file=sys.stdout) 00092 else: 00093 print("[ERROR] %s" % str(e)) 00094 00095 sys.exit(1)
Generated on Tue Jul 12 2022 18:18:36 by
