def addBraCustomInfoToCppProject_(self, cppProject):
        '''
        Add custom information to the Visual Studio project (additional libraries, preprocessor definitions, etc.)
        for the annotations to compile.
        It creates a backup to be restored when the "Bug-reproducer Assistant" project is removed. 
        '''
        cppProjectBkp = project.getCppProjectFileBackup(cppProject)
        shutil.copy(cppProject, cppProjectBkp)
        
        installationFolder = config.installationConfig().getInstallationFolder()

        additionalDependencies = ['bug_reproducer_assistant.lib', 'jsoncpp.lib']
        preprocessorDefinitions = ['BUG_REPRODUCER_ASSISTANT_ENABLED']
        BOOST_LIB_FOLDER = config.instance().boostLibraryFolder
        LIBRARIES_LIB_PREFIX = os.path.join(installationFolder, 'C++', 'libs')
        
        additionalLibraryDirectoriesDebug = [BOOST_LIB_FOLDER, os.path.join(LIBRARIES_LIB_PREFIX, 'Debug')] 
        additionalLibraryDirectoriesRelease = [BOOST_LIB_FOLDER, os.path.join(LIBRARIES_LIB_PREFIX, 'Release')]
        
        additionalIncludeDirectories = [config.instance().boostIncludeFolder, os.path.join(installationFolder, 'C++', 'include')]
        
        myBraCustomProjectInfo = parse_project.BraCustomProjectInfo(additionalDependencies, preprocessorDefinitions, additionalLibraryDirectoriesDebug, additionalLibraryDirectoriesRelease, additionalIncludeDirectories)

        myProjectParser = parse_project.ProjectParser(cppProjectBkp, cppProject, 'vcxproj', myBraCustomProjectInfo)
        myProjectParser.parseProject()
 def __init__(self, parent=None):
     """
     Constructor.
     """
     self.folderNumber = 0
     QMainWindow.__init__(self, parent)
     self.setupUi(self)
     self.connect(self.actionExit, SIGNAL("triggered()"), qApp, SLOT("quit()"))
     self.createActions()
     self.outputStr_ = OUTPUT_WINDOW_PROMPT
     self.loadControls()
     # self.setWindowIcon(QIcon(r'images\icon.jpg'))
     config.ConfigSerializer.loadConfig()
     self.currentProject = None
     project.ProjectSerializer.loadProjectsList()
     if config.installationConfig().getIsFirstUse():
         config.installationConfig().setIsFirstUse(0)
         self.options()
 def __init__(self, parent=None):
     '''
     Constructor.
     '''
     self.folderNumber = 0
     QMainWindow.__init__(self, parent)
     self.setupUi(self)
     self.connect(self.actionExit, SIGNAL("triggered()"), qApp,
                  SLOT("quit()"))
     self.createActions()
     self.outputStr_ = OUTPUT_WINDOW_PROMPT
     self.loadControls()
     #self.setWindowIcon(QIcon(r'images\icon.jpg'))
     config.ConfigSerializer.loadConfig()
     self.currentProject = None
     project.ProjectSerializer.loadProjectsList()
     if config.installationConfig().getIsFirstUse():
         config.installationConfig().setIsFirstUse(0)
         self.options()
    def loadProjectsList():
        '''
        Load the projects from disk into memory.
        '''
        ##
        # @param projectMap A project represented as a map, to ease Json-serialization.
        # @return The source files to be displayed in the annotations tree.
        def loadTreeFiles(projectMap):
            '''
            Load the source files to be displayed in the annotations tree.
            '''
            treeFiles = []
            jsonTreeFiles = projectMap[ProjectSerializer.TREE_FILES]
            for jsonTreeFile in jsonTreeFiles:
                fileToAnnotate = jsonTreeFile[ProjectSerializer.FILE_TO_ANNOTATE]
                headerToInclude = jsonTreeFile[ProjectSerializer.HEADER_TO_INCLUDE]
                myTreeFile = fileToAnnotate, headerToInclude
                treeFiles.append(myTreeFile)
            return treeFiles
            
        projects = {}
        #First, get all projects information
        dataFolder = config.installationConfig().getDataFolder()
        indexFilePath = os.path.join(dataFolder, ProjectSerializer.INDEX_FILE_NAME)
        
        if os.path.exists(indexFilePath):
            with open(indexFilePath, 'r') as fp:
                projectsIndexMap = json.load(fp)
            
            for projectName, projectFolder in projectsIndexMap.items():
                
                projectConfigPath = os.path.join(projectFolder, ProjectSerializer.PROJECT_SETTINGS_FILE_NAME)
                with open(projectConfigPath, 'r') as fp:
                    projectMap = json.load(fp)
    
                name = projectMap[ProjectSerializer.NAME]
                folder = projectMap[ProjectSerializer.LOCATION]
                language = projectMap[ProjectSerializer.LANGUAGE]
                solutionFile = projectMap[ProjectSerializer.SOLUTION_FILE]
                mainFile = projectMap[ProjectSerializer.MAIN_FILE]
                mainFunction = projectMap[ProjectSerializer.MAIN_FUNCTION]
                exeCommand = projectMap[ProjectSerializer.EXE_COMMAND]
                treeFiles = loadTreeFiles(projectMap)
                compilingCommand = projectMap[ProjectSerializer.COMPILING_COMMAND]
                cppProject = projectMap[ProjectSerializer.CPP_PROJECT]
               
                if projectName != name:
                    raise RuntimeError('Inconsistency between project names: "' + projectName + '", "' + name + '". Check configuration folders.')

                aProject = Project(name, folder, language, solutionFile, mainFile, mainFunction, exeCommand, treeFiles, cppProject, compilingCommand)
                projects[name] = aProject
        return projects
    def saveProjectsList(allProjects):
        '''
        Store all the projects from memory into disk.
        '''
        def saveTreeFiles(treeFiles):
            jsonTreeFiles = []
            for myTreeFile in treeFiles:
                jsonTreeFile = {}
                jsonTreeFile[ProjectSerializer.FILE_TO_ANNOTATE] = myTreeFile[0]
                jsonTreeFile[ProjectSerializer.HEADER_TO_INCLUDE] = myTreeFile[1]
                jsonTreeFiles.append(jsonTreeFile)
            return jsonTreeFiles
        
        #First, save in all projects information
        dataFolder = config.installationConfig().getDataFolder()
        indexFilePath = os.path.join(dataFolder, ProjectSerializer.INDEX_FILE_NAME)
        
        projectsIndexMap = {}
        for projectName, aProject in allProjects.items():
            projectsIndexMap[projectName] = aProject.getFolder()
            #Now, save current project
            projectMap = {}
            projectMap[ProjectSerializer.NAME] = aProject.getName()
            projectMap[ProjectSerializer.LOCATION] = aProject.getFolder()
            projectMap[ProjectSerializer.LANGUAGE] = aProject.getLanguage()
            projectMap[ProjectSerializer.SOLUTION_FILE] = aProject.getSolutionFile()
            projectMap[ProjectSerializer.MAIN_FILE] = aProject.getMainFile()
            projectMap[ProjectSerializer.MAIN_FUNCTION] = aProject.getMainFunction()
            projectMap[ProjectSerializer.EXE_COMMAND] = aProject.getExeCommand()
            projectMap[ProjectSerializer.TREE_FILES] = saveTreeFiles(aProject.getTreeFiles())
            projectMap[ProjectSerializer.COMPILING_COMMAND] = aProject.getCompilingCommand()                        
            projectMap[ProjectSerializer.CPP_PROJECT] = aProject.getCppProject()
            
            projectFolder = aProject.getFolder()
            createFolderIfNotExists(projectFolder)
            executionsFolder = aProject.getExecutionsFolder()
            createFolderIfNotExists(executionsFolder)

            projectConfigPath = os.path.join(projectFolder, ProjectSerializer.PROJECT_SETTINGS_FILE_NAME)
            
            with open(projectConfigPath, 'w') as fp:
                json.dump(projectMap, fp, sort_keys=True, indent=ProjectSerializer.INDENT)
                
        with open(indexFilePath, 'w') as fp:
            json.dump(projectsIndexMap, fp, sort_keys=True, indent=ProjectSerializer.INDENT)
Example #6
0
    def addBraCustomInfoToCppProject_(self, cppProject):
        '''
        Add custom information to the Visual Studio project (additional libraries, preprocessor definitions, etc.)
        for the annotations to compile.
        It creates a backup to be restored when the "Bug-reproducer Assistant" project is removed. 
        '''
        cppProjectBkp = project.getCppProjectFileBackup(cppProject)
        shutil.copy(cppProject, cppProjectBkp)

        installationFolder = config.installationConfig().getInstallationFolder(
        )

        additionalDependencies = [
            'bug_reproducer_assistant.lib', 'jsoncpp.lib'
        ]
        preprocessorDefinitions = ['BUG_REPRODUCER_ASSISTANT_ENABLED']
        BOOST_LIB_FOLDER = config.instance().boostLibraryFolder
        LIBRARIES_LIB_PREFIX = os.path.join(installationFolder, 'C++', 'libs')

        additionalLibraryDirectoriesDebug = [
            BOOST_LIB_FOLDER,
            os.path.join(LIBRARIES_LIB_PREFIX, 'Debug')
        ]
        additionalLibraryDirectoriesRelease = [
            BOOST_LIB_FOLDER,
            os.path.join(LIBRARIES_LIB_PREFIX, 'Release')
        ]

        additionalIncludeDirectories = [
            config.instance().boostIncludeFolder,
            os.path.join(installationFolder, 'C++', 'include')
        ]

        myBraCustomProjectInfo = parse_project.BraCustomProjectInfo(
            additionalDependencies, preprocessorDefinitions,
            additionalLibraryDirectoriesDebug,
            additionalLibraryDirectoriesRelease, additionalIncludeDirectories)

        myProjectParser = parse_project.ProjectParser(cppProjectBkp,
                                                      cppProject, 'vcxproj',
                                                      myBraCustomProjectInfo)
        myProjectParser.parseProject()