Skip to content

TuxMake Python API

The public tuxmake API is provided by the module, and is documented here.

The Build class

class'.', output_dir=None, build_dir=None, target_arch=None, toolchain=None, wrapper=None, environment={}, kconfig='defconfig', kconfig_add=[], make_variables={}, targets=['config', 'kernel', 'xipkernel', 'modules', 'dtbs', 'dtbs-legacy', 'debugkernel', 'headers'], kernel_image=None, jobs=None, runtime=None, verbose=False, quiet=False, debug=False, auto_cleanup=True)

This class encapsulates a tuxmake build.

The class constructor takes in more or less the same parameters as the the command line API, and will raise an exception if any of the arguments, or combinarion of them, is not supported. For example, if you want to only validate a set of build arguments, but not actually run the build, you can just instantiate this class.

Only the methods and properties that are documented here can be considered as the public API of this class. All other methods must be considered as implementation details.

All constructor parameters are optional, and have sane defaults. They are:

  • tree: the source directory to build. Defaults to the current directory.
  • output_dir: directory where the build artifacts will be copied. Defaults to a new directory under ~/.cache/tuxmake/builds.
  • build_dir: directory where the build will be performed. Defaults to a temporary directory under output_dir. An existing directory can be specified to do an incremental build on top of a previous one.
  • target_arch: target architecture name (str). Defaults to the native architecture of the hosts where tuxmake is running.
  • toolchain: toolchain to use in the build (str). Defaults to whatever Linux uses by default (gcc).
  • wrapper: compiler wrapper to use (str).
  • environment: environment variables to use in the build (dict with str as keys and values).
  • kconfig: which configuration to build (str). Defaults to defconfig.
  • kconfig_add: additional kconfig fragments/options to use. List of str, defaulting to an empty list.
  • make_variables: KEY=VALUE arguments to pass to make. dict with strings as values and strings as keys. Some KEYs are now allowed, as they would interfere with the tuxmake normal operation(e.g. ARCH, CC, CROSS_COMPILE, HOSTCC, INSTALL_MOD_PATH,INSTALL_DTBS_PATH,O`, etc).
  • targets: targets to build, list of str. If None or an empty list is passed, the default list of targets will be built.
  • kernel_image: which kernel image to build, overriding the default kernel image name defined for the target architecture.
  • jobs: number of concurrent jobs to run (as in make -j N). int, defaults to the number of available CPU cores.
  • runtime: name of the runtime to use (str).
  • verbose: do a verbose build. The default is to do a silent build (i.e. make -s).
  • quiet: don't show the build logs in the console. The build log is still saved to the output directory, unconditionally.
  • debug: produce extra output for debugging tuxmake itself. This output will not appear in the build log.
  • auto_cleanup: whether to automatically remove the build directory after the build finishes. Ignored if build_dir is passed, in which case the build directory will not be removed.

Performs the build. After this method completes, the results of the build can be inspected though the status, passed, and failed properties.


A dictionary with target names (str) as keys, and BuildInfo objects as values.

This property is only guaranteed to have a meaningful value after run() has been called.


False if any targets failed, True otherwise.

This property is only guaranteed to have a meaningful value after run() has been called.


True if any target failed to build, False otherwise.

This property is only guaranteed to have a meaningful value after run() has been called.

The BuildInfo class

class, duration=None)

Instances of this class represent the build results of each target (see Build.status).


The target build status. "PASS", "FAIL", or "SKIP".


Time this target took to build; a float, representing the duration in seconds.


True if this target failed.


True if this target passed.


True if this target was skipped.

The build wrapper function**kwargs)

This function instantiates a Build objecty, forwarding all the options received in **kwargs. It hen calls run() on that instance, and returns it. It can be used as quick way of running a build and inspecting the results.

For full control over the build, you will probably want to use the Build class directly.