Actions

EmSys

Difference between revisions of "Using Visual Studio Code for ARM Development – Build Tasks"

From EdWiki

(Created page with "__NOTOC__ == Using Visual Studio Code for ARM Development – Build Tasks == It isn’t strictly necessary to use [https://code.visualstudio.com/ Visual Studio Code] to build...")
 
m
Line 45: Line 45:
  
 
</pre>
 
</pre>
 +
 +
The first task just runs the command-line “'''make'''”. The Terminal pane will be opened to show the results. This is the default build task, so it can be performed using ctrl-shift-B.
 +
 +
The second task is similar, but it runs “'''make clean'''”. It doesn’t have a defined shortcut key. However, this can be performed by selecting Terminal/Run Build Task... from the menu or alt-shift-B. You can then select from the defined tasks.
 +
 +
(VSCode does have configurable keybindings, so if you want to assign a task to a shortcut key, you can do this easily!)

Revision as of 08:42, 27 December 2019

Using Visual Studio Code for ARM Development – Build Tasks

It isn’t strictly necessary to use Visual Studio Code to build your code. We can still drop to the command line and build it more directly. However, it is handy to be able to build with a shortcut key or not have to manage another window.

For example code, If we have a Makefile that we use with “make all” as the default target, and “make clean” to delete everything.

We can set up custom tasks within VSCode that can execute any shell command, even specifying which shell to use. There is a special “Default Build” task.

To start, select the “Terminal” menu, then “Configure Tasks”. If this is the first time, it will ask for a type – select “Make”; VSCode will create the .vscode/tasks.json file for us. Copy the following code and save it.


{
	"version": "2.0.0",
	"tasks": [
		{
			"label": "Make",
			"type": "shell",
			"command": "make",
			"presentation": {
				"echo": true,
				"reveal": "always",
				"focus": false,
				"panel": "shared"
			},
			"group": {
				"kind": "build",
				"isDefault": true
			}
		},
		{
			"label": "Make Clean",
			"type": "shell",
			"command": "make clean",
			"presentation": {
				"echo": true,
				"reveal": "always",
				"focus": false,
				"panel": "shared"
			},
			"group": "build"
		}
	]
}

The first task just runs the command-line “make”. The Terminal pane will be opened to show the results. This is the default build task, so it can be performed using ctrl-shift-B.

The second task is similar, but it runs “make clean”. It doesn’t have a defined shortcut key. However, this can be performed by selecting Terminal/Run Build Task... from the menu or alt-shift-B. You can then select from the defined tasks.

(VSCode does have configurable keybindings, so if you want to assign a task to a shortcut key, you can do this easily!)