主要内容

polyspace.project.OwnedBuildConfiguration Class

R2026b

Namespace: polyspace.project

(Python) Build configurations attached to specific project

Since R2024a

Description

The properties of the polyspace.project.OwnedBuildConfiguration class contain the build-related configuration options attached to a specific Polyspace® Platform project. These properties correspond to the build options listed in Polyspace Test options, Polyspace Bug Finder options (Polyspace Bug Finder), and Polyspace Code Prover options (Polyspace Code Prover).

To create modular projects, where project components like configurations and graphical tests are saved in separate files, consider using external configurations. An external configuration is a build, static analysis, or testing and profiling configuration that is saved in a separate file that is referenced by the project. To work with external build configurations in the Polyspace Python® API see polyspace.project.BuildConfigurationRef and polyspace.project.BuildConfiguration. For more information about project structure, see Modularize Project by Using External Configurations, Test References, and External Stub Files.

Build configurations created from a build command (using polyspace-configure) or from Polyspace for AUTOSAR workspaces cannot be converted to external configurations or removed from the project. To save a copy of these configurations to a file, use the export() method.

Creation

Description

Create Build Configuration

buildConfig = proj.BuildConfigurations.create(configName) creates a new polyspace.project.OwnedBuildConfiguration object with the Name property set to configName and all other properties set to their default values. The resulting buildConfig object is attached to the polyspace.project.Project object proj.

Load Build Configuration

buildConfig = proj.BuildConfigurations[configName] loads the existing polyspace.project.OwnedBuildConfiguration object with the Name property set to configName from the polyspace.project.Project object proj.

Create Copy of Build Configuration

buildConfig = proj.BuildConfigurations.createFrom(existingConfigObj) creates a new polyspace.project.OwnedBuildConfiguration object by copying an existing owned build configuration existingConfigObj and attaches this copied object to the polyspace.project.Project object proj. To assign a unique name to buildConfig, Polyspace uses the Name property of existingConfigObj and appends the next available numeric suffix.

buildConfig = proj.BuildConfigurations.createFrom(existingConfigObj, configName) creates a new polyspace.project.OwnedBuildConfiguration object by copying an existing owned build configuration existingConfigObj and attaches this copied object to the polyspace.project.Project object proj. Use the configName argument to set the Name property of the resulting object.

buildConfig = proj.BuildConfigurations.createFrom(existingConfigFile) creates a new polyspace.project.OwnedBuildConfiguration object by copying the build configuration defined in the file existingConfigFile, and attaches this object to the polyspace.project.Project object proj.

buildConfig = proj.BuildConfigurations.createFrom(existingConfigFile, configName) creates a new polyspace.project.OwnedBuildConfiguration object by copying the build configuration defined in the file existingConfigFile and attaches this object to the polyspace.project.Project object proj. Use the configName argument to set the Name property of the resulting object.

Convert Build Configuration

buildConfig = proj.BuildConfigurations.moveAsOwned(existingConfigRefObj) converts the build configuration that the project proj references through existingConfigRefObj to a polyspace.project.OwnedBuildConfiguration object and removes existingConfigRefObj from the project.

Input Arguments

expand all

Name of the build configuration, specified as a string. This argument sets the Name property of the object.

Example: "My Build Configuration"

Existing owned build configuration to make a copy of, specified as a polyspace.project.OwnedBuildConfiguration object.

Example: proj.BuildConfigurations[2]

Absolute or relative path to an existing .pscfg or .toml.pscfg file, specified as a string. Relative paths are considered relative to the location of the .psprjx project file.

Example: "myBuildConfig.pscfg"

The existing referenced build configuration that you want to convert to a polyspace.project.OwnedBuildConfiguration object, specified as a polyspace.project.BuildConfigurationRef object.

Example: proj.BuildConfigurationRefs[0]

Properties

expand all

Name of the build configuration, specified as a string.

Optional description of the build configuration. Use this property to provide information about the build configuration.

Example: "My build configuration"

Specify that your compiler implements right shifts on signed integers as arithmetic shifts.

See also Shift right on signed integers as arithmetic shift (-logical-signed-right-shift) (Polyspace Bug Finder).

Example: buildConf.ArithmeticSignedIntegerRightShift=False

Specify the name of the target board Polyspace Test™ uses to run the test executable.

See also Target board name (Testing).

Example: buildConf.Board="myBoard"

Specify C standard version followed in code, as a buildConf.CVersion value.

See also C standard version (-c-version).

Example: buildConf.CVersion=buildConf.CVersion.C_17

Specify C++ standard version followed in code, as a buildConf.CppVersion value.

See also C++ standard version (-cpp-version)

Example: buildConf.CppVersion=buildConf.CppVersion.CPP_17

Emulate your compiler behavior by replacing macros with their definitions in preprocessed code. Specify the macro definition as macroName=macroDefinition. To ignore a macro, set it equal to blank (macroName=). To replace a macro by 1, specify only macroName.

To modify this property, use these methods:

  • append(macroDefinition) — Add a macro definition.

  • pop(macroDefinitionIdx) — Remove the macro definition with index macroDefinitionIdx. If you do not specify an index, the last item in the list is removed.

  • clear() — Remove all macro definitions.

See also Preprocessor definitions (-D).

Example: buildConf.Defines.append("uint32=int")

Example: buildConf.Defines.append("NDEBUG")

Example: buildConf.Defines.pop(0)

This property behaves like a Python sequence. The Python API for Polyspace supports most standard operations on Python sequences. See Supported Operations on Sequences.

Enable or disable the compilation of code on your host machine while retaining the word sizes of target processor on which the code is intended to run.

See also Enable portable word sizes.

Example: buildConf.EnablePortableWordSizes=True

Specify paths of headers and precompiled libraries for tests that you import from an external framework such as GoogleTest.

Specify path of folders where Polyspace Test looks for headers files included in external tests.

To modify this property, use these methods:

  • add(folderPath) — Add an include path.

  • pop(folderPathIdx) — Remove the include path with index folderPathIdx. If you do not specify an index, the last item in the list is removed.

  • clear() — Remove all macro definitions.

See also Include paths for external tests.

Example: buildConf.ExternalTestsBuildOptions.IncludePaths.add("/usr/lib/import")

Example: buildConf.ExternalTestsBuildOptions.IncludePaths.pop(0)

Specify the name of the precompile objects, static libraries, or dynamic libraries that Polyspace Test links with your source files and test code to build test executables for external tests.

To modify this property, use these methods:

  • append(libraryName) — Add a value to this property.

  • pop(libraryNameIdx) — Remove the value with index libraryNameIdx. If you do not specify an index, the last item in the list is removed.

  • clear() — Remove all values associated with this property.

See also Libraries for external tests.

Example: buildConf.ExternalTestsBuildOptions.Libraries.append("libgtest.a")

Example: buildConf.ExternalTestsBuildOptions.Libraries.pop(0)

This property behaves like a Python sequence. The Python API for Polyspace supports most standard operations on Python sequences. See Supported Operations on Sequences.

Specify the path of the folders where Polyspace Test looks for precompiled objects, static libraries, or dynamic libraries that you specify with buildConf.ExternalTestsBuildOptions.Libraries.

To modify this property, use these methods:

  • append(folderPath) — Add a value to this property.

  • pop(folderPathIdx) — Remove the value with index folderPathIdx. If you do not specify an index, the last item in the list is removed.

  • clear() — Remove all values associated with this property.

See also Library paths for external tests.

Example: buildConf.ExternalTestsBuildOptions.LibraryPaths.append("/usr/local/googletest/build/lib/")

Example: buildConf.ExternalTestsBuildOptions.LibraryPaths.pop(0)

This property behaves like a Python sequence. The Python API for Polyspace supports most standard operations on Python sequences. See Supported Operations on Sequences.

Specify additional C compilation flags that your compiler needs to build your C code project correctly. Use this option for flags that you cannot specify through other options.

See also Extra C flags.

Example: buildConf.ExtraCFlags="-ffast-math"

Specify additional C++ compilation flags that your compiler needs to build your C++ code project correctly. Use this option for flags that you cannot specify through other options.

See also Extra C++ flags.

Example: buildConf.ExtraCppFlags="-fno-rtti"

Specify additional linker flags that your compiler needs to build your C or C++ code project correctly. Use this option for flags that you cannot specify through other options.

See also Extra flags for linking.

Example: buildConf.ExtraLinkFlags="-pthread"

Specify build options that you want to associate with a specific file without applying those options to other files in your project.

Use add(filePath) to associate file filePath with a polyspace.project.FileBuildOptions object or addChecked(filePath) to add the file only if filePath has already been declared in the project. To remove the polyspace.project.FileBuildOptions object associated with filePath, use pop(filePath). To remove all polyspace.project.FileBuildOptions objects, use clear().

To change the properties of an existing polyspace.project.FileBuildOptions object, use square brackets to select the corresponding source file. For example, buildConf.FileOverrides["filePath"].

The polyspace.project.FileBuildOptions object stores these file-specific options:

  • CVersion

  • CppVersion

  • Defines

  • ExtraFlags

  • ImplicitCompilerDefines

  • ImplicitCompilerIncludePaths

  • IncludePaths

  • Language

  • PreIncludes

  • Undefines

The Defines, Undefines, ImplicitCompilerDefines, and PreIncludes properties behave like Python sequences. The Python API for Polyspace supports most standard operations on Python sequences. See Supported Operations on Sequences.

See also -options-for-sources (Polyspace Bug Finder).

Example: buildConf.FileOverrides.add("filePath")

Example: buildConf.FileOverrides["filePath"].Language=polyspace.project.FileLanguage.CPP

Example: buildConf.FileOverrides["filePath"].CppVersion=buildConf.CppVersion.CPP_17

Example: buildConf.FileOverrides.pop("filePath")

Specify the path of folders where Polyspace Test looks for files that are included by your source and test code. You can specify the absolute path or the path relative to the current folder.

To modify this property, use these methods:

  • add(folderPath) — Add a folder path.

  • pop(folderPathIdx) — Remove the folder path with index folderPathIdx. If you do not specify an index, the last folder path in the list is removed.

  • clear() — Remove all folder paths associated with this property.

See also Include paths (-I).

Example: buildConf.IncludePaths.add("/usr/local/polyspace/pstunit")

Example: buildConf.IncludePaths.pop(0)

Specify how your compiler rounds down the results of a negative integer division if your compiler follows the C90 Standard. By default, the quotient is rounded toward zero, or the smallest integer greater than or equal to the algebraic quotient. For example, -5/3 = -1. Specify Floor to round the quotient to the largest integer less than or equal to the algebraic quotient. For example, -5/3 = -2.

See also Round down results of negative integer division (-div-round-down) (Polyspace Bug Finder).

Example: buildConf.IntegerDivisionRounding=buildConf.IntegerDivisionRounding.Floor

Specify the language of your source files. Polyspace Test uses the language conventions of the language that you specify. Some options are available only if you select C as the language, and some options are available only if you select C++ as the language.

Select C_CPP if your project contains both C and C++ files. In this case, Polyspace interprets .c files as C code and other file extensions as C++ code.

See also Source code language (-lang).

Example: buildConf.Language=buildConf.Language.C_CPP

Specify the name of the precompile objects, static libraries, or dynamic libraries that Polyspace Test links with your source files and test code to build test executables.

To modify this property, use these methods:

  • append(libraryName) — Add a value to this property.

  • pop(libraryNameIdx) — Remove the value with index libraryNameIdx. If you do not specify an index, the last value in the list is removed.

  • clear() — Remove all values associated with this property.

See also Libraries.

Example: buildConf.Libraries.append("mylib.so")

Example: buildConf.Libraries.pop(0)

This property behaves like a Python sequence. The Python API for Polyspace supports most standard operations on Python sequences. See Supported Operations on Sequences.

Specify the path of the folders where Polyspace Test looks for precompiled objects, static libraries, or dynamic libraries that you specify with buildConf.Libraries.

To modify this property, use these methods:

  • append(folderPath) — Add a folder path.

  • pop(folderPathIdx) — Remove the folder path with index folderPathIdx. If you do not specify an index, the last folder path in the list is removed.

  • clear() — Remove all folder paths associated with this property.

See also Library paths.

Example: buildConf.LibraryPaths.append("/usr/local/build/lib/")

Example: buildConf.LibraryPaths.pop(0)

This property behaves like a Python sequence. The Python API for Polyspace supports most standard operations on Python sequences. See Supported Operations on Sequences.

Specify the default packing alignment, in bytes, for structures, unions, and class members.

See also Pack alignment value (-pack-alignment-value).

Example: buildConf.PackAlignmentValue=buildConf.PackAlignmentValue.SIZE_4_B

Specify files to be included by every source file. Specifying this property does not modify the original source files. For example, set this property to define types that are not defined in your code.

To modify this property, use these methods:

  • append(filePath) — Add a file path.

  • pop(filePathIdx) — Remove the file path with index filePathIdx. If you do not specify an index, the last file path in the list is removed.

  • clear() — Remove all file paths associated with this property.

See also Forced includes (-include).

Example: buildConf.PreIncludes.append("/usr/lib/types/mytypes.h")

Example: buildConf.PreIncludes.pop(0)

This property behaves like a Python sequence. The Python API for Polyspace supports most standard operations on Python sequences. See Supported Operations on Sequences.

Select or manage the processor for the current build configuration, returned as a polyspace.project.Processor object. To view a list of available processors for a project proj, type proj.Processors.

Note that if you set the Board property to the name of a previously registered hardware board (that is, a value other than "None" or "Host Computer"), the Processor property is set to the processor associated with the board. For an example of setting a hardware board, see Add Target and Build Tests on Target.

See also Processor.

Example: buildConf.Processor=proj.Processors[2]

Size of special function registers (sfr) data types, specified in bits as typename=sizeInBits.

To modify this property, use these methods:

  • append(typename=sizeInBits) — Add a value to this property.

  • pop(typenameIdx) — Remove the value with index typenameIdx. If you do not specify an index, the last value in the list is removed.

  • clear() — Remove all values associated with this property.

See also Sfr type support (-sfr-types) (Polyspace Bug Finder)

Example: buildConf.SfrTypes.append("sfr32=32")

Example: buildConf.SfrTypes.pop(0)

This property behaves like a Python sequence. The Python API for Polyspace supports most standard operations on Python sequences. See Supported Operations on Sequences.

Name of compiler that Polyspace uses to build your source code for static analysis (Bug Finder or Code Prover analysis). For a list of available compilers, see Compilation toolchain (Static Analysis) (Polyspace Bug Finder).

The default value is "Same as testing toolchain". With this setting, the compiler and target values for static analysis are automatically determined from the testing toolchain that you select. For more information, see Selecting Common Toolchain for Static Analysis and Testing (Polyspace Bug Finder).

When you set this property, the property StaticAnalysisTargetName might change as follows:

  • If you set a built-in compiler (such as "gnu9.x" or "visual17.x") or reset to the default value, "Same as testing toolchain", any previous value of the StaticAnalysisTargetName property is cleared.

    In this case, the Processor property determines the target characteristics used for static analysis.

  • If you change from one cross-compiler to another (such as, from "diab" to "renesas") and the StaticAnalysisTargetName property has a value that is not supported for the new compiler, it is automatically set to a supported target.

  • If you set an invalid compiler name, a ValueError is raised.

For more information on static analysis compilers and targets, see Compilation toolchain for static analysis (-compiler, -compiler -target) (Polyspace Bug Finder) and Processor (-custom-target) (Polyspace Bug Finder).

Example: buildConf.StaticAnalysisCompilerName="Same as testing toolchain"

Example: buildConf.StaticAnalysisCompilerName="gnu9.x"

Example: buildConf.StaticAnalysisCompilerName="renesas"

Name of processor target whose fundamental data type sizes Polyspace uses to build your source code for static analysis (Bug Finder and Code Prover). For a list of available targets, see Target processor type (-target) (Polyspace Bug Finder).

This property is set to None unless the static analysis compiler StaticAnalysisCompilerName is a cross-compiler (for example, for built-in compilers such as "gnu9.x" or when it is reset to the default "Same as testing toolchain"). In this case, the Processor property determines the target characteristics used for static analysis.

When you set this property and a cross-compiler is specified for the property StaticAnalysisCompilerName, it might change as follows:

  • If you set a target that is supported by the current cross-compiler in StaticAnalysisCompilerName, the compiler is unchanged.

  • If you set a target that is not supported by the current cross-compiler, the StaticAnalysisCompilerName property is automatically updated to the first available compiler that supports that target.

  • If you set this property to None while a cross-compiler is selected, the StaticAnalysisCompilerName property is reset to "Same as testing toolchain".

  • If you set an invalid target name, a ValueError is raised.

For more information on static analysis compilers and targets, see Compilation toolchain for static analysis (-compiler, -compiler -target) (Polyspace Bug Finder) and Processor (-custom-target) (Polyspace Bug Finder).

Example: buildConf.StaticAnalysisTargetName="rh850"

Example: buildConf.StaticAnalysisTargetName=None

Toolchain configuration for dynamic testing, returned as a polyspace.project.ProjectToolchain object. This object stores the toolchain name, version, and toolchain-specific configuration variables. By default, Polyspace automatically detects an installed toolchain.

To change the toolchain, assign a toolchain name string to this property. If the specified name is different from the current toolchain, all toolchain settings are reset to their defaults.

See also Compilation toolchain (Testing).

Example: buildConf.Toolchain="GNU gcc/g++ | CMake/Ninja (64-bit Linux)"

Emulate your compiler behavior by declaring macros as undefined in preprocessed code.

To modify this property, use these methods:

  • append(macroName) — Add a macro to this property.

  • pop(macroNameIdx) — Remove the macro with index macroNameIdx. If you do not specify an index, the last macro in the list is removed.

  • clear() — Remove all macros associated with this property.

This property has no effect on macros that you define using a #define preprocessor directive.

See also Disabled preprocessor definitions (-U).

Example: buildConf.Undefines.append("_WIN32")

Example: buildConf.Undefines.pop(0)

This property behaves like a Python sequence. The Python API for Polyspace supports most standard operations on Python sequences. See Supported Operations on Sequences.

Methods

expand all

Version History

Introduced in R2024a

expand all