blob: 1938278262fb6e40ace5711936dd512d5bebb843 [file] [log] [blame]
Devin Moorefaa5b0e2025-01-08 18:36:14 +00001#!/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 Moore7a354002025-01-21 21:26:41 +000017"""Finalizes the current compatibility matrix and allows `next` targets to
18
Devin Moorefaa5b0e2025-01-08 18:36:14 +000019use the new FCM.
20"""
21
22import argparse
23import os
24import pathlib
25import re
26import subprocess
27import textwrap
28
29
30def check_call(*args, **kwargs):
Devin Moore7a354002025-01-21 21:26:41 +000031 print(args)
32 subprocess.check_call(*args, **kwargs)
33
Devin Moorefaa5b0e2025-01-08 18:36:14 +000034
35def check_output(*args, **kwargs):
Devin Moore7a354002025-01-21 21:26:41 +000036 print(args)
37 return subprocess.check_output(*args, **kwargs)
38
Devin Moorefaa5b0e2025-01-08 18:36:14 +000039
40class Bump(object):
41
Devin Moore7a354002025-01-21 21:26:41 +000042 def __init__(self, cmdline_args):
43 self.top = pathlib.Path(os.environ["ANDROID_BUILD_TOP"])
44 self.interfaces_dir = self.top / "hardware/interfaces"
Devin Moorefaa5b0e2025-01-08 18:36:14 +000045
Devin Moore7a354002025-01-21 21:26:41 +000046 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 Moorefaa5b0e2025-01-08 18:36:14 +000051
Devin Moore7a354002025-01-21 21:26:41 +000052 def run(self):
53 self.edit_android_bp()
Devin Moorefaa5b0e2025-01-08 18:36:14 +000054
Devin Moore7a354002025-01-21 21:26:41 +000055 def edit_android_bp(self):
56 android_bp = self.interfaces_dir / "compatibility_matrices/Android.bp"
Devin Moorefaa5b0e2025-01-08 18:36:14 +000057
Devin Moore7a354002025-01-21 21:26:41 +000058 # 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 Moorefaa5b0e2025-01-08 18:36:14 +000066
Devin Moore7a354002025-01-21 21:26:41 +000067 lines.append(line)
Devin Moorefaa5b0e2025-01-08 18:36:14 +000068
Devin Moore7a354002025-01-21 21:26:41 +000069 with open(android_bp, "w") as f:
70 f.write("".join(lines))
71
Devin Moorefaa5b0e2025-01-08 18:36:14 +000072
73def main():
Devin Moore7a354002025-01-21 21:26:41 +000074 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 Moorefaa5b0e2025-01-08 18:36:14 +000081
Devin Moore7a354002025-01-21 21:26:41 +000082 Bump(cmdline_args).run()
Devin Moorefaa5b0e2025-01-08 18:36:14 +000083
84
85if __name__ == "__main__":
Devin Moore7a354002025-01-21 21:26:41 +000086 main()