diff options
| author | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-09-09 11:31:30 +0300 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-10-01 21:54:38 +0300 |
| commit | 8d490ab081dc15abeaece45bacf2ae1bb73e67fd (patch) | |
| tree | 2c34c03679027fe07fa0480172922fb5d2944bf2 /mesonbuild | |
| parent | d30396672ba1bd1da1f0c238c95195af4c92624c (diff) | |
| download | meson-8d490ab081dc15abeaece45bacf2ae1bb73e67fd.tar.gz | |
Use new naming scheme in shared libraries.
Diffstat (limited to 'mesonbuild')
| -rw-r--r-- | mesonbuild/build.py | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index c7944d51c..2a69eef36 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -69,6 +69,13 @@ DEFAULT_STATIC_LIBRARY_NAMES: T.Mapping[str, T.Tuple[str, str]] = { 'cygwin': ('lib', 'a'), } +DEFAULT_SHARED_LIBRARY_NAMES: T.Mapping[str, T.Tuple[str, str, str]] = { + 'unix': ('lib', 'so', ''), + 'windows': ('', 'dll', 'dll.lib'), + 'darwin': ('lib', 'dylib', ''), + 'cygwin': ('cyg', 'dll', 'dll.a'), +} + pch_kwargs = {'c_pch', 'cpp_pch'} lang_arg_kwargs = {f'{lang}_args' for lang in all_languages} @@ -2490,13 +2497,17 @@ class SharedLibrary(BuildTarget): return self.environment.get_shared_lib_dir(), '{libdir_shared}' def determine_naming_info(self) -> T.Tuple[str, str, str, str, bool]: - prefix = '' - suffix = '' + scheme = self.environment.coredata.get_option_for_target(self, 'namingscheme') + assert isinstance(scheme, str), 'for mypy' + if scheme == 'platform': + schemename = self.get_platform_scheme_name() + prefix, suffix, import_suffix = DEFAULT_SHARED_LIBRARY_NAMES[schemename] + else: + prefix = None + suffix = None + import_suffix = None filename_tpl = self.basic_filename_tpl - import_filename_tpl = '' create_debug_file = False - prefix = '' - suffix = '' create_debug_file = False self.filename_tpl = self.basic_filename_tpl import_filename_tpl = None @@ -2511,27 +2522,29 @@ class SharedLibrary(BuildTarget): # Only Windows uses a separate import library for linking # For all other targets/platforms import_filename stays None elif self.environment.machines[self.for_machine].is_windows(): - suffix = 'dll' + suffix = suffix if suffix is not None else 'dll' if self.uses_rust(): # Shared library is of the form foo.dll - prefix = '' + prefix = prefix if prefix is not None else '' # Import library is called foo.dll.lib import_filename_tpl = '{0.prefix}{0.name}.dll.lib' # .pdb file is only created when debug symbols are enabled create_debug_file = self.environment.coredata.optstore.get_value_for(OptionKey("debug")) elif self.get_using_msvc(): # Shared library is of the form foo.dll - prefix = '' + prefix = prefix if prefix is not None else '' # Import library is called foo.lib - import_filename_tpl = '{0.prefix}{0.name}.lib' + import_suffix = import_suffix if import_suffix is not None else 'lib' + import_filename_tpl = '{0.prefix}{0.name}.' + import_suffix # .pdb file is only created when debug symbols are enabled create_debug_file = self.environment.coredata.optstore.get_value_for(OptionKey("debug")) # Assume GCC-compatible naming else: # Shared library is of the form libfoo.dll - prefix = 'lib' + prefix = prefix if prefix is not None else 'lib' # Import library is called libfoo.dll.a - import_filename_tpl = '{0.prefix}{0.name}.dll.a' + import_suffix = import_suffix if import_suffix is not None else '.dll.a' + import_filename_tpl = '{0.prefix}{0.name}' + import_suffix # Shared library has the soversion if it is defined if self.soversion: filename_tpl = '{0.prefix}{0.name}-{0.soversion}.{0.suffix}' @@ -2543,15 +2556,16 @@ class SharedLibrary(BuildTarget): # (ld --dll-search-prefix=cyg is the default) prefix = 'cyg' # Import library is called libfoo.dll.a + import_suffix = import_suffix if import_suffix is not None else '.dll.a' import_prefix = self.prefix if self.prefix is not None else 'lib' - import_filename_tpl = import_prefix + '{0.name}.dll.a' + import_filename_tpl = import_prefix + '{0.name}' + import_suffix if self.soversion: filename_tpl = '{0.prefix}{0.name}-{0.soversion}.{0.suffix}' else: filename_tpl = '{0.prefix}{0.name}.{0.suffix}' elif self.environment.machines[self.for_machine].is_darwin(): - prefix = 'lib' - suffix = 'dylib' + prefix = prefix if prefix is not None else 'lib' + suffix = suffix if suffix is not None else 'dylib' # On macOS, the filename can only contain the major version if self.soversion: # libfoo.X.dylib @@ -2560,13 +2574,13 @@ class SharedLibrary(BuildTarget): # libfoo.dylib filename_tpl = '{0.prefix}{0.name}.{0.suffix}' elif self.environment.machines[self.for_machine].is_android(): - prefix = 'lib' - suffix = 'so' + prefix = prefix if prefix is not None else 'lib' + suffix = suffix if suffix is not None else 'so' # Android doesn't support shared_library versioning filename_tpl = '{0.prefix}{0.name}.{0.suffix}' else: - prefix = 'lib' - suffix = 'so' + prefix = prefix if prefix is not None else 'lib' + suffix = suffix if suffix is not None else 'so' if self.ltversion: # libfoo.so.X[.Y[.Z]] (.Y and .Z are optional) filename_tpl = '{0.prefix}{0.name}.{0.suffix}.{0.ltversion}' |
