6.1.2.11. MSBuildIntegration

Use MSBuild for analysis compilation

This rule builds Visual Studio projects or solutions with Axivion's MSBuild integration.

It only supports C/C++ (.vcxproj) projects, for C# (.csproj) projects see AxivionC#Frontend.

This rule corresponds to the command-line tools build_sln and build_vcxproj.

The build with Axivion will output an IR file next to the output file of the native build (or, instead of the native output file, if with_ir_suffix is disabled). You will need to configure /Project/ir to the final linked IR you wish to analyze (typically the .exe.ir). Alternatively you can use the /Project/advanced.multi_binary option and the AxivionLinker rule to link together multiple .exe.ir files for a combined analysis.

You can either compile a whole solution (by setting the solution option), or a single project and its dependencies (by setting the project option).

The MSBuildIntegration is designed for Windows projects compiled with Microsoft's C/C++ compiler. It cannot be used with projects targeting Linux, or with projects where MSBuild merely calls a separate build system.

Some scenarios require building the code with Microsoft's C++ compiler before the code can be built with Axivion's compiler. See the option omit_native_build for more details.

Options

The following places define options that affect this rule: BuildSystemIntegration, Project-GlobalOptions

abort_on_error

abort_on_error : bool = True

If set to true and the build step returns a non-zero exit-code, the build is aborted. Otherwise a non-zero exit-code is logged but the build continues.
 

binary

binary : bauhaus.analysis.config.ProjectRelativePath | None = None

Location of the MSBuild.exe to use.

If this option is not specified, this tool will auto-detect the MSBuild executable to use from the VisualStudioVersion specified in the solution file, or (if no solution is given), the ToolsVersion attribute in the project.

 

build_configuration

build_configuration : str | None = None

Configuration to build.

This configuration will be passed to MSBuild via /p:Configuration. Note that when the solution option is set, this value should be a solution configuration. The mapping within the .sln file will then be used to apply the expected configurations to the individual projects.

 

build_platform

build_platform : str | None = None

Platform to build.

This configuration will be passed to MSBuild via /p:Platform. Note that when the solution option is set, this value should be a solution platform. The mapping within the .sln file will then be used to apply the expected platforms to the individual projects.

 

build_target

build_target : str = 'AxivionBuild'

The target name for building the project.

Corresponds to the /t parameter when using MSBuild. The AxivionBuild target will use cafeCC instead of the Microsoft compilers in order to produce an IR file.

 

capture_output

capture_output : bool = False

Sets whether the shell output of the step should be captured. Note that only the output of the build step will be captured and not the output of possible clean steps.

The output will be parsed according to the format configured with the options output_format, stdout_format, stderr_format.

 

clean_target

clean_target : str = 'Clean'

The target name for cleaning the project.

Can be set to an empty string to avoid cleaning anything.

 

environment

environment : dict[str, str] = {}

Environment for extending the call of MSBuild. These entries are added to the environment and existing ones will be overwritten.
 

omit_native_build

omit_native_build : bool = True

Whether to avoid performing a native build as part of the Axivion build. This saves some build time, but has some downsides:
  • When using #import with COM type libraries, a native build is required because it creates header files from the type library, the Axivion build then reads those header files.
  • A native build is required for C++/CLI libraries.
 

options

options : str | None = None

Additional command-line parameters for MSBuild.
 

output_format

output_format : list[str] = ['generic']

Name of the format(s) describing the output pattern to capture from stdout/stderr.

The format names available here correspond to the provider options in /Analysis/AnalysisControl/ExternalAnalysisFormats.

This option only has an effect if capture_output is true.

 

plain_console_logger

plain_console_logger : bool = False

Use a custom MSBuild logger that simplifies the console output to make it machine readable.

This option should be enabled when capture_output is in use. If you do not need capture_output, disabling this option will result in the normal MSBuild console output better suited for human consumption.

 

project

project : bauhaus.analysis.config.ProjectRelativePath | None = None

Project file (e.g. .vcxproj).

This or solution must be specified.

 

properties

properties : dict[str, str] = {}

Additional properties for MSBuild that are transformed into /p:key=value options.
 

reference_build_target

reference_build_target : str | None = None

The target name for building referenced projects (leave unspecified unless you know what you are doing).

Will be passed to MSBuild via /p:ProjectReferenceBuildTargets when building (but not when cleaning).

 

reference_clean_target

reference_clean_target : str | None = None

The target name for cleaning referenced projects (leave unspecified unless you know what you are doing).

Will be passed to MSBuild via /p:ProjectReferenceBuildTargets when cleaning (but not when building).

 

solution

solution : bauhaus.analysis.config.ProjectRelativePath | None = None

Solution file (.sln).

If a solution is specified but no project is specified, all projects in the solution will be built.

If both a project and a solution are specified, only the specified project and its dependencies will be built. In this case the solution only serves to apply the correct configurations/platforms to the individual projects, and to set the $(SolutionDir) (etc.) properties.

If no solution is specified, the same configuration/platform setting will be used for the project and all of its dependencies.

 

stderr_format

stderr_format : list[str] = []

Name of the format(s) describing the output pattern to capture from stderr. This takes precedence over output_format if set.

The format names available here correspond to the provider options in /Analysis/AnalysisControl/ExternalAnalysisFormats.

This option only has an effect if capture_output is true.

 

stdout_format

stdout_format : list[str] = []

Name of the format(s) describing the output pattern to capture from stdout. This takes precedence over output_format if set.

The format names available here correspond to the provider options in /Analysis/AnalysisControl/ExternalAnalysisFormats.

This option only has an effect if capture_output is true.

 

with_ir_suffix

with_ir_suffix : bool = True

Whether to add a .ir suffix to the output file name specified in the .vcxproj file (resulting in .obj.ir, .exe.ir, .dll.ir and .lib.ir files). If this option is enabled, the results of native builds and Axivion builds can coexist for the same configuration/platform in the same workspace.