]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/GenMake.py
Sync BaseTools Branch (version r2149) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / GenMake.py
index b58d0c641f4b1a284c12a9b1fa3a1f6b1efed5ff..6396c612ad1cf4a1e1a17141c72a4831bd142fe2 100644 (file)
@@ -1,8 +1,8 @@
 ## @file
 # Create makefile for MS nmake and GNU make
 #
-# Copyright (c) 2007 - 2010, Intel Corporation
-# All rights reserved. This program and the accompanying materials
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.  The full text of the license may be found at
 # http://opensource.org/licenses/bsd-license.php
@@ -26,7 +26,7 @@ from BuildEngine import *
 import Common.GlobalData as GlobalData
 
 ## Regular expression for finding header file inclusions
-gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:[\"<]?[ \t]*)([\w.\\/]+)(?:[ \t]*[\">]?)", re.MULTILINE|re.UNICODE)
+gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE|re.UNICODE|re.IGNORECASE)
 
 ## Regular expression for matching macro used in header file inclusion
 gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
@@ -448,7 +448,7 @@ cleanlib:
                             % (self._AutoGenObject.BuildTarget, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch),
                             ExtraData="[%s]" % str(self._AutoGenObject))
 
-        # convert dependent libaries to build command
+        # convert dependent libraries to build command
         self.ProcessDependentLibrary()
         if len(self._AutoGenObject.Module.ModuleEntryPointList) > 0:
             ModuleEntryPoint = self._AutoGenObject.Module.ModuleEntryPointList[0]
@@ -493,7 +493,7 @@ cleanlib:
 
         # convert source files and binary files to build targets
         self.ResultFileList = [str(T.Target) for T in self._AutoGenObject.CodaTargetList]
-        if len(self.ResultFileList) == 0:
+        if len(self.ResultFileList) == 0 and len(self._AutoGenObject.SourceFileList) <> 0:
             EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build",
                             ExtraData="[%s]" % str(self._AutoGenObject))
 
@@ -632,7 +632,7 @@ cleanlib:
         if DepSet == None:
             DepSet = set()
         #
-        # Extract comman files list in the dependency files
+        # Extract common files list in the dependency files
         #
         for File in DepSet:
             self.CommonFileDependency.append(self.PlaceMacro(File.Path, self.Macros))
@@ -728,6 +728,9 @@ cleanlib:
             gDependencyDatabase[self._AutoGenObject.Arch] = {}
         DepDb = gDependencyDatabase[self._AutoGenObject.Arch]
 
+        # add path of given source file into search path list.
+        if File.Dir not in SearchPathList:
+            SearchPathList.append(File.Dir)
         while len(FileStack) > 0:
             F = FileStack.pop()
 
@@ -754,6 +757,7 @@ cleanlib:
 
                 CurrentFilePath = F.Dir
                 for Inc in IncludedFileList:
+                    Inc = Inc.strip()
                     # if there's macro used to reference header file, expand it
                     HeaderList = gMacroPattern.findall(Inc)
                     if len(HeaderList) == 1 and len(HeaderList[0]) == 2:
@@ -768,7 +772,7 @@ cleanlib:
                     Inc = os.path.normpath(Inc)
                     for SearchPath in [CurrentFilePath] + SearchPathList:
                         FilePath = os.path.join(SearchPath, Inc)
-                        if not os.path.exists(FilePath) or FilePath in CurrentFileDependencyList:
+                        if not os.path.isfile(FilePath) or FilePath in CurrentFileDependencyList:
                             continue
                         FilePath = PathClass(FilePath)
                         CurrentFileDependencyList.append(FilePath)
@@ -776,7 +780,7 @@ cleanlib:
                             FileStack.append(FilePath)
                         break
                     else:
-                        EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was not found"\
+                        EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was not found "\
                                         "in any given path:\n\t%s" % (Inc, F, "\n\t".join(SearchPathList)))
 
                 if not MacroUsedByIncludedFile: