diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2023-03-28 08:43:15 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-03-30 17:10:53 -0400 |
commit | 0418a40e68704e2ad36148eb72e92a1206de72dd (patch) | |
tree | ce86b96a61bb87379e481a3b9f8df499711bbb10 | |
parent | ad151d9f1123e84fea055848867c33bc965307f8 (diff) | |
download | meson-0418a40e68704e2ad36148eb72e92a1206de72dd.zip meson-0418a40e68704e2ad36148eb72e92a1206de72dd.tar.gz meson-0418a40e68704e2ad36148eb72e92a1206de72dd.tar.bz2 |
msetup: use more consistent exceptions on exit
- MesonException for errors is clearer than SystemExit('error message')
and provides meson-formatted "ERROR: ..."
- `raise SystemExit` with no parameter isn't obvious that it intends to
exit successfully
While clarifying the latter, it was observed to cause
test_preprocessor_checks_CPPFLAGS() failure to be ignored. That test
checks get_define() on both c and cpp compilers, which means we need to
define either CPPFLAGS or both CFLAGS+CXXFLAGS.
-rw-r--r-- | mesonbuild/msetup.py | 21 | ||||
-rw-r--r-- | unittests/allplatformstests.py | 8 |
2 files changed, 18 insertions, 11 deletions
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py index d824e1f..166f7ef 100644 --- a/mesonbuild/msetup.py +++ b/mesonbuild/msetup.py @@ -165,16 +165,21 @@ class MesonApp: has_partial_build = os.path.isdir(priv_dir) if has_valid_build: if not reconfigure and not wipe: - print('Directory already configured.\n' - '\nJust run your build command (e.g. ninja) and Meson will regenerate as necessary.\n' + print('Directory already configured.\n\n' + 'Just run your build command (e.g. ninja) and Meson will regenerate as necessary.\n' 'If ninja fails, run "ninja reconfigure" or "meson setup --reconfigure"\n' - 'to force Meson to regenerate.\n' - '\nIf build failures persist, run "meson setup --wipe" to rebuild from scratch\n' - 'using the same options as passed when configuring the build.' - '\nTo change option values, run "meson configure" instead.') - raise SystemExit + 'to force Meson to regenerate.\n\n' + 'If build failures persist, run "meson setup --wipe" to rebuild from scratch\n' + 'using the same options as passed when configuring the build.\n' + 'To change option values, run "meson configure" instead.') + # FIXME: This returns success and ignores new option values from CLI. + # We should either make this a hard error, or update options and + # return success. + # Note that making this an error would not be backward compatible (and also isn't + # universally agreed on): https://github.com/mesonbuild/meson/pull/4249. + raise SystemExit(0) elif not has_partial_build and 'MESON_RUNNING_IN_PROJECT_TESTS' not in os.environ: - raise SystemExit(f'Directory is not empty and does not contain a previous build:\n{build_dir}') + raise MesonException(f'Directory is not empty and does not contain a previous build:\n{build_dir}') return src_dir, build_dir def generate(self) -> None: diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index bb50128..ea9d795 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -1139,7 +1139,7 @@ class AllPlatformTests(BasePlatformTests): def test_preprocessor_checks_CPPFLAGS(self): ''' - Test that preprocessor compiler checks read CPPFLAGS and also CFLAGS but + Test that preprocessor compiler checks read CPPFLAGS and also CFLAGS/CXXFLAGS but not LDFLAGS. ''' testdir = os.path.join(self.common_test_dir, '132 get define') @@ -1150,11 +1150,13 @@ class AllPlatformTests(BasePlatformTests): # % and # confuse the MSVC preprocessor # !, ^, *, and < confuse lcc preprocessor value = 'spaces and fun@$&()-=_+{}[]:;>?,./~`' - for env_var in ['CPPFLAGS', 'CFLAGS']: + for env_var in [{'CPPFLAGS'}, {'CFLAGS', 'CXXFLAGS'}]: env = {} - env[env_var] = f'-D{define}="{value}"' + for i in env_var: + env[i] = f'-D{define}="{value}"' env['LDFLAGS'] = '-DMESON_FAIL_VALUE=cflags-read' self.init(testdir, extra_args=[f'-D{define}={value}'], override_envvars=env) + self.new_builddir() def test_custom_target_exe_data_deterministic(self): testdir = os.path.join(self.common_test_dir, '109 custom target capture') |