blob: 7b86f428baa70b36ad986cdeb9f0ec71f0e7d7c5 (
plain)
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
|
import os
# patch the following
# QMAKE_CFLAGS add $(CFLAGS_EXTRA)
# QMAKE_CXXFLAGS add $(CXXFLAGS_EXTRA)
# QMAKE_LFLAGS add $(LFLAGS_EXTRA)
# QMAKE_LIBS add $(LIBS_EXTRA)
# QMAKE_CFLAGS_RELEASE include old argument
#
add_map = { "QMAKE_CFLAGS" : "$(CFLAGS_EXTRA)",
"QMAKE_CXXFLAGS" : "$(CXXFLAGS_EXTRA)",
"QMAKE_LFLAGS" : "$(LFLAGS_EXTRA)",
"QMAKE_LIBS" : "$(LIBS_EXTRA)" }
rep_map = { "QMAKE_CFLAGS_RELEASE" : ["$(if $(CFLAGS_RELEASE),$(CFLAGS_RELEASE),", ")"] }
def split_text(line):
"""
SPlits the text in the form of "key = value"
and returns a two tuple-tuple
"""
## disabled strip and split tab stuff
left = line.find('=')
if left == -1:
raise Exception, "No src line"
key = line[0:left].strip()
val = line[left+1:].strip()
return (key,val)
def apply_line(line):
"""
Apply changes to a line. This will not handle the exception
thrown by split_text
"""
key,val = split_text(line)
tabs = '\t'
if len(key) <= 14:
tabs = tabs + '\t'
spac = ''
if len(val) != 0:
spac = ' '
# for minimal changes on the file we've three returns
if add_map.has_key(key):
val = val + spac + add_map[key]
return key + tabs + '= ' + val + '\n'
elif rep_map.has_key(key):
val = rep_map[key][0] + ' ' + val + rep_map[key][1]
return key + tabs + '= ' + val + '\n'
return line
def apply_on_file(fi):
"""
Apply the maps on files
"""
lines = []
for line in file(fi):
try:
line = apply_line(line)
except:
pass
lines.append(line)
f = file(fi,'w')
for line in lines:
f.write(line)
def fix_it():
for root, dirs, files in os.walk('./mkspecs'):
for fil in files:
print root + '/' + fil
apply_on_file(root+'/'+fil)
if __name__ == '__main__':
fix_it()
|