Project/Project.py

branch
make_support
changeset 6248
9458a3d45f27
parent 6244
233eea858c32
child 6251
02afc7d22c41
equal deleted inserted replaced
6245:6499ccd42dd6 6248:9458a3d45f27
146 appendStdout = pyqtSignal(str) 146 appendStdout = pyqtSignal(str)
147 appendStderr = pyqtSignal(str) 147 appendStderr = pyqtSignal(str)
148 148
149 eols = [os.linesep, "\n", "\r", "\r\n"] 149 eols = [os.linesep, "\n", "\r", "\r\n"]
150 150
151 DefaultMake = "make"
152 DefaultMakefile = "makefile"
153
151 def __init__(self, parent=None, filename=None): 154 def __init__(self, parent=None, filename=None):
152 """ 155 """
153 Constructor 156 Constructor
154 157
155 @param parent parent widget (usually the ui object) (QWidget) 158 @param parent parent widget (usually the ui object) (QWidget)
429 self.dbgExcIgnoreList = [] 432 self.dbgExcIgnoreList = []
430 self.dbgAutoClearShell = True 433 self.dbgAutoClearShell = True
431 self.dbgTracePython = False 434 self.dbgTracePython = False
432 self.dbgAutoContinue = True 435 self.dbgAutoContinue = True
433 436
434 # TODO: add 'make' support
435 self.pdata = { 437 self.pdata = {
436 "DESCRIPTION": "", 438 "DESCRIPTION": "",
437 "VERSION": "", 439 "VERSION": "",
438 "SOURCES": [], 440 "SOURCES": [],
439 "FORMS": [], 441 "FORMS": [],
464 "PROJECTTYPESPECIFICDATA": {}, 466 "PROJECTTYPESPECIFICDATA": {},
465 "CHECKERSPARMS": {}, 467 "CHECKERSPARMS": {},
466 "PACKAGERSPARMS": {}, 468 "PACKAGERSPARMS": {},
467 "DOCUMENTATIONPARMS": {}, 469 "DOCUMENTATIONPARMS": {},
468 "OTHERTOOLSPARMS": {}, 470 "OTHERTOOLSPARMS": {},
471 "MAKEPARAMS": {
472 "MakeEnabled": False,
473 "MakeExecutable": "",
474 "MakeFile": "",
475 "MakeTarget": "",
476 "MakeParameters": "",
477 "MakeTestOnly": True,
478 },
469 "EOL": -1, 479 "EOL": -1,
470 } 480 }
471 481
472 self.__initDebugProperties() 482 self.__initDebugProperties()
473 483
2252 "<p>The project directory <b>{0}</b> could not" 2262 "<p>The project directory <b>{0}</b> could not"
2253 " be created.</p>") 2263 " be created.</p>")
2254 .format(self.ppath)) 2264 .format(self.ppath))
2255 self.vcs = self.initVCS() 2265 self.vcs = self.initVCS()
2256 return 2266 return
2267
2257 # create an empty __init__.py file to make it a Python package 2268 # create an empty __init__.py file to make it a Python package
2258 # (only for Python and Python3) 2269 # (only for Python and Python3)
2259 if self.pdata["PROGLANGUAGE"] in \ 2270 if self.pdata["PROGLANGUAGE"] in \
2260 ["Python", "Python2", "Python3"]: 2271 ["Python", "Python2", "Python3"]:
2261 fn = os.path.join(self.ppath, "__init__.py") 2272 fn = os.path.join(self.ppath, "__init__.py")
2262 f = open(fn, "w", encoding="utf-8") 2273 f = open(fn, "w", encoding="utf-8")
2263 f.close() 2274 f.close()
2264 self.appendFile(fn, True) 2275 self.appendFile(fn, True)
2276
2265 # create an empty main script file, if a name was given 2277 # create an empty main script file, if a name was given
2266 if self.pdata["MAINSCRIPT"]: 2278 if self.pdata["MAINSCRIPT"]:
2267 if not os.path.isabs(self.pdata["MAINSCRIPT"]): 2279 if not os.path.isabs(self.pdata["MAINSCRIPT"]):
2268 ms = os.path.join( 2280 ms = os.path.join(
2269 self.ppath, self.pdata["MAINSCRIPT"]) 2281 self.ppath, self.pdata["MAINSCRIPT"])
2270 else: 2282 else:
2271 ms = self.pdata["MAINSCRIPT"] 2283 ms = self.pdata["MAINSCRIPT"]
2272 f = open(ms, "w") 2284 f = open(ms, "w")
2273 f.close() 2285 f.close()
2274 self.appendFile(ms, True) 2286 self.appendFile(ms, True)
2287
2288 if self.pdata["MAKEPARAMS"]["MakeEnabled"]:
2289 mf = self.pdata["MAKEPARAMS"]["MakeFile"]
2290 if mf:
2291 if not os.path.isabs(mf):
2292 mf = os.path.join(self.ppath, mf)
2293 else:
2294 mf = os.path.join(self.ppath, Project.DefaultMakefile)
2295 f = open(mf, "w")
2296 f.close()
2297 self.appendFile(mf)
2298
2275 tpd = os.path.join(self.ppath, self.translationsRoot) 2299 tpd = os.path.join(self.ppath, self.translationsRoot)
2276 if not self.translationsRoot.endswith(os.sep): 2300 if not self.translationsRoot.endswith(os.sep):
2277 tpd = os.path.dirname(tpd) 2301 tpd = os.path.dirname(tpd)
2278 if not os.path.isdir(tpd): 2302 if not os.path.isdir(tpd):
2279 os.makedirs(tpd) 2303 os.makedirs(tpd)
2316 self.ui, 2340 self.ui,
2317 self.tr("Create main script"), 2341 self.tr("Create main script"),
2318 self.tr( 2342 self.tr(
2319 "<p>The mainscript <b>{0}</b> could not" 2343 "<p>The mainscript <b>{0}</b> could not"
2320 " be created.<br/>Reason: {1}</p>") 2344 " be created.<br/>Reason: {1}</p>")
2321 .format(self.ppath, str(err))) 2345 .format(ms, str(err)))
2322 self.appendFile(ms) 2346 self.appendFile(ms, True)
2323 else: 2347 else:
2324 ms = "" 2348 ms = ""
2349
2350 if self.pdata["MAKEPARAMS"]["MakeEnabled"]:
2351 mf = self.pdata["MAKEPARAMS"]["MakeFile"]
2352 if mf:
2353 if not os.path.isabs(mf):
2354 mf = os.path.join(self.ppath, mf)
2355 else:
2356 mf = os.path.join(self.ppath, Project.DefaultMakefile)
2357 if not os.path.exists(mf):
2358 try:
2359 f = open(mf, "w")
2360 f.close()
2361 except EnvironmentError as err:
2362 E5MessageBox.critical(
2363 self.ui,
2364 self.tr("Create Makefile"),
2365 self.tr(
2366 "<p>The makefile <b>{0}</b> could not"
2367 " be created.<br/>Reason: {1}</p>")
2368 .format(mf, str(err)))
2369 self.appendFile(mf)
2325 2370
2326 # add existing files to the project 2371 # add existing files to the project
2327 res = E5MessageBox.yesNo( 2372 res = E5MessageBox.yesNo(
2328 self.ui, 2373 self.ui,
2329 self.tr("New Project"), 2374 self.tr("New Project"),
2578 else: 2623 else:
2579 ms = self.pdata["MAINSCRIPT"] 2624 ms = self.pdata["MAINSCRIPT"]
2580 if os.path.exists(ms): 2625 if os.path.exists(ms):
2581 self.appendFile(ms) 2626 self.appendFile(ms)
2582 2627
2628 if self.pdata["MAKEPARAMS"]["MakeEnabled"]:
2629 mf = self.pdata["MAKEPARAMS"]["MakeFile"]
2630 if mf:
2631 if not os.path.isabs(mf):
2632 mf = os.path.join(self.ppath, mf)
2633 else:
2634 mf = os.path.join(self.ppath, Project.DefaultMakefile)
2635 if not os.path.exists(mf):
2636 try:
2637 f = open(mf, "w")
2638 f.close()
2639 except EnvironmentError as err:
2640 E5MessageBox.critical(
2641 self.ui,
2642 self.tr("Create Makefile"),
2643 self.tr(
2644 "<p>The makefile <b>{0}</b> could not"
2645 " be created.<br/>Reason: {1}</p>")
2646 .format(mf, str(err)))
2647 self.appendFile(mf)
2648
2583 if self.pdata["PROJECTTYPE"] != projectType: 2649 if self.pdata["PROJECTTYPE"] != projectType:
2584 # reinitialize filetype associations 2650 # reinitialize filetype associations
2585 self.initFileTypes() 2651 self.initFileTypes()
2586 2652
2587 if self.translationsRoot: 2653 if self.translationsRoot:

eric ide

mercurial