Skip to content

Commit

Permalink
Move configure option -A functionality to -D.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Oct 2, 2024
1 parent 82ff975 commit a5aa940
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
10 changes: 1 addition & 9 deletions mesonbuild/mconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None:
help='Clear cached state (e.g. found dependencies)')
parser.add_argument('--no-pager', action='store_false', dest='pager',
help='Do not redirect output to a pager')
parser.add_argument('-A', action='append', dest='A',
help='Add a subproject option.')
parser.add_argument('-U', action='append', dest='U',
help='Remove a subproject option.')

Expand Down Expand Up @@ -358,8 +356,6 @@ def print_augments(self) -> None:
def has_option_flags(options: T.Any) -> bool:
if options.cmd_line_options:
return True
if options.A:
return True
if hasattr(options, 'D') and options.D:
return True
if options.U:
Expand All @@ -386,18 +382,14 @@ def run_impl(options: CMDOptions, builddir: str) -> int:

save = False
if has_option_flags(options):
if hasattr(options, 'A'):
A = options.A
else:
A = []
if hasattr(options, 'U'):
U = options.U
else:
U = []
all_D = options.projectoptions[:]
for keystr, valstr in options.cmd_line_options.items():
all_D.append(f'{keystr}={valstr}')
save |= c.coredata.optstore.set_from_configure_command(all_D, A, U)
save |= c.coredata.optstore.set_from_configure_command(all_D, U)
coredata.update_cmd_line_file(builddir, options)
if options.clearcache:
c.clear_cache()
Expand Down
1 change: 0 additions & 1 deletion mesonbuild/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,6 @@ def get_value_for(self, name: 'T.Union[OptionKey, str]', subproject: T.Optional[
vobject, resolved_value = self.get_value_object_and_value_for(key)
return resolved_value


def num_options(self):
basic = len(self.options)
build = len(self.build_options) if self.build_options else 0
Expand Down
4 changes: 2 additions & 2 deletions unittests/linuxliketests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,7 @@ def test_persp_options(self):
self.check_has_flag(compdb, sub2src, '-O1')

# Set subproject option to O2
self.setconf(['-Dround=2', '-A', 'sub2:optimization=3'])
self.setconf(['-Dround=2', '-D', 'sub2:optimization=3'])
compdb = self.get_compdb()
self.check_has_flag(compdb, mainsrc, '-O1')
self.check_has_flag(compdb, sub1src, '-O1')
Expand All @@ -1861,7 +1861,7 @@ def test_persp_options(self):
self.check_has_flag(compdb, sub2src, '-O2')

# Set top level option to O3
self.setconf(['-Dround=4', '-A:optimization=3'])
self.setconf(['-Dround=4', '-D:optimization=3'])
compdb = self.get_compdb()
self.check_has_flag(compdb, mainsrc, '-O3')
self.check_has_flag(compdb, sub1src, '-O1')
Expand Down
12 changes: 6 additions & 6 deletions unittests/optiontests.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,24 @@ def test_augments(self):
self.assertEqual(optstore.get_value_for(name, sub2_name), top_value)

# First augment a subproject
optstore.set_from_configure_command([], [f'{sub_name}:{name}={aug_value}'], [])
optstore.set_from_configure_command([f'{sub_name}:{name}={aug_value}'], [])
self.assertEqual(optstore.get_value_for(name), top_value)
self.assertEqual(optstore.get_value_for(name, sub_name), aug_value)
self.assertEqual(optstore.get_value_for(name, sub2_name), top_value)

optstore.set_from_configure_command([], [], [f'{sub_name}:{name}'])
optstore.set_from_configure_command([], [f'{sub_name}:{name}'])
self.assertEqual(optstore.get_value_for(name), top_value)
self.assertEqual(optstore.get_value_for(name, sub_name), top_value)
self.assertEqual(optstore.get_value_for(name, sub2_name), top_value)

# And now augment the top level option
optstore.set_from_configure_command([], [f':{name}={aug_value}'], [])
optstore.set_from_configure_command([f':{name}={aug_value}'], [])
self.assertEqual(optstore.get_value_for(name, None), top_value)
self.assertEqual(optstore.get_value_for(name, ''), aug_value)
self.assertEqual(optstore.get_value_for(name, sub_name), top_value)
self.assertEqual(optstore.get_value_for(name, sub2_name), top_value)

optstore.set_from_configure_command([], [], [f':{name}'])
optstore.set_from_configure_command([], [f':{name}'])
self.assertEqual(optstore.get_value_for(name), top_value)
self.assertEqual(optstore.get_value_for(name, sub_name), top_value)
self.assertEqual(optstore.get_value_for(name, sub2_name), top_value)
Expand All @@ -155,8 +155,8 @@ def test_augment_set_sub(self):
['c++98', 'c++11', 'c++14', 'c++17', 'c++20', 'c++23'],
top_value)
optstore.add_system_option(name, co)
optstore.set_from_configure_command([], [f'{sub_name}:{name}={aug_value}'], [])
optstore.set_from_configure_command([f'{sub_name}:{name}={set_value}'], [], [])
optstore.set_from_configure_command([f'{sub_name}:{name}={aug_value}'], [])
optstore.set_from_configure_command([f'{sub_name}:{name}={set_value}'], [])
self.assertEqual(optstore.get_value_for(name), top_value)
self.assertEqual(optstore.get_value_for(name, sub_name), set_value)

Expand Down

0 comments on commit a5aa940

Please sign in to comment.