aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-08-25 15:14:38 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2020-09-09 18:10:18 +0530
commit59a54d806bf5102a387ad00ac896cd92c839a3d3 (patch)
tree29f4071394cbb83a75303b3f1720058e68034a7d
parent53dd994ce0d256849b64a242b47f940aa3f34560 (diff)
downloadmeson-59a54d806bf5102a387ad00ac896cd92c839a3d3.zip
meson-59a54d806bf5102a387ad00ac896cd92c839a3d3.tar.gz
meson-59a54d806bf5102a387ad00ac896cd92c839a3d3.tar.bz2
Fix typo when fetching buildtype option for compiler checks
This type happened in https://github.com/mesonbuild/meson/pull/7432 and wasn't noticed because I didn't add a test for it. Rectified now. If we don't specify the CRT, MSVC will pick /MT by default (!?) and link to `libcmt.lib`. This actually *breaks* UWP because `libcmt.lib` is not available by default when building for UWP. Was noticed here: https://github.com/cisco/libsrtp/pull/505
-rw-r--r--mesonbuild/compilers/mixins/clike.py2
-rwxr-xr-xrun_unittests.py53
2 files changed, 54 insertions, 1 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index 95b9592..d5ea8d1 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -373,7 +373,7 @@ class CLikeCompiler:
# us in that case and will error out asking us to pick one.
try:
crt_val = env.coredata.base_options['b_vscrt'].value
- buildtype = env.coredata.base_options['buildtype'].value
+ buildtype = env.coredata.builtins['buildtype'].value
cargs += self.get_crt_compile_args(crt_val, buildtype)
except (KeyError, AttributeError):
pass
diff --git a/run_unittests.py b/run_unittests.py
index fbeee80..1f7b228 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1780,6 +1780,15 @@ class BasePlatformTests(unittest.TestCase):
cmds = [l[len(prefix):].split() for l in log if l.startswith(prefix)]
return cmds
+ def get_meson_log_sanitychecks(self):
+ '''
+ Same as above, but for the sanity checks that were run
+ '''
+ log = self.get_meson_log()
+ prefix = 'Sanity check compiler command line:'
+ cmds = [l[len(prefix):].split() for l in log if l.startswith(prefix)]
+ return cmds
+
def introspect(self, args):
if isinstance(args, str):
args = [args]
@@ -5613,6 +5622,50 @@ class WindowsTests(BasePlatformTests):
m = re.search('build qt5core.exe: cpp_LINKER.*Qt5Cored.lib', contents)
self.assertIsNotNone(m, msg=contents)
+ def test_compiler_checks_vscrt(self):
+ '''
+ Test that the correct VS CRT is used when running compiler checks
+ '''
+ # Verify that the `b_vscrt` option is available
+ env = get_fake_env()
+ cc = env.detect_c_compiler(MachineChoice.HOST)
+ if 'b_vscrt' not in cc.base_options:
+ raise unittest.SkipTest('Compiler does not support setting the VS CRT')
+
+ def sanitycheck_vscrt(vscrt):
+ checks = self.get_meson_log_sanitychecks()
+ self.assertTrue(len(checks) > 0)
+ for check in checks:
+ self.assertIn(vscrt, check)
+
+ testdir = os.path.join(self.common_test_dir, '1 trivial')
+ self.init(testdir)
+ sanitycheck_vscrt('/MDd')
+
+ self.new_builddir()
+ self.init(testdir, extra_args=['-Dbuildtype=debugoptimized'])
+ sanitycheck_vscrt('/MD')
+
+ self.new_builddir()
+ self.init(testdir, extra_args=['-Dbuildtype=release'])
+ sanitycheck_vscrt('/MD')
+
+ self.new_builddir()
+ self.init(testdir, extra_args=['-Db_vscrt=md'])
+ sanitycheck_vscrt('/MD')
+
+ self.new_builddir()
+ self.init(testdir, extra_args=['-Db_vscrt=mdd'])
+ sanitycheck_vscrt('/MDd')
+
+ self.new_builddir()
+ self.init(testdir, extra_args=['-Db_vscrt=mt'])
+ sanitycheck_vscrt('/MT')
+
+ self.new_builddir()
+ self.init(testdir, extra_args=['-Db_vscrt=mtd'])
+ sanitycheck_vscrt('/MTd')
+
@unittest.skipUnless(is_osx(), "requires Darwin")
class DarwinTests(BasePlatformTests):