예제 #1
0
 def addLibrariesToProject(self, libs):
     if self.main:
         path = self.mainPath()
         mkPath = os.path.join(path, "mk.cfg")
         props = Properties(mkPath)
         lst = props.get("LINK_LIBS").split(',')
         lst = [x for x in lst if len(x) > 0]
         for l in libs:
             lst.append(l)
         props.assign("LINK_LIBS", ",".join(lst))
         props.save(mkPath)
         self.depsChanged.emit(path)
예제 #2
0
파일: workspace.py 프로젝트: amirgeva/coide
 def addLibrariesToProject(self, libs):
     if self.main:
         path = self.mainPath()
         mkPath = os.path.join(path, "mk.cfg")
         props = Properties(mkPath)
         lst = props.get("LINK_LIBS").split(",")
         lst = [x for x in lst if len(x) > 0]
         for l in libs:
             lst.append(l)
         props.assign("LINK_LIBS", ",".join(lst))
         props.save(mkPath)
         self.depsChanged.emit(path)
예제 #3
0
파일: workspace.py 프로젝트: amirgeva/coide
 def editDependencies(self):
     item = self.currentItem()
     path = item.data(0, DirectoryRole).toString()
     mkPath = os.path.join(path, "mk.cfg")
     props = Properties(mkPath)
     libs = re.split("\W+", props.get("LINK_LIBS"))
     d = DependenciesDialog(libs)
     if d.exec_():
         props.assign("LINK_LIBS", ",".join(d.libs))
         props.save(mkPath)
         self.depsChanged.emit(path)
         return True
     return False
예제 #4
0
 def editDependencies(self):
     item = self.currentItem()
     path = item.data(0, DirectoryRole).toString()
     mkPath = os.path.join(path, "mk.cfg")
     props = Properties(mkPath)
     libs = re.split(' |;|,', props.get('LINK_LIBS'))
     d = DependenciesDialog(libs)
     if d.exec_():
         props.assign("LINK_LIBS", ",".join(d.libs))
         props.save(mkPath)
         self.depsChanged.emit(path)
         return True
     return False
예제 #5
0
파일: workspace.py 프로젝트: amirgeva/coide
 def editDebugSettings(self):
     item = self.currentItem()
     path = item.data(0, DirectoryRole).toString()
     mkPath = os.path.join(path, "mk.cfg")
     props = Properties(mkPath)
     d = uis.loadDialog("debug_settings")
     d.cwdEdit.setText(props.get("DEBUG_CWD"))
     d.paramsEdit.setText(props.get("DEBUG_PARAMS"))
     d.browseDirButton.clicked.connect(lambda: utils.browseDirectory(d.cwdEdit))
     if d.exec_():
         props.assign("DEBUG_CWD", d.cwdEdit.text())
         props.assign("DEBUG_PARAMS", d.paramsEdit.text())
         self.debug = (d.cwdEdit.text(), d.paramsEdit.text())
         props.save(mkPath)
예제 #6
0
 def editDebugSettings(self):
     item = self.currentItem()
     path = item.data(0, DirectoryRole).toString()
     mkPath = os.path.join(path, "mk.cfg")
     props = Properties(mkPath)
     d = uis.loadDialog('debug_settings')
     d.cwdEdit.setText(props.get("DEBUG_CWD"))
     d.paramsEdit.setText(props.get("DEBUG_PARAMS"))
     d.browseDirButton.clicked.connect(
         lambda: utils.browseDirectory(d.cwdEdit))
     if d.exec_():
         props.assign('DEBUG_CWD', d.cwdEdit.text())
         props.assign('DEBUG_PARAMS', d.paramsEdit.text())
         self.debug = (d.cwdEdit.text(), d.paramsEdit.text())
         props.save(mkPath)
예제 #7
0
    def generateConfig(self, dir, files, cfg, o, props):
        '''
        Generate rules for a configuration (Debug/Release)
        '''
        name = os.path.basename(dir)
        absdir = os.path.abspath(dir)
        pb = Properties(os.path.join(dir, "mk.cfg"))
        type = pb.get("TYPE")
        if len(type) == 0:
            if findMain(absdir):
                type = "APP"
            else:
                type = "LIB"
        o.write('TYPE={}\n'.format(type))
        libs = re.split(',| ', pb.get("LINK_LIBS"))
        libs = filter(bool, libs)  # remove empty strings
        if len(type) == 0:
            return False
        srcs = filterSources(files)
        subdirs = self.findAllSubdirs(srcs)
        intr = os.path.join(dir.replace(self.srcDir, self.intrDir), cfg)
        verifyDir(intr)
        for sd in subdirs:
            verifyDir(os.path.join(intr, sd))
        outdir = os.path.join(dir.replace(self.srcDir, self.outDir), cfg)
        verifyDir(outdir)
        #reloutdir=os.path.relpath(outdir,dir)
        reloutdir = outdir
        #globalInclude=os.path.relpath(self.globalInc,dir)
        cfgInclude = ''

        #o = open(output,'w')
        mkProps = Properties()
        o.write('CPP_{}=g++\n'.format(cfg))
        mkProps.assign('CPP_{}'.format(cfg), 'g++')
        o.write('INC_{}=-I{} {}\n'.format(cfg, self.globalInc, cfgInclude))
        mkProps.assign('INC_{}'.format(cfg),
                       '-I{} {}'.format(self.globalInc, cfgInclude))

        cflags = '-c $(OPT_{}) $(INC_{}) '.format(cfg, cfg)
        cflags = self.addCompileSettings(cflags, props, cfg)

        lflags = '$(OPT_{}) $(OBJS_{}) '.format(cfg, cfg)
        lflags = self.addLinkSettings(lflags, props, cfg)
        libdeps = {}
        for stage in ['local', 'package']:
            for lib in libs:
                if lib in packages:
                    if stage == 'package':
                        cflags = cflags + ' `pkg-config --cflags {}` '.format(
                            lib)
                        lflags = lflags + ' `pkg-config --libs {}` '.format(
                            lib)
                else:
                    if lib in self.wsLibs:
                        if stage == 'local':
                            rel = self.wsLibs.get(lib)
                            libdir = os.path.join(self.root, 'out', rel, cfg)
                            libDir = os.path.join(self.root, 'src', rel)
                            libProps = Properties(
                                os.path.join(libDir, "mk.cfg"))
                            wPrefix = ''
                            wSuffix = ''
                            if libProps.get('BUILD_WHOLE_ARCHIVE',
                                            'False') == 'True':
                                wPrefix = ' -Wl,--whole-archive'
                                wSuffix = '-Wl,--no-whole-archive '
                            lflags = lflags + '{} -L{} -l{} {}'.format(
                                wPrefix, libdir, lib, wSuffix)
                            libdeps[lib] = libDir
                    else:
                        if stage == 'package':
                            lflags = lflags + ' -l{} '.format(lib)
        o.write('CFLAGS_{}={}\n'.format(cfg, cflags))
        o.write('LFLAGS_{}={}\n'.format(cfg, lflags))
        objs = srcs
        for e in src_exts:
            objs = arreplace(objs, e, '.o')
        for i in xrange(0, len(objs)):
            objs[i] = os.path.join(intr, objs[i])

        o.write("OBJS_{}=".format(cfg))
        for obj in objs:
            o.write("\\\n" + obj)
        o.write("\n\n")

        liblist = []

        for lib in libdeps:
            libname = "{}_{}".format(lib, cfg)
            liblist.append(libname)
            libpath = libdeps.get(lib)
            o.write("{}:\n".format(libname))
            o.write("\t@make --no-print-directory -C {} {}\n\n".format(
                libpath, cfg))
            o.write("clean_{}:\n".format(libname))
            o.write("\t@make --no-print-directory -C {} clean_{}\n\n".format(
                libpath, cfg))

        cleanlibs = ''
        if type == 'LIB':
            outfile = '{}/lib{}.a'.format(reloutdir, name)
            o.write('{}: $(OBJS_{})\n'.format(outfile, cfg))
            o.write('\tar cr {} $(OBJS_{})\n\n'.format(outfile, cfg))
        else:
            outfile = "{}/{}".format(reloutdir, name)
            o.write('OUTPUT_PATH_{}={}\n\n'.format(cfg, outfile))
            if len(liblist) > 0:
                cleanlibs = 'clean_' + ' clean_'.join(liblist)
            liblist = ' '.join(liblist)
            o.write('{}: $(OBJS_{}) {}\n'.format(outfile, cfg, liblist))
            o.write('\t$(CPP_{}) -o {} $(LFLAGS_{})\n\n'.format(
                cfg, outfile, cfg))

        o.write('clean_{}: {}\n\t@rm -f $(OBJS_{}) {}\n\n'.format(
            cfg, cleanlibs, cfg, outfile))
        o.write('{}: {}\n\n'.format(cfg, outfile))

        for i in xrange(0, len(objs)):
            src = os.path.join(absdir, srcs[i])
            depcmd = 'g++ {} -MM {}'.format(cflags, src)
            depcmd = templates.generateMkCommand(depcmd, mkProps)
            (out, err) = utils.shellcall(dir, depcmd)
            p = out.find(':')
            hdeps = ':\n'
            if p > 0:
                hdeps = out[p:].replace('\\\n', '')
            o.write('{}{}'.format(objs[i], hdeps))
            if self.cppcheck:
                o.write('\tcppcheck {}/{}\n'.format(absdir, srcs[i]))
            o.write('\t$(CPP_{}) $(CFLAGS_{}) -o {} {}/{}\n\n'.format(
                cfg, cfg, objs[i], absdir, srcs[i]))

        return True
예제 #8
0
파일: genmake.py 프로젝트: amirgeva/coide
    def generateConfig(self,dir,files,cfg,o,props):
        '''
        Generate rules for a configuration (Debug/Release)
        '''
        name=os.path.basename(dir)
        absdir=os.path.abspath(dir)
        pb=Properties(os.path.join(dir,"mk.cfg"))
        type=pb.get("TYPE")
        if len(type)==0: 
            if findMain(absdir):
                type="APP"
            else:
                type="LIB"
        o.write('TYPE={}\n'.format(type))
        libs=re.split(',| ',pb.get("LINK_LIBS"))
        libs=filter(bool,libs)  # remove empty strings
        if len(type)==0:
            return False
        srcs=filterSources(files)
        subdirs=self.findAllSubdirs(srcs)
        intr=os.path.join(dir.replace(self.srcDir,self.intrDir),cfg)
        verifyDir(intr)
        for sd in subdirs:
            verifyDir(os.path.join(intr,sd))
        outdir=os.path.join(dir.replace(self.srcDir,self.outDir),cfg)
        verifyDir(outdir)
        #reloutdir=os.path.relpath(outdir,dir)
        reloutdir=outdir
        #globalInclude=os.path.relpath(self.globalInc,dir)
        cfgInclude=''
        
        #o = open(output,'w')
        mkProps=Properties()
        o.write('CPP_{}=g++\n'.format(cfg))
        mkProps.assign('CPP_{}'.format(cfg),'g++')
        o.write('INC_{}=-I{} {}\n'.format(cfg,self.globalInc,cfgInclude))
        mkProps.assign('INC_{}'.format(cfg),'-I{} {}'.format(self.globalInc,cfgInclude))

        cflags='-c $(OPT_{}) $(INC_{}) '.format(cfg,cfg)
        cflags=self.addCompileSettings(cflags,props,cfg)
        
        lflags='$(OPT_{}) $(OBJS_{}) '.format(cfg,cfg)
        lflags=self.addLinkSettings(lflags,props,cfg)
        libdeps={}
        for stage in ['local','package']:
            for lib in libs:
                if lib in packages:
                    if stage=='package':
                        cflags=cflags+' `pkg-config --cflags {}` '.format(lib)
                        lflags=lflags+' `pkg-config --libs {}` '.format(lib)
                else:
                    if lib in self.wsLibs:
                        if stage=='local':
                            rel=self.wsLibs.get(lib)
                            libdir=os.path.join(self.root,'out',rel,cfg)
                            libDir=os.path.join(self.root,'src',rel)
                            libProps=Properties(os.path.join(libDir,"mk.cfg"))
                            wPrefix=''
                            wSuffix=''
                            if libProps.get('BUILD_WHOLE_ARCHIVE','False')=='True':
                                wPrefix=' -Wl,--whole-archive'
                                wSuffix='-Wl,--no-whole-archive '
                            lflags=lflags+'{} -L{} -l{} {}'.format(wPrefix,libdir,lib,wSuffix)
                            libdeps[lib]=libDir
                    else:
                        if stage=='package':
                            lflags=lflags+' -l{} '.format(lib)
        o.write('CFLAGS_{}={}\n'.format(cfg,cflags))
        o.write('LFLAGS_{}={}\n'.format(cfg,lflags))
        objs = arreplace(srcs,'.cpp','.o')
        for i in xrange(0,len(objs)):
            objs[i]=os.path.join(intr,objs[i])
            
        o.write("OBJS_{}=".format(cfg))
        for obj in objs:
            o.write("\\\n"+obj)
        o.write("\n\n")
        
        liblist=[]

        for lib in libdeps:
            libname="{}_{}".format(lib,cfg)
            liblist.append(libname)
            libpath=libdeps.get(lib)
            o.write("{}:\n".format(libname))
            o.write("\t@make --no-print-directory -C {} {}\n\n".format(libpath,cfg))
            o.write("clean_{}:\n".format(libname))
            o.write("\t@make --no-print-directory -C {} clean_{}\n\n".format(libpath,cfg))
        
        cleanlibs=''
        if type=='LIB':
            outfile='{}/lib{}.a'.format(reloutdir,name)
            o.write('{}: $(OBJS_{})\n'.format(outfile,cfg))
            o.write('\tar cr {} $(OBJS_{})\n\n'.format(outfile,cfg))
        else:
            outfile="{}/{}".format(reloutdir,name)
            o.write('OUTPUT_PATH_{}={}\n\n'.format(cfg,outfile))
            if len(liblist)>0:
                cleanlibs='clean_'+' clean_'.join(liblist)
            liblist=' '.join(liblist)
            o.write('{}: $(OBJS_{}) {}\n'.format(outfile,cfg,liblist))
            o.write('\t$(CPP_{}) -o {} $(LFLAGS_{})\n\n'.format(cfg,outfile,cfg))
            
        o.write('clean_{}: {}\n\t@rm -f $(OBJS_{}) {}\n\n'.format(cfg,cleanlibs,cfg,outfile))        
        o.write('{}: {}\n\n'.format(cfg,outfile))
            
        for i in xrange(0,len(objs)):
            src=os.path.join(absdir,srcs[i])
            depcmd='g++ {} -MM {}'.format(cflags,src)
            depcmd=templates.generateMkCommand(depcmd,mkProps)
            (out,err)=utils.shellcall(dir,depcmd)
            p=out.find(':')
            if p>0:
                hdeps=out[p:].replace('\\\n','')
                o.write('{}{}'.format(objs[i],hdeps))
            if self.cppcheck:
                o.write('\tcppcheck {}/{}\n'.format(absdir,srcs[i]))
            o.write('\t$(CPP_{}) $(CFLAGS_{}) -o {} {}/{}\n\n'.format(cfg,cfg,objs[i],absdir,srcs[i]))
            
        return True