Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4be20f79 authored by Devin Moore's avatar Devin Moore
Browse files

Update bump.py for Trunk Stable

The next year's compatbility matrix is added to a conditional statement
so it's only available on in-development release configurations.

The curent year's compatibility matrix is moved from the conditional
statement to always be added to all release configs.

The next year's compatibility matrix level is set to the next year's
level after copying the current matrix file.

Test: ./bump.py
Bug: 279809333

Change-Id: Id711ba79110c8775f715eddf37a9bf51b073ec91
parent 7ad57972
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ class Bump(object):
        self.current_level = cmdline_args.current
        self.current_module_name = f"framework_compatibility_matrix.{self.current_level}.xml"
        self.current_xml = self.interfaces_dir / f"compatibility_matrices/compatibility_matrix.{self.current_level}.xml"
        self.device_module_name = "framework_compatibility_matrix.device.xml"

        self.next_level = cmdline_args.next
        self.next_module_name = f"framework_compatibility_matrix.{self.next_level}.xml"
@@ -81,7 +82,8 @@ class Bump(object):
        ])

    def copy_matrix(self):
        shutil.copyfile(self.current_xml, self.next_xml)
        with open(self.current_xml) as f_current, open(self.next_xml, "w") as f_next:
            f_next.write(f_current.read().replace(f"level=\"{self.current_level}\"", f"level=\"{self.next_level}\""))

    def edit_android_bp(self):
        android_bp = self.interfaces_dir / "compatibility_matrices/Android.bp"
@@ -124,19 +126,20 @@ class Bump(object):

    def edit_android_mk(self):
        android_mk = self.interfaces_dir / "compatibility_matrices/Android.mk"
        lines = []
        with open(android_mk) as f:
            if self.next_module_name in f.read():
                return
            f.seek(0)
            lines = f.readlines()
        current_module_line_number = None
        for line_number, line in enumerate(lines):
            for line in f:
              if f"    {self.device_module_name} \\\n" in line:
                  lines.append(f"    {self.current_module_name} \\\n")

              if self.current_module_name in line:
                current_module_line_number = line_number
                break
        assert current_module_line_number is not None
        lines.insert(current_module_line_number + 1,
                     f"    {self.next_module_name} \\\n")
                  lines.append(f"    {self.next_module_name} \\\n")
              else:
                  lines.append(line)

        with open(android_mk, "w") as f:
            f.write("".join(lines))