Shop OBEX P1 Docs P2 Docs Learn Events
Better build tasks config for VS Code — Parallax Forums

Better build tasks config for VS Code

Andrey DemenevAndrey Demenev Posts: 377
edited 2023-04-22 05:48 in Propeller 2

The tasks.json file recommended on the Parallax site works well, except one thing: each time you compile or download code, it opens a new terminal. It's not a big deal, but I just do not like that. So I made changes that make VS Code reuse same terminal panel, and the workspace looks a bit cleaner.

The list of changes:

  • "presentation" sections:

    • changed "panel": "new" to "panel": "dedicated". This makes the task reuse its own terminal panel
    • changed "focus": true to "focus": false. This way the editor does not lose focus when running a task
    • added "showReuseMessage":false. This removes the message from the terminal that is added when terminal is reused
    • added "clear": true. This clears the terminal output before running a task
  • changed task labels. I feel "Propeller: Compile Current File" looks better than "compileP2"

I also had to modify the custom key bindings file to use the new task labels.

I hope this can be useful

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Propeller: Compile Current File",
            "type": "shell",
              "osx": {
                "command": "flexspin.mac",
              },
              "windows": {
                "command": "flexspin.exe",
              },
              "linux": {
                "command": "flexspin",
              },
            "args": [
                "-2",
                "-Wabs-paths",
                "-Wmax-errors=99",
                "${fileBasename}"
            ],
            "problemMatcher": {
                "owner": "Spin2",
                "fileLocation": ["autoDetect", "${workspaceFolder}/src"],
                "pattern": {
                    "regexp": "^(.*):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "severity": 3,
                    "message": 4
                }
            },
            "presentation": {
                "panel": "dedicated",
                "focus": false,
                "showReuseMessage":false,
                "clear": true
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "Propeller: Compile Top File",
            "type": "shell",
            "osx": {
                "command": "flexspin.mac",
            },
            "windows": {
                "command": "flexspin.exe",
            },
            "linux": {
                "command": "flexspin",
            },
            "args": [
                "-2",
                "-Wabs-paths",
                "-Wmax-errors=99",
                "${config:topLevel}.spin2"
            ],
            "problemMatcher": {
                "owner": "Spin2",
                "fileLocation": ["autoDetect", "${workspaceFolder}"],
                "pattern": {
                    "regexp": "^(.*):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "severity": 3,
                    "message": 4
                }
            },
            "presentation": {
                "panel": "dedicated",
                "focus": false,
                "showReuseMessage":false,
                "clear": true
            },
        },
        {
            "label": "Propeller: Download Code",
            "type": "shell",
            "args": [
                "-b230400",
                "${config:topLevel}.binary",
                "-t"
            ],
            "osx": {
                "command": "loadp2.mac",
            },
            "windows": {
                "command": "loadp2.exe",
            },
            "linux": {
                "command": "loadp2",
                "args": [
                    "-b230400",
                    "${config:topLevel}.binary",
                    "-t",
                    "-p/dev/ttyUSB0"
                ],
            },
            "problemMatcher": [],
            "presentation": {
                "panel": "dedicated",
                "focus": false,
                "showReuseMessage":false,
                "clear": true
            },
            "dependsOn": [
                "Propeller: Compile Top File"
            ]
        }
    ]
}

Comments

  • Hadden notice that. It always reuses the terminal window for me. I often have to kill it because my serial connection to the P2 is not broken.

    Compiles always reuse the same terminal for me.

    Mike

  • @"Andrey Demenev" Hmmm... thanks for figuring this out and posting. I'll test and then adjust my documentation and examples at my site.

    -Stephen

  • @"Stephen Moraco"

    Maybe that depends on VS Code version? @iseries says it worked differently

Sign In or Register to comment.