Re: [edk2] [PATCH] BaseTools: Revert r15816 and r15831 to fix !if in .fdf

Subject: Re: [edk2] [PATCH] BaseTools: Revert r15816 and r15831 to fix !if in .fdf

From: "Carsey, Jaben" <jaben.carsey@intel.com>

To: "edk2-devel@lists.sourceforge.net" <edk2-devel@lists.sourceforge.net>

Date: 2014-08-20 05:06:20

Jordan,

Olivier sent in two patches for an issue related to this.  Is this reversion instead of that patch?

-Jaben

> -----Original Message-----
> From: Jordan Justen [mailto:jordan.l.justen@intel.com]
> Sent: Tuesday, August 19, 2014 12:48 PM
> To: edk2-devel@lists.sourceforge.net
> Subject: [edk2] [PATCH] BaseTools: Revert r15816 and r15831 to fix !if in .fdf
> 
> r15816: "This patch is going to retire the top level makefile on BaseTools for
> supporting a pure binary build without any complier."
> 
> r15831: "This patch is going to fix a build failure (running of
> GenFds) in Linux system caused by patch at r15816."
> 
> Something in these changes causes !if processing to not work correctly.
> Reverting these changes appears to fix it.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jordan Justen 
> Cc: Hess Chen 
> ---
> Hess,
> 
> I think I should revert these changes. Can you investigate the !if processing
> bug, and resubmit the patch?
> 
> Olivier mentioned that !if may only work if !endif is present. Perhaps that can
> help debug it.
> 
>  BaseTools/Source/Python/AutoGen/AutoGen.py |  30 ++---
> BaseTools/Source/Python/AutoGen/GenMake.py |  96 ++++++++++++++-
>  BaseTools/Source/Python/build/build.py     | 181 ++---------------------------
>  3 files changed, 116 insertions(+), 191 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
> b/BaseTools/Source/Python/AutoGen/AutoGen.py
> index 36e4347..c466257 100644
> --- a/BaseTools/Source/Python/AutoGen/AutoGen.py
> +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
> @@ -655,8 +655,6 @@ class WorkspaceAutoGen(AutoGen):
>                                      )
>                      Count += 1
> 
> -    def _GenFdsCommand(self):
> -        return
> (GenMake.TopLevelMakefile(self)._TEMPLATE_.Replace(GenMake.TopLeve
> lMakefile(self)._TemplateDict)).strip()
> 
>      ## Create makefile for the platform and modules in it
>      #
> @@ -664,6 +662,15 @@ class WorkspaceAutoGen(AutoGen):
>      #                                       modules will be created as well
>      #
>      def CreateMakeFile(self, CreateDepsMakeFile=False):
> +        # create makefile for platform
> +        Makefile = GenMake.TopLevelMakefile(self)
> +        if Makefile.Generate():
> +            EdkLogger.debug(EdkLogger.DEBUG_9, "Generated makefile for
> platform [%s] %s\n" %
> +                            (self.MetaFile, self.ArchList))
> +        else:
> +            EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of
> makefile for platform [%s] %s\n" %
> +                            (self.MetaFile, self.ArchList))
> +
>          if CreateDepsMakeFile:
>              for Pa in self.AutoGenObjectList:
>                  Pa.CreateMakeFile(CreateDepsMakeFile)
> @@ -698,7 +705,6 @@ class WorkspaceAutoGen(AutoGen):
>      FvDir               = property(_GetFvDir)
>      MakeFileDir         = property(_GetMakeFileDir)
>      BuildCommand        = property(_GetBuildCommand)
> -    GenFdsCommand       = property(_GenFdsCommand)
> 
>  ## AutoGen class for platform
>  #
> @@ -795,9 +801,6 @@ class PlatformAutoGen(AutoGen):
>          self._LibraryAutoGenList = None
>          self._BuildCommand = None
> 
> -        # get library/modules for build
> -        self.LibraryBuildDirectoryList = []
> -        self.ModuleBuildDirectoryList = []
>          # get the original module/package/platform objects
>          self.BuildDatabase = Workspace.BuildDatabase
>          return True
> @@ -824,10 +827,6 @@ class PlatformAutoGen(AutoGen):
>          # don't do this twice
>          self.IsCodeFileCreated = True
> 
> -    ## Generate Fds Command
> -    def _GenFdsCommand(self):
> -        return self.Workspace.GenFdsCommand
> -
>      ## Create makefile for the platform and mdoules in it
>      #
>      #   @param      CreateModuleMakeFile    Flag indicating if the makefile for
> @@ -845,11 +844,14 @@ class PlatformAutoGen(AutoGen):
>          if self.IsMakeFileCreated:
>              return
> 
> -        # create library/module build dirs for platform
> +        # create makefile for platform
>          Makefile = GenMake.PlatformMakefile(self)
> -        self.LibraryBuildDirectoryList = Makefile.GetLibraryBuildDirectoryList()
> -        self.ModuleBuildDirectoryList = Makefile.GetModuleBuildDirectoryList()
> -
> +        if Makefile.Generate():
> +            EdkLogger.debug(EdkLogger.DEBUG_9, "Generated makefile for
> platform [%s] [%s]\n" %
> +                            (self.MetaFile, self.Arch))
> +        else:
> +            EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of
> makefile for platform [%s] [%s]\n" %
> +                            (self.MetaFile, self.Arch))
>          self.IsMakeFileCreated = True
> 
>      ## Deal with Shared FixedAtBuild Pcds diff --git
> a/BaseTools/Source/Python/AutoGen/GenMake.py
> b/BaseTools/Source/Python/AutoGen/GenMake.py
> index 0ad368a..64eedfa 100644
> --- a/BaseTools/Source/Python/AutoGen/GenMake.py
> +++ b/BaseTools/Source/Python/AutoGen/GenMake.py
> @@ -1105,7 +1105,6 @@ cleanlib:
>          self.IntermediateDirectoryList = []
>          self.ModuleBuildDirectoryList = []
>          self.LibraryBuildDirectoryList = []
> -        self.LibraryMakeCommandList = []
> 
>      # Compose a dict object containing information used to do replacement in
> template
>      def _CreateTemplateDict(self):
> @@ -1129,7 +1128,6 @@ cleanlib:
>              Command = self._MAKE_TEMPLATE_[self._FileType] %
> {"file":Makefile}
>              LibraryMakefileList.append(Makefile)
>              LibraryMakeCommandList.append(Command)
> -        self.LibraryMakeCommandList = LibraryMakeCommandList
> 
>          ModuleMakefileList = []
>          ModuleMakeCommandList = []
> @@ -1200,7 +1198,99 @@ cleanlib:
>  #
>  class TopLevelMakefile(BuildFile):
>      ## template used to generate toplevel makefile
> -    _TEMPLATE_ = TemplateString('''${BEGIN}\tGenFds -f ${fdf_file} -o
> ${platform_build_directory} -t ${toolchain_tag} -b ${build_target} -p
> ${active_platform} -a ${build_architecture_list}
> ${extra_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv}
> ${END}${BEGIN} -C ${cap} ${END}${BEGIN} -D ${macro} ${END}''')
> +    _TEMPLATE_ = TemplateString('''\
> +${makefile_header}
> +
> +#
> +# Platform Macro Definition
> +#
> +PLATFORM_NAME = ${platform_name}
> +PLATFORM_GUID = ${platform_guid}
> +PLATFORM_VERSION = ${platform_version}
> +
> +#
> +# Build Configuration Macro Definition
> +#
> +TOOLCHAIN = ${toolchain_tag}
> +TOOLCHAIN_TAG = ${toolchain_tag}
> +TARGET = ${build_target}
> +
> +#
> +# Build Directory Macro Definition
> +#
> +BUILD_DIR = ${platform_build_directory} FV_DIR =
> +${platform_build_directory}${separator}FV
> +
> +#
> +# Shell Command Macro
> +#
> +${BEGIN}${shell_command_code} = ${shell_command} ${END}
> +
> +MAKE = ${make_path}
> +MAKE_FILE = ${makefile_path}
> +
> +#
> +# Default target
> +#
> +all: modules fds
> +
> +#
> +# Initialization target: print build information and create necessary
> +directories #
> +init:
> +\t-@
> +\t${BEGIN}-@${create_directory_command}
> +\t${END}
> +#
> +# library build target
> +#
> +libraries: init
> +${BEGIN}\t@cd $(BUILD_DIR)${separator}${arch} && "$(MAKE)"
> +$(MAKE_FLAGS) libraries ${END}\t@cd $(BUILD_DIR)
> +
> +#
> +# module build target
> +#
> +modules: init
> +${BEGIN}\t@cd $(BUILD_DIR)${separator}${arch} && "$(MAKE)"
> +$(MAKE_FLAGS) modules ${END}\t@cd $(BUILD_DIR)
> +
> +#
> +# Flash Device Image Target
> +#
> +fds: init
> +\t-@cd $(FV_DIR)
> +${BEGIN}\tGenFds -f ${fdf_file} -o $(BUILD_DIR) -t $(TOOLCHAIN) -b
> +$(TARGET) -p ${active_platform} -a ${build_architecture_list}
> +${extra_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv}
> +${END}${BEGIN} -C ${cap} ${END}${BEGIN} -D ${macro} ${END}
> +
> +#
> +# run command for emulator platform only #
> +run:
> +\tcd $(BUILD_DIR)${separator}IA32 && ".${separator}SecMain"
> +\tcd $(BUILD_DIR)
> +
> +#
> +# Clean intermediate files
> +#
> +clean:
> +${BEGIN}\t-@${sub_build_command} clean
> +${END}\t@cd $(BUILD_DIR)
> +
> +#
> +# Clean all generated files except to makefile #
> +cleanall:
> +${BEGIN}\t${cleanall_command}
> +${END}
> +
> +#
> +# Clean all library files
> +#
> +cleanlib:
> +${BEGIN}\t-@${sub_build_command} cleanlib ${END}\t@cd
> $(BUILD_DIR)\n
> +''')
> 
>      ## Constructor of TopLevelMakefile
>      #
> diff --git a/BaseTools/Source/Python/build/build.py
> b/BaseTools/Source/Python/build/build.py
> index 85ee998..bd43f2c 100644
> --- a/BaseTools/Source/Python/build/build.py
> +++ b/BaseTools/Source/Python/build/build.py
> @@ -245,14 +245,7 @@ def LaunchCommand(Command, WorkingDir):
>      # if working directory doesn't exist, Popen() will raise an exception
>      if not os.path.isdir(WorkingDir):
>          EdkLogger.error("build", FILE_NOT_FOUND, ExtraData=WorkingDir)
> -
> -    # Command is used as the first Argument in following Popen().
> -    # It could be a string or sequence. We find that if command is a string in
> following Popen(),
> -    # ubuntu may fail with an error message that the command is not found.
> -    # So here we may need convert command from string to list instance.
> -    if not isinstance(Command, list):
> -        Command = Command.split()
> -
> +
>      Proc = None
>      EndOfProcedure = None
>      try:
> @@ -873,136 +866,7 @@ class Build():
>      #   @param  CreateDepModuleMakeFile     Flag used to indicate creating
> makefile
>      #                                       for dependent modules/Libraries
>      #
> -    def _BuildPa(self, Target, AutoGenObject, CreateDepsCodeFile=True,
> CreateDepsMakeFile=True, BuildModule=False):
> -        if AutoGenObject == None:
> -            return False
> -
> -        # skip file generation for cleanxxx targets, run and fds target
> -        if Target not in ['clean', 'cleanlib', 'cleanall', 'run', 'fds']:
> -            # for target which must generate AutoGen code and makefile
> -            if not self.SkipAutoGen or Target == 'genc':
> -                self.Progress.Start("Generating code")
> -                AutoGenObject.CreateCodeFile(CreateDepsCodeFile)
> -                self.Progress.Stop("done!")
> -            if Target == "genc":
> -                return True
> -
> -            if not self.SkipAutoGen or Target == 'genmake':
> -                self.Progress.Start("Generating makefile")
> -                AutoGenObject.CreateMakeFile(CreateDepsMakeFile)
> -                self.Progress.Stop("done!")
> -            if Target == "genmake":
> -                return True
> -        else:
> -            # always recreate top/platform makefile when clean, just in case of
> inconsistency
> -            AutoGenObject.CreateCodeFile(False)
> -            AutoGenObject.CreateMakeFile(False)
> -
> -        if EdkLogger.GetLevel() == EdkLogger.QUIET:
> -            EdkLogger.quiet("Building ... %s" % repr(AutoGenObject))
> -
> -        BuildCommand = AutoGenObject.BuildCommand
> -        if BuildCommand == None or len(BuildCommand) == 0:
> -            EdkLogger.error("build", OPTION_MISSING,
> -                            "No build command found for this module. "
> -                            "Please check your setting of %s_%s_%s_MAKE_PATH in
> Conf/tools_def.txt file." %
> -                                (AutoGenObject.BuildTarget, AutoGenObject.ToolChain,
> AutoGenObject.Arch),
> -                            ExtraData=str(AutoGenObject))
> -
> -        makefile =
> GenMake.BuildFile(AutoGenObject)._FILE_NAME_[GenMake.gMakeType]
> -
> -        # genfds
> -        if Target == 'fds':
> -            LaunchCommand(AutoGenObject.GenFdsCommand,
> AutoGenObject.MakeFileDir)
> -            return True
> -
> -        # run
> -        if Target == 'run':
> -            RunDir = os.path.normpath(os.path.join(AutoGenObject.BuildDir,
> 'IA32'))
> -            Command = '.\SecMain'
> -            os.chdir(RunDir)
> -            LaunchCommand(Command, RunDir)
> -            return True
> -
> -        # build modules
> -        if BuildModule:
> -            BuildCommand = BuildCommand + [Target]
> -            LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)
> -            self.CreateAsBuiltInf()
> -            return True
> -
> -        # build library
> -        if Target == 'libraries':
> -            for Lib in AutoGenObject.LibraryBuildDirectoryList:
> -                NewBuildCommand = BuildCommand + ['-f',
> os.path.normpath(os.path.join(Lib, makefile)), 'pbuild']
> -                LaunchCommand(NewBuildCommand,
> AutoGenObject.MakeFileDir)
> -            return True
> -
> -        # build module
> -        if Target == 'modules':
> -            for Lib in AutoGenObject.LibraryBuildDirectoryList:
> -                NewBuildCommand = BuildCommand + ['-f',
> os.path.normpath(os.path.join(Lib, makefile)), 'pbuild']
> -                LaunchCommand(NewBuildCommand,
> AutoGenObject.MakeFileDir)
> -            for Mod in AutoGenObject.ModuleBuildDirectoryList:
> -                NewBuildCommand = BuildCommand + ['-f',
> os.path.normpath(os.path.join(Mod, makefile)), 'pbuild']
> -                LaunchCommand(NewBuildCommand,
> AutoGenObject.MakeFileDir)
> -            self.CreateAsBuiltInf()
> -            return True
> -
> -        # cleanlib
> -        if Target == 'cleanlib':
> -            for Lib in AutoGenObject.LibraryBuildDirectoryList:
> -                LibMakefile = os.path.normpath(os.path.join(Lib, makefile))
> -                if os.path.exists(LibMakefile):
> -                    NewBuildCommand = BuildCommand + ['-f', LibMakefile, 'cleanall']
> -                    LaunchCommand(NewBuildCommand,
> AutoGenObject.MakeFileDir)
> -            return True
> -
> -        # clean
> -        if Target == 'clean':
> -            for Mod in AutoGenObject.ModuleBuildDirectoryList:
> -                ModMakefile = os.path.normpath(os.path.join(Mod, makefile))
> -                if os.path.exists(ModMakefile):
> -                    NewBuildCommand = BuildCommand + ['-f', ModMakefile,
> 'cleanall']
> -                    LaunchCommand(NewBuildCommand,
> AutoGenObject.MakeFileDir)
> -            for Lib in AutoGenObject.LibraryBuildDirectoryList:
> -                LibMakefile = os.path.normpath(os.path.join(Lib, makefile))
> -                if os.path.exists(LibMakefile):
> -                    NewBuildCommand = BuildCommand + ['-f', LibMakefile, 'cleanall']
> -                    LaunchCommand(NewBuildCommand,
> AutoGenObject.MakeFileDir)
> -            return True
> -
> -        # cleanall
> -        if Target == 'cleanall':
> -            try:
> -                #os.rmdir(AutoGenObject.BuildDir)
> -                RemoveDirectory(AutoGenObject.BuildDir, True)
> -                #
> -                # First should close DB.
> -                #
> -                self.Db.Close()
> -                RemoveDirectory(os.path.dirname(GlobalData.gDatabasePath),
> True)
> -            except WindowsError, X:
> -                EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X))
> -        return True
> -
> -    ## Build a module or platform
> -    #
> -    # Create autogen code and makefile for a module or platform, and the
> launch
> -    # "make" command to build it
> -    #
> -    #   @param  Target                      The target of build command
> -    #   @param  Platform                    The platform file
> -    #   @param  Module                      The module file
> -    #   @param  BuildTarget                 The name of build target, one of
> "DEBUG", "RELEASE"
> -    #   @param  ToolChain                   The name of toolchain to build
> -    #   @param  Arch                        The arch of the module/platform
> -    #   @param  CreateDepModuleCodeFile     Flag used to indicate creating
> code
> -    #                                       for dependent modules/Libraries
> -    #   @param  CreateDepModuleMakeFile     Flag used to indicate creating
> makefile
> -    #                                       for dependent modules/Libraries
> -    #
> -    def _Build(self, Target, AutoGenObject, CreateDepsCodeFile=True,
> CreateDepsMakeFile=True, BuildModule=False):
> +    def _Build(self, Target, AutoGenObject, CreateDepsCodeFile=True,
> CreateDepsMakeFile=True):
>          if AutoGenObject == None:
>              return False
> 
> @@ -1019,7 +883,7 @@ class Build():
>              if not self.SkipAutoGen or Target == 'genmake':
>                  self.Progress.Start("Generating makefile")
>                  AutoGenObject.CreateMakeFile(CreateDepsMakeFile)
> -                #AutoGenObject.CreateAsBuiltInf()
> +                AutoGenObject.CreateAsBuiltInf()
>                  self.Progress.Stop("done!")
>              if Target == "genmake":
>                  return True
> @@ -1039,34 +903,8 @@ class Build():
>                                  (AutoGenObject.BuildTarget, AutoGenObject.ToolChain,
> AutoGenObject.Arch),
>                              ExtraData=str(AutoGenObject))
> 
> -        # genfds
> -        if Target == 'fds':
> -            LaunchCommand(AutoGenObject.GenFdsCommand,
> AutoGenObject.MakeFileDir)
> -            return True
> -
> -        # run
> -        if Target == 'run':
> -            RunDir = os.path.normpath(os.path.join(AutoGenObject.BuildDir,
> 'IA32'))
> -            Command = '.\SecMain'
> -            os.chdir(RunDir)
> -            LaunchCommand(Command, RunDir)
> -            return True
> -
> -        # build modules
>          BuildCommand = BuildCommand + [Target]
> -        if BuildModule:
> -            LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)
> -            self.CreateAsBuiltInf()
> -            return True
> -
> -        # build library
> -        if Target == 'libraries':
> -            pass
> -
> -        # not build modules
> -
> -
> -        # cleanall
> +        LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)
>          if Target == 'cleanall':
>              try:
>                  #os.rmdir(AutoGenObject.BuildDir) @@ -1406,10 +1244,7 @@ class
> Build():
>                  self.LoadFixAddress = Wa.Platform.LoadFixAddress
>                  self.BuildReport.AddPlatformReport(Wa)
>                  self.Progress.Stop("done!")
> -                for Arch in Wa.ArchList:
> -                    GlobalData.gGlobalDefines['ARCH'] = Arch
> -                    Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget,
> ToolChain, Arch)
> -                    self._BuildPa(self.Target, Pa)
> +                self._Build(self.Target, Wa)
> 
>                  # Create MAP file when Load Fix Address is enabled.
>                  if self.Target in ["", "all", "fds"]:
> @@ -1492,8 +1327,7 @@ class Build():
>                      Ma = ModuleAutoGen(Wa, self.ModuleFile, BuildTarget,
> ToolChain, Arch, self.PlatformFile)
>                      if Ma == None: continue
>                      MaList.append(Ma)
> -                    if not Ma.IsBinaryModule:
> -                        self._Build(self.Target, Ma, BuildModule=True)
> +                    self._Build(self.Target, Ma)
> 
>                  self.BuildReport.AddPlatformReport(Wa, MaList)
>                  if MaList == []:
> @@ -1674,8 +1508,7 @@ class Build():
>                          #
>                          # Generate FD image if there's a FDF file found
>                          #
> -                        LaunchCommand(Wa.GenFdsCommand, os.getcwd())
> -
> +                        LaunchCommand(Wa.BuildCommand + ["fds"],
> + Wa.MakeFileDir)
>                          #
>                          # Create MAP file for all platform FVs after GenFds.
>                          #
> --
> 2.1.0
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel