Specify Polyspace Compiler Options Through Eclipse Project

This topic describes how to configure a Polyspace® analysis of Eclipse™ projects using Polyspace Bug Finder or Polyspace Code Prover. For the Polyspace as You Code plugin, see Run Polyspace as You Code in Eclipse (Polyspace Bug Finder Access).

Polyspace analysis in Eclipse uses a set of default analysis options preconfigured for your coding language and operating system. For each project, you can customize the analysis options further.

  • Compiler options: You specify the compiler that you use, the libraries that you include and the macros that are defined for your compilation.

  • Other options: Through the other options, you specify which analysis results you want and how precise you want them to be.To specify these options in Eclipse, select Polyspace > Configure Project.

For information on how to run Polyspace from Eclipse, see Run Polyspace Analysis on Eclipse Projects.

Eclipse Refers Directly to Your Compilation Toolchain

When setting up your Eclipse project, you might be directly referring to your compilation toolchain without using a build command. For instance, you might refer to the MinGW GCC toolchain in the project setup wizard as below.

The compiler options from your Eclipse project, such as include paths and preprocessor macros, are reused for the analysis.

You cannot view the options directly in the Polyspace configuration but you can view them in your Eclipse editor. In your project properties (Project > Properties), in the Paths and Symbols node:

  • See the include paths under the Includes tab.

    During analysis, the paths are implicitly used with the analysis option -I.

  • See the preprocessor macros under the Symbols tab.

    During analysis, the macros are implicitly used with the analysis option Preprocessor definitions (-D).

Eclipse Uses Your Compilation Toolchain Through Build Command

When setting up your Eclipse project, instead of specifying your compilation toolchain directly, you might be specifying it through a build command. For instance, in the Wind River Workbench IDE (an Eclipse-based IDE), you might specify your build command as shown in the following figure.

If you use a build command for compilation, the analysis cannot automatically extract the compiler options. You must trace your build command.

  1. Replace your build command with:

    polyspaceroot\polyspace\bin\polyspace-configure.exe -no-sources -output-project PolyspaceWorkspace\EclipseProjects\Name\Name.psprj buildCommand
    Here:

    • polyspaceroot is the Polyspace installation folder.

    • polyspaceWorkspace is the folder where your Polyspace files are stored. You specify this location on the Project and Results Folder tab in your Polyspace preferences (Tools > Preferences in the Polyspace user interface).

    • Name is the name of your Eclipse project.

    • buildCommand is the original build command that you want to trace.

      For instance, in the preceding example, buildCommand is the following:

      %makeprefix% make --no-print-directory

    For information on the options -output-project and -no-sources, see polyspace-configure.

  2. Build your Eclipse project. Perform a clean build so that files are recompiled.

    For instance, select the option Project > Clean. Normally, the option runs your build command. With your replacement in the previous step, the option also traces the build to extract the compiler options.

  3. Restore the original build command and restart Eclipse.

    You can now run analysis on your Eclipse project. The analysis uses the compiler options that it has extracted.

Related Topics