| 185 | self.is_makeing_project = False |
| 186 | |
| 187 | def read_setting(self): |
| 188 | import platform |
| 189 | import os |
| 190 | |
| 191 | home = '' |
| 192 | if platform.system() == 'Windows': |
| 193 | driver = os.environ['HOMEDRIVE'] |
| 194 | home = os.environ['HOMEPATH'] |
| 195 | home = os.path.join(driver, home) |
| 196 | else: |
| 197 | home = os.environ['HOME'] |
| 198 | |
| 199 | setting_path = os.path.join(home, '.rtt_scons') |
| 200 | if os.path.exists(setting_path): |
| 201 | setting = open(os.path.join(home, '.rtt_scons')) |
| 202 | for line in setting: |
| 203 | line = line.replace('\n', '') |
| 204 | line = line.replace('\r', '') |
| 205 | if line.find('=') != -1: |
| 206 | items = line.split('=') |
| 207 | if items[0] == 'RTTRoot': |
| 208 | self.RTTRoot.set_path(items[1]) |
| 209 | elif items[0] == 'BSPRoot': |
| 210 | self.BSPRoot.set_path(items[1]) |
| 211 | elif items[0] == 'compiler': |
| 212 | compiler = items[1] |
| 213 | else: |
| 214 | self.CompilersPath[items[0]].set_path(items[1]) |
| 215 | setting.close() |
| 216 | |
| 217 | # set RT-Thread Root Directory according environ |
| 218 | if 'RTT_ROOT' in os.environ: |
| 219 | self.RTTRoot.set_path(os.environ['RTT_ROOT']) |
| 220 | |
| 221 | if self.RTTRoot.get_path() == '': |
| 222 | rtt_root = '' |
| 223 | # detect RT-Thread directory |
| 224 | if os.path.exists(os.path.join('..', 'include', 'rtthread.h')): |
| 225 | rtt_root = os.path.join('..') |
| 226 | elif os.path.exists(os.path.join('..', '..', 'include', 'rtthread.h')): |
| 227 | rtt_root = os.path.join('..', '..') |
| 228 | if rtt_root: |
| 229 | self.RTTRoot.set_path(os.path.abspath(rtt_root)) |
| 230 | |
| 231 | # detect compiler path |
| 232 | if platform.system() == 'Windows': |
| 233 | # Keil MDK |
| 234 | if not self.CompilersPath['ARMCC'].get_path(): |
| 235 | if os.path.exists('C:\\Keil'): |
| 236 | self.CompilersPath['ARMCC'].set_path('C:\\Keil') |
| 237 | elif os.path.exists('D:\\Keil'): |
| 238 | self.CompilersPath['ARMCC'].set_path('D:\\Keil') |
| 239 | elif os.path.exists('E:\\Keil'): |
| 240 | self.CompilersPath['ARMCC'].set_path('E:\\Keil') |
| 241 | elif os.path.exists('F:\\Keil'): |
| 242 | self.CompilersPath['ARMCC'].set_path('F:\\Keil') |
| 243 | elif os.path.exists('G:\\Keil'): |
| 244 | self.CompilersPath['ARMCC'].set_path('G:\\Keil') |