diff --git a/buildsettings.py b/buildsettings.py
index 390dab2..c40512d 100644
--- a/buildsettings.py
+++ b/buildsettings.py
@@ -42,26 +42,54 @@ def setCombo(cb,value):
return
class BuildSettingsDialog(QtGui.QDialog):
- def __init__(self,mainwin,parent=None):
+ def __init__(self,mainwin,startPath,parent=None):
super(BuildSettingsDialog,self).__init__(parent)
self.mainWindow=mainwin
uis.loadDialog('build_settings',self)
self.settingsGroup.setDisabled(True)
+ self.defaults.stateChanged.connect(self.defaultsToggled)
self.workspaceItem=QtGui.QTreeWidgetItem(['Workspace'])
self.mainWindow.workspaceTree.addProjectsToTree(self.workspaceItem)
+ self.workspaceDir=self.workspaceItem.data(0,DirectoryRole).toString()
self.projTree.addTopLevelItem(self.workspaceItem)
self.workspaceItem.setExpanded(True)
self.projTree.itemSelectionChanged.connect(self.selectionChanged)
self.closeButton.clicked.connect(self.closeClicked)
self.prevPath=''
- self.projTree.setCurrentItem(self.workspaceItem)
- wsdir=self.workspaceItem.data(0,DirectoryRole).toString()
- self.prevPath=os.path.join(wsdir,'mk.cfg')
+ firstItem=None
+ if startPath==self.workspaceDir:
+ firstItem=self.workspaceItem
+ else:
+ firstItem=self.findItem(self.workspaceItem,startPath)
+ if not firstItem:
+ firstItem=self.workspaceItem
+ self.projTree.setCurrentItem(firstItem)
+ self.projTree.scrollToItem(firstItem)
+ dir=firstItem.data(0,DirectoryRole).toString()
+ self.prevPath=os.path.join(dir,'mk.cfg')
+
+ def findItem(self,parent,path):
+ n=parent.childCount()
+ for i in xrange(0,n):
+ item=parent.child(i)
+ dir=item.data(0,DirectoryRole).toString()
+ if dir==path:
+ return item
+ res=self.findItem(item,path)
+ if res:
+ return res
+ return None
def closeClicked(self):
self.save(self.prevPath)
self.close()
+ def defaultsToggled(self,state):
+ if state==QtCore.Qt.Checked:
+ self.settingsGroup.setDisabled(True)
+ else:
+ self.settingsGroup.setEnabled(True)
+
def selectionChanged(self):
if self.prevPath:
self.save(self.prevPath)
@@ -80,6 +108,7 @@ def load(self,path):
setCombo(self.optCB,getStr(props,'OPT','-O2'))
setCombo(self.warnCB,getStr(props,'WARN','Default'))
check(self.pedantic,getBool(props,'PEDANTIC',False))
+ check(self.warnErrors,getBool(props,'WARNERR',False))
self.customFlags.setPlainText(getStr(props,'CUSTOM',''))
def save(self,path):
@@ -88,6 +117,7 @@ def save(self,path):
setStr(props,'OPT',self.optCB.currentText())
setStr(props,'WARN',self.warnCB.currentText())
setBool(props,'PEDANTIC',getCheck(self.pedantic))
+ setBool(props,'WARNERR',getCheck(self.warnErrors))
setStr(props,'CUSTOM',self.customFlags.toPlainText())
props.save(path)
diff --git a/gen/build_settings.py b/gen/build_settings.py
index 618a9ca..7d5fa39 100644
--- a/gen/build_settings.py
+++ b/gen/build_settings.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'uis/build_settings.ui'
#
-# Created: Tue Sep 30 15:04:51 2014
+# Created: Tue Sep 30 19:39:29 2014
# by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!
@@ -62,9 +62,9 @@ def setupUi(self, BuildSettingsDialog):
BuildSettingsDialog.pedantic = QtGui.QCheckBox(BuildSettingsDialog.settingsGroup)
BuildSettingsDialog.pedantic.setGeometry(QtCore.QRect(16, 80, 161, 22))
BuildSettingsDialog.pedantic.setObjectName(_fromUtf8("pedantic"))
- BuildSettingsDialog.checkBox = QtGui.QCheckBox(BuildSettingsDialog.settingsGroup)
- BuildSettingsDialog.checkBox.setGeometry(QtCore.QRect(16, 112, 201, 22))
- BuildSettingsDialog.checkBox.setObjectName(_fromUtf8("checkBox"))
+ BuildSettingsDialog.warnErrors = QtGui.QCheckBox(BuildSettingsDialog.settingsGroup)
+ BuildSettingsDialog.warnErrors.setGeometry(QtCore.QRect(16, 112, 201, 22))
+ BuildSettingsDialog.warnErrors.setObjectName(_fromUtf8("warnErrors"))
BuildSettingsDialog.customFlags = QtGui.QPlainTextEdit(BuildSettingsDialog.settingsGroup)
BuildSettingsDialog.customFlags.setGeometry(QtCore.QRect(16, 208, 257, 91))
BuildSettingsDialog.customFlags.setObjectName(_fromUtf8("customFlags"))
@@ -92,7 +92,7 @@ def retranslateUi(self, BuildSettingsDialog):
BuildSettingsDialog.warnCB.setItemText(1, _translate("BuildSettingsDialog", "None (-w)", None))
BuildSettingsDialog.warnCB.setItemText(2, _translate("BuildSettingsDialog", "All (-Wall)", None))
BuildSettingsDialog.pedantic.setText(_translate("BuildSettingsDialog", "Pedantic", None))
- BuildSettingsDialog.checkBox.setText(_translate("BuildSettingsDialog", "Warnings as errors", None))
+ BuildSettingsDialog.warnErrors.setText(_translate("BuildSettingsDialog", "Warnings as errors", None))
BuildSettingsDialog.label_3.setText(_translate("BuildSettingsDialog", "Custom Flags", None))
BuildSettingsDialog.closeButton.setText(_translate("BuildSettingsDialog", "Close", None))
diff --git a/gen/debug_settings.py b/gen/debug_settings.py
index 130a0c3..6facb0d 100644
--- a/gen/debug_settings.py
+++ b/gen/debug_settings.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'uis/debug_settings.ui'
#
-# Created: Tue Sep 30 15:04:51 2014
+# Created: Tue Sep 30 19:39:29 2014
# by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!
diff --git a/gen/libsuggest.py b/gen/libsuggest.py
index 41bc155..f58d007 100644
--- a/gen/libsuggest.py
+++ b/gen/libsuggest.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'uis/libsuggest.ui'
#
-# Created: Tue Sep 30 15:04:51 2014
+# Created: Tue Sep 30 19:39:29 2014
# by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!
diff --git a/genmake.py b/genmake.py
index 7a674f7..d61a4a6 100755
--- a/genmake.py
+++ b/genmake.py
@@ -9,6 +9,17 @@
root=os.path.abspath('.')
#print ("ROOT={}".format(root))
+def mkProps(props, dir):
+ path=os.path.join(dir,'mk.cfg')
+ if os.path.exists(path):
+ p=Properties(path)
+ if p.get("BUILD_DEFAULTS")!="True":
+ names=p.search('BUILD_.+')
+ for name in names:
+ if name!="BUILD_DEFAULTS":
+ props.assign(name,p.get(name))
+ return props
+
packages=listAllPackages()
class C:
@@ -71,7 +82,14 @@ def findMain(dir):
if re.search(pat,line):
return True
return False
-
+
+flagsPat=re.compile('\((.+)\)')
+def extractFlags(s):
+ m=re.search(flagsPat,s)
+ if m:
+ g=m.groups()
+ return g[0]
+ return ""
class Generator:
def __init__(self,root):
@@ -102,7 +120,7 @@ def scanWorkspace(self):
self.wsLibs[dirname]=os.path.relpath(dir,self.srcDir)
- def generateConfig(self,dir,files,cfg,o):
+ def generateConfig(self,dir,files,cfg,o,props):
name=os.path.basename(dir)
absdir=os.path.abspath(dir)
pb=Properties(os.path.join(dir,"mk.cfg"))
@@ -130,7 +148,15 @@ def generateConfig(self,dir,files,cfg,o):
#o = open(output,'w')
o.write('CPP_{}=g++\n'.format(cfg))
o.write('INC_{}=-I{} {}\n'.format(cfg,self.globalInc,cfgInclude))
- cflags='-c -std=c++11 $(OPT_{}) $(INC_{}) '.format(cfg,cfg)
+ warn=extractFlags(props.get("BUILD_WARN",""))
+ cflags='-c {} -std=c++11 $(OPT_{}) $(INC_{}) '.format(warn,cfg,cfg)
+ if props.get("BUILD_PEDANTIC")=="True":
+ cflags=cflags+" -pedantic-errors "
+ if props.get("BUILD_WARNERR")=="True":
+ cflags=cflags+" -Werror "
+ custom=props.get("BUILD_CUSTOM")
+ if custom:
+ cflags=cflags+" "+custom
lflags='$(OPT_{}) $(OBJS_{}) '.format(cfg,cfg)
libdeps={}
for lib in libs:
@@ -191,12 +217,29 @@ def generateConfig(self,dir,files,cfg,o):
return True
def generate(self,dir,files):
+ #props=mkProps(Properties(),root)
+ stack=[]
+ curdir=dir
+ while True:
+ stack.append(curdir)
+ if curdir==self.root:
+ break
+ curdir=os.path.abspath(os.path.join(curdir,'..'))
+ props=Properties()
+ while len(stack)>0:
+ props=mkProps(props,stack[-1])
+ del stack[-1]
output=os.path.join(dir,"Makefile")
o=open(output,"w")
- o.write('OPT_Release=-O2\n')
+ opt=props.get("BUILD_OPT")
+ if len(opt)==0:
+ opt="-O2"
+ if opt=="Custom":
+ opt=""
+ o.write('OPT_Release={}\n'.format(opt))
o.write('OPT_Debug=-g\n')
- self.generateConfig(dir,files,"Release",o)
- if self.generateConfig(dir,files,"Debug",o):
+ self.generateConfig(dir,files,"Release",o,props)
+ if self.generateConfig(dir,files,"Debug",o,props):
pass
diff --git a/mainwindow.py b/mainwindow.py
index 0055f67..b0983e4 100644
--- a/mainwindow.py
+++ b/mainwindow.py
@@ -283,11 +283,13 @@ def attemptUndefResolution(self,undefs):
self.workspaceTree.addLibrariesToProject(self.added)
- def buildSettings(self):
+ def buildSettings(self,path=''):
from buildsettings import BuildSettingsDialog
- d=BuildSettingsDialog(self)
- if d.exec_():
- pass
+ if not path:
+ path=self.workspaceTree.root
+ d=BuildSettingsDialog(self,path)
+ d.exec_()
+ self.generateAll()
def buildSpecific(self,path):
self.saveAll()
diff --git a/properties.py b/properties.py
index 706ae0b..2419e76 100644
--- a/properties.py
+++ b/properties.py
@@ -1,4 +1,5 @@
import os
+import re
class Properties:
def __init__(self,path=''):
@@ -10,6 +11,9 @@ def __init__(self,path=''):
if len(parts)==2:
self.props[parts[0]]=parts[1]
+ def copyFrom(self,props):
+ self.props=props.props.copy()
+
def has(self,name):
return name in self.props
@@ -20,6 +24,16 @@ def get(self,name,default=''):
def assign(self,name,value):
self.props[name]=value
+
+ def search(self,exp):
+ '''
+ Returns a list of name that match the regular expression
+ '''
+ res=[]
+ for name in self.props:
+ if re.match(exp,name):
+ res.append(name)
+ return res
def save(self,path):
f=open(path,"w")
diff --git a/uis/build_settings.ui b/uis/build_settings.ui
index b4cfa38..fddc393 100644
--- a/uis/build_settings.ui
+++ b/uis/build_settings.ui
@@ -155,7 +155,7 @@
Pedantic
-
+
16
diff --git a/workspace.py b/workspace.py
index 899623f..300df91 100644
--- a/workspace.py
+++ b/workspace.py
@@ -20,6 +20,7 @@ def __init__(self,pane,mainwin):
self.actBuild = QtGui.QAction('Build',self,triggered=self.buildCurrent)
self.actClean = QtGui.QAction('Clean',self,triggered=self.cleanCurrent)
self.actRebuild = QtGui.QAction('Rebuild',self,triggered=self.rebuildCurrent)
+ self.actBuildSettings = QtGui.QAction('Build Settings',self,triggered=self.buildSettings)
self.actSetMain = QtGui.QAction('Set Main Project',self,triggered=self.setMain)
self.actEditDependencies = QtGui.QAction('Dependencies',self,triggered=self.editDependencies)
self.actDebugSettings = QtGui.QAction('Debug Settings',self,triggered=self.editDebugSettings)
@@ -50,6 +51,7 @@ def contextMenuEvent(self,event):
menu.addAction(self.actBuild)
menu.addAction(self.actRebuild)
menu.addAction(self.actClean)
+ menu.addAction(self.actBuildSettings)
menu.addSeparator()
menu.addAction(self.actSetMain)
menu.addAction(self.actEditDependencies)
@@ -137,7 +139,12 @@ def mainPath(self):
if self.main:
return self.main.data(0,DirectoryRole).toString()
return ""
-
+
+ def buildSettings(self):
+ item=self.currentItem()
+ path=item.data(0,DirectoryRole).toString()
+ self.mainWindow.buildSettings(path)
+
def buildCurrent(self):
item=self.currentItem()
path=item.data(0,DirectoryRole).toString()