diff options
-rw-r--r-- | mesonbuild/utils/universal.py | 20 | ||||
-rw-r--r-- | unittests/darwintests.py | 5 |
2 files changed, 19 insertions, 6 deletions
diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index db59a60..8cfc04d 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -702,15 +702,23 @@ def darwin_get_object_archs(objpath: str) -> 'ImmutableListProtocol[str]': mlog.debug(f'lipo {objpath}: {stderr}') return None stdo = stdo.rsplit(': ', 1)[1] + # Convert from lipo-style archs to meson-style CPUs - stdo = stdo.replace('i386', 'x86') - stdo = stdo.replace('arm64', 'aarch64') - stdo = stdo.replace('ppc7400', 'ppc') - stdo = stdo.replace('ppc970', 'ppc') + map_arch = { + 'i386': 'x86', + 'arm64': 'aarch64', + 'arm64e': 'aarch64', + 'ppc7400': 'ppc', + 'ppc970': 'ppc', + } + lipo_archs = stdo.split() + meson_archs = [map_arch.get(lipo_arch, lipo_arch) for lipo_arch in lipo_archs] + # Add generic name for armv7 and armv7s if 'armv7' in stdo: - stdo += ' arm' - return stdo.split() + meson_archs.append('arm') + + return meson_archs def windows_detect_native_arch() -> str: """ diff --git a/unittests/darwintests.py b/unittests/darwintests.py index 254b3d0..1f17760 100644 --- a/unittests/darwintests.py +++ b/unittests/darwintests.py @@ -148,3 +148,8 @@ class DarwinTests(BasePlatformTests): testdir = os.path.join(self.objcpp_test_dir, '1 simple') self.init(testdir) self.assertIn('-std=c++14', self.get_compdb()[0]['command']) + + def test_darwin_get_object_archs(self): + from mesonbuild.mesonlib import darwin_get_object_archs + archs = darwin_get_object_archs('/System/Library/CoreServices/Encodings/libSymbolConverter.dylib') + self.assertEqual(archs, ['x86_64', 'aarch64']) |