aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-05-22 13:39:00 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-06-06 07:53:10 +0000
commit3e1a610702adfec51a24a7dfdcba8a0319a795a1 (patch)
tree48e7a07ca16ba946ce03eedff498383db5e17aae /run_unittests.py
parent68001193d30909c6b00044360e6366630c8ff337 (diff)
downloadmeson-3e1a610702adfec51a24a7dfdcba8a0319a795a1.zip
meson-3e1a610702adfec51a24a7dfdcba8a0319a795a1.tar.gz
meson-3e1a610702adfec51a24a7dfdcba8a0319a795a1.tar.bz2
Add a new option for building with Apple bitcode support
Normally, people would just pass -fembed-bitcode in CFLAGS, but this conflicts with -Wl,-dead_strip_dylibs and -bundle, so we need it as an option so that those can be quietly disabled.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 1e2cc27..a25ba34 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -3195,6 +3195,49 @@ endian = 'little'
deps.append(b'-lintl')
self.assertEqual(set(deps), set(stdo.split()))
+ def test_apple_bitcode(self):
+ '''
+ Test that -fembed-bitcode is correctly added while compiling and
+ -bitcode_bundle is added while linking when b_bitcode is true and not
+ when it is false. This can't be an ordinary test case because we need
+ to inspect the compiler database.
+ '''
+ if not is_osx():
+ raise unittest.SkipTest('Apple bitcode not relevant')
+ testdir = os.path.join(self.common_test_dir, '4 shared')
+ # Try with bitcode enabled
+ self.init(testdir, extra_args='-Db_bitcode=true')
+ compdb = self.get_compdb()
+ self.assertIn('-fembed-bitcode', compdb[0]['command'])
+ build_ninja = os.path.join(self.builddir, 'build.ninja')
+ with open(build_ninja, 'r', encoding='utf-8') as f:
+ contents = f.read()
+ m = re.search('LINK_ARGS =.*-bitcode_bundle', contents)
+ self.assertIsNotNone(m, msg=contents)
+ # Try with bitcode disabled
+ self.setconf('-Db_bitcode=false')
+ # Regenerate build
+ self.build()
+ compdb = self.get_compdb()
+ self.assertNotIn('-fembed-bitcode', compdb[0]['command'])
+ build_ninja = os.path.join(self.builddir, 'build.ninja')
+ with open(build_ninja, 'r', encoding='utf-8') as f:
+ contents = f.read()
+ m = re.search('LINK_ARGS =.*-bitcode_bundle', contents)
+ self.assertIsNone(m, msg=contents)
+
+ def test_apple_bitcode_modules(self):
+ '''
+ Same as above, just for shared_module()
+ '''
+ if not is_osx():
+ raise unittest.SkipTest('Apple bitcode not relevant')
+ testdir = os.path.join(self.common_test_dir, '156 shared module resolving symbol in executable')
+ # Ensure that it builds even with bitcode enabled
+ self.init(testdir, extra_args='-Db_bitcode=true')
+ self.build()
+ self.run_tests()
+
class LinuxArmCrossCompileTests(BasePlatformTests):
'''
Tests that verify cross-compilation to Linux/ARM