]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools: Remove unused logic for EDKI
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / GenMake.py
index b168a6663d2f266c1cda5baef3031343ddd7cfa4..4da10e39505ac2ade7e2ec1952dbf9d5d6015f96 100644 (file)
@@ -13,6 +13,7 @@
 \r
 ## Import Modules\r
 #\r
+from __future__ import absolute_import\r
 import Common.LongFilePathOs as os\r
 import sys\r
 import string\r
@@ -29,7 +30,7 @@ from collections import OrderedDict
 from Common.DataType import TAB_COMPILER_MSFT\r
 \r
 ## Regular expression for finding header file inclusions\r
-gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNICODE | re.IGNORECASE)\r
+gIncludePattern = re.compile(r"^[ \t]*[#%]?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNICODE | re.IGNORECASE)\r
 \r
 ## Regular expression for matching macro used in header file inclusion\r
 gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)\r
@@ -166,7 +167,7 @@ class BuildFile(object):
         "gmake" :   "include"\r
     }\r
 \r
-    _INC_FLAG_ = {TAB_COMPILER_MSFT : "/I", "GCC" : "-I", "INTEL" : "-I", "RVCT" : "-I"}\r
+    _INC_FLAG_ = {TAB_COMPILER_MSFT : "/I", "GCC" : "-I", "INTEL" : "-I", "RVCT" : "-I", "NASM" : "-I"}\r
 \r
     ## Constructor of BuildFile\r
     #\r
@@ -475,23 +476,16 @@ cleanlib:
         else:\r
             ModuleEntryPoint = "_ModuleEntryPoint"\r
 \r
-        # Intel EBC compiler enforces EfiMain\r
-        if MyAgo.AutoGenVersion < 0x00010005 and MyAgo.Arch == "EBC":\r
-            ArchEntryPoint = "EfiMain"\r
-        else:\r
-            ArchEntryPoint = ModuleEntryPoint\r
+        ArchEntryPoint = ModuleEntryPoint\r
 \r
         if MyAgo.Arch == "EBC":\r
             # EBC compiler always use "EfiStart" as entry point. Only applies to EdkII modules\r
             ImageEntryPoint = "EfiStart"\r
-        elif MyAgo.AutoGenVersion < 0x00010005:\r
-            # Edk modules use entry point specified in INF file\r
-            ImageEntryPoint = ModuleEntryPoint\r
         else:\r
             # EdkII modules always use "_ModuleEntryPoint" as entry point\r
             ImageEntryPoint = "_ModuleEntryPoint"\r
 \r
-        for k, v in MyAgo.Module.Defines.items():\r
+        for k, v in MyAgo.Module.Defines.iteritems():\r
             if k not in MyAgo.Macros:\r
                 MyAgo.Macros[k] = v\r
 \r
@@ -503,7 +497,7 @@ cleanlib:
             MyAgo.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint\r
 \r
         PCI_COMPRESS_Flag = False\r
-        for k, v in MyAgo.Module.Defines.items():\r
+        for k, v in MyAgo.Module.Defines.iteritems():\r
             if 'PCI_COMPRESS' == k and 'TRUE' == v:\r
                 PCI_COMPRESS_Flag = True\r
 \r
@@ -595,6 +589,24 @@ cleanlib:
                                                 }\r
                                                 )\r
         FileMacroList.append(FileMacro)\r
+        # Add support when compiling .nasm source files\r
+        for File in self.FileCache.keys():\r
+            if not str(File).endswith('.nasm'):\r
+                continue\r
+            IncludePathList = []\r
+            for P in  MyAgo.IncludePathList:\r
+                IncludePath = self._INC_FLAG_['NASM'] + self.PlaceMacro(P, self.Macros)\r
+                if IncludePath.endswith(os.sep):\r
+                    IncludePath = IncludePath.rstrip(os.sep)\r
+                # When compiling .nasm files, need to add a literal backslash at each path\r
+                # To specify a literal backslash at the end of the line, precede it with a caret (^)\r
+                if P == MyAgo.IncludePathList[-1] and os.sep == '\\':\r
+                    IncludePath = ''.join([IncludePath, '^', os.sep])\r
+                else:\r
+                    IncludePath = os.path.join(IncludePath, '')\r
+                IncludePathList.append(IncludePath)\r
+            FileMacroList.append(self._FILE_MACRO_TEMPLATE.Replace({"macro_name": "NASM_INC", "source_file": IncludePathList}))\r
+            break\r
 \r
         # Generate macros used to represent files containing list of input files\r
         for ListFileMacro in self.ListFileMacros:\r
@@ -606,11 +618,6 @@ cleanlib:
                 False\r
                 )\r
 \r
-        # Edk modules need <BaseName>StrDefs.h for string ID\r
-        #if MyAgo.AutoGenVersion < 0x00010005 and len(MyAgo.UnicodeFileList) > 0:\r
-        #    BcTargetList = ['strdefs']\r
-        #else:\r
-        #    BcTargetList = []\r
         BcTargetList = []\r
 \r
         MakefileName = self._FILE_NAME_[self._FileType]\r
@@ -654,7 +661,7 @@ cleanlib:
             "module_relative_directory" : MyAgo.SourceDir,\r
             "module_dir"                : mws.join (self.Macros["WORKSPACE"], MyAgo.SourceDir),\r
             "package_relative_directory": package_rel_dir,\r
-            "module_extra_defines"      : ["%s = %s" % (k, v) for k, v in MyAgo.Module.Defines.items()],\r
+            "module_extra_defines"      : ["%s = %s" % (k, v) for k, v in MyAgo.Module.Defines.iteritems()],\r
 \r
             "architecture"              : MyAgo.Arch,\r
             "toolchain_tag"             : MyAgo.ToolChain,\r
@@ -1031,7 +1038,7 @@ cleanlib:
                 CurrentFileDependencyList = DepDb[F]\r
             else:\r
                 try:\r
-                    Fd = open(F.Path, 'rb')\r
+                    Fd = open(F.Path, 'r')\r
                 except BaseException as X:\r
                     EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path + "\n\t" + str(X))\r
 \r
@@ -1041,14 +1048,8 @@ cleanlib:
                     continue\r
 \r
                 if FileContent[0] == 0xff or FileContent[0] == 0xfe:\r
-                    FileContent = str(FileContent, encoding="utf-16")\r
-                    IncludedFileList = gIncludePattern.findall(FileContent)\r
-                else:\r
-                    try:\r
-                        FileContent = str(FileContent, encoding="utf-8")\r
-                        IncludedFileList = gIncludePattern.findall(FileContent)\r
-                    except:\r
-                        continue\r
+                    FileContent = unicode(FileContent, "utf-16")\r
+                IncludedFileList = gIncludePattern.findall(FileContent)\r
 \r
                 for Inc in IncludedFileList:\r
                     Inc = Inc.strip()\r
@@ -1524,13 +1525,9 @@ class TopLevelMakefile(BuildFile):
         if MyAgo.FdfFile is not None and MyAgo.FdfFile != "":\r
             FdfFileList = [MyAgo.FdfFile]\r
             # macros passed to GenFds\r
-            MacroList.append('"%s=%s"' % ("EFI_SOURCE", GlobalData.gEfiSource.replace('\\', '\\\\')))\r
-            MacroList.append('"%s=%s"' % ("EDK_SOURCE", GlobalData.gEdkSource.replace('\\', '\\\\')))\r
             MacroDict = {}\r
             MacroDict.update(GlobalData.gGlobalDefines)\r
             MacroDict.update(GlobalData.gCommandLineDefines)\r
-            MacroDict.pop("EFI_SOURCE", "dummy")\r
-            MacroDict.pop("EDK_SOURCE", "dummy")\r
             for MacroName in MacroDict:\r
                 if MacroDict[MacroName] != "":\r
                     MacroList.append('"%s=%s"' % (MacroName, MacroDict[MacroName].replace('\\', '\\\\')))\r