|
|
|
@ -2141,7 +2141,7 @@ class SharedLibrary(BuildTarget): |
|
|
|
|
self.soversion: T.Optional[str] = None |
|
|
|
|
self.ltversion: T.Optional[str] = None |
|
|
|
|
# Max length 2, first element is compatibility_version, second is current_version |
|
|
|
|
self.darwin_versions = [] |
|
|
|
|
self.darwin_versions: T.Optional[T.Tuple[str, str]] = None |
|
|
|
|
self.vs_module_defs = None |
|
|
|
|
# The import library this target will generate |
|
|
|
|
self.import_filename = None |
|
|
|
@ -2307,44 +2307,6 @@ class SharedLibrary(BuildTarget): |
|
|
|
|
if create_debug_file: |
|
|
|
|
self.debug_filename = os.path.splitext(self.filename)[0] + '.pdb' |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def _validate_darwin_versions(darwin_versions): |
|
|
|
|
try: |
|
|
|
|
if isinstance(darwin_versions, int): |
|
|
|
|
darwin_versions = str(darwin_versions) |
|
|
|
|
if isinstance(darwin_versions, str): |
|
|
|
|
darwin_versions = 2 * [darwin_versions] |
|
|
|
|
if not isinstance(darwin_versions, list): |
|
|
|
|
raise InvalidArguments('Shared library darwin_versions: must be a string, integer,' |
|
|
|
|
f'or a list, not {darwin_versions!r}') |
|
|
|
|
if len(darwin_versions) > 2: |
|
|
|
|
raise InvalidArguments('Shared library darwin_versions: list must contain 2 or fewer elements') |
|
|
|
|
if len(darwin_versions) == 1: |
|
|
|
|
darwin_versions = 2 * darwin_versions |
|
|
|
|
for i, v in enumerate(darwin_versions[:]): |
|
|
|
|
if isinstance(v, int): |
|
|
|
|
v = str(v) |
|
|
|
|
if not isinstance(v, str): |
|
|
|
|
raise InvalidArguments('Shared library darwin_versions: list elements ' |
|
|
|
|
f'must be strings or integers, not {v!r}') |
|
|
|
|
if not re.fullmatch(r'[0-9]+(\.[0-9]+){0,2}', v): |
|
|
|
|
raise InvalidArguments('Shared library darwin_versions: must be X.Y.Z where ' |
|
|
|
|
'X, Y, Z are numbers, and Y and Z are optional') |
|
|
|
|
parts = v.split('.') |
|
|
|
|
if len(parts) in {1, 2, 3} and int(parts[0]) > 65535: |
|
|
|
|
raise InvalidArguments('Shared library darwin_versions: must be X.Y.Z ' |
|
|
|
|
'where X is [0, 65535] and Y, Z are optional') |
|
|
|
|
if len(parts) in {2, 3} and int(parts[1]) > 255: |
|
|
|
|
raise InvalidArguments('Shared library darwin_versions: must be X.Y.Z ' |
|
|
|
|
'where Y is [0, 255] and Y, Z are optional') |
|
|
|
|
if len(parts) == 3 and int(parts[2]) > 255: |
|
|
|
|
raise InvalidArguments('Shared library darwin_versions: must be X.Y.Z ' |
|
|
|
|
'where Z is [0, 255] and Y, Z are optional') |
|
|
|
|
darwin_versions[i] = v |
|
|
|
|
except ValueError: |
|
|
|
|
raise InvalidArguments('Shared library darwin_versions: value is invalid') |
|
|
|
|
return darwin_versions |
|
|
|
|
|
|
|
|
|
def process_kwargs(self, kwargs): |
|
|
|
|
super().process_kwargs(kwargs) |
|
|
|
|
|
|
|
|
@ -2358,11 +2320,10 @@ class SharedLibrary(BuildTarget): |
|
|
|
|
# number of the version by default. |
|
|
|
|
self.soversion = self.ltversion.split('.')[0] |
|
|
|
|
# macOS, iOS and tvOS dylib compatibility_version and current_version |
|
|
|
|
if 'darwin_versions' in kwargs: |
|
|
|
|
self.darwin_versions = self._validate_darwin_versions(kwargs['darwin_versions']) |
|
|
|
|
elif self.soversion: |
|
|
|
|
self.darwin_versions = T.cast('T.Optional[T.Tuple[str, str]]', kwargs.get('darwin_versions')) |
|
|
|
|
if self.darwin_versions is None and self.soversion is not None: |
|
|
|
|
# If unspecified, pick the soversion |
|
|
|
|
self.darwin_versions = 2 * [self.soversion] |
|
|
|
|
self.darwin_versions = (self.soversion, self.soversion) |
|
|
|
|
|
|
|
|
|
# Visual Studio module-definitions file |
|
|
|
|
if 'vs_module_defs' in kwargs: |
|
|
|
|