[edk2] [RFC Patch 0/3] Expand PREBUILD/POSTBUILD actions

Michael D Kinney posted 3 patches 6 years, 8 months ago
Failed in applying to current master (apply log)
BaseTools/Scripts/RunMakefile.py                   | 178 +++++++++++++++++++++
BaseTools/Scripts/RunMakefileSample.mak            |  43 +++++
.../Source/Python/Workspace/WorkspaceDatabase.py   |   4 +-
BaseTools/Source/Python/build/build.py             | 108 +++++++++----
4 files changed, 303 insertions(+), 30 deletions(-)
create mode 100644 BaseTools/Scripts/RunMakefile.py
create mode 100644 BaseTools/Scripts/RunMakefileSample.mak
[edk2] [RFC Patch 0/3] Expand PREBUILD/POSTBUILD actions
Posted by Michael D Kinney 6 years, 8 months ago
A platform DSC file can provide PREBUILD and POSTBUILD actions in the 
[Defines] section of the DSC file.  The EDK II DSC specification only allows
a single argument for these two defines, which means the PREBUILD and 
POSTBUILD actions are limited to simple batch files, shell scripts, or
applications with no additional arguments.  This also means that a platform
DSC file that uses the PREBUILD/POSTBUILD feature is typically limited to single
OS development environment.

This RFC and associated patch series expands the PREBUILD and POSTBUILD 
define syntax to support multiple arguments.  All arguments are scanned.
Arguments that are WORKSPACE or PACKAGES_PATH relative file paths are converted
to absolute paths.  Supporting multiple arguments allows PREBUILD and POSTBUILD
actions to be implemented in OS independent scripts such as Python. The 
following is an example of a PREBUILD action that runs the python interpreter
on a python script provided in a platform package:

[Defines]
  PREBUILD = python MyPlatformPackage/MyPreBuildScript.py

Supporting multiple arguments also allows additional platform arguments to be
passed into the script:

[Defines]
  PREBUILD = python MyPlatformPackage/MyPreBuildScript.py --FlashSize 4MB

In addition, the EDK II Build Specification states that TARGET, ARCH, and
TOOL_CHAIN_TAG are passed to the PREBUILD and POSTBUILD commands.  The path
to the platform DSC file being build, the path to the Conf directory, and the 
build target form the following set are not provided:

  [all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]
  
It is important for the PREBUILD and POSTBUILD actions to receive the same 
context that is provided to the build command. 

This RFC and associated patch series expands the context passed into the
PREBUILD and POSTBUILD actions to include the -p <DSC File>,
--conf=<Conf Directory>, and build target arguments.

I have also seen requests to support makefiles in the PREBUILD and POSTBUILD
actions.  Makefiles receive context from system environment and define values
passed in on the command line.  In order to support makefiles, a generic python
script called /BaseTools/Scripts/RunMakefile.py is also included in this patch
series.  This python script converts command line arguments to makefile defines
and runs a makefile specified with the --makefile flag. A sample makefile that
echos the relevant system environment variables and defines is provided in
BaseTools/Scripts/RunMakefileSample.mak.  An example PREBUIILD action that runs
a makefile is as follows:

[Defines]
  PREBUILD = python BaseTools/Script/RunMakefile.py --makefile BaseTools/Scripts/RunMakefileSample.mak

The example above contains 4 arguments.  2 of these arguments are WORKSPACE or
PACKAGES_PATH relative paths that must be converted to absolute paths.  This
is a use case that justifies expanding the PREBUILD and POSTBUILD define
statements to support multiple arguments.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>

Michael D Kinney (3):
  BaseTools/build: Expand PREBUILD/POSTBUILD DSC actions
  BaseTools/Scripts: Add python script to run a makefile
  BaseTools/Scripts: Add sample makefile for use with RunMakefile.py

 BaseTools/Scripts/RunMakefile.py                   | 178 +++++++++++++++++++++
 BaseTools/Scripts/RunMakefileSample.mak            |  43 +++++
 .../Source/Python/Workspace/WorkspaceDatabase.py   |   4 +-
 BaseTools/Source/Python/build/build.py             | 108 +++++++++----
 4 files changed, 303 insertions(+), 30 deletions(-)
 create mode 100644 BaseTools/Scripts/RunMakefile.py
 create mode 100644 BaseTools/Scripts/RunMakefileSample.mak

-- 
2.13.1.windows.2

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel