Shop OBEX P1 Docs P2 Docs Learn Events
VS Code Build Task for Fastspin and PNut - Redux — Parallax Forums

VS Code Build Task for Fastspin and PNut - Redux

larryvclarryvc Posts: 42
edited 2020-06-13 04:09 in Propeller 2
I put together the VS Code build task below and have been using it for over a month now without any problems. It is Windows specific but can be adapted for other OSes. See Cluso99's post for where to place this file, though I use it in a .vscode subfolder in my P2 development folder so that it is not global to all of my builds. It is pretty self explanatory as to what is being done, but you will have to alter the paths to where your tools are located.

It calls either Fastspin or PNut to perform the build and then calls loadp2 only if the build completed without errors. To prevent accidental loading of a stale .binary or .bin file, it checks for and deletes that file prior to calling Fastspin or PNut.

You need to have both the folder containing the file you want built and the file itself open within VS Code, then Invoke the build with Ctrl-Shift-B and select either RunP2Fastspin or RunP2PNut.
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "CompileFastspin",
            "type": "shell",
            "command": "if (test-path ${fileDirname}/${fileBasenameNoExtension}.binary) {remove-item ${fileDirname}/${fileBasenameNoExtension}.binary}",
        },
        {
            "label": "CompileP2Fastspin",
            "type": "shell",
            "command": "d:/Parallax/flexgui/bin/fastspin.exe -2 ${file}",
        },
        {
            "label": "RunP2Fastspin",
            "type": "shell",
            "command": "d:/Parallax/flexgui/bin/loadp2.exe -pCOM5 -b230400 -t ${fileDirname}/${fileBasenameNoExtension}.binary",
            "dependsOrder": "sequence",
            "dependsOn": [
                "CompileFastspin", "CompileP2Fastspin"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
        },
        {
            "label": "CompileSpin2",
            "type": "shell",
            "command": "if (test-path ${fileDirname}/${fileBasenameNoExtension}.bin) {remove-item ${fileDirname}/${fileBasenameNoExtension}.bin}",
         },
        {
            "label": "CompileP2PNut",
            "type": "shell",
            "command": "d:/Parallax/PNut/PNut.exe ${fileDirname}/${fileBasenameNoExtension} -c",
        },
        {
            "label": "RunP2PNut",
            "type": "shell",
            "command": "d:/Parallax/flexgui/bin/loadp2.exe -pCOM5 -b230400 -t ${fileDirname}/${fileBasenameNoExtension}.bin",
            "dependsOrder": "sequence",
            "dependsOn": [
                "CompileSpin2", "CompileP2PNut"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
Sign In or Register to comment.