diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2023-10-16 10:16:40 -0700 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2024-02-23 09:48:32 -0800 |
| commit | a75ced6d50a3d479eda6dcdc9c3482493f2161f0 (patch) | |
| tree | 18fa2240065c4dfbdebc790c78b0812409f5b325 /mesonbuild/modules/rust.py | |
| parent | 05d49c6990aedb850266f22b40442af7a54e13fc (diff) | |
| download | meson-a75ced6d50a3d479eda6dcdc9c3482493f2161f0.tar.gz | |
modules/rust: inject a C/C++ standard for bindgen
Especially for C++ this is very important.
Diffstat (limited to 'mesonbuild/modules/rust.py')
| -rw-r--r-- | mesonbuild/modules/rust.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py index 4978f1205..6a00fb3ce 100644 --- a/mesonbuild/modules/rust.py +++ b/mesonbuild/modules/rust.py @@ -268,6 +268,23 @@ class RustModule(ExtensionModule): if language == 'cpp': clang_args.extend(['-x', 'c++']) + # Add the C++ standard to the clang arguments. Attempt to translate VS + # extension versions into the nearest standard version + std = state.get_option('std', lang=language) + assert isinstance(std, str), 'for mypy' + if std.startswith('vc++'): + if std.endswith('latest'): + mlog.warning('Attempting to translate vc++latest into a clang compatible version.', + 'Currently this is hardcoded for c++20', once=True, fatal=False) + std = 'c++20' + else: + mlog.debug('The current C++ standard is a Visual Studio extension version.', + 'bindgen will use a the nearest C++ standard instead') + std = std[1:] + + if std != 'none': + clang_args.append(f'-std={std}') + cmd = self._bindgen_bin.get_command() + \ [ '@INPUT@', '--output', |
