public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [RFC Patch 0/3] Expand PREBUILD/POSTBUILD actions
@ 2017-08-03 17:30 Michael D Kinney
  2017-08-03 17:30 ` [RFC Patch 1/3] BaseTools/build: Expand PREBUILD/POSTBUILD DSC actions Michael D Kinney
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michael D Kinney @ 2017-08-03 17:30 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu, Michael Kinney

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-08-12  4:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-03 17:30 [RFC Patch 0/3] Expand PREBUILD/POSTBUILD actions Michael D Kinney
2017-08-03 17:30 ` [RFC Patch 1/3] BaseTools/build: Expand PREBUILD/POSTBUILD DSC actions Michael D Kinney
2017-08-03 17:30 ` [RFC Patch 2/3] BaseTools/Scripts: Add python script to run a makefile Michael D Kinney
2017-08-03 17:30 ` [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile for use with RunMakefile.py Michael D Kinney
2017-08-11  5:40   ` Zhu, Yonghong
2017-08-11 16:33     ` Kinney, Michael D
2017-08-12  4:19       ` Zhu, Yonghong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox