コード例 #1
0
    def getRunTask(self):
        '''
        Create Run task.
        '''
        taskData = """
        {
            "label": "will be replaced with templateStrings string",
            "type": "shell",
            "command": "specified below",
            "args": ["specified below"],
            "problemMatcher": []
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["label"] = tmpStr.taskName_CPU_run
        jsonTaskData["command"] = buildData[self.bStr.openOcdPath]
        jsonTaskData["args"] = []
        jsonTaskData["args"].append("-f")
        jsonTaskData["args"].append(buildData[self.bStr.openOcdInterfacePath])
        for arg in buildData[self.bStr.openOcdConfig]:
            jsonTaskData["args"].append("-f")
            jsonTaskData["args"].append(arg)

        jsonTaskData["args"].append("-c init")  # init must be executed before other commands!
        jsonTaskData["args"].append("-c resume")
        jsonTaskData["args"].append("-c exit")

        return jsonTaskData
コード例 #2
0
    def addCleanBuildFolderTask(self, tasksData):
        '''
        Add clean task (execute 'make clean-build-dir' command).

        Note: Currenly disabled (also in Makefile).
        '''
        # User edit BEGIN

        taskData = """
        {
            "label": "Clean build folder",
            "type": "shell",
            "command": "specified below",
            "args": ["specified below"],
            "problemMatcher": [],
            "presentation": {
                "focus": false
            }
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["command"] = buildData[self.bStr.buildToolsPath]
        jsonTaskData["args"] = [tmpStr.cleanBuildDirFunctionName]

        # User edit END
        tasksData = self.addOrReplaceTask(tasksData, jsonTaskData)
        return tasksData
コード例 #3
0
    def addRunTask(self, tasksData):
        '''
        Create/repair 'CPU: Run' task.
        '''
        # User edit BEGIN
        taskData = """
        {
            "label": "CPU: Run",
            "type": "shell",
            "command": "specified below",
            "args": ["specified below"],
            "problemMatcher": []
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["command"] = buildData[self.bStr.openOCDPath]
        jsonTaskData["args"] = []
        jsonTaskData["args"].append("-f")
        jsonTaskData["args"].append(buildData[self.bStr.openOCDInterfacePath])
        jsonTaskData["args"].append("-f")
        jsonTaskData["args"].append(buildData[self.bStr.openOCDTargetPath])

        jsonTaskData["args"].append(
            "-c init")  # init must be executed before other commands!
        jsonTaskData["args"].append("-c resume  ")
        jsonTaskData["args"].append("-c exit")

        # User edit END
        tasksData = self.addOrReplaceTask(tasksData, jsonTaskData)
        return tasksData
コード例 #4
0
    def addDeleteBuildFolderTask(self, tasksData):
        '''
        Add delte task (execute 'make clean' command).
        '''
        # User edit BEGIN
        taskData = """
        {
            "label": "Delete build folder",
            "type": "shell",
            "command": "specified below",
            "args": ["clean"],
            "problemMatcher": [],
            "presentation": {
                "focus": false
            }
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["command"] = buildData[self.bStr.buildToolsPath]

        # User edit END
        tasksData = self.addOrReplaceTask(tasksData, jsonTaskData)
        return tasksData
コード例 #5
0
    def getHaltTask(self):
        '''
        Create Halt/stop task.
        '''
        taskData = """
        {
            "label": "will be replaced with templateStrings string",
            "type": "shell",
            "command": "specified below",
            "args": ["specified below"],
            "problemMatcher": []
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["label"] = tmpStr.taskName_CPU_halt
        jsonTaskData["command"] = buildData[self.bStr.openOCDPath]
        jsonTaskData["args"] = []
        jsonTaskData["args"].append("-f")
        jsonTaskData["args"].append(buildData[self.bStr.openOCDInterfacePath])
        jsonTaskData["args"].append("-f")
        jsonTaskData["args"].append(buildData[self.bStr.openOCDTargetPath])

        jsonTaskData["args"].append(
            "-c init")  # init must be executed before other commands!
        jsonTaskData["args"].append("-c halt")
        jsonTaskData["args"].append("-c exit")

        return jsonTaskData
コード例 #6
0
    def getDebugLaunchConfig(self):
        '''
        Create/repair 'Cortex debug' launch configuration.
        '''
        configurationData = """
        {
            "name": "will be replaced with templateStrings string",
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "openocd",
            "cwd": "${workspaceFolder}",
            "executable": "will be replaced with path from buildData.json",
            "svdFile": "will be replaced with path from buildData.json",
            "configFiles": ["will be replaced with path from buildData.json"],
            "preLaunchTask": "will be replaced with templateStrings string"
        }
        """
        jsonConfigurationData = json.loads(configurationData)

        buildData = build.BuildData().getBuildData()

        jsonConfigurationData["name"] = tmpStr.launchName_Debug
        jsonConfigurationData["executable"] = buildData[
            self.bStr.targetExecutablePath]
        jsonConfigurationData["svdFile"] = buildData[self.bStr.stm32SvdPath]
        jsonConfigurationData["configFiles"] = [
            buildData[self.bStr.openOcdInterfacePath]
        ]
        jsonConfigurationData["configFiles"].extend(
            buildData[self.bStr.openOcdConfig])
        jsonConfigurationData["preLaunchTask"] = tmpStr.taskName_build

        return jsonConfigurationData
コード例 #7
0
    def addDownloadAndRunTask(self, tasksData):
        '''
        Create/repair 'CPU: Download and run' task.
        '''
        # User edit BEGIN
        taskData = """
        {
            "label": "CPU: Download and run",
            "type": "shell",
            "command": "specified below",
            "args": ["specified below"],
            "problemMatcher": []
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["command"] = buildData[self.bStr.openOCDPath]
        jsonTaskData["args"] = []
        jsonTaskData["args"].append("-f")
        jsonTaskData["args"].append(buildData[self.bStr.openOCDInterfacePath])
        jsonTaskData["args"].append("-f")
        jsonTaskData["args"].append(buildData[self.bStr.openOCDTargetPath])

        # program filename [verify] [reset] [exit] [offset] ([] are optional arguments)
        programString = "-c program " + buildData[
            self.bStr.targetExecutablePath] + " verify reset exit"
        jsonTaskData["args"].append(programString)

        # User edit END
        tasksData = self.addOrReplaceTask(tasksData, jsonTaskData)
        return tasksData
コード例 #8
0
    def getDownloadAndRunTask(self):
        '''
        Create Download and run task.
        '''
        taskData = """
        {
            "label": "will be replaced with templateStrings string",
            "type": "shell",
            "command": "specified below",
            "args": ["specified below"],
            "problemMatcher": []
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["label"] = tmpStr.taskName_CPU_downloadRun
        jsonTaskData["command"] = buildData[self.bStr.openOcdPath]
        jsonTaskData["args"] = []
        jsonTaskData["args"].append("-f")
        jsonTaskData["args"].append(buildData[self.bStr.openOcdInterfacePath])
        for arg in buildData[self.bStr.openOcdConfig]:
            jsonTaskData["args"].append("-f")
            jsonTaskData["args"].append(arg)

        # -c program filename [verify] [reset] [exit] [offset] ([] are optional arguments)
        # Note: due problems with VS Code OpenOCD Tasks in case of workspace path containing spaces, target executable is passed
        # as relative path.
        workspacePath = utils.workspacePath
        jsonTaskData["args"].append("-c")
        programString = "program " + buildData[self.bStr.targetExecutablePath] + " verify reset exit"
        jsonTaskData["args"].append(programString)

        return jsonTaskData
コード例 #9
0
    def getBuildTask(self):
        '''
        Add build task (execute 'make' command). Also the VS Code default 'build' task.
        '''
        taskData = """
        {
            "label": "will be replaced with templateStrings string",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "type": "shell",
            "command": "specified below",
            "args": ["specified below"],
            "problemMatcher": {
                "pattern": {
                    "regexp": "^(.*):(\\\\d+):(\\\\d+):\\\\s+(warning|error):\\\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            },
            "presentation": {
                "focus": true
            }
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["label"] = tmpStr.taskName_build
        jsonTaskData["command"] = buildData[self.bStr.buildToolsPath]

        gccFolderPath = os.path.dirname(buildData[self.bStr.gccExePath])
        gccFolderPath = utils.pathWithForwardSlashes(gccFolderPath)
        jsonTaskData["args"] = ["GCC_PATH=" + gccFolderPath
                                ]  # specify compiler path to make command

        numOfCores = os.cpu_count()
        parallelJobsNumber = int(
            numOfCores * 1.5
        )  # https://stackoverflow.com/questions/15289250/make-j4-or-j8/15295032
        parallelJobsStr = "-j" + str(parallelJobsNumber)
        jsonTaskData["args"].append(
            parallelJobsStr)  # set 'make' parallel job execution

        return jsonTaskData
コード例 #10
0
    def getBuildTask(self):
        '''
        Add build task (execute 'make' command). Also the VS Code default 'build' task.
        '''
        taskData = """
        {
            "label": "will be replaced with templateStrings string",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "type": "shell",
            "command": "specified below",
            "args": ["specified below"],
            "problemMatcher": {
                "pattern": {
                    "regexp": "^(.*):(\\\\d+):(\\\\d+):\\\\s+(warning|error):\\\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            },
            "presentation": {
                "focus": true
            }
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["label"] = tmpStr.taskName_build
        jsonTaskData["command"] = buildData[self.bStr.buildToolsPath]

        gccFolderPath = os.path.dirname(buildData[self.bStr.gccExePath])
        gccFolderPath = utils.pathWithForwardSlashes(gccFolderPath)
        jsonTaskData["args"] = ["GCC_PATH=" + gccFolderPath
                                ]  # specify compiler path to make command

        return jsonTaskData
コード例 #11
0
    def addBuildTask(self, tasksData):
        '''
        Add build task (execute 'make' command).
        '''
        # User edit BEGIN

        taskData = """
        {
            "label": "Build project",
            "type": "shell",
            "command": "specified below",
            "args": ["specified below"],
            "problemMatcher": {
                "pattern": {
                    "regexp": "^(.*):(\\\\d+):(\\\\d+):\\\\s+(warning|error):\\\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            },
            "presentation": {
                "focus": true
            }
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["command"] = buildData[self.bStr.buildToolsPath]

        gccFolderPath = os.path.dirname(buildData[self.bStr.gccExePath])
        gccFolderPath = utils.pathWithForwardSlashes(gccFolderPath)
        jsonTaskData["args"] = ["GCC_PATH=" + gccFolderPath
                                ]  # specify compiler path to make command

        # User edit END
        tasksData = self.addOrReplaceTask(tasksData, jsonTaskData)
        return tasksData
コード例 #12
0
    def addDownloadAndRunTask(self, tasksData):
        '''
        Create/repair 'CPU: Download and run' task.
        '''
        # User edit BEGIN
        taskData = """
        {
            "label": "CPU: Download and run",
            "type": "shell",
            "command": "specified below",
            "args": ["specified below"],
            "problemMatcher": []
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["command"] = buildData[self.bStr.openOCDPath]
        jsonTaskData["args"] = []
        jsonTaskData["args"].append("-f")
        jsonTaskData["args"].append(buildData[self.bStr.openOCDInterfacePath])
        jsonTaskData["args"].append("-f")
        jsonTaskData["args"].append(buildData[self.bStr.openOCDTargetPath])

        # -c program filename [verify] [reset] [exit] [offset] ([] are optional arguments)
        # Note: due problems with VS Code OpenOCD Tasks in case of workspace path containing spaces, target executable is passed
        # as relative path. Not a problem since VS Code shell is started from workspace folder.
        workspacePath = utils.workspacePath
        targetExecutablePath = buildData[self.bStr.targetExecutablePath]
        relativeTargetExecutablePath = os.path.relpath(targetExecutablePath,
                                                       workspacePath)
        relativeTargetExecutablePath = utils.pathWithForwardSlashes(
            relativeTargetExecutablePath)
        jsonTaskData["args"].append("-c")
        programString = "program " + relativeTargetExecutablePath + " verify reset exit"
        jsonTaskData["args"].append(programString)

        # User edit END
        tasksData = self.addOrReplaceTask(tasksData, jsonTaskData)
        return tasksData
コード例 #13
0
    def getDeleteBuildFolderTask(self):
        '''
        Create delete task (execute 'make clean' command).
        '''
        taskData = """
        {
            "label": "will be replaced with templateStrings string",
            "type": "shell",
            "command": "specified below",
            "args": ["clean"],
            "problemMatcher": [],
            "presentation": {
                "focus": false
            }
        }
        """
        jsonTaskData = json.loads(taskData)

        buildData = build.BuildData().getBuildData()
        jsonTaskData["label"] = tmpStr.taskName_clean
        jsonTaskData["command"] = buildData[self.bStr.buildToolsPath]

        return jsonTaskData
コード例 #14
0
    def addDebugLaunchConfig(self, launchData):
        '''
        Create/repair 'Cortex debug' launch configuration.
        '''
        # User edit BEGIN

        configurationData = """
        {
            "name": "Cortex debug",
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "openocd",
            "cwd": "${workspaceFolder}",
            "executable": "will be replaced with path from buildData.json",
            "svdFile": "will be replaced with path from buildData.json",
            "configFiles": ["will be replaced with path from buildData.json"]
        }
        """
        jsonConfigurationData = json.loads(configurationData)

        # get data from 'buildData.json'
        buildData = build.BuildData().getBuildData()

        jsonConfigurationData["executable"] = buildData[
            self.bStr.targetExecutablePath]
        jsonConfigurationData["svdFile"] = buildData[self.bStr.stm32svdPath]
        jsonConfigurationData["configFiles"] = []
        jsonConfigurationData["configFiles"].append(
            buildData[self.bStr.openOCDInterfacePath])
        jsonConfigurationData["configFiles"].append(
            buildData[self.bStr.openOCDTargetPath])

        # User edit END
        launchData = self.addOrReplaceLaunchConfiguration(
            launchData, jsonConfigurationData)
        return launchData
コード例 #15
0
    def getRunCurrentPythonFileTask(self):
        '''
        Create Run Python file task, which runs current active Python file.
        '''
        taskData = """
        {
            "label": "will be replaced with templateStrings string",
            "type": "shell",
            "command": "specified below",
            "args": [
                "${file}"
            ],
            "presentation": {
                "focus": true
            },
            "problemMatcher": []
        }
        """
        buildData = build.BuildData().getBuildData()
        jsonTaskData = json.loads(taskData)
        jsonTaskData["label"] = tmpStr.taskName_Python
        jsonTaskData["command"] = buildData[self.bStr.pythonExec]

        return jsonTaskData
コード例 #16
0
    def getUpdateTask(self):
        '''
        Create Update workspace task, which runs update.py script.
        '''
        taskData = """
        {
            "label": "will be replaced with templateStrings string",
            "type": "shell",
            "command": "specified below",
            "args": [
                "${workspaceFolder}/ideScripts/update.py"
            ],
            "presentation": {
                "focus": true
            },
            "problemMatcher": []
        }
        """
        buildData = build.BuildData().getBuildData()
        jsonTaskData = json.loads(taskData)
        jsonTaskData["label"] = tmpStr.taskName_updateWorkspace
        jsonTaskData["command"] = buildData[self.bStr.pythonExec]

        return jsonTaskData
コード例 #17
0
        if pathDefault is not None:
            msg = "\n\tDefault path to '" + pathName + "' detected at '" + pathDefault + "'\n\tUse this path? [y/n]: "
            if utils.getYesNoAnswer(msg):
                return pathDefault

        # default not detected or user wants custom path/command
        newPath = utils.getUserPath(pathName)
        return newPath


########################################################################################################################
if __name__ == "__main__":
    utils.verifyFolderStructure()

    paths = UpdatePaths()
    bData = build.BuildData()
    tasks = tasks.Tasks()
    launch = launch.LaunchConfigurations()
    wksFile = workspaceFile.UpdateWorkspaceFile()

    # update build data
    buildData = bData.prepareBuildData(request=True)
    bData.overwriteBuildDataFile(buildData)

    # update tasks
    tasks.checkTasksFile()
    tasksData = tasks.getTasksData()
    tasksData = tasks.addAllTasks(tasksData)
    tasks.overwriteTasksFile(tasksData)

    # update launch configurations
コード例 #18
0
    def getCompileTask(self):
        '''
        Create compile current file task (execute gcc compile command).
        '''
        taskData = """
        {
            "label": "will be replaced with templateStrings string",
            "type": "shell",
            "command": "will be replaced with GCC path below",
            "args": ["will be replaced with path from buildData.json"],
            "problemMatcher": {
                "pattern": {
                    "regexp": "^(.*):(\\\\d+):(\\\\d+):\\\\s+(warning|error):\\\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            },
            "presentation": {
                "focus": true
            }
        }
        """
        jsonTaskData = json.loads(taskData)

        # get compiler C flags, defines, includes, ... from 'buildData.json'
        buildData = build.BuildData().getBuildData()
        jsonTaskData["label"] = tmpStr.taskName_compile

        # defines
        cDefines = buildData[self.bStr.cDefines]
        cDefines = utils.preappendString(cDefines, '-D')

        # includes
        cIncludes = buildData[self.bStr.cIncludes]
        cIncludes = utils.preappendString(cIncludes, '-I')

        # build directory
        buildDir = buildData[self.bStr.buildDirPath]

        # c flags
        cFlags = buildData[self.bStr.cFlags]
        for flagIndex, flag in enumerate(cFlags):
            if flag == "-MF":
                newFlagString = "-MF'" + buildDir + "/${fileBasenameNoExtension}.d'"
                cFlags[flagIndex] = newFlagString
                continue

        # output file
        outputFilePath = "'" + buildDir + "/${fileBasenameNoExtension}.o'"
        outputFile = ["-o"]
        outputFile.append(outputFilePath)

        # compile file string
        fileString = "'${relativeFile}'"
        fileString = [fileString]

        jsonTaskData["command"] = buildData[self.bStr.gccExePath]
        jsonTaskData["args"] = ["-c"]   # only compile switch
        jsonTaskData["args"].extend(cDefines)
        jsonTaskData["args"].extend(cIncludes)
        jsonTaskData["args"].extend(cFlags)
        jsonTaskData["args"].extend(fileString)
        jsonTaskData["args"].extend(outputFile)

        return jsonTaskData