Skip to content

Commit 49ea849

Browse files
bonzinijpakkane
authored andcommitted
options: split pending subproject options into their own dictionary
Reserve pending_options for those that could appear later in the configuration process. Options are added there only if accept_as_pending_option() is true. This is a preparation for changing the code so that it checks pending_options for subprojects as well. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 5768692 commit 49ea849

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

mesonbuild/options.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,11 @@ def __init__(self, is_cross: bool) -> None:
812812
self.augments: OptionDict = {}
813813
self.is_cross = is_cross
814814

815-
# Pending options are options that need to be initialized later, either
816-
# configuration dependent options like compiler options, or options for
817-
# a different subproject
815+
# Pending options are configuration dependent options that could be
816+
# initialized later, such as compiler options
818817
self.pending_options: OptionDict = {}
818+
# Subproject options from toplevel project()
819+
self.pending_subproject_options: OptionDict = {}
819820

820821
def clear_pending(self) -> None:
821822
self.pending_options = {}
@@ -1305,9 +1306,9 @@ def initialize_from_top_level_project_call(self,
13051306
if not self.is_cross and key.is_for_build():
13061307
continue
13071308
if key.subproject:
1308-
# do apply project() default_options for subprojects here, because
1309-
# they have low priority
1310-
self.pending_options[key] = valstr
1309+
# Subproject options from toplevel project() have low priority
1310+
# and will be processed when the subproject is found
1311+
self.pending_subproject_options[key] = valstr
13111312
else:
13121313
# Setting a project option with default_options
13131314
# should arguably be a hard error; the default
@@ -1359,7 +1360,7 @@ def initialize_from_subproject_call(self,
13591360
cmd_line_options: OptionDict,
13601361
machine_file_options: OptionDict) -> None:
13611362
# pick up pending per-project settings from the toplevel project() invocation
1362-
options = {k: v for k, v in self.pending_options.items() if k.subproject == subproject}
1363+
options = {k: v for k, v in self.pending_subproject_options.items() if k.subproject == subproject}
13631364

13641365
# apply project() and subproject() default_options
13651366
for key, valstr in itertools.chain(project_default_options.items(), spcall_default_options.items()):
@@ -1375,7 +1376,7 @@ def initialize_from_subproject_call(self,
13751376
for key, valstr in itertools.chain(machine_file_options.items(), cmd_line_options.items()):
13761377
if key.subproject is None and not self.is_project_option(key.as_root()):
13771378
subp_key = key.evolve(subproject=subproject)
1378-
self.pending_options.pop(subp_key, None)
1379+
self.pending_subproject_options.pop(subp_key, None)
13791380
options.pop(subp_key, None)
13801381

13811382
# then finally per project augments from machine file and command line
@@ -1385,7 +1386,12 @@ def initialize_from_subproject_call(self,
13851386

13861387
# merge everything that has been computed above, while giving self.augments priority
13871388
for key, valstr in options.items():
1388-
self.pending_options.pop(key, None)
1389+
if key.subproject != subproject:
1390+
# Subproject options from project() will be processed when the subproject is found
1391+
self.pending_subproject_options[key] = valstr
1392+
continue
1393+
1394+
self.pending_subproject_options.pop(key, None)
13891395
valstr = self.augments.pop(key, valstr)
13901396
if key in self.project_options:
13911397
self.set_option(key, valstr, True)

0 commit comments

Comments
 (0)