summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2023-08-19 20:40:21 -0400
committerXavier Claessens <xclaesse@gmail.com>2023-08-24 18:50:12 -0400
commit6f87215f1f7c104de2f8720e3c0926bcffdc7232 (patch)
tree327333ca374d4f7e518420ea049a43574a418002
parent10e8995fc8394c71e5def6d055f542c5f80ca06c (diff)
downloadmeson-6f87215f1f7c104de2f8720e3c0926bcffdc7232.tar.gz
build: Simplify import_filename handling
This removes deadcode, vs_import_filename and gcc_import_filename were not needed.
-rw-r--r--mesonbuild/build.py56
1 files changed, 17 insertions, 39 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 1463e51e3..d064fff0b 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1950,10 +1950,6 @@ class Executable(BuildTarget):
# The import library this target will generate
self.import_filename = None
- # The import library that Visual Studio would generate (and accept)
- self.vs_import_filename = None
- # The import library that GCC would generate (and prefer)
- self.gcc_import_filename = None
# The debugging information file this target will generate
self.debug_filename = None
@@ -1963,12 +1959,10 @@ class Executable(BuildTarget):
if isinstance(self.implib, str):
implib_basename = self.implib
if machine.is_windows() or machine.is_cygwin():
- self.vs_import_filename = f'{implib_basename}.lib'
- self.gcc_import_filename = f'lib{implib_basename}.a'
if self.get_using_msvc():
- self.import_filename = self.vs_import_filename
+ self.import_filename = f'{implib_basename}.lib'
else:
- self.import_filename = self.gcc_import_filename
+ self.import_filename = f'lib{implib_basename}.a'
create_debug_file = (
machine.is_windows()
@@ -1997,11 +1991,6 @@ class Executable(BuildTarget):
"""
return self.import_filename
- def get_import_filenameslist(self):
- if self.import_filename:
- return [self.vs_import_filename, self.gcc_import_filename]
- return []
-
def get_debug_filename(self) -> T.Optional[str]:
"""
The name of debuginfo file that will be created by the compiler
@@ -2083,6 +2072,9 @@ class StaticLibrary(BuildTarget):
# libfoo.a. However, we cannot use foo.lib because that's the same as
# the import library. Using libfoo.a is ok because people using MSVC
# always pass the library filename while linking anyway.
+ #
+ # See our FAQ for more detailed rationale:
+ # https://mesonbuild.com/FAQ.html#why-does-building-my-project-with-msvc-output-static-libraries-called-libfooa
if not hasattr(self, 'prefix'):
self.prefix = 'lib'
if not hasattr(self, 'suffix'):
@@ -2145,10 +2137,6 @@ class SharedLibrary(BuildTarget):
self.vs_module_defs = None
# The import library this target will generate
self.import_filename = None
- # The import library that Visual Studio would generate (and accept)
- self.vs_import_filename = None
- # The import library that GCC would generate (and prefer)
- self.gcc_import_filename = None
# The debugging information file this target will generate
self.debug_filename = None
# Use by the pkgconfig module
@@ -2203,21 +2191,16 @@ class SharedLibrary(BuildTarget):
The template is needed while creating aliases (self.get_aliases),
which are needed while generating .so shared libraries for Linux.
- Besides this, there's also the import library name, which is only used
- on Windows since on that platform the linker uses a separate library
- called the "import library" during linking instead of the shared
- library (DLL). The toolchain will output an import library in one of
- two formats: GCC or Visual Studio.
-
- When we're building with Visual Studio, the import library that will be
- generated by the toolchain is self.vs_import_filename, and with
- MinGW/GCC, it's self.gcc_import_filename. self.import_filename will
- always contain the import library name this target will generate.
+ Besides this, there's also the import library name (self.import_filename),
+ which is only used on Windows since on that platform the linker uses a
+ separate library called the "import library" during linking instead of
+ the shared library (DLL).
"""
prefix = ''
suffix = ''
create_debug_file = False
self.filename_tpl = self.basic_filename_tpl
+ import_filename_tpl = None
# NOTE: manual prefix/suffix override is currently only tested for C/C++
# C# and Mono
if 'cs' in self.compilers:
@@ -2230,20 +2213,18 @@ class SharedLibrary(BuildTarget):
# For all other targets/platforms import_filename stays None
elif self.environment.machines[self.for_machine].is_windows():
suffix = 'dll'
- self.vs_import_filename = '{}{}.lib'.format(self.prefix if self.prefix is not None else '', self.name)
- self.gcc_import_filename = '{}{}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
if self.uses_rust():
# Shared library is of the form foo.dll
prefix = ''
# Import library is called foo.dll.lib
- self.import_filename = f'{self.name}.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.get_option(OptionKey("debug"))
elif self.get_using_msvc():
# Shared library is of the form foo.dll
prefix = ''
# Import library is called foo.lib
- self.import_filename = self.vs_import_filename
+ import_filename_tpl = '{0.prefix}{0.name}.lib'
# .pdb file is only created when debug symbols are enabled
create_debug_file = self.environment.coredata.get_option(OptionKey("debug"))
# Assume GCC-compatible naming
@@ -2251,7 +2232,7 @@ class SharedLibrary(BuildTarget):
# Shared library is of the form libfoo.dll
prefix = 'lib'
# Import library is called libfoo.dll.a
- self.import_filename = self.gcc_import_filename
+ import_filename_tpl = '{0.prefix}{0.name}.dll.a'
# Shared library has the soversion if it is defined
if self.soversion:
self.filename_tpl = '{0.prefix}{0.name}-{0.soversion}.{0.suffix}'
@@ -2259,12 +2240,12 @@ class SharedLibrary(BuildTarget):
self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
elif self.environment.machines[self.for_machine].is_cygwin():
suffix = 'dll'
- self.gcc_import_filename = '{}{}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
# Shared library is of the form cygfoo.dll
# (ld --dll-search-prefix=cyg is the default)
prefix = 'cyg'
# Import library is called libfoo.dll.a
- self.import_filename = self.gcc_import_filename
+ import_prefix = self.prefix if self.prefix is not None else 'lib'
+ import_filename_tpl = import_prefix + '{0.name}.dll.a'
if self.soversion:
self.filename_tpl = '{0.prefix}{0.name}-{0.soversion}.{0.suffix}'
else:
@@ -2301,6 +2282,8 @@ class SharedLibrary(BuildTarget):
if self.suffix is None:
self.suffix = suffix
self.filename = self.filename_tpl.format(self)
+ if import_filename_tpl:
+ self.import_filename = import_filename_tpl.format(self)
# There may have been more outputs added by the time we get here, so
# only replace the first entry
self.outputs[0] = self.filename
@@ -2370,11 +2353,6 @@ class SharedLibrary(BuildTarget):
"""
return self.debug_filename
- def get_import_filenameslist(self):
- if self.import_filename:
- return [self.vs_import_filename, self.gcc_import_filename]
- return []
-
def get_all_link_deps(self):
return [self] + self.get_transitive_link_deps()