You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 1, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+35-4
Original file line number
Diff line number
Diff line change
@@ -101,8 +101,8 @@ The following settings are as per sketch settings of the Arduino extension. You
101
101
"board": "adafruit:samd:adafruit_feather_m0",
102
102
"output": "../build",
103
103
"debugger": "jlink",
104
-
"prebuild": "bash prebuild.sh",
105
-
"postbuild": "bash postbuild.sh",
104
+
"prebuild": "./prebuild.sh",
105
+
"postbuild": "./postbuild.sh",
106
106
"intelliSenseGen": "global"
107
107
}
108
108
```
@@ -111,13 +111,44 @@ The following settings are as per sketch settings of the Arduino extension. You
111
111
-`board` - Currently selected Arduino board alias. Can be set by the `Arduino: Change Board Type` command. Also, you can find the board list there.
112
112
-`output` - Arduino build output path. If not set, Arduino will create a new temporary output folder each time, which means it cannot reuse the intermediate result of the previous build leading to long verify/upload time, so it is recommended to set the field. Arduino requires that the output path should not be the workspace itself or in a subfolder of the workspace, otherwise, it may not work correctly. By default, this option is not set. It's worth noting that the contents of this file could be deleted during the build process, so pick (or create) a directory that will not store files you want to keep.
113
113
-`debugger` - The short name of the debugger that will be used when the board itself does not have a debugger and there is more than one debugger available. You can find the list of debuggers [here](https://github.com/Microsoft/vscode-arduino/blob/master/misc/debuggerUsbMapping.json). By default, this option is not set.
114
-
-`prebuild` - External command which will be invoked before any sketch build (verify, upload). You must only set one `prebuild` command. `command1 && command2` does not work. If you need to run multiple commands before the build, then create a script.
115
-
-`postbuild` - External command to be run after the sketch has been built successfully. Same rules as for `prebuild` apply. <!-- TODO: note about cwd would be a good thing -->
114
+
-`prebuild` - External command which will be invoked before any sketch build (verify, upload, ...). For details see the [Pre- and Post-Build Commands](#Pre--and-Post-Build-Commands) section.
115
+
-`postbuild` - External command to be run after the sketch has been built successfully. See the afore mentioned section for more details.
116
116
-`intelliSenseGen` - Override the global setting for auto-generation of the IntelliSense configuration (i.e. `.vscode/c_cpp_properties.json`). Three options are available:
117
117
-`"global"`: Use the global settings (default)
118
118
-`"disable"`: Disable the auto-generation even if globally enabled
119
119
-`"enable"`: Enable the auto-generation even if globally disabled
120
120
121
+
## Pre- and Post-Build Commands
122
+
On Windows the commands run within a `cmd`-, on Linux and OSX within a `bash`-instance. Therefore your command can be anything what you can run within those shells. Instead of running a command you can invoke a script. This makes writing more complex pre-/post-build mechanisms much easier and opens up the possibility to run python or other scripting languages.
123
+
The commands run within the workspace root directory and vscode-arduino sets the following environment variables:
124
+
**`VSCA_BUILD_MODE`** The current build mode, one of `Verifying`, `Uploading`, `Uploading (programmer)` or `Analyzing`. This allows you to run your script on certain build modes only.
125
+
**`VSCA_SKETCH`** The sketch file relative to your workspace root directory.
126
+
**`VSCA_BOARD`** Your board and configuration, e.g. `arduino:avr:nano:cpu=atmega328`.
127
+
**`VSCA_WORKSPACE_DIR`** The absolute path of your workspace root directory.
128
+
**`VSCA_LOG_LEVEL`** The current log level. This allows you to control the verbosity of your scripts.
129
+
**`VSCA_SERIAL`** The serial port used for uploading. Not set if you haven't set one in your `arduino.json`.
130
+
**`VSCA_BUILD_DIR`** The build directory. Not set if you haven't set one in your `arduino.json`.
131
+
132
+
For example under Windows the following `arduino.json` setup
vscode-arduino auto-configures IntelliSense by default. vscode-arduino analyzes Arduino's compiler output by running a separate build and generates the corresponding configuration file at `.vscode/c_cpp_properties.json`. vscode-arduino tries as hard as possible to keep things up to date, e.g. it runs the analysis when switching the board or the sketch.
0 commit comments