How to run a command before build in DVT IDE
Overview
This video covers how to run a shell command before the DVT build, for use cases such as generating source files or updating filelists.
The +dvt_pre_full_build_cmd build config directive is the the most straightforward option and works across all tools, including DVT IDE for VS Code or Eclipse as well as batch-mode tools like Verissimo, Specador or the DVT MCP Server.
Then the video covers alternative methods using VS Code Tasks and Eclipse Run Configurations that enable explicit control over when the pre-build step executes, or chaining it into a longer sequence of actions.
The video was made using DVT IDE version 26.1.20.
Details
Introduction
This video covers how to run a shell command before the DVT build — for example, to generate source files or update filelists.
Method 1: Using +dvt_pre_full_build_cmd+
The most straightforward way is to specify the +dvt_pre_full_build_cmd+ directive in your build
configuration file:
+dvt_pre_full_build_cmd+"./generate.sh testbench"
The command runs before the build starts, with the working directory set to the project directory. Then, the build configuration is re-parsed, so any changes made by the command take effect for the actual project build. The directive works across all tools, both in GUI and batch modes.
You can specify multiple such directives, and they will be executed in order. If a command terminates with a non-zero exit code, an error is reported at the directive's location.
The specified command runs unconditionally on every build. If you want explicit control over when the pre-build step executes, or to define multiple flows with different pre-build commands or mix the step into a longer sequence of actions, you can use VS Code Tasks or Eclipse Run Configurations.
Method 2: VS Code Tasks
In DVT IDE for VS Code, run the Tasks: Configure
Task command,
select Create tasks.json from template, and choose Others.
This will create a tasks.json file under the .vscode directory.
Then define the following tasks, each handling a specific step in the workflow:
- The first one executes the external script.
- The second one triggers the DVT build, equivalent to calling DVT: Build from the Command Palette.
- And finally the main task chains the previous two together.
To run everything, select the Tasks: Run Task command and pick the main one. Note that a problem matcher can be added to scan the command output and report issues in the Problems view. For this example, let's continue without scanning.
For quick access, open the keyboard shortcuts file and add an entry binding a key combination to the task.
Now, pressing Ctrl+Alt+B will run the script and trigger the build in one go.
Method 3: Eclipse Run Configurations
In DVT IDE for Eclipse, you can define a similar workflow using Run Configurations.
Go to the Run menu and open the Run Configurations dialog. Select the DVT Generic category, create a New Launch Configuration, then fill in the configuration name and the command to execute.
On the Build tab, check Run internal builder after the launch command.
Optionally, on the Refresh tab you can choose what resources should be automatically refreshed after the run - for example generated source files, while on the Filters tab you can define filters that scan the command output to provide direct links to source code from the console.
For quick access, go to the Shortcuts tab, check Add button on main toolbar, and assign a keyboard shortcut.
Now you can launch the configuration either using the newly created toolbar button or the shortcut.