|
18 | 18 | """
|
19 | 19 | from __future__ import print_function
|
20 | 20 | import sys
|
21 |
| -from os.path import isdir, abspath, dirname, join |
22 |
| -from os import _exit |
| 21 | +from os.path import abspath, dirname, join |
23 | 22 |
|
24 | 23 | # Be sure that the tools directory is in the search path
|
25 | 24 | ROOT = abspath(join(dirname(__file__), ".."))
|
|
31 | 30 | from tools.build_api import get_config
|
32 | 31 | from tools.config import Config
|
33 | 32 | from tools.utils import argparse_filestring_type
|
34 |
| -try: |
35 |
| - import tools.private_settings as ps |
36 |
| -except: |
37 |
| - ps = object() |
38 | 33 |
|
39 | 34 | if __name__ == '__main__':
|
40 | 35 | # Parse Options
|
41 | 36 | parser = get_default_options_parser(add_clean=False, add_options=False)
|
42 |
| - parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type, required=True, |
43 |
| - default=[], help="The source (input) directory", action="append") |
44 |
| - parser.add_argument("--prefix", dest="prefix", action="append", |
45 |
| - default=[], help="Restrict listing to parameters that have this prefix") |
46 |
| - parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", |
47 |
| - default=False, help="Verbose diagnostic output") |
| 37 | + parser.add_argument( |
| 38 | + "--source", dest="source_dir", type=argparse_filestring_type, |
| 39 | + required=True, default=[], help="The source (input) directory", |
| 40 | + action="append") |
| 41 | + parser.add_argument( |
| 42 | + "--prefix", dest="prefix", action="append", default=[], |
| 43 | + help="Restrict listing to parameters that have this prefix") |
| 44 | + parser.add_argument( |
| 45 | + "-v", "--verbose", action="store_true", dest="verbose", default=False, |
| 46 | + help="Verbose diagnostic output") |
48 | 47 |
|
49 | 48 | options = parser.parse_args()
|
50 | 49 |
|
|
61 | 60 | options.prefix = options.prefix or [""]
|
62 | 61 |
|
63 | 62 | try:
|
64 |
| - params, macros, features = get_config(options.source_dir, target, toolchain) |
| 63 | + params, macros, features = get_config( |
| 64 | + options.source_dir, target, toolchain) |
65 | 65 | if not params and not macros:
|
66 | 66 | print("No configuration data available.")
|
67 |
| - _exit(0) |
| 67 | + sys.exit(0) |
68 | 68 | if params:
|
69 | 69 | print("Configuration parameters")
|
70 | 70 | print("------------------------")
|
71 |
| - for p in sorted(params): |
72 |
| - for s in options.prefix: |
73 |
| - if p.startswith(s): |
74 |
| - print(str(params[p]) if not options.verbose else params[p].get_verbose_description()) |
75 |
| - break |
| 71 | + for p in sorted(list(params.keys())): |
| 72 | + if any(p.startswith(s) for s in options.prefix): |
| 73 | + if options.verbose: |
| 74 | + print(params[p].get_verbose_description()) |
| 75 | + else: |
| 76 | + print(str(params[p])) |
76 | 77 | print("")
|
77 | 78 |
|
78 | 79 | print("Macros")
|
79 | 80 | print("------")
|
80 |
| - if macros: |
81 |
| - print('Defined with "macros":', Config.config_macros_to_macros(macros)) |
82 |
| - print("Generated from configuration parameters:", Config.parameters_to_macros(params)) |
| 81 | + for m in Config.config_macros_to_macros(macros): |
| 82 | + if any(m.startswith(s) for s in options.prefix): |
| 83 | + print(m) |
83 | 84 |
|
84 | 85 | except KeyboardInterrupt as e:
|
85 | 86 | print("\n[CTRL+c] exit")
|
|
0 commit comments