-
Notifications
You must be signed in to change notification settings - Fork 0
/
OptionManager.py
executable file
·85 lines (67 loc) · 2.99 KB
/
OptionManager.py
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
import os
import sys
import Helper
class OptionManager:
def __init__(self):
pass
def readOption(self, f):
options = ""
for line in f:
line = Helper.trim_comment(line)
line = line.rstrip()
if not line == "":
# print "len: ", len(line)
options += line + " "
options = options.rstrip()
return options
def getOptionFilePath(self, filename, config):
optionFilePath = filename + "-" + config + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
if filename.endswith(".cpp") or filename.endswith(".h"):
optionFilePath = "generalcxx" + "-" + config + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
optionFilePath = "generalcxx" + "-" + "any" + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
epmdir = os.path.dirname(sys.argv[0]) + "/"
optionFilePath = epmdir + "defaultcxx" + "-" + config + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
optionFilePath = epmdir + "defaultcxx" + "-" + "any" + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
elif filename.endswith(".c"):
optionFilePath = "generalc" + "-" + config + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
optionFilePath = "generalc" + "-" + "any" + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
epmdir = os.path.dirname(sys.argv[0]) + "/"
optionFilePath = epmdir + "defaultc" + "-" + config + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
optionFilePath = epmdir + "defaultc" + "-" + "any" + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
else:
optionFilePath = "generallink" + "-" + config + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
optionFilePath = "generallink" + "-" + "any" + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
epmdir = os.path.dirname(sys.argv[0]) + "/"
optionFilePath = epmdir + "defaultlink" + "-" + config + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
optionFilePath = epmdir + "defaultlink" + "-" + "any" + ".options"
if os.access(optionFilePath, os.R_OK):
return optionFilePath
return ""
def getOptionFor(self, filename, config):
optionFilePath = self.getOptionFilePath(filename, config)
f = open(optionFilePath, 'r')
return self.readOption(f)