public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Zhu, Yonghong" <yonghong.zhu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [Patch] BaseTools: Add Platform Override Build Options for PcdValueInit
Date: Wed, 27 Dec 2017 02:33:30 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E198E92@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1514278352-5824-1-git-send-email-yonghong.zhu@intel.com>

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>Yonghong Zhu
>Sent: Tuesday, December 26, 2017 4:53 PM
>To: edk2-devel@lists.01.org
>Subject: [edk2] [Patch] BaseTools: Add Platform Override Build Options for
>PcdValueInit
>
>Add Platform's CC_FLAGS /D option for PcdValueInit generation.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> 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_C
>ONF]
>+            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
>
>_______________________________________________
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel


      reply	other threads:[~2017-12-27  2:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-26  8:52 [Patch] BaseTools: Add Platform Override Build Options for PcdValueInit Yonghong Zhu
2017-12-27  2:33 ` Gao, Liming [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E198E92@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox