(
input_file: TextIOBase,
output_file: TextIOBase,
library_name: str,
version: str)
| 55 | |
| 56 | |
| 57 | def write_header( |
| 58 | input_file: TextIOBase, |
| 59 | output_file: TextIOBase, |
| 60 | library_name: str, |
| 61 | version: str): |
| 62 | if "-" in version: |
| 63 | version, version_tag = version.split("-") |
| 64 | else: |
| 65 | version_tag = "" |
| 66 | version_major, version_minor, version_micro = [int(v) for v in version.split(".")] |
| 67 | |
| 68 | encoded_versions = generate_encoded_versions(library_name) |
| 69 | visibility_macros = generate_visibility_macros(library_name) |
| 70 | availability_macros = generate_availability_macros(library_name) |
| 71 | |
| 72 | replacements = { |
| 73 | "VERSION_MAJOR": str(version_major), |
| 74 | "VERSION_MINOR": str(version_minor), |
| 75 | "VERSION_MICRO": str(version_micro), |
| 76 | "VERSION_TAG": version_tag, |
| 77 | "ENCODED_VERSIONS": encoded_versions, |
| 78 | "VISIBILITY_MACROS": visibility_macros, |
| 79 | "AVAILABILITY_MACROS": availability_macros, |
| 80 | } |
| 81 | |
| 82 | output_file.write(re.sub( |
| 83 | r"@([A-Z_]+)@", lambda match: replacements[match[1]], input_file.read())) |
| 84 | |
| 85 | |
| 86 | def generate_visibility_macros(library: str) -> str: |
no test coverage detected