Skip to content
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

Added 'section' key to buildoptions introspection #4546

Merged
merged 3 commits into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
37 changes: 31 additions & 6 deletions mesonbuild/mintro.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,43 @@ def list_target_files(target_name, coredata, builddata):

def list_buildoptions(coredata, builddata):
optlist = []
add_keys(optlist, coredata.user_options)
add_keys(optlist, coredata.compiler_options)
add_keys(optlist, coredata.base_options)
add_keys(optlist, coredata.builtins)

dir_option_names = ['prefix',
'libdir',
'libexecdir',
'bindir',
'sbindir',
'includedir',
'datadir',
'mandir',
'infodir',
'localedir',
'sysconfdir',
'localstatedir',
'sharedstatedir']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe sort these lists alphabetically?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Fixed with the last commit.
I also sorted the lists in mconf.py since I have copied them from there.

test_option_names = ['stdsplit',
'errorlogs']
core_option_names = [k for k in coredata.builtins if k not in dir_option_names + test_option_names]

dir_options = {k: o for k, o in coredata.builtins.items() if k in dir_option_names}
test_options = {k: o for k, o in coredata.builtins.items() if k in test_option_names}
core_options = {k: o for k, o in coredata.builtins.items() if k in core_option_names}

add_keys(optlist, core_options, 'core')
add_keys(optlist, coredata.backend_options, 'backend')
add_keys(optlist, coredata.base_options, 'base')
add_keys(optlist, coredata.compiler_options, 'compiler')
add_keys(optlist, dir_options, 'directory')
add_keys(optlist, coredata.user_options, 'user')
add_keys(optlist, test_options, 'test')
print(json.dumps(optlist))

def add_keys(optlist, options):
def add_keys(optlist, options, section):
keys = list(options.keys())
keys.sort()
for key in keys:
opt = options[key]
optdict = {'name': key, 'value': opt.value}
optdict = {'name': key, 'value': opt.value, 'section': section}
if isinstance(opt, cdata.UserStringOption):
typestr = 'string'
elif isinstance(opt, cdata.UserBooleanOption):
Expand Down
3 changes: 3 additions & 0 deletions run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,7 @@ def get_opt():
expected = {
'name': 'list',
'description': 'list',
'section': 'user',
'type': 'array',
'value': ['foo', 'bar'],
}
Expand All @@ -2277,6 +2278,7 @@ def get_opt():
expected = {
'name': 'list',
'description': 'list',
'section': 'user',
'type': 'array',
'value': ['foo', 'bar'],
}
Expand All @@ -2301,6 +2303,7 @@ def get_opt():
expected = {
'name': 'list',
'description': 'list',
'section': 'user',
'type': 'array',
'value': [],
}
Expand Down