Using the OpenViBE build scripts in Visual Studio

Hello  !

This article present a new tip for those who are using Visual Studio as their primary development tool for OpenViBE.
If you try to install OpenViBE from the source code on the SVN repository, then you have to use the provided scripts for nearly everything… And Visual Studio will only be a C++ code editor. No “build project” command, no debug/release configurations, etc. I felt this frustrating as I had always used VS in the past as my “all-in-one” developer tool.

A previous article on this blog described how to use the Visual Studio debugger when developing a new plugin or driver.
This time I will focus on using the scripts provided with OpenViBE right inside Visual Studio.

This article is based on Jay Smith blog post here.

What we need:

Let’s list what we may want to integrate in the IDE. First, the build scripts:

  1. win32-build.cmd: builds every project of the software platform (applications, plugins, etc.)
  2. win32-clean.cmd: cleanup the CMake cache directory, thus when building again everything will be compiled and installed from scratch.

Then some launchers for the main applications:

  1. ov-designer.cmd
  2. ov-acquisition-server.cmd
  3. ov-skeleton-generator.cmd

Add new menu contents :

Open Visual Studio and your openvibe solution, then go in Tools > External Tools. You should have something like this :

Let’s add the win32-build.cmd script. Add a new content and fill it with the following information:

Title:                   Build OpenViBE
Command:                 C:\[path-to-repository]\scripts\win32-build.cmd
Arguments:               [NO ARGUMENT]
Initial directory:       C:\[path-to-repository]\scripts\
Use Output Window:       YES
Prompt for arguments:    NO
Treat output as Unicode: NO

With Use Output Window checked, the build log will be directly printed in the “output” console of Visual Studio. I didn’t find how to redirect the output with the color information, so the log is just printed black on white in Visual Studio. Uncheck this option if you still want the CMD terminal popping up when building the software.

You can do exactly the same for win32-clean.cmd if you’d like to.

For the application launchers, add new content with the following information:

Title:                   ov-designer
Command:                 C:\[path-to-repository]\dist\test-designer.cmd
Arguments:               [NO ARGUMENT]
Initial directory:       C:\[path-to-repository]\dist\
Use Output Window:       NO
Prompt for arguments:    NO
Treat output as Unicode: NO

This time I don’t want to print the output console in Visual Studio.

You can do the same for the acquisition-server and/or the skeleton-generator for example.

Now that you defined all your personal the menu contents, note their indexes in the list of External Tools, starting at 1.
Why that ?! because Visual Studio doesn’t seem to be capable of referencing these new menu contents by their names… instead you will have something like “External Command 4“, “External Command 5“, etc.
Nevermind… :s

Access the new commands:

Now that we defined some new commands, let’s use them. In my case, I want to be able to run the build process in the context menu of the editor (right click in the main edition panel) or with a dedicated button in the toolbar.
Right click somewhere in the toolbar and select Customize. You have 2 panels, one for the toolbars and one for the commands that appears in the toolbars and menus.

In Toolbars you can add a new group named “OpenViBE”. We will add new buttons in it for our new commands.
Go in the Commands tab.

In the Toolbar selection box, search for “OpenViBE”. You should see in the Controls panel… nothing at all. Click on the Add Command… button.
You will find your new menu content in the category Tool, under the name “External Command #”. I hope your remember the indexes 🙂
Add the external commands corresponding to the build script and the launchers, you should see them in the Visual studio toolbar.

In the Context menus selection box, search for Project and Solution Context Menus |Item. This correspond to the context menu that pops up when right-clicking somewhere in the editor main panel.
As I want to be able to launch the build from there, I also add the corresponding external command.

Want more ?

As we already discussed in a previous article how to customize the build process, it is possible to have more than one build script. For example I personaly have 3 of them:

  • One in Release, that builds every project.
  • 2 others in Debug and Release, that rely on a specific win32-init_env_command script that only select for build the project I’m currently working on (e.g. work-in-progress branches)

Thus I added 3 commands in Visual Studio: “OpenViBE build (wip/release)”, “OpenViBE build (wip/debug)”,“OpenViBE build (all/release)”.

I hope this article will give you some new ideas to improve your development environment, not only for OpenViBE of course 🙂

Cheers !

About Laurent Bonnet
Research Engineer at INRIA. Software developer for OpenViBE, the open-source platform for Brain-Computer Interfaces.

Leave a comment