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

* [RFC Patch 1/3] BaseTools/build: Expand PREBUILD/POSTBUILD DSC actions
  2017-08-03 17:30 [RFC Patch 0/3] Expand PREBUILD/POSTBUILD actions Michael D Kinney
@ 2017-08-03 17:30 ` 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
  2 siblings, 0 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

* Extend PREBUILD/POSTBUILD define values to support more than
  one argument.
* Delay normalization of PREBUILD/POSTBUILD define values
  until all arguments in the define values can be processed.
* Convert PREBUILD/POSTBUILD build define value arguments
  that are WORKSPACE or PACKAGES_PATH relative paths to
  absolute paths.
* Append -p PlatformFile, --conf=ConfDirectory, and build target
  flags to command line used to execute PREBUILD/POSTBUILD
  actions.
* Remove PrebuildScript and PostbuildScript fields from the
  Build class and use Prebuild and Postbuild fields instead.

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>
---
 .../Source/Python/Workspace/WorkspaceDatabase.py   |   4 +-
 BaseTools/Source/Python/build/build.py             | 108 +++++++++++++++------
 2 files changed, 82 insertions(+), 30 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
index 73b3fe7134..fe2c7c17c4 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
@@ -237,7 +237,7 @@ class DscBuildData(PlatformBuildClassObject):
                         EdkLogger.error('build', FORMAT_INVALID, 'Missing double quotes in the end of %s statement.' % TAB_DSC_PREBUILD,
                                     File=self.MetaFile, Line=Record[-1])
                     PrebuildValue = Record[2][1:-1]
-                self._Prebuild = PathClass(NormPath(PrebuildValue, self._Macros), GlobalData.gWorkspace)
+                self._Prebuild = PrebuildValue
             elif Name == TAB_DSC_POSTBUILD:
                 PostbuildValue = Record[2]
                 if Record[2][0] == '"':
@@ -245,7 +245,7 @@ class DscBuildData(PlatformBuildClassObject):
                         EdkLogger.error('build', FORMAT_INVALID, 'Missing double quotes in the end of %s statement.' % TAB_DSC_POSTBUILD,
                                     File=self.MetaFile, Line=Record[-1])
                     PostbuildValue = Record[2][1:-1]
-                self._Postbuild = PathClass(NormPath(PostbuildValue, self._Macros), GlobalData.gWorkspace)
+                self._Postbuild = PostbuildValue
             elif Name == TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES:
                 self._SupArchList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT)
             elif Name == TAB_DSC_DEFINES_BUILD_TARGETS:
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 4d05ee2761..7436453582 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -796,8 +796,6 @@ class Build():
         self.BuildModules = []
         self.Db_Flag = False
         self.LaunchPrebuildFlag = False
-        self.PrebuildScript = ''
-        self.PostbuildScript = ''
         self.PlatformBuildPath = os.path.join(GlobalData.gConfDirectory,'.cache', '.PlatformBuild')
         if BuildOptions.CommandLength:
             GlobalData.gCommandMaxLength = BuildOptions.CommandLength
@@ -819,11 +817,11 @@ class Build():
         EdkLogger.quiet("%-16s = %s" % ("CONF_PATH", GlobalData.gConfDirectory))
         self.InitPreBuild()
         self.InitPostBuild()
-        if self.PrebuildScript:
-            EdkLogger.quiet("%-16s = %s" % ("PREBUILD", self.PrebuildScript))
-        if self.PostbuildScript:
-            EdkLogger.quiet("%-16s = %s" % ("POSTBUILD", self.PostbuildScript))
-        if self.PrebuildScript:
+        if self.Prebuild:
+            EdkLogger.quiet("%-16s = %s" % ("PREBUILD", self.Prebuild))
+        if self.Postbuild:
+            EdkLogger.quiet("%-16s = %s" % ("POSTBUILD", self.Postbuild))
+        if self.Prebuild:
             self.LaunchPrebuild()
             self.TargetTxt = TargetTxtClassObject()
             self.ToolDef   = ToolDefClassObject()
@@ -964,16 +962,37 @@ class Build():
             Platform = self.Db._MapPlatform(str(self.PlatformFile))
             self.Prebuild = str(Platform.Prebuild)
         if self.Prebuild:
-            PrebuildList = self.Prebuild.split()
-            if not os.path.isabs(PrebuildList[0]):
-                PrebuildList[0] = mws.join(self.WorkspaceDir, PrebuildList[0])
-            if os.path.isfile(PrebuildList[0]):
-                self.PrebuildScript = PrebuildList[0]
-                self.Prebuild = ' '.join(PrebuildList)
-                self.Prebuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList)
-                #self.LaunchPrebuild()
-            else:
-                EdkLogger.error("Prebuild", PREBUILD_ERROR, "the prebuild script %s is not exist.\n If you'd like to disable the Prebuild process, please use the format: -D PREBUILD=\"\" " %(PrebuildList[0]))
+            PrebuildList = []
+            #
+            # Evaluate all arguments and convert arguments that are WORKSPACE
+            # relative paths to absolute paths.  Filter arguments that look like
+            # flags or do not follow the file/dir naming rules to avoid false
+            # positives on this conversion.
+            #
+            for Arg in self.Prebuild.split():
+                #
+                # Do not modify Arg if it looks like a flag or an absolute file path
+                #
+                if Arg.startswith('-')  or os.path.isabs(Arg):
+                    PrebuildList.append(Arg)
+                    continue
+                #
+                # Do not modify Arg if it does not look like a Workspace relative
+                # path that starts with a valid package directory name
+                #
+                if not Arg[0].isalpha() or os.path.dirname(Arg) == '':
+                    PrebuildList.append(Arg)
+                    continue
+                #
+                # If Arg looks like a WORKSPACE relative path, then convert to an
+                # absolute path and check to see if the file exists.
+                #
+                Temp = mws.join(self.WorkspaceDir, Arg)
+                if os.path.isfile(Temp):
+                    Arg = Temp
+                PrebuildList.append(Arg)
+            self.Prebuild       = ' '.join(PrebuildList)
+            self.Prebuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList, self.PlatformFile, self.Target)
 
     def InitPostBuild(self):
         if 'POSTBUILD' in GlobalData.gCommandLineDefines.keys():
@@ -982,23 +1001,46 @@ class Build():
             Platform = self.Db._MapPlatform(str(self.PlatformFile))
             self.Postbuild = str(Platform.Postbuild)
         if self.Postbuild:
-            PostbuildList = self.Postbuild.split()
-            if not os.path.isabs(PostbuildList[0]):
-                PostbuildList[0] = mws.join(self.WorkspaceDir, PostbuildList[0])
-            if os.path.isfile(PostbuildList[0]):
-                self.PostbuildScript = PostbuildList[0]
-                self.Postbuild = ' '.join(PostbuildList)
-                self.Postbuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList)
-            else:
-                EdkLogger.error("Postbuild", POSTBUILD_ERROR, "the postbuild script %s is not exist.\n If you'd like to disable the Postbuild process, please use the format: -D POSTBUILD=\"\" " %(PostbuildList[0]))
-
-    def PassCommandOption(self, BuildTarget, TargetArch, ToolChain):
+            PostbuildList = []
+            #
+            # Evaluate all arguments and convert arguments that are WORKSPACE
+            # relative paths to absolute paths.  Filter arguments that look like
+            # flags or do not follow the file/dir naming rules to avoid false
+            # positives on this conversion.
+            #
+            for Arg in self.Postbuild.split():
+                #
+                # Do not modify Arg if it looks like a flag or an absolute file path
+                #
+                if Arg.startswith('-')  or os.path.isabs(Arg):
+                    PostbuildList.append(Arg)
+                    continue
+                #
+                # Do not modify Arg if it does not look like a Workspace relative
+                # path that starts with a valid package directory name
+                #
+                if not Arg[0].isalpha() or os.path.dirname(Arg) == '':
+                    PostbuildList.append(Arg)
+                    continue
+                #
+                # If Arg looks like a WORKSPACE relative path, then convert to an
+                # absolute path and check to see if the file exists.
+                #
+                Temp = mws.join(self.WorkspaceDir, Arg)
+                if os.path.isfile(Temp):
+                    Arg = Temp
+                PostbuildList.append(Arg)
+            self.Postbuild       = ' '.join(PostbuildList)
+            self.Postbuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList, self.PlatformFile, self.Target)
+
+    def PassCommandOption(self, BuildTarget, TargetArch, ToolChain, PlatformFile, Target):
         BuildStr = ''
         if GlobalData.gCommand and isinstance(GlobalData.gCommand, list):
             BuildStr += ' ' + ' '.join(GlobalData.gCommand)
         TargetFlag = False
         ArchFlag = False
         ToolChainFlag = False
+        PlatformFileFlag = False
 
         if GlobalData.gOptions and not GlobalData.gOptions.BuildTarget:
             TargetFlag = True
@@ -1006,6 +1048,8 @@ class Build():
             ArchFlag = True
         if GlobalData.gOptions and not GlobalData.gOptions.ToolChain:
             ToolChainFlag = True
+        if GlobalData.gOptions and not GlobalData.gOptions.PlatformFile:
+            PlatformFileFlag = True
 
         if TargetFlag and BuildTarget:
             if isinstance(BuildTarget, list) or isinstance(BuildTarget, tuple):
@@ -1022,6 +1066,14 @@ class Build():
                 BuildStr += ' -t ' + ' -t '.join(ToolChain)
             elif isinstance(ToolChain, str):
                 BuildStr += ' -t ' + ToolChain
+        if PlatformFileFlag and PlatformFile:
+            if isinstance(PlatformFile, list) or isinstance(PlatformFile, tuple):
+                BuildStr += ' -p ' + ' -p '.join(PlatformFile)
+            elif isinstance(PlatformFile, str):
+                BuildStr += ' -p' + PlatformFile
+        BuildStr += ' --conf=' + GlobalData.gConfDirectory
+        if Target:
+            BuildStr += ' ' + Target
 
         return BuildStr
 
-- 
2.13.1.windows.2



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

* [RFC Patch 2/3] BaseTools/Scripts: Add python script to run a makefile
  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 ` 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
  2 siblings, 0 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

Add the python script RunMakefile.py that can be used
in a PREBUILD/POSTBUIILD action to invoke a makefile
passing in context as makefile defines.  The command
line arguments passed into RunMakefile.py are converted
to the following set of defines.

* ACTIVE_PLATFORM
* TARGET_ARCH
* TOOL_CHAIN_TAG
* CONF_DIRECTORY
* TARGET
* EXTRA_FLAGS

In addition, a makefile can access the system environment
variables including WORKSPACE and PACKAGES_PATH.

The makefile target from the following set is also passed
into the makefile.  If no target is passed into build, then
the 'all' target is used.

[all|fds|genc|genmake|clean|cleanall|cleanlib|modules|libraries|run]

A platform DSC file can use a statements in the [Defines]
section of the following form to use this script.  MAKEFILE
is a WORKSPACE or PACKAGES_PATH relative path to the makefile
to run.

[Defines]
  PREBUILD  = python BaseTools/Script/RunMakefile.py --makefile MAKEFILE
  POSTBUILD = python BaseTools/Script/RunMakefile.py --makefile MAKEFILE

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>
---
 BaseTools/Scripts/RunMakefile.py | 178 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 178 insertions(+)
 create mode 100644 BaseTools/Scripts/RunMakefile.py

diff --git a/BaseTools/Scripts/RunMakefile.py b/BaseTools/Scripts/RunMakefile.py
new file mode 100644
index 0000000000..48bc198c76
--- /dev/null
+++ b/BaseTools/Scripts/RunMakefile.py
@@ -0,0 +1,178 @@
+## @file
+# Run a makefile as part of a PREBUILD or POSTBUILD action.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution.  The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+'''
+RunMakefile.py
+'''
+
+import os
+import sys
+import argparse
+import subprocess
+
+#
+# Globals for help information
+#
+__prog__        = 'RunMakefile'
+__version__     = '%s Version %s' % (__prog__, '1.0')
+__copyright__   = 'Copyright (c) 2017, Intel Corporation. All rights reserved.'
+__description__ = 'Run a makefile as part of a PREBUILD or POSTBUILD action.\n'
+
+#
+# Globals
+#
+gArgs = None
+
+def Log(Message):
+  if not gArgs.Verbose:
+    return
+  sys.stdout.write (__prog__ + ': ' + Message + '\n')
+
+def Error(Message, ExitValue=1):
+  sys.stderr.write (__prog__ + ': ERROR: ' + Message + '\n')
+  sys.exit (ExitValue)
+
+def RelativePath(target):
+  return os.path.relpath (target, gWorkspace)
+
+def NormalizePath(target):
+  if isinstance(target, tuple):
+    return os.path.normpath (os.path.join (*target))
+  else:
+    return os.path.normpath (target)
+
+if __name__ == '__main__':
+  #
+  # Create command line argument parser object
+  #
+  parser = argparse.ArgumentParser (
+                      prog = __prog__,
+                      version = __version__,
+                      description = __description__ + __copyright__,
+                      conflict_handler = 'resolve'
+                      )
+  parser.add_argument (
+           '-a', '--arch', dest = 'Arch', nargs = '+', action = 'append',
+           required = True,
+           help = '''ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 or EBC,
+                     which overrides target.txt's TARGET_ARCH definition. To
+                     specify more archs, please repeat this option.'''
+           )
+  parser.add_argument (
+           '-t', '--tagname', dest = 'ToolChain', required = True,
+           help = '''Using the Tool Chain Tagname to build the platform,
+                     overriding target.txt's TOOL_CHAIN_TAG definition.'''
+           )
+  parser.add_argument (
+           '-p', '--platform', dest = 'PlatformFile', required = True,
+           help = '''Build the platform specified by the DSC file name argument,
+                     overriding target.txt's ACTIVE_PLATFORM definition.'''
+           )
+  parser.add_argument (
+           '-b', '--buildtarget', dest = 'BuildTarget', required = True,
+           help = '''Using the TARGET to build the platform, overriding
+                     target.txt's TARGET definition.'''
+           )
+  parser.add_argument (
+           '--conf=', dest = 'ConfDirectory', required = True,
+           help = '''Specify the customized Conf directory.'''
+           )
+  parser.add_argument (
+           '-D', '--define', dest = 'Define', nargs='*', action = 'append',
+           help = '''Macro: "Name [= Value]".'''
+           )
+  parser.add_argument (
+           '--makefile', dest = 'Makefile', required = True,
+           help = '''Makefile to run passing in arguments as makefile defines.'''
+           )
+  parser.add_argument (
+           '-v', '--verbose', dest = 'Verbose', action = 'store_true',
+           help = '''Turn on verbose output with informational messages printed'''
+           )
+
+  #
+  # Parse command line arguments
+  #
+  gArgs, remaining = parser.parse_known_args()
+  gArgs.BuildType = 'all'
+  for BuildType in ['all', 'fds', 'genc', 'genmake', 'clean', 'cleanall', 'modules', 'libraries', 'run']:
+    if BuildType in remaining:
+      gArgs.BuildType = BuildType
+      remaining.remove(BuildType)
+      break
+  gArgs.Remaining = ' '.join(remaining)
+
+  #
+  # Start
+  #
+  Log ('Start')
+
+  #
+  # Find makefile in WORKSPACE or PACKAGES_PATH
+  #
+  PathList = ['']
+  try:
+    PathList.append(os.environ['WORKSPACE'])
+  except:
+    Error ('WORKSPACE environment variable not set')
+  try:
+    PathList += os.environ['PACKAGES_PATH'].split(os.pathsep)
+  except:
+    pass
+  for Path in PathList:
+    Makefile = NormalizePath((Path, gArgs.Makefile))
+    if os.path.exists (Makefile):
+      break
+  if not os.path.exists(Makefile):
+    Error ('makefile %s not found' % (gArgs.Makefile))
+
+  #
+  # Build command line arguments converting build arguments to makefile defines
+  #
+  CommandLine = [Makefile]
+  CommandLine.append('TARGET_ARCH="%s"' % (' '.join([Item[0] for Item in gArgs.Arch])))
+  CommandLine.append('TOOL_CHAIN_TAG="%s"' % (gArgs.ToolChain))
+  CommandLine.append('TARGET="%s"' % (gArgs.BuildTarget))
+  CommandLine.append('ACTIVE_PLATFORM="%s"' % (gArgs.PlatformFile))
+  CommandLine.append('CONF_DIRECTORY="%s"' % (gArgs.ConfDirectory))
+  if gArgs.Define:
+    for Item in gArgs.Define:
+      if '=' not in Item[0]:
+        continue
+      Item = Item[0].split('=',1)
+      CommandLine.append('%s="%s"' % (Item[0], Item[1]))
+  CommandLine.append('EXTRA_FLAGS="%s"' % (gArgs.Remaining))
+  CommandLine.append(gArgs.BuildType)
+  if sys.platform == "win32":
+    CommandLine = 'nmake /f %s' % (' '.join(CommandLine))
+  else:
+    CommandLine = 'make -f %s' % (' '.join(CommandLine))
+
+  #
+  # Run the makefile
+  #
+  try:
+    Process = subprocess.Popen(CommandLine, shell=True)
+  except:
+    Error ('make command not available.  Please verify PATH')
+  Process.communicate()
+
+  #
+  # Done
+  #
+  Log ('Done')
+
+  #
+  # Return status from running the makefile
+  #
+  sys.exit(Process.returncode)
-- 
2.13.1.windows.2



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

* [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile for use with RunMakefile.py
  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 ` Michael D Kinney
  2017-08-11  5:40   ` Zhu, Yonghong
  2 siblings, 1 reply; 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

Add sample makefile that can be used to test RunMakefile.py
script and can also be used as a template to start a new
PREBUILD/POSTBUILD makefile.

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>
---
 BaseTools/Scripts/RunMakefileSample.mak | 43 +++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 BaseTools/Scripts/RunMakefileSample.mak

diff --git a/BaseTools/Scripts/RunMakefileSample.mak b/BaseTools/Scripts/RunMakefileSample.mak
new file mode 100644
index 0000000000..b0947b7644
--- /dev/null
+++ b/BaseTools/Scripts/RunMakefileSample.mak
@@ -0,0 +1,43 @@
+## @file
+# Sample makefile for PREBUILD or POSTBUILD action.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution.	The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+all: show
+	@echo $@
+genc: show
+	@echo $@
+genmake: show
+	@echo $@
+modules: show
+	@echo $@
+libraries: show
+	@echo $@
+fds: show
+	@echo $@
+clean: show
+	@echo $@
+cleanall: show
+	@echo $@
+cleanlib: show
+	@echo $@
+run: show
+	@echo $@
+
+show:
+	@echo WORKSPACE........ $(WORKSPACE)
+	@echo PACKAGES_PATH.... $(PACKAGES_PATH)
+	@echo ACTIVE_PLATFORM.. $(ACTIVE_PLATFORM)
+	@echo TARGET_ARCH...... $(TARGET_ARCH)
+	@echo TOOL_CHAIN_TAG... $(TOOL_CHAIN_TAG)
+	@echo CONF_DIRECTORY... $(CONF_DIRECTORY)
+	@echo TARGET........... $(TARGET)
+	@echo EXTRA_FLAGS...... $(EXTRA_FLAGS)
-- 
2.13.1.windows.2



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

* Re: [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile for use with RunMakefile.py
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Zhu, Yonghong @ 2017-08-11  5:40 UTC (permalink / raw)
  To: Kinney, Michael D, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Hi Mike,

The patch 3 has some "Tab character used". Please fix it when you commit.
Others are good to me.

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Kinney, Michael D 
Sent: Friday, August 04, 2017 1:30 AM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile for use with RunMakefile.py

Add sample makefile that can be used to test RunMakefile.py script and can also be used as a template to start a new PREBUILD/POSTBUILD makefile.

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>
---
 BaseTools/Scripts/RunMakefileSample.mak | 43 +++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 BaseTools/Scripts/RunMakefileSample.mak

diff --git a/BaseTools/Scripts/RunMakefileSample.mak b/BaseTools/Scripts/RunMakefileSample.mak
new file mode 100644
index 0000000000..b0947b7644
--- /dev/null
+++ b/BaseTools/Scripts/RunMakefileSample.mak
@@ -0,0 +1,43 @@
+## @file
+# Sample makefile for PREBUILD or POSTBUILD action.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> # 
+This program and the accompanying materials # are licensed and made 
+available under the terms and conditions of the BSD License
+# which accompanies this distribution.	The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+all: show
+	@echo $@
+genc: show
+	@echo $@
+genmake: show
+	@echo $@
+modules: show
+	@echo $@
+libraries: show
+	@echo $@
+fds: show
+	@echo $@
+clean: show
+	@echo $@
+cleanall: show
+	@echo $@
+cleanlib: show
+	@echo $@
+run: show
+	@echo $@
+
+show:
+	@echo WORKSPACE........ $(WORKSPACE)
+	@echo PACKAGES_PATH.... $(PACKAGES_PATH)
+	@echo ACTIVE_PLATFORM.. $(ACTIVE_PLATFORM)
+	@echo TARGET_ARCH...... $(TARGET_ARCH)
+	@echo TOOL_CHAIN_TAG... $(TOOL_CHAIN_TAG)
+	@echo CONF_DIRECTORY... $(CONF_DIRECTORY)
+	@echo TARGET........... $(TARGET)
+	@echo EXTRA_FLAGS...... $(EXTRA_FLAGS)
--
2.13.1.windows.2



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

* Re: [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile for use with RunMakefile.py
  2017-08-11  5:40   ` Zhu, Yonghong
@ 2017-08-11 16:33     ` Kinney, Michael D
  2017-08-12  4:19       ` Zhu, Yonghong
  0 siblings, 1 reply; 7+ messages in thread
From: Kinney, Michael D @ 2017-08-11 16:33 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org, Kinney, Michael D; +Cc: Gao, Liming

Hi Yonghong,

The tab characters in the makefile are required.  The makefile
does not run in all environments if they are replaced with spaces.

The makefiles generated by build also use tabs.

Mike

> -----Original Message-----
> From: Zhu, Yonghong
> Sent: Thursday, August 10, 2017 10:41 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; edk2-
> devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong
> <yonghong.zhu@intel.com>
> Subject: RE: [RFC Patch 3/3] BaseTools/Scripts: Add sample
> makefile for use with RunMakefile.py
> 
> Hi Mike,
> 
> The patch 3 has some "Tab character used". Please fix it when
> you commit.
> Others are good to me.
> 
> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
> 
> Best Regards,
> Zhu Yonghong
> 
> 
> -----Original Message-----
> From: Kinney, Michael D
> Sent: Friday, August 04, 2017 1:30 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong
> <yonghong.zhu@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile
> for use with RunMakefile.py
> 
> Add sample makefile that can be used to test RunMakefile.py
> script and can also be used as a template to start a new
> PREBUILD/POSTBUILD makefile.
> 
> 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>
> ---
>  BaseTools/Scripts/RunMakefileSample.mak | 43
> +++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
>  create mode 100644 BaseTools/Scripts/RunMakefileSample.mak
> 
> diff --git a/BaseTools/Scripts/RunMakefileSample.mak
> b/BaseTools/Scripts/RunMakefileSample.mak
> new file mode 100644
> index 0000000000..b0947b7644
> --- /dev/null
> +++ b/BaseTools/Scripts/RunMakefileSample.mak
> @@ -0,0 +1,43 @@
> +## @file
> +# Sample makefile for PREBUILD or POSTBUILD action.
> +#
> +# Copyright (c) 2017, Intel Corporation. All rights
> reserved.<BR> #
> +This program and the accompanying materials # are licensed and
> made
> +available under the terms and conditions of the BSD License
> +# which accompanies this distribution.	The full text of the
> license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
> IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +#
> +
> +all: show
> +	@echo $@
> +genc: show
> +	@echo $@
> +genmake: show
> +	@echo $@
> +modules: show
> +	@echo $@
> +libraries: show
> +	@echo $@
> +fds: show
> +	@echo $@
> +clean: show
> +	@echo $@
> +cleanall: show
> +	@echo $@
> +cleanlib: show
> +	@echo $@
> +run: show
> +	@echo $@
> +
> +show:
> +	@echo WORKSPACE........ $(WORKSPACE)
> +	@echo PACKAGES_PATH.... $(PACKAGES_PATH)
> +	@echo ACTIVE_PLATFORM.. $(ACTIVE_PLATFORM)
> +	@echo TARGET_ARCH...... $(TARGET_ARCH)
> +	@echo TOOL_CHAIN_TAG... $(TOOL_CHAIN_TAG)
> +	@echo CONF_DIRECTORY... $(CONF_DIRECTORY)
> +	@echo TARGET........... $(TARGET)
> +	@echo EXTRA_FLAGS...... $(EXTRA_FLAGS)
> --
> 2.13.1.windows.2



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

* Re: [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile for use with RunMakefile.py
  2017-08-11 16:33     ` Kinney, Michael D
@ 2017-08-12  4:19       ` Zhu, Yonghong
  0 siblings, 0 replies; 7+ messages in thread
From: Zhu, Yonghong @ 2017-08-12  4:19 UTC (permalink / raw)
  To: Kinney, Michael D, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Got you. Thanks.

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Kinney, Michael D 
Sent: Saturday, August 12, 2017 12:33 AM
To: Zhu, Yonghong <yonghong.zhu@intel.com>; edk2-devel@lists.01.org; Kinney, Michael D <michael.d.kinney@intel.com>
Cc: Gao, Liming <liming.gao@intel.com>
Subject: RE: [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile for use with RunMakefile.py

Hi Yonghong,

The tab characters in the makefile are required.  The makefile does not run in all environments if they are replaced with spaces.

The makefiles generated by build also use tabs.

Mike

> -----Original Message-----
> From: Zhu, Yonghong
> Sent: Thursday, August 10, 2017 10:41 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; edk2- 
> devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong 
> <yonghong.zhu@intel.com>
> Subject: RE: [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile 
> for use with RunMakefile.py
> 
> Hi Mike,
> 
> The patch 3 has some "Tab character used". Please fix it when you 
> commit.
> Others are good to me.
> 
> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
> 
> Best Regards,
> Zhu Yonghong
> 
> 
> -----Original Message-----
> From: Kinney, Michael D
> Sent: Friday, August 04, 2017 1:30 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong 
> <yonghong.zhu@intel.com>; Kinney, Michael D 
> <michael.d.kinney@intel.com>
> Subject: [RFC Patch 3/3] BaseTools/Scripts: Add sample makefile for 
> use with RunMakefile.py
> 
> Add sample makefile that can be used to test RunMakefile.py script and 
> can also be used as a template to start a new PREBUILD/POSTBUILD 
> makefile.
> 
> 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>
> ---
>  BaseTools/Scripts/RunMakefileSample.mak | 43
> +++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
>  create mode 100644 BaseTools/Scripts/RunMakefileSample.mak
> 
> diff --git a/BaseTools/Scripts/RunMakefileSample.mak
> b/BaseTools/Scripts/RunMakefileSample.mak
> new file mode 100644
> index 0000000000..b0947b7644
> --- /dev/null
> +++ b/BaseTools/Scripts/RunMakefileSample.mak
> @@ -0,0 +1,43 @@
> +## @file
> +# Sample makefile for PREBUILD or POSTBUILD action.
> +#
> +# Copyright (c) 2017, Intel Corporation. All rights
> reserved.<BR> #
> +This program and the accompanying materials # are licensed and
> made
> +available under the terms and conditions of the BSD License
> +# which accompanies this distribution.	The full text of the
> license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
> IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +#
> +
> +all: show
> +	@echo $@
> +genc: show
> +	@echo $@
> +genmake: show
> +	@echo $@
> +modules: show
> +	@echo $@
> +libraries: show
> +	@echo $@
> +fds: show
> +	@echo $@
> +clean: show
> +	@echo $@
> +cleanall: show
> +	@echo $@
> +cleanlib: show
> +	@echo $@
> +run: show
> +	@echo $@
> +
> +show:
> +	@echo WORKSPACE........ $(WORKSPACE)
> +	@echo PACKAGES_PATH.... $(PACKAGES_PATH)
> +	@echo ACTIVE_PLATFORM.. $(ACTIVE_PLATFORM)
> +	@echo TARGET_ARCH...... $(TARGET_ARCH)
> +	@echo TOOL_CHAIN_TAG... $(TOOL_CHAIN_TAG)
> +	@echo CONF_DIRECTORY... $(CONF_DIRECTORY)
> +	@echo TARGET........... $(TARGET)
> +	@echo EXTRA_FLAGS...... $(EXTRA_FLAGS)
> --
> 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