X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2Fbuild%2Fbuild.py;h=4d05ee27612d22bec11d24c1ef1749c3617d1d18;hb=cc993a16e40372c07a0507d02d1030546470f986;hp=4f859bf5a774268c62c20ee9bfc89159ec19a8d8;hpb=f6190a01c13a6b4dd01a1765b28964db7dc58e35;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index 4f859bf5a7..4d05ee2761 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -2,7 +2,7 @@ # build a platform or a module # # Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -54,7 +54,7 @@ import Common.GlobalData as GlobalData # Version and Copyright VersionNumber = "0.60" + ' ' + gBUILD_VERSION __version__ = "%prog Version " + VersionNumber -__copyright__ = "Copyright (c) 2007 - 2016, Intel Corporation All rights reserved." +__copyright__ = "Copyright (c) 2007 - 2017, Intel Corporation All rights reserved." ## standard targets of build command gSupportedTarget = ['all', 'genc', 'genmake', 'modules', 'libraries', 'fds', 'clean', 'cleanall', 'cleanlib', 'run'] @@ -265,15 +265,16 @@ def LaunchCommand(Command, WorkingDir): # 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): - if platform.system() != 'Windows': + if platform.system() != 'Windows': + if not isinstance(Command, list): Command = Command.split() + Command = ' '.join(Command) Proc = None EndOfProcedure = None try: # launch the command - Proc = Popen(Command, stdout=PIPE, stderr=PIPE, env=os.environ, cwd=WorkingDir, bufsize=-1) + Proc = Popen(Command, stdout=PIPE, stderr=PIPE, env=os.environ, cwd=WorkingDir, bufsize=-1, shell=True) # launch two threads to read the STDOUT and STDERR EndOfProcedure = Event() @@ -775,8 +776,11 @@ class Build(): # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf ConfDirectoryPath = mws.join(self.WorkspaceDir, ConfDirectoryPath) else: - # Get standard WORKSPACE/Conf use the absolute path to the WORKSPACE/Conf - ConfDirectoryPath = mws.join(self.WorkspaceDir, 'Conf') + if "CONF_PATH" in os.environ: + ConfDirectoryPath = os.path.normcase(os.path.normpath(os.environ["CONF_PATH"])) + else: + # Get standard WORKSPACE/Conf use the absolute path to the WORKSPACE/Conf + ConfDirectoryPath = mws.join(self.WorkspaceDir, 'Conf') GlobalData.gConfDirectory = ConfDirectoryPath GlobalData.gDatabasePath = os.path.normpath(os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath)) @@ -786,6 +790,7 @@ class Build(): self.Db = WorkspaceDatabase(GlobalData.gDatabasePath, self.Reparse) self.BuildDatabase = self.Db.BuildObject self.Platform = None + self.ToolChainFamily = None self.LoadFixAddress = 0 self.UniFlag = BuildOptions.Flag self.BuildModules = [] @@ -811,7 +816,7 @@ class Build(): if "EDK_TOOLS_BIN" in os.environ: # Print the same path style with WORKSPACE env. EdkLogger.quiet("%-16s = %s" % ("EDK_TOOLS_BIN", os.path.normcase(os.path.normpath(os.environ["EDK_TOOLS_BIN"])))) - + EdkLogger.quiet("%-16s = %s" % ("CONF_PATH", GlobalData.gConfDirectory)) self.InitPreBuild() self.InitPostBuild() if self.PrebuildScript: @@ -820,6 +825,8 @@ class Build(): EdkLogger.quiet("%-16s = %s" % ("POSTBUILD", self.PostbuildScript)) if self.PrebuildScript: self.LaunchPrebuild() + self.TargetTxt = TargetTxtClassObject() + self.ToolDef = ToolDefClassObject() if not (self.LaunchPrebuildFlag and os.path.exists(self.PlatformBuildPath)): self.InitBuild() @@ -878,6 +885,17 @@ class Build(): else: self.ToolChainList = NewToolChainList + ToolChainFamily = [] + ToolDefinition = self.ToolDef.ToolsDefTxtDatabase + for Tool in self.ToolChainList: + if TAB_TOD_DEFINES_FAMILY not in ToolDefinition or Tool not in ToolDefinition[TAB_TOD_DEFINES_FAMILY] \ + or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][Tool]: + EdkLogger.warn("build", "No tool chain family found in configuration for %s. Default to MSFT." % Tool) + ToolChainFamily.append("MSFT") + else: + ToolChainFamily.append(ToolDefinition[TAB_TOD_DEFINES_FAMILY][Tool]) + self.ToolChainFamily = ToolChainFamily + if self.ThreadNumber == None: self.ThreadNumber = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER] if self.ThreadNumber == '': @@ -936,6 +954,8 @@ class Build(): if self.ToolChainList: GlobalData.gGlobalDefines['TOOLCHAIN'] = self.ToolChainList[0] GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = self.ToolChainList[0] + if self.ToolChainFamily: + GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[0] if 'PREBUILD' in GlobalData.gCommandLineDefines.keys(): self.Prebuild = GlobalData.gCommandLineDefines.get('PREBUILD') else: @@ -969,7 +989,6 @@ class Build(): self.PostbuildScript = PostbuildList[0] self.Postbuild = ' '.join(PostbuildList) self.Postbuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList) - #self.LanuchPostbuild() 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])) @@ -1010,6 +1029,11 @@ class Build(): if self.Prebuild: EdkLogger.info("\n- Prebuild Start -\n") self.LaunchPrebuildFlag = True + # + # The purpose of .PrebuildEnv file is capture environment variable settings set by the prebuild script + # and preserve them for the rest of the main build step, because the child process environment will + # evaporate as soon as it exits, we cannot get it in build step. + # PrebuildEnvFile = os.path.join(GlobalData.gConfDirectory,'.cache','.PrebuildEnv') if os.path.isfile(PrebuildEnvFile): os.remove(PrebuildEnvFile) @@ -1017,10 +1041,10 @@ class Build(): os.remove(self.PlatformBuildPath) if sys.platform == "win32": args = ' && '.join((self.Prebuild, 'set > ' + PrebuildEnvFile)) - Process = Popen(args, stdout=PIPE, stderr=PIPE) + Process = Popen(args, stdout=PIPE, stderr=PIPE, shell=True) else: args = ' && '.join((self.Prebuild, 'env > ' + PrebuildEnvFile)) - Process = Popen(args, stdout=PIPE, stderr=PIPE, shell=True, executable="/bin/bash") + Process = Popen(args, stdout=PIPE, stderr=PIPE, shell=True) # launch two threads to read the STDOUT and STDERR EndOfProcedure = Event() @@ -1056,13 +1080,13 @@ class Build(): os.environ.update(dict(envs)) EdkLogger.info("\n- Prebuild Done -\n") - def LanuchPostbuild(self): + def LaunchPostbuild(self): if self.Postbuild: EdkLogger.info("\n- Postbuild Start -\n") if sys.platform == "win32": - Process = Popen(self.Postbuild, stdout=PIPE, stderr=PIPE) + Process = Popen(self.Postbuild, stdout=PIPE, stderr=PIPE, shell=True) else: - Process = Popen(self.Postbuild, stdout=PIPE, stderr=PIPE, shell=True, executable="/bin/bash") + Process = Popen(self.Postbuild, stdout=PIPE, stderr=PIPE, shell=True) # launch two threads to read the STDOUT and STDERR EndOfProcedure = Event() EndOfProcedure.clear() @@ -1480,7 +1504,7 @@ class Build(): if IsIpfPlatform and ImageInfo.Image.Size % 0x2000 != 0: ImageInfo.Image.Size = (ImageInfo.Image.Size / 0x2000 + 1) * 0x2000 RtSize += ImageInfo.Image.Size - elif Module.ModuleType in ['SMM_CORE', 'DXE_SMM_DRIVER']: + elif Module.ModuleType in ['SMM_CORE', 'DXE_SMM_DRIVER', 'MM_STANDALONE', 'MM_CORE_STANDALONE']: SmmModuleList[Module.MetaFile] = ImageInfo SmmSize += ImageInfo.Image.Size if Module.ModuleType == 'DXE_SMM_DRIVER': @@ -1599,9 +1623,12 @@ class Build(): SaveFileOnChange(self.PlatformBuildPath, '# DO NOT EDIT \n# FILE auto-generated\n', False) for BuildTarget in self.BuildTargetList: GlobalData.gGlobalDefines['TARGET'] = BuildTarget + index = 0 for ToolChain in self.ToolChainList: GlobalData.gGlobalDefines['TOOLCHAIN'] = ToolChain GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain + GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[index] + index += 1 Wa = WorkspaceAutoGen( self.WorkspaceDir, self.PlatformFile, @@ -1679,9 +1706,12 @@ class Build(): def _BuildModule(self): for BuildTarget in self.BuildTargetList: GlobalData.gGlobalDefines['TARGET'] = BuildTarget + index = 0 for ToolChain in self.ToolChainList: GlobalData.gGlobalDefines['TOOLCHAIN'] = ToolChain GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain + GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[index] + index += 1 # # module build needs platform build information, so get platform # AutoGen first @@ -1711,12 +1741,15 @@ class Build(): MaList = [] for Arch in Wa.ArchList: GlobalData.gGlobalDefines['ARCH'] = Arch - Ma = ModuleAutoGen(Wa, self.ModuleFile, BuildTarget, ToolChain, Arch, self.PlatformFile) - if Ma == None: continue - MaList.append(Ma) - self.BuildModules.append(Ma) - if not Ma.IsBinaryModule: - self._Build(self.Target, Ma, BuildModule=True) + Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch) + for Module in Pa.Platform.Modules: + if self.ModuleFile.Dir == Module.Dir and self.ModuleFile.File == Module.File: + Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile) + if Ma == None: continue + MaList.append(Ma) + self.BuildModules.append(Ma) + if not Ma.IsBinaryModule: + self._Build(self.Target, Ma, BuildModule=True) self.BuildReport.AddPlatformReport(Wa, MaList) if MaList == []: @@ -1773,9 +1806,12 @@ class Build(): SaveFileOnChange(self.PlatformBuildPath, '# DO NOT EDIT \n# FILE auto-generated\n', False) for BuildTarget in self.BuildTargetList: GlobalData.gGlobalDefines['TARGET'] = BuildTarget + index = 0 for ToolChain in self.ToolChainList: GlobalData.gGlobalDefines['TOOLCHAIN'] = ToolChain GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = ToolChain + GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[index] + index += 1 Wa = WorkspaceAutoGen( self.WorkspaceDir, self.PlatformFile, @@ -2302,7 +2338,7 @@ def Main(): if ReturnCode == 0: try: - MyBuild.LanuchPostbuild() + MyBuild.LaunchPostbuild() Conclusion = "Done" except: Conclusion = "Failed"