dpu.compiler module

This module provides standard C compilation features.

class dpu.compiler.Compiler(path, target=None, verbose=False)

Bases: object

A representation of a compiler with some parameters

path

Path to the compiler executable

Type:

str

target

if specified, the target to use instead of the default one

Type:

str, optional

verbose

if set to True, outputs some details on the executed command and its outputs

Type:

bool, optional

compile(sources, output=None, includes=[], defines={}, options=[], target=None, opt_lvl=None, debug=True, verbose=False)

Compiles some sources files

Parameters:
  • sources (str or list of str) – The source files

  • output (str, optional) – The output file path (default is None)

  • includes ((list of str), optional) – The include directories (default is [])

  • str (defines ((dict of) – str, optional), optional): The defines to add during preprocessing (default is {})

  • options ((list of str), optional) – Additional options for the compiler execution (default is [])

  • target (str, optional) – The target for the compilation (default is None)

  • opt_lvl (str, optional) – The optimization level to use (default is None)

  • debug (bool, optional) – Whether the debug information should be added to the output (default is True)

  • verbose (bool, optional) – Whether compilation information concerning the executed command and its outputs should be printed (default is False)

Returns:

The status of the finish compiler executable execution

Return type:

CompletedProcess

Raises:

CalledProcessError – If the compiler executable returns a non-zero exit code

dpu.compiler.O0 = '-O0'

Optimization level corresponding to ‘-O0’

dpu.compiler.O1 = '-O1'

Optimization level corresponding to ‘-O1’

dpu.compiler.O2 = '-O2'

Optimization level corresponding to ‘-O2’

dpu.compiler.O3 = '-O3'

Optimization level corresponding to ‘-O3’

dpu.compiler.Os = '-Os'

Optimization level corresponding to ‘-Os’

dpu.compiler.Oz = '-Oz'

Optimization level corresponding to ‘-Oz’

dpu.compiler.getDpuArchVersion(target)