aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/mintro.py53
1 files changed, 45 insertions, 8 deletions
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index 76efdac..25e05b2 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -85,36 +85,73 @@ def list_target_files(target_name, coredata, builddata):
sources = [os.path.join(i.subdir, i.fname) for i in sources]
print(json.dumps(sources))
+def split_options(user_options, suboptions):
+ main_options = {}
+ main_suboptions = {}
+ subproject_options = {}
+ subproject_suboptions = {}
+ for k in user_options.keys():
+ if ':' in k:
+ subproject_options[k] = user_options[k]
+ else:
+ main_options[k] = user_options[k]
+ for k in suboptions.keys():
+ if ':' in k:
+ subproject_suboptions[k] = suboptions[k]
+ else:
+ main_suboptions[k] = suboptions[k]
+ return (main_options, main_suboptions, subproject_options, subproject_suboptions)
+
def list_buildoptions(coredata, builddata):
+ (main_options, main_suboptions, subproject_options, subproject_suboptions) = split_options(coredata.user_options, coredata.suboptions)
all_opt = [{'name' : 'builtin',
'description': 'Meson builtin options',
'type': 'suboption',
'value': get_keys(coredata.builtins),
}]
- all_opt.append({'name': 'user',
- 'description' : 'User defined options',
+ all_opt.append({'name': 'base',
+ 'description' : 'Base options',
'type' : 'suboption',
- 'value' : build_usertree(coredata.suboptions, coredata.user_options),
+ 'value' : get_keys(coredata.base_options),
})
all_opt.append({'name' : 'compilers',
'description' : 'Options for compilers',
'type' : 'suboption',
'value' : get_keys(coredata.compiler_options),
})
- all_opt.append({'name': 'base',
- 'description' : 'Base options',
+ all_opt.append({'name': 'user',
+ 'description' : 'User options',
'type' : 'suboption',
- 'value' : get_keys(coredata.base_options),
+ 'value' : build_usertree(main_options, main_suboptions),
})
+ all_opt += build_subprojecttree(subproject_options, subproject_suboptions)
print(json.dumps(all_opt, indent=2))
-def build_usertree(suboptions, user_options, subbranch=None):
+def build_subprojecttree(options, suboptions):
+ result = []
+ sp_names = {}
+ for n in options.keys():
+ sp_names[n.split(':')[0]] = True
+ for n in suboptions.keys():
+ sp_names[n.split(':')[0]] = True
+ for subproject in sorted(sp_names.keys()):
+ prefix = subproject + ':'
+ cur_opt = {x.name : x for x in options.values() if x.name.startswith(prefix)}
+ cur_subopt = {x.name : x for x in suboptions.values() if x.name.startswith(prefix)}
+ result.append({'name' : subproject,
+ 'description' : 'Options of subproject: %s' % subproject,
+ 'type' : 'suboption',
+ 'value' : build_usertree(cur_opt, cur_subopt)
+ })
+ return result
+
+def build_usertree(user_options, suboptions, subbranch=None):
current = []
current_suboptions = [x for x in suboptions.values() if x.parent == subbranch]
current_options = [x for x in user_options.values() if x.parent == subbranch]
for so in current_suboptions:
subentry = {'type' : 'subobject',
- 'value' : build_usertree(suboptions, user_options, so.name),
+ 'value' : build_usertree(user_options, suboptions, so.name),
'description' : so.description,
'name' : so.name
}