build: Support debug_rename and import_rename in exe, shlib and shmod

Executables, shared libraries and shared modules may all install two
additional files, an import library and a debuginfo file. Provide new
keyword arguments, 'import_rename', and 'debug_rename' so that these
can be installed with names matching the output filename when
using the 'rename' keyword argument.

Signed-off-by: Keith Packard <keithp@keithp.com>
pull/13960/head
Keith Packard 3 months ago
parent be0cc6005b
commit d4cece6478
  1. 16
      docs/yaml/functions/executable.yaml
  2. 16
      docs/yaml/functions/shared_library.yaml
  3. 16
      docs/yaml/functions/shared_module.yaml
  4. 4
      mesonbuild/backend/backends.py
  5. 54
      mesonbuild/build.py
  6. 9
      mesonbuild/interpreter/type_checking.py
  7. 8
      test cases/common/117 shared module/meson.build
  8. 4
      test cases/common/117 shared module/test.json

@ -57,3 +57,19 @@ kwargs:
This can be used to expose which functions a shared_module loaded by an
executable will be allowed to use.
import_rename:
type: str
since: 1.7.0
description: |
If specified, renames the import library during install. Nested
paths are allowed and they are joined with `install_dir`. If
the value is an empty string, then this feature is disabled.
debug_rename:
type: str
since: 1.7.0
description: |
If specified, renames the debuginfo file during install. Nested
paths are allowed and they are joined with `install_dir`. If
the value is an empty string, then this feature is disabled.

@ -54,3 +54,19 @@ kwargs:
Set the specific ABI to compile (when compiling rust).
- 'rust' (default): Create a "dylib" crate.
- 'c': Create a "cdylib" crate.
import_rename:
type: str
since: 1.7.0
description: |
If specified, renames the import library during install. Nested
paths are allowed and they are joined with `install_dir`. If
the value is an empty string, then this feature is disabled.
debug_rename:
type: str
since: 1.7.0
description: |
If specified, renames the debuginfo file during install. Nested
paths are allowed and they are joined with `install_dir`. If
the value is an empty string, then this feature is disabled.

@ -49,3 +49,19 @@ kwargs:
Set the specific ABI to compile (when compiling rust).
- 'rust' (default): Create a "dylib" crate.
- 'c': Create a "cdylib" crate.
import_rename:
type: str
since: 1.7.0
description: |
If specified, renames the import library during install. Nested
paths are allowed and they are joined with `install_dir`. If
the value is an empty string, then this feature is disabled.
debug_rename:
type: str
since: 1.7.0
description: |
If specified, renames the debuginfo file during install. Nested
paths are allowed and they are joined with `install_dir`. If
the value is an empty string, then this feature is disabled.

@ -1795,7 +1795,7 @@ class Backend:
implib_install_dir, first_outdir_name,
False, {}, set(), '', install_mode,
t.subproject, optional=isinstance(t, build.SharedModule),
tag='devel')
tag='devel', out_fname = t.get_import_rename())
d.targets.append(i)
if not should_strip and t.get_debug_filename():
@ -1804,7 +1804,7 @@ class Backend:
first_outdir_name,
False, {}, set(), '',
install_mode, t.subproject,
optional=True, tag='devel')
optional=True, tag='devel', out_fname = t.get_debug_rename())
d.targets.append(i)
# Install secondary outputs. Only used for Vala right now.
if num_outdirs > 1:

@ -113,9 +113,9 @@ known_build_target_kwargs = (
rust_kwargs |
cs_kwargs)
known_exe_kwargs = known_build_target_kwargs | {'implib', 'export_dynamic', 'pie', 'vs_module_defs'}
known_shlib_kwargs = known_build_target_kwargs | {'version', 'soversion', 'vs_module_defs', 'darwin_versions', 'rust_abi'}
known_shmod_kwargs = known_build_target_kwargs | {'vs_module_defs', 'rust_abi'}
known_exe_kwargs = known_build_target_kwargs | {'implib', 'export_dynamic', 'pie', 'vs_module_defs', 'import_rename', 'debug_rename'}
known_shlib_kwargs = known_build_target_kwargs | {'version', 'soversion', 'vs_module_defs', 'darwin_versions', 'rust_abi', 'import_rename', 'debug_rename'}
known_shmod_kwargs = known_build_target_kwargs | {'vs_module_defs', 'rust_abi', 'import_rename', 'debug_rename'}
known_stlib_kwargs = known_build_target_kwargs | {'pic', 'prelink', 'rust_abi'}
known_jar_kwargs = known_exe_kwargs | {'main_class', 'java_resources'}
@ -1973,6 +1973,10 @@ class Executable(BuildTarget):
# Remember that this exe was returned by `find_program()` through an override
self.was_returned_by_find_program = False
# Get renames for import library and debuginfo file
self.import_rename = kwargs.get('import_rename')
self.debug_rename = kwargs.get('debug_rename')
self.vs_module_defs: T.Optional[File] = None
self.process_vs_module_defs_kw(kwargs)
@ -2077,6 +2081,26 @@ class Executable(BuildTarget):
"""
return self.debug_filename
def get_import_rename(self) -> T.Optional[str]:
"""
The filename to be used while installing the import library
Returns None if no value was provided
"""
if self.import_rename:
return self.import_rename
return None
def get_debug_rename(self) -> T.Optional[str]:
"""
The filename to be used while installing the debug info
Returns None if no value was provided
"""
if self.debug_rename:
return self.debug_rename
return None
def is_linkable_target(self):
return self.is_linkwithable
@ -2406,6 +2430,10 @@ class SharedLibrary(BuildTarget):
# Visual Studio module-definitions file
self.process_vs_module_defs_kw(kwargs)
# Get renames for import library and debuginfo file
self.import_rename = kwargs.get('import_rename')
self.debug_rename = kwargs.get('debug_rename')
rust_abi = kwargs.get('rust_abi')
rust_crate_type = kwargs.get('rust_crate_type')
if rust_crate_type:
@ -2468,6 +2496,26 @@ class SharedLibrary(BuildTarget):
aliases.append((self.basic_filename_tpl.format(self), ltversion_filename, tag))
return aliases
def get_import_rename(self) -> T.Optional[str]:
"""
The filename to be used while installing the import library
Returns None if no value was provided
"""
if self.import_rename:
return self.import_rename
return None
def get_debug_rename(self) -> T.Optional[str]:
"""
The filename to be used while installing the debug info
Returns None if no value was provided
"""
if self.debug_rename:
return self.debug_rename
return None
def type_suffix(self):
return "@sha"

@ -705,6 +705,8 @@ _EXCLUSIVE_EXECUTABLE_KWS: T.List[KwargInfo] = [
convertor=lambda x: x.lower() if isinstance(x, str) else None,
validator=_validate_win_subsystem,
),
KwargInfo('debug_rename', str, default='', since='1.7.0'),
KwargInfo('import_rename', str, default='', since='1.7.0'),
]
# The total list of arguments used by Executable
@ -741,6 +743,8 @@ _EXCLUSIVE_SHARED_LIB_KWS: T.List[KwargInfo] = [
_DARWIN_VERSIONS_KW,
KwargInfo('soversion', (str, int, NoneType), convertor=lambda x: str(x) if x is not None else None),
KwargInfo('version', (str, NoneType), validator=_validate_shlib_version),
KwargInfo('debug_rename', str, default='', since='1.7.0'),
KwargInfo('import_rename', str, default='', since='1.7.0'),
]
# The total list of arguments used by SharedLibrary
@ -754,7 +758,10 @@ SHARED_LIB_KWS = [
# Arguments exclusive to SharedModule. These are separated to make integrating
# them into build_target easier
_EXCLUSIVE_SHARED_MOD_KWS: T.List[KwargInfo] = []
_EXCLUSIVE_SHARED_MOD_KWS: T.List[KwargInfo] = [
KwargInfo('debug_rename', str, default='', since='1.7.0'),
KwargInfo('import_rename', str, default='', since='1.7.0'),
]
# The total list of arguments used by SharedModule
SHARED_MOD_KWS = [

@ -34,12 +34,16 @@ test('import test', e, args : m)
m2 = build_target('mymodule2', 'module.c', target_type: 'shared_module')
test('import test 2', e, args : m2)
import_rename = 'subdir/libmymodule.dll.a'
debug_rename = ''
if target_machine.system() == 'windows'
rename = 'subdir/libmymodule.dll'
debug_rename = 'subdir/libmymodule.pdb'
elif target_machine.system() == 'darwin'
rename = 'subdir/libmymodule.dylib'
elif target_machine.system() == 'cygwin'
rename = 'subdir/cygmymodule.dll'
debug_rename = 'subdir/cygmymodule.pdb'
else
rename = 'subdir/libmymodule.so'
endif
@ -48,7 +52,9 @@ endif
m3 = shared_module('mymodule3', 'module.c',
install : true,
install_dir : join_paths(get_option('libdir'), 'modules'),
rename: rename)
rename: rename,
import_rename: import_rename,
debug_rename: debug_rename)
test('import test 3', e, args : m3)
# Shared module that does not export any symbols

@ -4,7 +4,7 @@
{"type": "implibempty", "file": "usr/lib/modules/libnosyms"},
{"type": "pdb", "file": "usr/lib/modules/nosyms"},
{"type": "expr", "file": "usr/lib/modules/subdir/libmymodule?so"},
{"type": "implib", "file": "usr/lib/modules/libmymodule3"},
{"type": "pdb", "file": "usr/lib/modules/mymodule3"}
{"type": "implib", "file": "usr/lib/modules/subdir/libmymodule"},
{"type": "pdb", "file": "usr/lib/modules/subdir/mymodule"}
]
}

Loading…
Cancel
Save