• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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#
17"""Finalizes the current compatibility matrix and allows `next` targets to
18
19use the new FCM.
20"""
21
22import argparse
23import os
24import pathlib
25import re
26import subprocess
27import textwrap
28
29
30def check_call(*args, **kwargs):
31  print(args)
32  subprocess.check_call(*args, **kwargs)
33
34
35def check_output(*args, **kwargs):
36  print(args)
37  return subprocess.check_output(*args, **kwargs)
38
39
40class Bump(object):
41
42  def __init__(self, cmdline_args):
43    self.top = pathlib.Path(os.environ["ANDROID_BUILD_TOP"])
44    self.interfaces_dir = self.top / "hardware/interfaces"
45
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"
51
52  def run(self):
53    self.edit_android_bp()
54
55  def edit_android_bp(self):
56    android_bp = self.interfaces_dir / "compatibility_matrices/Android.bp"
57
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')
66
67        lines.append(line)
68
69    with open(android_bp, "w") as f:
70      f.write("".join(lines))
71
72
73def main():
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()
81
82  Bump(cmdline_args).run()
83
84
85if __name__ == "__main__":
86  main()
87