]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
sync_qemu_models_i386: Update meson.build
authorJiri Denemark <jdenemar@redhat.com>
Thu, 28 Nov 2024 12:39:29 +0000 (13:39 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 13 Dec 2024 13:41:56 +0000 (14:41 +0100)
When adding new CPU models to CPU map it's easy (and very common) to
forget to add the new files to meson.build. We already update index.xml
with the new models so updating meson.build too makes sense.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/cpu_map/sync_qemu_models_i386.py

index 798d767f4d64ec6af90602a43ccb11471fa5d43a..11fe1f7435ae9d7488cbe7c5b5fdf23597d17052 100755 (executable)
@@ -596,6 +596,32 @@ def update_index(outdir, models):
         f.write("\n")
 
 
+def update_meson(outdir, models):
+    meson = os.path.join(outdir, "meson.build")
+
+    with open(meson, "r") as f:
+        lines = f.readlines()
+
+    start = None
+    end = None
+    for i in range(len(lines)):
+        if start is None and lines[i].startswith("cpumap_data ="):
+            start = i + 1
+
+        if start is not None and lines[i] == "]\n":
+            end = i
+            break
+
+    xmls = lines[start:end]
+    for files in models.values():
+        xmls.extend([f"  '{file}',\n" for file in files])
+
+    with open(meson, "w") as f:
+        f.writelines(lines[:start])
+        f.writelines(sorted(xmls, key=str.lower))
+        f.writelines(lines[end:])
+
+
 def main():
     parser = argparse.ArgumentParser(
         description="Synchronize x86 cpu models from QEMU i386 target.")
@@ -658,6 +684,7 @@ def main():
             output_model(f, extra, model)
 
     update_index(args.outdir, files)
+    update_meson(args.outdir, files)
 
     features = set()
     for model in models: