]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/GenMake.py
Sync BaseTools Branch (version r2362) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / GenMake.py
index f689a8692db8060933017392690fe0d6c99494a5..3720c8bfedbdfb8abdd2ba8ae669f7c2bf540c2f 100644 (file)
@@ -1,8 +1,8 @@
 ## @file
 # Create makefile for MS nmake and GNU make
 #
-# Copyright (c) 2007, 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,12 +26,12 @@ 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)
 
-## pattern for include style in R8.x code
+## pattern for include style in Edk.x code
 gProtocolDefinition = "Protocol/%(HeaderKey)s/%(HeaderKey)s.h"
 gGuidDefinition = "Guid/%(HeaderKey)s/%(HeaderKey)s.h"
 gArchProtocolDefinition = "ArchProtocol/%(HeaderKey)s/%(HeaderKey)s.h"
@@ -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]
@@ -462,13 +462,13 @@ cleanlib:
             ArchEntryPoint = ModuleEntryPoint
 
         if self._AutoGenObject.Arch == "EBC":
-            # EBC compiler always use "EfiStart" as entry point. Only applies to R9 modules
+            # EBC compiler always use "EfiStart" as entry point. Only applies to EdkII modules
             ImageEntryPoint = "EfiStart"
         elif self._AutoGenObject.AutoGenVersion < 0x00010005:
-            # R8 modules use entry point specified in INF file
+            # Edk modules use entry point specified in INF file
             ImageEntryPoint = ModuleEntryPoint
         else:
-            # R9 modules always use "_ModuleEntryPoint" as entry point
+            # EdkII modules always use "_ModuleEntryPoint" as entry point
             ImageEntryPoint = "_ModuleEntryPoint"
 
         # tools definitions
@@ -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))
 
@@ -535,7 +535,7 @@ cleanlib:
                 False
                 )
 
-        # R8 modules need <BaseName>StrDefs.h for string ID
+        # Edk modules need <BaseName>StrDefs.h for string ID
         #if self._AutoGenObject.AutoGenVersion < 0x00010005 and len(self._AutoGenObject.UnicodeFileList) > 0:
         #    BcTargetList = ['strdefs']
         #else:
@@ -614,7 +614,7 @@ cleanlib:
         self.FileDependency = self.GetFileDependency(
                                     SourceFileList,
                                     ForceIncludedFile,
-                                    self._AutoGenObject.IncludePathList
+                                    self._AutoGenObject.IncludePathList + self._AutoGenObject.BuildOptionIncPathList
                                     )
         DepSet = None
         for File in self.FileDependency:
@@ -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:
@@ -1249,7 +1253,7 @@ ${END}\t@cd $(BUILD_DIR)
 #
 fds: init
 \t-@cd $(FV_DIR)
-${BEGIN}\tGenFds -f ${fdf_file} -o $(BUILD_DIR) -t $(TOOLCHAIN) -b $(TARGET) -p ${active_platform} -a ${build_architecture_list} ${extra_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv} ${END}${BEGIN} -D ${macro} ${END}
+${BEGIN}\tGenFds -f ${fdf_file} -o $(BUILD_DIR) -t $(TOOLCHAIN) -b $(TARGET) -p ${active_platform} -a ${build_architecture_list}${END}${BEGIN}${extra_options}${END}${BEGIN} -r ${fd}${END}${BEGIN} -i ${fv}${END}${BEGIN} -C ${cap}${END}${BEGIN} -D${macro}${END}
 
 #
 # run command for emulator platform only
@@ -1308,8 +1312,14 @@ ${END}\t@cd $(BUILD_DIR)\n
         if PlatformInfo.FdfFile != None and PlatformInfo.FdfFile != "":
             FdfFileList = [PlatformInfo.FdfFile]
             # macros passed to GenFds
+            # MacroList.append('"%s=%s"' % ("WORKSPACE", GlobalData.gWorkspace))
+            MacroList.append('"%s=%s"' % ("EFI_SOURCE", GlobalData.gEfiSource))
+            MacroList.append('"%s=%s"' % ("EDK_SOURCE", GlobalData.gEdkSource))
             for MacroName in GlobalData.gGlobalDefines:
-                MacroList.append('"%s=%s"' % (MacroName, GlobalData.gGlobalDefines[MacroName]))
+                if GlobalData.gGlobalDefines[MacroName] != "":
+                    MacroList.append('"%s=%s"' % (MacroName, GlobalData.gGlobalDefines[MacroName]))
+                else:
+                    MacroList.append('"%s"' % MacroName)
         else:
             FdfFileList = []
 
@@ -1325,6 +1335,9 @@ ${END}\t@cd $(BUILD_DIR)\n
 
         if GlobalData.gCaseInsensitive:
             ExtraOption += " -c"
+        ExtraOptionList = []
+        if ExtraOption:
+            ExtraOptionList.append(ExtraOption)
 
         MakefileName = self._FILE_NAME_[self._FileType]
         SubBuildCommandList = []
@@ -1355,7 +1368,8 @@ ${END}\t@cd $(BUILD_DIR)\n
             "active_platform"           : str(PlatformInfo),
             "fd"                        : PlatformInfo.FdTargetList,
             "fv"                        : PlatformInfo.FvTargetList,
-            "extra_options"             : ExtraOption,
+            "cap"                       : PlatformInfo.CapTargetList,
+            "extra_options"             : ExtraOptionList,
             "macro"                     : MacroList,
         }