]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/IncludesAutoGen.py
BaseTools: add '-p' for Linux 'cp' command.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / IncludesAutoGen.py
index 1ca1798907ef9b46a17d8938bb2f673d5ade662f..5ec26eb98b428dc8dfdc92d0d6f2e814c7b20980 100644 (file)
@@ -2,6 +2,7 @@
 # Build cache intermediate result and state\r
 #\r
 # Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2020, ARM Limited. All rights reserved.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 from Common.caching import cached_property\r
@@ -12,20 +13,6 @@ from Common.Misc import SaveFileOnChange, PathClass
 from Common.Misc import TemplateString\r
 import sys\r
 gIsFileMap = {}\r
-if sys.platform == "win32":\r
-    _INCLUDE_DEPS_TEMPLATE = TemplateString('''\r
-${BEGIN}\r
-!IF EXIST(${deps_file})\r
-!INCLUDE ${deps_file}\r
-!ENDIF\r
-${END}\r
-        ''')\r
-else:\r
-    _INCLUDE_DEPS_TEMPLATE = TemplateString('''\r
-${BEGIN}\r
--include ${deps_file}\r
-${END}\r
-        ''')\r
 \r
 DEP_FILE_TAIL = "# Updated \n"\r
 \r
@@ -59,6 +46,25 @@ class IncludesAutoGen():
 \r
     def CreateDepsInclude(self):\r
         deps_file = {'deps_file':self.deps_files}\r
+\r
+        MakePath = self.module_autogen.BuildOption.get('MAKE', {}).get('PATH')\r
+        if not MakePath:\r
+            EdkLogger.error("build", PARAMETER_MISSING, Message="No Make path available.")\r
+        elif "nmake" in MakePath:\r
+            _INCLUDE_DEPS_TEMPLATE = TemplateString('''\r
+${BEGIN}\r
+!IF EXIST(${deps_file})\r
+!INCLUDE ${deps_file}\r
+!ENDIF\r
+${END}\r
+               ''')\r
+        else:\r
+            _INCLUDE_DEPS_TEMPLATE = TemplateString('''\r
+${BEGIN}\r
+-include ${deps_file}\r
+${END}\r
+               ''')\r
+\r
         try:\r
             deps_include_str = _INCLUDE_DEPS_TEMPLATE.Replace(deps_file)\r
         except Exception as e:\r
@@ -97,7 +103,7 @@ class IncludesAutoGen():
                     if os.path.normpath(dependency_file +".deps") == abspath:\r
                         continue\r
                     filename = os.path.basename(dependency_file).strip()\r
-                    if filename not in self.SourceFileList and filename not in targetname:\r
+                    if filename not in targetname:\r
                         includes.add(dependency_file.strip())\r
 \r
                 for item in lines[1:]:\r
@@ -105,11 +111,11 @@ class IncludesAutoGen():
                         continue\r
                     dependency_file = item.strip(" \\\n")\r
                     dependency_file = dependency_file.strip('''"''')\r
+                    if dependency_file == '':\r
+                        continue\r
                     if os.path.normpath(dependency_file +".deps") == abspath:\r
                         continue\r
                     filename = os.path.basename(dependency_file).strip()\r
-                    if filename in self.SourceFileList:\r
-                        continue\r
                     if filename in targetname:\r
                         continue\r
                     includes.add(dependency_file.strip())\r
@@ -195,7 +201,17 @@ class IncludesAutoGen():
                             cc_options = line[len(cc_cmd)+2:].split()\r
                         else:\r
                             cc_options = line[len(cc_cmd):].split()\r
-                        SourceFileAbsPathMap = {os.path.basename(item):item for item in cc_options if not item.startswith("/") and os.path.exists(item)}\r
+                        for item in cc_options:\r
+                            if not item.startswith("/"):\r
+                                if item.endswith(".txt") and item.startswith("@"):\r
+                                    with open(item[1:], "r") as file:\r
+                                        source_files = file.readlines()[0].split()\r
+                                        SourceFileAbsPathMap = {os.path.basename(file): file for file in source_files if\r
+                                                                os.path.exists(file)}\r
+                                else:\r
+                                    if os.path.exists(item):\r
+                                        SourceFileAbsPathMap.update({os.path.basename(item): item.strip()})\r
+                        # SourceFileAbsPathMap = {os.path.basename(item):item for item in cc_options if not item.startswith("/") and os.path.exists(item)}\r
             if line in SourceFileAbsPathMap:\r
                 current_source = line\r
                 if current_source not in ModuleDepDict:\r
@@ -275,7 +291,8 @@ class IncludesAutoGen():
                 targetitem = self.GetRealTarget(source_abs.strip(" :"))\r
 \r
                 targetitem += ": "\r
-                targetitem += lines[1]\r
+                if len(lines)>=2:\r
+                    targetitem += lines[1]\r
                 newcontent.append(targetitem)\r
                 newcontent.extend(lines[2:])\r
                 newcontent.append("\n")\r