]> granicus.if.org Git - graphviz/commitdiff
Add ci/generate-configuration-table.py
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Sun, 7 Jun 2020 14:05:58 +0000 (16:05 +0200)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Sat, 13 Jun 2020 06:16:54 +0000 (08:16 +0200)
ci/generate-configuration-table.py [new file with mode: 0755]

diff --git a/ci/generate-configuration-table.py b/ci/generate-configuration-table.py
new file mode 100755 (executable)
index 0000000..6afcf0d
--- /dev/null
@@ -0,0 +1,50 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+
+from optparse import OptionParser
+import os
+
+def main():
+    parser = OptionParser(usage='usage: %prog [options] files...')
+    parser.description = 'Generate a table of the Graphviz compile ' \
+    'configuration for different platforms from files generated by the ' \
+    './configure command.'
+    parser.add_option('-v', '--verbose', action='store_true',
+                      dest='verbose', default=False,
+                      help='Log info about what is going on')
+
+    (opts, args) = parser.parse_args()
+
+    table = {}
+    table_sections = []
+    component_names = {}
+    platforms = []
+
+    for filename in args:
+        os_path = os.path.dirname(filename)
+        os_version_id = os.path.basename(os_path)
+        os_id = os.path.basename(os.path.dirname(os_path))
+        platform = os_id.capitalize() + ' ' + os_version_id
+        if platform not in platforms:
+            platforms.append(platform)
+        fp = open(filename, 'r')
+        lines = fp.readlines()
+        for line in lines:
+            item = [item.strip() for item in line.split(':')]
+            if len(item) == 2:
+                if item[1] == '':
+                    section_name = item[0]
+                    if section_name not in table:
+                        table[section_name] = {};
+                        table_sections.append(section_name)
+                        component_names[section_name] = []
+                else:
+                    component_name, component_value = item;
+                    if component_name not in table[section_name]:
+                        table[section_name][component_name] = {};
+                        component_names[section_name].append(component_name)
+                    table[section_name][component_name][platform] = component_value
+
+# Python trick to get a main routine
+if __name__ == "__main__":
+    main()