Skip to content

Cleanup get_config (mbed compile --config) #6580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions tools/get_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"""
from __future__ import print_function
import sys
from os.path import isdir, abspath, dirname, join
from os import _exit
from os.path import abspath, dirname, join

# Be sure that the tools directory is in the search path
ROOT = abspath(join(dirname(__file__), ".."))
Expand All @@ -31,20 +30,20 @@
from tools.build_api import get_config
from tools.config import Config
from tools.utils import argparse_filestring_type
try:
import tools.private_settings as ps
except:
ps = object()

if __name__ == '__main__':
# Parse Options
parser = get_default_options_parser(add_clean=False, add_options=False)
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")
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")

options = parser.parse_args()

Expand All @@ -61,25 +60,27 @@
options.prefix = options.prefix or [""]

try:
params, macros, features = get_config(options.source_dir, target, toolchain)
params, macros, features = get_config(
options.source_dir, target, toolchain)
if not params and not macros:
print("No configuration data available.")
_exit(0)
sys.exit(0)
if params:
print("Configuration parameters")
print("------------------------")
for p in sorted(params):
for s in options.prefix:
if p.startswith(s):
print(str(params[p]) if not options.verbose else params[p].get_verbose_description())
break
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]))
print("")

print("Macros")
print("------")
if macros:
print('Defined with "macros":', Config.config_macros_to_macros(macros))
print("Generated from configuration parameters:", Config.parameters_to_macros(params))
for m in Config.config_macros_to_macros(macros):
if any(m.startswith(s) for s in options.prefix):
print(m)

except KeyboardInterrupt as e:
print("\n[CTRL+c] exit")
Expand Down