30.5 Building a UEFI driver

Building a UEFI Driver involves the use of the build.exe command provided with the
EDK II tools. If the pre-requisites were followed at the beginning of this chapter, then the only flag that need to be passed into build.exe is the DSC file that is to be used for the build.
build -p MyDriverPkg/MyDriverPkg.dsc
If the build competes successfully, then the UEFI Driver generated can be found in the build output directory that is specified in the DSC file. In the example above, OUTPUT_DIRECTORY is set to Build/MyDriverPkg. The following example shows where MyDriver.efi is located. This specific example shows that a DEBUG build was used with a Microsoft family compiler to generate MyDriver.efi for IA32.

Example 264-Build Output Directory

If a UEFI Driver needs to be built as a DEBUG build or a RELEASE build, this can be specified on the command line. The following two examples show how to build for DEBUG and RELEASE. If the -b flag is not specified, then the build type is retrieved from Conf/target.txt.
  • build -b DEBUG -p MyDriverPkg/MyDriverPkg.dsc
  • build -b RELEASE -p MyDriverPkg/MyDriverPkg.dsc
If a UEFI Driver needs to be built for other CPU architectures, then those can also be specified on the command line. The following 4 examples show how to build for IA32, X64, IPF, and EBC if the compiler and linkers installed support all these architectures.
  • build -a IA32 -p MyDriverPkg/MyDriverPkg.dsc
  • build -a X64 -p MyDriverPkg/MyDriverPkg.dsc
  • build -a IPF -p MyDriverPkg/MyDriverPkg.dsc
  • build -a EBC -p MyDriverPkg/MyDriverPkg.dsc
The 4 separate commands above can also be combined into a single command:
  • build -a IA32 -a X64 -a IPF -a EBC -p MyDriverPkg/MyDriverPkg.dsc
The EDK II also supports a configuration file for builds in the file path Conf/target.txt.
This file may be updated with the specific configuration that is most commonly used. For example, the ACTIVE_PLATFORM can be set to MyDriverPkg/MyDriverPkg.dsc, and the build command can then be invoked with no parameters at all:
  • build
Please see the EDK II User's Manual and other EDK II documents for more details on how to use the build command and for details on INF files, DEC files, and DSC files.