# 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
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
\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
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
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
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
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