Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright (C) 2025 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 17 | """Finalizes the current compatibility matrix and allows `next` targets to |
| 18 | |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 19 | use the new FCM. |
| 20 | """ |
| 21 | |
| 22 | import argparse |
| 23 | import os |
| 24 | import pathlib |
| 25 | import re |
| 26 | import subprocess |
| 27 | import textwrap |
| 28 | |
| 29 | |
| 30 | def check_call(*args, **kwargs): |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 31 | print(args) |
| 32 | subprocess.check_call(*args, **kwargs) |
| 33 | |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 34 | |
| 35 | def check_output(*args, **kwargs): |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 36 | print(args) |
| 37 | return subprocess.check_output(*args, **kwargs) |
| 38 | |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 39 | |
| 40 | class Bump(object): |
| 41 | |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 42 | def __init__(self, cmdline_args): |
| 43 | self.top = pathlib.Path(os.environ["ANDROID_BUILD_TOP"]) |
| 44 | self.interfaces_dir = self.top / "hardware/interfaces" |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 45 | |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 46 | self.current_level = cmdline_args.current_level |
| 47 | self.current_module_name = ( |
| 48 | f"framework_compatibility_matrix.{self.current_level}.xml" |
| 49 | ) |
| 50 | self.device_module_name = "framework_compatibility_matrix.device.xml" |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 51 | |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 52 | def run(self): |
| 53 | self.edit_android_bp() |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 54 | |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 55 | def edit_android_bp(self): |
| 56 | android_bp = self.interfaces_dir / "compatibility_matrices/Android.bp" |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 57 | |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 58 | # update the SYSTEM_MATRIX_DEPS variable to unconditionally include the |
| 59 | # latests FCM. This adds the file to `next` configs so releasing devices |
| 60 | # can use the latest interfaces. |
| 61 | lines = [] |
| 62 | with open(android_bp) as f: |
| 63 | for line in f: |
| 64 | if f' "{self.device_module_name}",\n' in line: |
| 65 | lines.append(f' "{self.current_module_name}",\n') |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 66 | |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 67 | lines.append(line) |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 68 | |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 69 | with open(android_bp, "w") as f: |
| 70 | f.write("".join(lines)) |
| 71 | |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 72 | |
| 73 | def main(): |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 74 | parser = argparse.ArgumentParser(description=__doc__) |
| 75 | parser.add_argument( |
| 76 | "current_level", |
| 77 | type=str, |
| 78 | help="VINTF level of the current version (e.g. 202404)", |
| 79 | ) |
| 80 | cmdline_args = parser.parse_args() |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 81 | |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 82 | Bump(cmdline_args).run() |
Devin Moore | faa5b0e | 2025-01-08 18:36:14 +0000 | [diff] [blame] | 83 | |
| 84 | |
| 85 | if __name__ == "__main__": |
Devin Moore | 7a35400 | 2025-01-21 21:26:41 +0000 | [diff] [blame] | 86 | main() |