From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 680BF21CB87A2 for ; Tue, 26 Dec 2017 00:47:42 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2017 00:52:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,459,1508828400"; d="scan'208";a="5643804" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga008.jf.intel.com with ESMTP; 26 Dec 2017 00:52:35 -0800 From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Tue, 26 Dec 2017 16:52:32 +0800 Message-Id: <1514278352-5824-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch] BaseTools: Add Platform Override Build Options for PcdValueInit X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Dec 2017 08:47:42 -0000 Add Platform's CC_FLAGS /D option for PcdValueInit generation. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/Workspace/DscBuildData.py | 77 +++++++++++++++++++++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 135b608..9262650 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -21,11 +21,12 @@ from Common.String import * from Common.DataType import * from Common.Misc import * from types import * from CommonDataClass.CommonClass import SkuInfoClass - +from Common.TargetTxtClassObject import * +from Common.ToolDefClassObject import * from MetaDataTable import * from MetaFileTable import * from MetaFileParser import * from WorkspaceCommon import GetDeclaredPcd @@ -75,15 +76,15 @@ PcdMakefileHeader = ''' # This file is auto-generated by build utility # ''' +WindowsCFLAGS = 'CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101 ' +LinuxCFLAGS = 'BUILD_CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable ' PcdMakefileEnd = ''' !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common -CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101 - LIBS = $(LIB_PATH)\Common.lib !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app ''' @@ -150,10 +151,11 @@ class DscBuildData(PlatformBuildClassObject): self._RawData = RawData self._Bdb = BuildDataBase self._Arch = Arch self._Target = Target self._Toolchain = Toolchain + self._ToolChainFamily = None self._Clear() self._HandleOverridePath() if os.getenv("WORKSPACE"): self.OutputPath = os.path.join(os.getenv("WORKSPACE"), 'Build', PcdValueInitName) else: @@ -1456,11 +1458,11 @@ class DscBuildData(PlatformBuildClassObject): if sys.platform == "win32": MakeApp = MakeApp + 'ARCH = IA32\nAPPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s\%s.obj\n' % (self.OutputPath, PcdValueInitName) + 'INC = ' else: MakeApp = MakeApp + PcdGccMakefile MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \ - 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'BUILD_CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable\n' + 'INCLUDE +=' + 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'INCLUDE +=' PlatformInc = {} for Cache in self._Bdb._CACHE_.values(): if Cache.MetaFile.Ext.lower() != '.dec': continue @@ -1481,10 +1483,54 @@ class DscBuildData(PlatformBuildClassObject): for pkg in PcdDependDEC: if pkg in PlatformInc: for inc in PlatformInc[pkg]: MakeApp += '-I' + str(inc) + ' ' MakeApp = MakeApp + '\n' + + CC_FLAGS = LinuxCFLAGS + if sys.platform == "win32": + CC_FLAGS = WindowsCFLAGS + BuildOptions = {} + for Options in self.BuildOptions: + if Options[2] != EDKII_NAME: + continue + Family = Options[0] + if Family and Family != self.ToolChainFamily: + continue + Target, Tag, Arch, Tool, Attr = Options[1].split("_") + if Tool != 'CC': + continue + + if Target == "*" or Target == self._Target: + if Tag == "*" or Tag == self._Toolchain: + if Arch == "*" or Arch == self.Arch: + if Tool not in BuildOptions: + BuildOptions[Tool] = {} + if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or self.BuildOptions[Options].startswith('='): + BuildOptions[Tool][Attr] = self.BuildOptions[Options] + else: + # append options for the same tool except PATH + if Attr != 'PATH': + BuildOptions[Tool][Attr] += " " + self.BuildOptions[Options] + else: + BuildOptions[Tool][Attr] = self.BuildOptions[Options] + if BuildOptions: + for Tool in BuildOptions: + for Attr in BuildOptions[Tool]: + if Attr == "FLAGS": + Value = BuildOptions[Tool][Attr] + ValueList = Value.split() + if ValueList: + for Id, Item in enumerate(ValueList): + if Item == '-D' or Item == '/D': + CC_FLAGS += ' ' + Item + if Id + 1 < len(ValueList): + CC_FLAGS += ' ' + ValueList[Id + 1] + elif Item.startswith('/D') or Item.startswith('-D'): + CC_FLAGS += ' ' + Item + MakeApp += CC_FLAGS + if sys.platform == "win32": MakeApp = MakeApp + PcdMakefileEnd MakeFileName = os.path.join(self.OutputPath, 'Makefile') File = open (MakeFileName, 'w') File.write(MakeApp) @@ -1962,10 +2008,32 @@ class DscBuildData(PlatformBuildClassObject): if FilePath not in self.Modules: Module = ModuleBuildClassObject() Module.MetaFile = FilePath self.Modules.append(Module) + def _GetToolChainFamily(self): + self._ToolChainFamily = "MSFT" + BuildConfigurationFile = os.path.normpath(os.path.join(GlobalData.gConfDirectory, "target.txt")) + if os.path.isfile(BuildConfigurationFile) == True: + TargetTxt = TargetTxtClassObject() + TargetTxt.LoadTargetTxtFile(BuildConfigurationFile) + ToolDefinitionFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF] + if ToolDefinitionFile == '': + ToolDefinitionFile = "tools_def.txt" + ToolDefinitionFile = os.path.normpath(mws.join(self.WorkspaceDir, 'Conf', ToolDefinitionFile)) + if os.path.isfile(ToolDefinitionFile) == True: + ToolDef = ToolDefClassObject() + ToolDef.LoadToolDefFile(ToolDefinitionFile) + ToolDefinition = ToolDef.ToolsDefTxtDatabase + if TAB_TOD_DEFINES_FAMILY not in ToolDefinition \ + or self._Toolchain not in ToolDefinition[TAB_TOD_DEFINES_FAMILY] \ + or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self._Toolchain]: + self._ToolChainFamily = "MSFT" + else: + self._ToolChainFamily = ToolDefinition[TAB_TOD_DEFINES_FAMILY][self._Toolchain] + return self._ToolChainFamily + ## Add external PCDs # # The external PCDs are mostly those listed in FDF file to specify address # or offset information. # @@ -2006,5 +2074,6 @@ class DscBuildData(PlatformBuildClassObject): Modules = property(_GetModules) LibraryInstances = property(_GetLibraryInstances) LibraryClasses = property(_GetLibraryClasses) Pcds = property(_GetPcds) BuildOptions = property(_GetBuildOptions) + ToolChainFamily = property(_GetToolChainFamily) -- 2.6.1.windows.1