86 def GetAddMenuItems(): |
86 def GetAddMenuItems(): |
87 return ExtractMenuItemsFromCatalog(features.catalog) |
87 return ExtractMenuItemsFromCatalog(features.catalog) |
88 |
88 |
89 class Iec2CSettings(): |
89 class Iec2CSettings(): |
90 def __init__(self): |
90 def __init__(self): |
91 self.iec2c = os.path.join(base_folder, "matiec", "iec2c"+(".exe" if wx.Platform == '__WXMSW__' else "")) |
91 self.iec2c = None |
92 self.iec2c_buildopts = None |
92 self.iec2c_buildopts = None |
93 self.ieclib_path = os.path.join(base_folder, "matiec", "lib") |
93 self.ieclib_path = self.findLibPath() |
94 self.ieclib_c_path = None |
94 self.ieclib_c_path = self.findLibCPath() |
95 |
95 |
|
96 def findObject(self, paths, test): |
|
97 path=None |
|
98 for p in paths: |
|
99 if test(p): |
|
100 path = p |
|
101 break |
|
102 return path |
|
103 |
|
104 def findCmd(self): |
|
105 cmd="iec2c"+(".exe" if wx.Platform == '__WXMSW__' else "") |
|
106 paths=[ |
|
107 os.path.join(base_folder, "matiec") |
|
108 ] |
|
109 path = self.findObject(paths, lambda p:os.path.isfile(os.path.join(p, cmd))) |
|
110 |
|
111 # otherwise use iec2c from PATH |
|
112 if path is not None: |
|
113 cmd=os.path.join(path, cmd) |
|
114 |
|
115 return cmd |
|
116 |
|
117 def findLibPath(self): |
|
118 paths=[ |
|
119 os.path.join(base_folder, "matiec", "lib"), |
|
120 "/usr/lib/matiec" |
|
121 ] |
|
122 path = self.findObject(paths, lambda p:os.path.isfile(os.path.join(p, "ieclib.txt"))) |
|
123 return path |
|
124 |
96 def findLibCPath(self): |
125 def findLibCPath(self): |
97 path="" |
126 path=None |
98 paths=[ |
127 paths=[ |
99 os.path.join(base_folder, "matiec", "lib", "C"), |
128 os.path.join(self.ieclib_path, "C"), |
100 os.path.join(base_folder, "matiec", "lib") ] |
129 self.ieclib_path] |
101 for p in paths: |
130 path = self.findObject(paths, lambda p:os.path.isfile(os.path.join(p, "iec_types.h"))) |
102 filename=os.path.join(p, "iec_types.h") |
|
103 if (os.path.isfile(filename)): |
|
104 path = p |
|
105 break |
|
106 return path |
131 return path |
107 |
132 |
108 def findSupportedOptions(self): |
133 def findSupportedOptions(self): |
109 buildcmd = "\"%s\" -h"%(self.iec2c) |
134 buildcmd = "\"%s\" -h"%(self.getCmd()) |
110 options =["-f", "-l", "-p"] |
135 options =["-f", "-l", "-p"] |
111 |
136 |
112 buildopt = "" |
137 buildopt = "" |
113 try: |
138 try: |
114 # Invoke compiler. Output files are listed to stdout, errors to stderr |
139 # Invoke compiler. Output files are listed to stdout, errors to stderr |