Skip to content

Commit

Permalink
Allow build wrappers
Browse files Browse the repository at this point in the history
Closes #340

Adds two optional environment variables that, if specified, will be
used in lieu of the `build` command and its parameters during build.

1. `EDK_BUILD_CMD` - If present, the absolute path to an application
   to use for the edk build process that will be invoked instead of
   `build`. This is primarily used to allow a tool to wrap around
   `build` such that it will eventually call `build` internally.

2. `EDK_BUILD_PARAMS` - If present, these parameters will be passed
   to the build command. This is primarily used to pair wrapper-
   specific parameters with the wrapper passed in `EDK_BUILD_CMD`.

From a practical standpoint, these are the minimum changes needed
in the build tools to allow the CodeQL CLI to be invoked as a build
wrapper.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
  • Loading branch information
makubacki committed Nov 7, 2022
1 parent bb936e7 commit ea2febc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/usability/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ Web dependencies. After the initial fetch, this can greatly improve the performa
calling `stuart_update` and make it far easier to switch between multiple branches or
scopes where dependencies may change.

## EDK_BUILD_CMD

If present, the absolute path to an application to use for the edk build process will be
invoked instead of `build`. This is primarily used to allow a tool to wrap around `build`.

## EDK_BUILD_PARAMS

If present, these parameters will be passed to the build command. This is primarily used to
pair wrapper-specific parameters with the wrapper passed in `EDK_BUILD_CMD`.

For more info, see [the External Dependencies docs](using_extdep.md).
13 changes: 12 additions & 1 deletion edk2toolext/environment/uefi_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,18 @@ def Build(self):
pre_build_env_chk = env.checkpoint()
env.set_shell_var('PYTHONHASHSEED', '0')
env.log_environment()
ret = RunCmd("build", params)

edk2_build_cmd = self.env.GetValue("EDK_BUILD_CMD")
if edk2_build_cmd is None:
edk2_build_cmd = "build"
logging.debug("The edk2 build command is %s" % edk2_build_cmd)

edk2_build_params = self.env.GetValue("EDK_BUILD_PARAMS")
if edk2_build_params is None:
edk2_build_params = params
logging.debug("Edk2 build parameters are %s" % edk2_build_params)

ret = RunCmd(edk2_build_cmd, edk2_build_params)
# WORKAROUND - Undo the workaround.
env.restore_checkpoint(pre_build_env_chk)

Expand Down

0 comments on commit ea2febc

Please sign in to comment.