Skip to content

Commit

Permalink
Get library name patterns with proper prefixes and suffixes on OS/2
Browse files Browse the repository at this point in the history
  • Loading branch information
komh committed Jan 10, 2025
1 parent 56e3d52 commit 4ad62d7
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions mesonbuild/compilers/mixins/clike.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,9 +990,24 @@ def symbols_have_underscore_prefix(self, env: 'Environment') -> bool:

def _get_patterns(self, env: 'Environment', prefixes: T.List[str], suffixes: T.List[str], shared: bool = False) -> T.List[str]:
patterns: T.List[str] = []
for p in prefixes:
if env.machines[self.for_machine].is_os2():
# On OS/2, search order for shared libs is
# 1. libfoo_dll.a
# 2. foo_dll.a
# 3. libfoo.a
# 4. foo.a
# 5. foo.dll
# For static libs, `_s' is used instead of `_dll'.
for s in suffixes:
patterns.append(p + '{}.' + s)
for p in prefixes:
if s.startswith('_dll.') or s.startswith('_s.'):
patterns.append(p + '{}' + s)
else:
patterns.append(p + '{}.' + s)
else:
for p in prefixes:
for s in suffixes:
patterns.append(p + '{}.' + s)
if shared and env.machines[self.for_machine].is_openbsd():
# Shared libraries on OpenBSD can be named libfoo.so.X.Y:
# https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs
Expand All @@ -1015,7 +1030,9 @@ def get_library_naming(self, env: 'Environment', libtype: LibType, strict: bool
# people depend on it. Also, some people use prebuilt `foo.so` instead
# of `libfoo.so` for unknown reasons, and may also want to create
# `foo.so` by setting name_prefix to ''
if strict and not isinstance(self, VisualStudioLikeCompiler): # lib prefix is not usually used with msvc
# lib prefix is not usually used with msvc and OS/2
if strict and not isinstance(self, VisualStudioLikeCompiler) \
and not env.machines[self.for_machine].is_os2():
prefixes = ['lib']
else:
prefixes = ['lib', '']
Expand All @@ -1038,6 +1055,14 @@ def get_library_naming(self, env: 'Environment', libtype: LibType, strict: bool
# TI C28x compilers can use both extensions for static or dynamic libs.
stlibext = ['a', 'lib']
shlibext = ['dll', 'so']
elif env.machines[self.for_machine].is_os2():
from ...options import OptionKey
if env.coredata.get_option(OptionKey('emxomf')):
stlibext = ['_s.lib', '_s.a', 'lib', 'a']
shlibext = ['_dll.lib', '_dll.a', 'lib', 'a', 'dll']
else:
stlibext = ['_s.a', 'a']
shlibext = ['_dll.a', 'a', 'dll']
else:
# Linux/BSDs
shlibext = ['so']
Expand Down

0 comments on commit 4ad62d7

Please sign in to comment.