Contenido principal

polyspace.project.ProjectToolchain Class

R2026b

Namespace: polyspace.project

(Python) Store toolchain configuration for a build configuration

Since R2026b

Description

This Python® class represents the toolchain associated with a build configuration. A polyspace.project.ProjectToolchain object stores the toolchain name, version, and toolchain-specific configuration variables such as compiler paths.

You obtain a polyspace.project.ProjectToolchain object from the Toolchain property of a polyspace.project.OwnedBuildConfiguration or polyspace.project.BuildConfiguration object. To change the toolchain, assign a toolchain name string to the Toolchain property of the build configuration.

Creation

Description

toolchain = buildConf.Toolchain returns the polyspace.project.ProjectToolchain object associated with the build configuration buildConf. Here, buildConf is a polyspace.project.OwnedBuildConfiguration or polyspace.project.BuildConfiguration object.

buildConf.Toolchain = toolchainName sets the toolchain for the build configuration. If the specified toolchain name is different from the current toolchain, all toolchain settings (version, variables, customization options) are reset to their defaults. If the specified toolchain name is the same as the current toolchain, the existing settings are preserved.

Input Arguments

expand all

Name of the toolchain to use for dynamic testing, specified as a string. For example, "visual" or "GNU gcc/g++ | CMake/Ninja (64-bit Linux)".

Properties

expand all

Name of the toolchain, returned as a string. This property is read-only. To change the toolchain, assign a new toolchain name string to the Toolchain property of the parent build configuration.

Example: "visual"

Version of the toolchain, specified as a string. The version must be a valid version supported by the selected toolchain. Assigning an empty string resets the version to unspecified. If you set a version that is not supported by the current toolchain, an error is raised.

Example: "12.0"

Configuration variables for setting up the toolchain, returned as a polyspace.project.ConstrainedStringMap object. This map contains key-value pairs where the keys are setup information required by the toolchain (such as compiler paths, linker paths, or setup commands) and the values are strings. The set of allowed keys is determined by the selected toolchain and cannot be modified.

To set a toolchain variable, use dictionary-style assignment:

toolchain.SetupInfo["Setup Command"] = "vcvarsall.bat"

To iterate over all toolchain variables:

for key, value in toolchain.SetupInfo.items():
    print(f"{key} = {value}")

The available keys depend on the type of template toolchain:

  • For visual toolchains:

    map = buildConf.Toolchain.SetupInfo
    map["Setup Command"] = r"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat"
    map["Setup Command arguments"] = "x86"
    map["Assembler executable"] = "ml.exe"
    map["C/C++ Compiler executable"] = "cl.exe"
  • For gnu or clang toolchains:

    map = buildConf.Toolchain.SetupInfo
    map["C Compiler path"] = r"C:\Work\mingw81\bin\gcc.exe"
    map["C Linker path"] = r"C:\Work\mingw81\bin\gcc.exe"
    map["Archiver path"] = r"C:\Work\mingw81\bin\ar.exe"
    map["C++ Compiler path"] = r"C:\Work\mingw81\bin\g++.exe"
    map["C++ Linker path"] = r"C:\Work\mingw81\bin\g++.exe"
    map["Assembler path"] = r"C:\Work\mingw81\bin\as.exe"
  • For cross-compiler template toolchains (folder-based) such as diab or iar-ew:

    map = buildConf.Toolchain.SetupInfo
    map["Folder"] = r"\\server\share\apps\diab7.0.6.0\win64"

The names of configuration variables for template toolchains are the same as the ones available in the user interface. For more information, see Configure Template Toolchains for Testing.

Version History

Introduced in R2026b