Debian Codegraph @

data/generators/qmake-gen.py

raw
1 #!/usr/bin/env python
2
3 # SPDX-FileCopyrightText: 2016 Kevin Funk <[email protected]>
4 #
5 # SPDX-License-Identifier: LGPL-2.0-or-later
6
7 # This script will print XML-like code you can put into the qmake.xml
8 # syntax definition file
9 #
10 # Prerequisite: You need to have a qtbase checkout somewhere
11 #
12 # Usage: qmake-gen.py /path/to/qtbase/
13
14 from __future__ import print_function
15
16 import subprocess
17 import os
18 import sys
19
20 qt5Source = sys.argv[1]
21
22 qmakeKeywords = subprocess.check_output("ag --nofilename 'QMAKE_[A-Z_0-9]+' {0}/mkspecs -o".format(qt5Source), shell=True).split(os.linesep)
23 extraKeywords = subprocess.check_output("sed -nr 's/\\\section1 ([A-Z_0-9]{{2,100}}).*/\\1/p' {0}/qmake/doc/src/qmake-manual.qdoc".format(qt5Source), shell=True).split(os.linesep)
24 keywords = []
25 keywords = [x.strip() for x in qmakeKeywords]
26 keywords += [x.strip() for x in extraKeywords]
27 keywords = list(set(keywords)) # remove duplicates
28 keywords.sort()
29
30 functions = subprocess.check_output("sed -nr 's/\{{ \\\"(.+)\\\", T_.+/\\1/p' {0}/qmake/library/qmakebuiltins.cpp".format(qt5Source), shell=True).split(os.linesep)
31 functions.sort()
32
33 def printItems(container):
34 for item in container:
35 trimmedText = item.strip()
36 if not trimmedText:
37 continue
38
39 print("<item> %s </item>" % trimmedText)
40 print()
41
42 print("KEYWORDS")
43 printItems(keywords)
44
45 print("FUNCTIONS")
46 printItems(functions)