Skip to content

Uefi build

uefi_build

Code that supports the Tianocore Edk2 build system.

This class is designed to be subclassed by a platform to allow more extensive and custom behavior.

UefiBuilder

Object responsible for the full build process.

The following steps are completed by the UefiBuilder and is overridable by the platform:

  1. PlatformPreBuild()
  2. UefiBuildPlugins that implement do_pre_build()
  3. Build() (should not be overridden)
  4. UefiBuildPlugins that implement do_post_build()
  5. PlatformFlashImage()

Attributes:

Name Type Description
SkipPreBuild bool

Skip Pre Build or not

SkipPostBuild bool

Skip Post Build or not

SkipBuild bool

Skip Build or not

FlashImage bool

Flash the image not

Clean bool

Clean the build directory or not

Update Conf (bool

Update the conf or not

env VarDict

Special dictionary containing build and env vars

mws MultipleWorkspace

DEPRECATED. Use self.edk2path

edk2path Edk2Path

path utilities for manipulating edk2 paths, packages, and modules

ws str

Workspace root dir

pp str

packagespath separated by os.pathsep

Helper HelperFunctions

object containing registered helper functions

pm PluginManager

The plugin manager

__init__

__init__() -> None

Inits an empty UefiBuilder.

AddPlatformCommandLineOptions

AddPlatformCommandLineOptions(
    parserObj: argparse.ArgumentParser,
) -> None

Adds command line options to the argparser.

Parameters:

Name Type Description Default
parserObj argparser

argparser object

required

RetrievePlatformCommandLineOptions

RetrievePlatformCommandLineOptions(
    args: argparse.Namespace,
) -> None

Retrieve command line options from the argparser.

Parameters:

Name Type Description Default
args Namespace

namespace containing gathered args from argparser

required

Go

Go(
    WorkSpace: str,
    PackagesPath: str,
    PInHelper: HelperFunctions,
    PInManager: PluginManager,
) -> int

Core executable that performs all build steps.

CleanTree

CleanTree(RemoveConfTemplateFilesToo: bool = False) -> int

Cleans the build directory.

Parameters:

Name Type Description Default
RemoveConfTemplateFilesToo bool

deletes conf files used for building makefiles

False

Build

Build() -> int

Adds all arguments to the build command and runs it.

PreBuild

PreBuild() -> int

Performs internal PreBuild steps.

This includes calling the platform overridable PlatformPreBuild()

PostBuild

PostBuild() -> int

Performs internal PostBuild steps.

This includes calling the platform overridable PlatformPostBuild().

SetEnv

SetEnv() -> int

Performs internal SetEnv steps.

This includes platform overridable SetPlatformEnv() and `SetPlatformEnvAfterTarget().

FlashRomImage

FlashRomImage() -> int

Executes platform overridable PlatformFlashImage().

PlatformPreBuild classmethod

PlatformPreBuild() -> int

Perform Platform PreBuild Steps.

Returns:

Type Description
int

0 on success, 1 on failure

PlatformPostBuild classmethod

PlatformPostBuild() -> int

Perform Platform PostBuild Steps.

Returns:

Type Description
int

0 on success, 1 on failure

SetPlatformEnv classmethod

SetPlatformEnv() -> int

Set and read Platform Env variables.

This is performed before platform files like the DSC and FDF have been parsed.

Tip

If a platform file (DSC, FDF, etc) relies on a variable set in the UefiBuilder, it must be set here, before the platform files have been parsed and values have been set.

Returns:

Type Description
int

0 on success, 1 on failure

SetPlatformEnvAfterTarget classmethod

SetPlatformEnvAfterTarget() -> int

Set and read Platform Env variables after platform files have been parsed.

Returns:

Type Description
int

0 on success, 1 on failure

SetPlatformDefaultEnv classmethod

SetPlatformDefaultEnv() -> list[namedtuple]

Sets platform default environment variables by returning them as a list.

Variables returned from this method are printed to the command line when calling stuart_build with -h, --help. Variables added here should be reserved only those that are commonly overwritten in the command line for developers.

Variables returned from this function are the last variables to be set, ensuring that default values are only added if none have been provided by other means.

Returns:

Type Description
list[namedtuple]

List of named tuples containing name, description, default

PlatformBuildRom classmethod

PlatformBuildRom() -> int

Build the platform Rom.

Tip

Typically called by the platform in PlatformFlashImage. Not called automatically by the UefiBuilder.

PlatformFlashImage classmethod

PlatformFlashImage() -> int

Flashes the image to the system.

Returns:

Type Description
int

0 on success, 1 on failure

PlatformGatedBuildShouldHappen classmethod

PlatformGatedBuildShouldHappen() -> bool

Specifies if a gated build should happen.

Returns:

Type Description
bool

True if gated build should happen, else False

ParseTargetFile

ParseTargetFile() -> int

Parses the target.txt file and adds values as env settings.

"Sets them so they can be overriden.

ParseToolsDefFile

ParseToolsDefFile() -> int

Parses the tools_def.txt file and adds values as env settings.

"Sets them so they can be overriden.

ParseDscFile

ParseDscFile() -> int

Parses the active platform DSC file.

This will get lots of variable info to be used in the build. This makes it so we don't have to define things twice.

ParseFdfFile

ParseFdfFile() -> int

Parses the active platform FDF file.

This will get lots of variable info to be used in the build. This makes it so we don't have to define things twice the FDF file usually comes from the Active Platform DSC file so it needs to be parsed first.

SetBasicDefaults

SetBasicDefaults() -> int

Sets default values for numerous build control flow variables.