2016-06-09 22:51:26 +00:00
|
|
|
#! /usr/bin/env python2
|
|
|
|
"""
|
|
|
|
mbed SDK
|
|
|
|
Copyright (c) 2011-2013 ARM Limited
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
|
|
|
|
"""
|
2018-03-21 15:50:56 +00:00
|
|
|
from __future__ import print_function
|
2016-06-09 22:51:26 +00:00
|
|
|
import sys
|
2018-04-09 14:23:15 +00:00
|
|
|
from os.path import abspath, dirname, join
|
2016-06-09 22:51:26 +00:00
|
|
|
|
|
|
|
# Be sure that the tools directory is in the search path
|
|
|
|
ROOT = abspath(join(dirname(__file__), ".."))
|
|
|
|
sys.path.insert(0, ROOT)
|
|
|
|
|
|
|
|
from tools.utils import args_error
|
|
|
|
from tools.options import get_default_options_parser
|
2017-04-06 19:40:38 +00:00
|
|
|
from tools.options import extract_mcus
|
2016-06-09 22:51:26 +00:00
|
|
|
from tools.build_api import get_config
|
2018-03-21 15:50:56 +00:00
|
|
|
from tools.config import Config
|
|
|
|
from tools.utils import argparse_filestring_type
|
2016-06-09 22:51:26 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# Parse Options
|
2018-05-02 14:36:32 +00:00
|
|
|
parser = get_default_options_parser(add_clean=False, add_options=False,
|
|
|
|
add_app_config=True)
|
2018-04-09 14:29:43 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"--source", dest="source_dir", type=argparse_filestring_type,
|
|
|
|
required=True, default=[], help="The source (input) directory",
|
|
|
|
action="append")
|
|
|
|
parser.add_argument(
|
|
|
|
"--prefix", dest="prefix", action="append", default=[],
|
|
|
|
help="Restrict listing to parameters that have this prefix")
|
|
|
|
parser.add_argument(
|
|
|
|
"-v", "--verbose", action="store_true", dest="verbose", default=False,
|
|
|
|
help="Verbose diagnostic output")
|
2016-06-09 22:51:26 +00:00
|
|
|
|
2016-06-24 22:15:01 +00:00
|
|
|
options = parser.parse_args()
|
2016-06-09 22:51:26 +00:00
|
|
|
|
|
|
|
# Target
|
|
|
|
if options.mcu is None :
|
2016-08-04 19:48:18 +00:00
|
|
|
args_error(parser, "argument -m/--mcu is required")
|
2017-04-06 19:40:38 +00:00
|
|
|
target = extract_mcus(parser, options)[0]
|
2016-06-09 22:51:26 +00:00
|
|
|
|
|
|
|
options.prefix = options.prefix or [""]
|
|
|
|
|
|
|
|
try:
|
2019-01-16 17:20:55 +00:00
|
|
|
params, macros, features, _ = get_config(
|
2018-06-26 15:12:43 +00:00
|
|
|
options.source_dir,
|
|
|
|
target,
|
|
|
|
options.tool[0] if options.tool else None,
|
|
|
|
app_config=options.app_config
|
|
|
|
)
|
2016-06-09 22:51:26 +00:00
|
|
|
if not params and not macros:
|
2018-03-21 15:50:56 +00:00
|
|
|
print("No configuration data available.")
|
2018-04-09 14:25:18 +00:00
|
|
|
sys.exit(0)
|
2016-06-09 22:51:26 +00:00
|
|
|
if params:
|
2018-03-21 15:50:56 +00:00
|
|
|
print("Configuration parameters")
|
|
|
|
print("------------------------")
|
2018-04-09 14:25:38 +00:00
|
|
|
for p in sorted(list(params.keys())):
|
|
|
|
if any(p.startswith(s) for s in options.prefix):
|
|
|
|
if options.verbose:
|
|
|
|
print(params[p].get_verbose_description())
|
|
|
|
else:
|
|
|
|
print(str(params[p]))
|
2018-03-21 15:50:56 +00:00
|
|
|
print("")
|
2016-06-09 22:51:26 +00:00
|
|
|
|
2018-03-21 15:50:56 +00:00
|
|
|
print("Macros")
|
|
|
|
print("------")
|
2018-04-09 14:26:11 +00:00
|
|
|
for m in Config.config_macros_to_macros(macros):
|
2018-04-09 14:27:09 +00:00
|
|
|
if any(m.startswith(s) for s in options.prefix):
|
|
|
|
print(m)
|
2016-06-09 22:51:26 +00:00
|
|
|
|
2018-03-21 15:50:56 +00:00
|
|
|
except KeyboardInterrupt as e:
|
|
|
|
print("\n[CTRL+c] exit")
|
|
|
|
except Exception as e:
|
2016-06-09 22:51:26 +00:00
|
|
|
if options.verbose:
|
|
|
|
import traceback
|
|
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
else:
|
2018-03-21 15:50:56 +00:00
|
|
|
print("[ERROR] %s" % str(e))
|
2016-06-09 22:51:26 +00:00
|
|
|
|
|
|
|
sys.exit(1)
|