Main Content

Create Projects from Visual Studio in Polyspace Platform User Interface

If you develop in the Visual Studio® IDE, you can trace the commands running underneath your Visual Studio build and create a Polyspace Platform project. This method of creating a project automatically adds source files and compilation options from the Visual Studio project to the Polyspace® project.

Note that to accurately reflect your Visual Studio project, you must run a complete build of your project and not an incremental build. An incremental build only rebuilds sources that changed since the previous build and can lead to incomplete Polyspace projects.

This example shows how to create a Polyspace Platform user interface project by tracing a Visual Studio build at the command line or within an IDE. Calling the build command at the command line is the recommended approach because building within an IDE introduces additional complications when you trace the build.

Create Polyspace Project from Build in Visual Studio Developer Command Prompt

To create a Polyspace Platform user interface project, you have to prepend polyspace-configure with the option -output-platform-project to your regular build command. For instance, suppose you have a Visual Studio project TestProject.vcxproj. To create a Polyspace Platform user interface project:

  1. Open the Visual Studio developer command prompt. For instance, in Windows®, start typing Developer Command Prompt for VS 2019.

    This command prompt is similar to a regular command prompt but with all Visual Studio environment variables appropriately set up.

  2. Perform a full build of your Visual Studio project at the command prompt:

    msbuild TestProject.vcxproj /t:Rebuild
    Ensuring that the build completes successfully by itself allows you to create a Polyspace project from an error-free build.

  3. For this step to work, you must add the path polyspaceroot\polyspace\bin to the Path environment variable in Windows. Here, polyspaceroot is the Polyspace installation folder, for instance, C:\Program Files\Polyspace\R2024b.

    Run the complete build command from the previous step but prepend the command with the polyspace-configure command and -output-platform-project option:

    polyspace-configure -output-platform-project TestProject msbuild TestProject.vcxproj /t:Rebuild

Instead of a project, you can also run polyspace-configure on the full build of a solution. However, a solution consists of multiple projects, each of which can generate a separate executable. In this example, polyspace-configure generates a project that mixes source files contributing to separate executables. To avoid the issue, use the -module option:

polyspace-configure -module -output-platform-project TestProject msbuild TestProject.vcxproj /t:Rebuild

Create Polyspace Project from Build in Visual Studio IDE

To create a Polyspace Platform user interface project, you can open the Visual Studio IDE from within the Polyspace Platform user interface and perform a full build within the IDE.

  1. In the Polyspace Platform user interface toolstrip, select New > From build command.

  2. In the Create project using build information window, enter a project name and author, and specify a save location for your project.

  3. In the Build section, select Use build command and enter the full path to the Visual Studio executable. For instance, "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe".

    example Create project using build information window with example path to visual studio environment.

  4. In the field Working Directory, enter a folder to which you have write access, for instance, C:\temp\Polyspace. Click to open the Visual Studio environment.

  5. In the Visual Studio environment, create and build a Visual Studio project.

    If you already have a Visual Studio project, open the existing project and build a clean solution. For instance, to build a clean solution in Visual Studio 2019, select Build > Rebuild Solution.

    Example of Build menu in visual studio.

  6. After the project builds, close Visual Studio.

    Polyspace traces your Visual Studio build and creates a Polyspace Platform user interface project.

    The Polyspace project contains the source files from your Visual Studio build and the relevant target and compiler options.

If you update your Visual Studio project, you can update the corresponding Polyspace project with the same changes. On the Projects pane, right-click the project name and select Update Using Build Command.

See Also

Related Topics