1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#!/usr/bin/env python
# Run this from the UI/Qt dir with:
# ./qmakeish.py ../../Makefile > Swiften.pri
import sys, re, os.path
def processSourcesLine(line) :
strippedLine = line.rstrip("\n")
sourceFile = re.sub("\\\\$", "", strippedLine).strip()
if len(sourceFile) > 0 :
print "SOURCES += $$PWD/../../" + sourceFile
return strippedLine.endswith("\\")
def processFlags(name, flags) :
flags = flags.replace("-isystem ", "-I")
for flag in flags.split(" ") :
if flag.startswith("-D") :
print "DEFINES += " + flag[2:]
elif flag.startswith("-I") :
print "INCLUDEPATH += $$PWD/../../" + flag[2:]
elif len(flag) > 0 :
print name + " += " + flag
assert(len(sys.argv) == 2)
basedir = os.path.dirname(sys.argv[1])
# Flatten the makefile
makefile = []
files = [open(sys.argv[1])]
while len(files) > 0 :
file = files[-1]
line = file.readline()
if line :
match = re.match("include (.*)", line)
if match and match.group(1) != "Makefile.config" :
files.append(open(os.path.join(basedir, match.group(1))))
makefile.append("## Begin File: " + match.group(1))
else :
makefile.append(line)
else :
makefile.append("## End file")
file.close()
files.pop()
# Process makefile
inSources = False
for line in makefile :
if inSources :
inSources = processSourcesLine(line)
else :
# Conditional
match = re.match("if(n?)eq \(\$\((.*)\),(.*)\)", line)
if match :
conditional = match.group(2)
if conditional == "WIN32" :
conditional = "win32"
elif conditional == "MACOSX" :
conditional = "mac"
elif match.group(2).startswith("HAVE_") or match.group(2).startswith("USE_") :
conditional = "!isEmpty(" + match.group(2) + ")"
else :
conditional = "DUMMY"
if (match.group(1) == "n") ^ (match.group(3) not in ["1", "yes"]) :
conditional = "!" + conditional
print conditional + " {"
continue
if re.match("^if(n?)def", line) :
print "DUMMY {"
continue
elif re.match("^if(n?)eq", line) :
print "DUMMY {"
continue
if re.match("^else$", line) :
print "} else {"
continue
if re.match("^endif$", line) :
print "}"
continue
match = re.match("(\w+)_SOURCES (\+?)= (.*)", line)
if match and match.group(1) in ["SWIFTEN", "ZLIB", "LIBIDN", "BOOST", "EXPAT"] :
inSources = processSourcesLine(match.group(3))
continue
match = re.match("(LIBS|CXXFLAGS|CPPFLAGS|CFLAGS) \+= (.*)", line)
if match :
processFlags(match.group(1), match.group(2))
if line.startswith("## ") :
print line
"""
#print sourceFiles
sys.exit(0)
print files
pro = open ('swiftall.pri', 'w')
for sourceType in files.keys():
pro.write("%s += \\\n" % sourceType)
for sourceFile in files[sourceType]:
pro.write("$$PWD/Swift/%s \\\n" % sourceFile)
pro.write("\n")
pro.close()
"""
|