fix using a CustomTargetIndex for vs_module_defs
Because `CustomTargetIndex`es don't have a `subdir` property, but they do implement the `get_subdir()` method
This commit is contained in:
parent
f4ea89be60
commit
5421c24ea0
|
@ -0,0 +1,8 @@
|
|||
## vs_module_defs keyword now supports indexes of custom_target
|
||||
|
||||
This means you can do something like:
|
||||
```meson
|
||||
defs = custom_target('generate_module_defs', ...)
|
||||
shared_library('lib1', vs_module_defs : defs[0])
|
||||
shared_library('lib2', vs_module_defs : defs[2])
|
||||
```
|
|
@ -45,6 +45,8 @@ kwargs:
|
|||
Specify a Microsoft module definition file for controlling symbol exports,
|
||||
etc., on platforms where that is possible (e.g. Windows).
|
||||
|
||||
*(Since 1.3.0)* [[@custom_idx]] are supported
|
||||
|
||||
rust_abi:
|
||||
type: str
|
||||
since: 1.3.0
|
||||
|
|
|
@ -40,6 +40,8 @@ kwargs:
|
|||
Specify a Microsoft module definition file for controlling symbol exports,
|
||||
etc., on platforms where that is possible (e.g. Windows).
|
||||
|
||||
*(Since 1.3.0)* [[@custom_idx]] are supported
|
||||
|
||||
rust_abi:
|
||||
type: str
|
||||
since: 1.3.0
|
||||
|
|
|
@ -2331,13 +2331,13 @@ class SharedLibrary(BuildTarget):
|
|||
elif isinstance(path, File):
|
||||
# When passing a generated file.
|
||||
self.vs_module_defs = path
|
||||
elif isinstance(path, CustomTarget):
|
||||
elif isinstance(path, (CustomTarget, CustomTargetIndex)):
|
||||
# When passing output of a Custom Target
|
||||
self.vs_module_defs = File.from_built_file(path.subdir, path.get_filename())
|
||||
self.vs_module_defs = File.from_built_file(path.get_subdir(), path.get_filename())
|
||||
else:
|
||||
raise InvalidArguments(
|
||||
'Shared library vs_module_defs must be either a string, '
|
||||
'a file object or a Custom Target')
|
||||
'a file object, a Custom Target, or a Custom Target Index')
|
||||
self.process_link_depends(path)
|
||||
|
||||
rust_abi = kwargs.get('rust_abi')
|
||||
|
|
|
@ -359,7 +359,7 @@ class _SharedLibMixin(TypedDict):
|
|||
darwin_versions: T.Optional[T.Tuple[str, str]]
|
||||
soversion: T.Optional[str]
|
||||
version: T.Optional[str]
|
||||
vs_module_defs: T.Optional[T.Union[str, File, build.CustomTarget]]
|
||||
vs_module_defs: T.Optional[T.Union[str, File, build.CustomTarget, build.CustomTargetIndex]]
|
||||
|
||||
|
||||
class SharedLibrary(_BuildTarget, _SharedLibMixin, _LibraryMixin):
|
||||
|
@ -368,7 +368,7 @@ class SharedLibrary(_BuildTarget, _SharedLibMixin, _LibraryMixin):
|
|||
|
||||
class SharedModule(_BuildTarget, _LibraryMixin):
|
||||
|
||||
vs_module_defs: T.Optional[T.Union[str, File, build.CustomTarget]]
|
||||
vs_module_defs: T.Optional[T.Union[str, File, build.CustomTarget, build.CustomTargetIndex]]
|
||||
|
||||
|
||||
class Library(_BuildTarget, _SharedLibMixin, _StaticLibMixin, _LibraryMixin):
|
||||
|
|
|
@ -513,9 +513,10 @@ RUST_ABI_KW: KwargInfo[T.Union[str, None]] = KwargInfo(
|
|||
since='1.3.0',
|
||||
validator=in_set_validator({'rust', 'c'}))
|
||||
|
||||
_VS_MODULE_DEFS_KW: KwargInfo[T.Optional[T.Union[str, File, CustomTarget]]] = KwargInfo(
|
||||
_VS_MODULE_DEFS_KW: KwargInfo[T.Optional[T.Union[str, File, CustomTarget, CustomTargetIndex]]] = KwargInfo(
|
||||
'vs_module_defs',
|
||||
(str, File, CustomTarget, NoneType),
|
||||
(str, File, CustomTarget, CustomTargetIndex, NoneType),
|
||||
since_values={CustomTargetIndex: '1.3.0'}
|
||||
)
|
||||
|
||||
# Applies to all build_target like classes
|
||||
|
|
|
@ -5,3 +5,5 @@ def_file = custom_target('gen_def',
|
|||
output: 'somedll.def')
|
||||
|
||||
shlib = shared_library('somedll', 'somedll.c', vs_module_defs: def_file)
|
||||
|
||||
shared_library('somedll2', 'somedll.c', vs_module_defs: def_file[0])
|
||||
|
|
Loading…
Reference in New Issue