From 0fe1254910a9889aff74fd9e68e63a8186b6769f Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Thu, 5 Sep 2024 16:56:50 +0300 Subject: [PATCH] Move configure option -A functionality to -D. --- mesonbuild/mconf.py | 10 +--------- mesonbuild/options.py | 1 - unittests/linuxliketests.py | 4 ++-- unittests/optiontests.py | 12 ++++++------ 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 42028307b61b..a7cbd2b5e01b 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -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.') @@ -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: @@ -386,10 +382,6 @@ 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: @@ -397,7 +389,7 @@ def run_impl(options: CMDOptions, builddir: str) -> int: 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() diff --git a/mesonbuild/options.py b/mesonbuild/options.py index a4bba3a66ea7..3ba6b786b7b6 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -788,7 +788,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 diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index 6b4223894227..b242e8ba441a 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -1883,7 +1883,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') @@ -1897,7 +1897,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') diff --git a/unittests/optiontests.py b/unittests/optiontests.py index 635d1ec9ea30..304a922f2254 100644 --- a/unittests/optiontests.py +++ b/unittests/optiontests.py @@ -118,24 +118,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) @@ -154,8 +154,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)