From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6AC8621E1DACF for ; Thu, 3 Aug 2017 10:28:18 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 03 Aug 2017 10:30:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,317,1498546800"; d="scan'208";a="135756518" Received: from mdkinney-mobl1.amr.corp.intel.com ([10.254.75.199]) by fmsmga006.fm.intel.com with ESMTP; 03 Aug 2017 10:30:28 -0700 From: Michael D Kinney To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu , Michael Kinney Date: Thu, 3 Aug 2017 10:30:20 -0700 Message-Id: <20170803173023.2452-1-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.13.1.windows.2 Subject: [RFC Patch 0/3] Expand PREBUILD/POSTBUILD actions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Aug 2017 17:28:18 -0000 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 , --conf=, 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 Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney 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