Fixed following bugs:
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Wed, 27 Feb 2008 03:28:45 +0000 (03:28 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Wed, 27 Feb 2008 03:28:45 +0000 (03:28 +0000)
    HSD200899: Passed " error" should be marked
    HSD200901: Single Module build cleanall does not remove the generated efi file outside of module directory
    HSD200904: Build cleanall does not clean the files under build directory
    HSD200927: DSC OUTPUT_DIRECTORY absolute path is not supported

git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1020 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/AutoGen/AutoGen.py
Source/Python/AutoGen/BuildEngine.py
Source/Python/AutoGen/GenMake.py
Source/Python/Common/Misc.py
Source/Python/build/BuildSpawn.py [deleted file]
Source/Python/build/build.py

index a10f4b7..4ef3403 100755 (executable)
@@ -218,9 +218,11 @@ class PlatformAutoGen:
         Info.WorkspaceDir = self.WorkspaceDir\r
         Info.SourceDir = path.dirname(Platform.DescFilePath)\r
         Info.OutputDir = Platform.OutputDirectory\r
-        Info.BuildDir = path.join(Info.OutputDir, self.BuildTarget + "_" + self.ToolChain)\r
+        if os.path.isabs(Info.OutputDir):\r
+            Info.BuildDir = path.join(path.abspath(Info.OutputDir), self.BuildTarget + "_" + self.ToolChain)\r
+        else:\r
+            Info.BuildDir = path.join(Info.WorkspaceDir, Info.OutputDir, self.BuildTarget + "_" + self.ToolChain)\r
         Info.MakeFileDir = Info.BuildDir\r
-\r
         if self.Workspace.Fdf != "":\r
             Info.FdfFile= path.join(self.WorkspaceDir, self.Workspace.Fdf)\r
 \r
@@ -240,7 +242,7 @@ class PlatformAutoGen:
     #   @retval     string  Makefile directory\r
     #\r
     def GetMakeFileDir(self):\r
-        return os.path.join(self.WorkspaceDir, self.BuildInfo[self.ArchList[0]].MakeFileDir)\r
+        return self.BuildInfo[self.ArchList[0]].MakeFileDir\r
 \r
     ## Return build command string\r
     #\r
@@ -504,16 +506,24 @@ class PlatformAutoGen:
     #   @param      Module  The module file\r
     #   @param      Arch    The arch the module will be built for\r
     #\r
-    def CheckModule(self, Module, Arch):\r
+    def IsValidModule(self, Module, Arch):\r
         if Arch not in self.Workspace.SupArchList:\r
-            EdkLogger.error("AutoGen", AUTOGEN_ERROR, "[%s] is not supported by active platform [%s] [%s]!"\r
-                                                      % (Arch, self.PlatformFile, self.Workspace.SupArchList))\r
+            return False\r
+            #EdkLogger.error("AutoGen", AUTOGEN_ERROR, "[%s] is not supported by active platform [%s] [%s]!"\r
+            #                                          % (Arch, self.PlatformFile, self.Workspace.SupArchList))\r
         if Arch not in self.ArchList:\r
-            EdkLogger.error("AutoGen", AUTOGEN_ERROR, "[%s] is not supported by current build configuration!" % Arch)\r
+            return False\r
+            #EdkLogger.error("AutoGen", AUTOGEN_ERROR, "[%s] is not supported by current build configuration!" % Arch)\r
 \r
-        if str(Module) not in self.ModuleDatabase[Arch]:\r
-            EdkLogger.error("AutoGen", AUTOGEN_ERROR, "Module [%s] [%s] is not required by active platform [%s]!"\r
-                                                      % (Module, Arch, self.PlatformFile))\r
+        if Arch not in self.ModuleDatabase or str(Module) not in self.ModuleDatabase[Arch]:\r
+            for A in self.ModuleDatabase:\r
+                if str(Module) in self.ModuleDatabase[A]:\r
+                    break\r
+            else:\r
+                EdkLogger.error("AutoGen", AUTOGEN_ERROR, "Module is not in active platform!",\r
+                                ExtraData=Module)\r
+            return False\r
+        return True\r
 \r
     ## Find the package containing the module\r
     #\r
@@ -634,9 +644,7 @@ class ModuleAutoGen(object):
         self.IsCodeFileCreated = False\r
 \r
         self.PlatformAutoGen = PlatformAutoGenObj\r
-        try:\r
-            self.PlatformAutoGen.CheckModule(ModuleFile, self.Arch)\r
-        except:\r
+        if not self.PlatformAutoGen.IsValidModule(ModuleFile, self.Arch):\r
             return False\r
 \r
         #\r
@@ -748,12 +756,11 @@ class ModuleAutoGen(object):
         Info.OutputDir = os.path.join(Info.BuildDir, "OUTPUT")\r
         Info.DebugDir = os.path.join(Info.BuildDir, "DEBUG")\r
         Info.MakeFileDir = Info.BuildDir\r
-        if os.path.isabs(Info.BuildDir):\r
-            CreateDirectory(Info.OutputDir)\r
-            CreateDirectory(Info.DebugDir)\r
-        else:\r
-            CreateDirectory(os.path.join(self.WorkspaceDir, Info.OutputDir))\r
-            CreateDirectory(os.path.join(self.WorkspaceDir, Info.DebugDir))\r
+        if not os.path.isabs(Info.BuildDir):\r
+            os.chdir(Info.PlatformInfo.BuildDir)\r
+        CreateDirectory(Info.OutputDir)\r
+        CreateDirectory(Info.DebugDir)\r
+        os.chdir(self.WorkspaceDir)\r
 \r
         for Type in self.Module.CustomMakefile:\r
             MakeType = gMakeTypeMap[Type]\r
@@ -781,8 +788,13 @@ class ModuleAutoGen(object):
         Info.Macro = self.GetMacroList()\r
         Info.DepexList = self.GetDepexTokenList(Info)\r
 \r
-        Info.IncludePathList = [Info.SourceDir, Info.DebugDir]\r
-        Info.IncludePathList.extend(self.GetIncludePathList(Info.DependentPackageList))\r
+        if Info.AutoGenVersion < 0x00010005:\r
+            # r8 module needs to put DEBUG_DIR at the end search path and not to use SOURCE_DIR all the time\r
+            Info.IncludePathList = self.GetIncludePathList(Info.DependentPackageList)\r
+            Info.IncludePathList.append(Info.DebugDir)\r
+        else:\r
+            Info.IncludePathList = [os.path.join(Info.WorkspaceDir, Info.SourceDir), Info.DebugDir]\r
+            Info.IncludePathList.extend(self.GetIncludePathList(Info.DependentPackageList))\r
 \r
         Info.SourceFileList = self.GetSourceFileList(Info)\r
         Info.AutoGenFileList = self.GetAutoGenFileList(Info)\r
@@ -795,7 +807,7 @@ class ModuleAutoGen(object):
     #   @retval     string  The directory string of module's makefile\r
     #\r
     def GetMakeFileDir(self):\r
-        return os.path.join(self.WorkspaceDir, self.BuildInfo.MakeFileDir)\r
+        return self.BuildInfo.MakeFileDir\r
 \r
     ## Return build command string\r
     #\r
@@ -938,7 +950,7 @@ class ModuleAutoGen(object):
             # add the file path into search path list for file including\r
             Dir = path.dirname(SourceFile)\r
             if Dir != "":\r
-                Dir = path.join(self.BuildInfo.SourceDir, Dir)\r
+                Dir = path.join(self.WorkspaceDir, self.BuildInfo.SourceDir, Dir)\r
                 if Dir not in self.BuildInfo.IncludePathList:\r
                     self.BuildInfo.IncludePathList.insert(0, Dir)\r
 \r
@@ -1118,16 +1130,19 @@ class ModuleAutoGen(object):
     #\r
     def GetIncludePathList(self, DependentPackageList):\r
         IncludePathList = []\r
-        for Inc in self.Module.Includes:\r
-            # '.' means "relative to module directory".\r
-            if Inc[0] == ".":\r
-                Inc = os.path.join(self.BuildInfo.SourceDir, Inc)\r
-            IncludePathList.append(Inc)\r
-            # for r8 modules\r
-            IncludePathList.append(os.path.join(Inc, self.Arch.capitalize()))\r
+        if self.BuildInfo.AutoGenVersion < 0x00010005:\r
+            for Inc in self.Module.Includes:\r
+                # '.' means "relative to module directory".\r
+                if Inc[0] == ".":\r
+                    Inc = os.path.join(self.WorkspaceDir, self.BuildInfo.SourceDir, Inc)\r
+                else:\r
+                    Inc = os.path.join(self.WorkspaceDir, Inc)\r
+                IncludePathList.append(Inc)\r
+                # for r8 modules\r
+                IncludePathList.append(os.path.join(Inc, self.Arch.capitalize()))\r
 \r
         for Package in DependentPackageList:\r
-            PackageDir = path.dirname(Package.DescFilePath)\r
+            PackageDir = os.path.join(self.WorkspaceDir, path.dirname(Package.DescFilePath))\r
             IncludePathList.append(PackageDir)\r
             for Inc in Package.Includes:\r
                 Inc = os.path.join(PackageDir, Inc)\r
@@ -1149,7 +1164,7 @@ class ModuleAutoGen(object):
             for Lib in self.BuildInfo.DependentLibraryList:\r
                 EdkLogger.debug(EdkLogger.DEBUG_1, "###" + str(Lib))\r
                 LibraryAutoGen = ModuleAutoGen.New(self.Workspace, self.Platform, Lib,\r
-                                                          self.BuildTarget, self.ToolChain, self.Arch)\r
+                                                   self.BuildTarget, self.ToolChain, self.Arch)\r
                 if LibraryAutoGen not in self.BuildInfo.LibraryAutoGenList:\r
                     self.BuildInfo.LibraryAutoGenList.append(LibraryAutoGen)\r
                 LibraryAutoGen.CreateMakeFile()\r
@@ -1182,26 +1197,26 @@ class ModuleAutoGen(object):
                     self.BuildInfo.LibraryAutoGenList.append(LibraryAutoGen)\r
                 LibraryAutoGen.CreateCodeFile()\r
 \r
+        os.chdir(self.BuildInfo.DebugDir)\r
         AutoGenList = []\r
         IgoredAutoGenList = []\r
         if self.AutoGenC.String != "":\r
-            if GenC.Generate(os.path.join(self.BuildInfo.WorkspaceDir, self.BuildInfo.DebugDir, gAutoGenCodeFileName),\r
-                             self.AutoGenC.String):\r
+            if GenC.Generate(gAutoGenCodeFileName, self.AutoGenC.String):\r
                 AutoGenList.append(gAutoGenCodeFileName)\r
             else:\r
                 IgoredAutoGenList.append(gAutoGenCodeFileName)\r
 \r
         if self.AutoGenH.String != "":\r
-            if GenC.Generate(os.path.join(self.BuildInfo.WorkspaceDir, self.BuildInfo.DebugDir, gAutoGenHeaderFileName),\r
-                             self.AutoGenH.String):\r
+            if GenC.Generate(gAutoGenHeaderFileName, self.AutoGenH.String):\r
                 AutoGenList.append(gAutoGenHeaderFileName)\r
             else:\r
                 IgoredAutoGenList.append(gAutoGenHeaderFileName)\r
 \r
+        os.chdir(self.BuildInfo.OutputDir)\r
         if self.BuildInfo.DepexList != []:\r
             Dpx = GenDepex.DependencyExpression(self.BuildInfo.DepexList, self.BuildInfo.ModuleType)\r
             DpxFile = gAutoGenDepexFileName % {"module_name" : self.BuildInfo.Name}\r
-            if Dpx.Generate(os.path.join(self.WorkspaceDir, self.BuildInfo.OutputDir, DpxFile)):\r
+            if Dpx.Generate(DpxFile):\r
                 AutoGenList.append(DpxFile)\r
             else:\r
                 IgoredAutoGenList.append(DpxFile)\r
@@ -1217,6 +1232,7 @@ class ModuleAutoGen(object):
                            (" ".join(AutoGenList), " ".join(IgoredAutoGenList), self.BuildInfo.Name, self.BuildInfo.Arch))\r
 \r
         self.IsCodeFileCreated = True\r
+        os.chdir(self.WorkspaceDir)\r
         return AutoGenList\r
 \r
 # Version and Copyright\r
index a2c90bc..ed7f036 100644 (file)
@@ -121,7 +121,7 @@ class FileBuildRule:
                 if SrcFileDir == "":\r
                     SrcFileDir = "."\r
 \r
-                SrcFile = PathSeparator.join(["$(WORKSPACE)", RelativeToDir, SourceFile])\r
+                SrcFile = PathSeparator.join([RelativeToDir, SourceFile])\r
             else:\r
                 SrcFileDir = "."\r
                 SrcFile = SourceFile\r
index 4df9a8f..41d3dfe 100755 (executable)
@@ -158,8 +158,8 @@ TARGET = ${build_target}
 #\r
 # Build Directory Macro Definition\r
 #\r
-PLATFORM_BUILD_DIR = ${platform_build_directory}\r
-BUILD_DIR = ${platform_build_directory}${separator}${build_target}_${toolchain_tag}\r
+PLATFORM_BUILD_DIR = ${platform_build_directory}\r
+BUILD_DIR = ${platform_build_directory}\r
 BIN_DIR = $(BUILD_DIR)${separator}${architecture}\r
 LIB_DIR = $(BIN_DIR)\r
 MODULE_BUILD_DIR = $(BUILD_DIR)${separator}${architecture}${separator}${module_relative_directory}${separator}${module_file_base_name}\r
@@ -266,8 +266,8 @@ TARGET = ${build_target}
 #\r
 # Build Directory Macro Definition\r
 #\r
-PLATFORM_BUILD_DIR = ${platform_build_directory}\r
-BUILD_DIR = ${platform_build_directory}${separator}${build_target}_${toolchain_tag}\r
+PLATFORM_BUILD_DIR = ${platform_build_directory}\r
+BUILD_DIR = ${platform_build_directory}\r
 BIN_DIR = $(BUILD_DIR)${separator}${architecture}\r
 LIB_DIR = $(BIN_DIR)\r
 MODULE_BUILD_DIR = $(BUILD_DIR)${separator}${architecture}${separator}${module_relative_directory}${separator}${module_file_base_name}\r
@@ -327,7 +327,7 @@ SOURCE_FILES = ${BEGIN}${source_file_macro_name} ${END}
 \r
 TARGET_FILES = ${BEGIN}${target_file_macro_name} ${END}\r
 \r
-INC = ${BEGIN}${include_path_prefix}$(WORKSPACE)${separator}${include_path} \\\r
+INC = ${BEGIN}${include_path_prefix}${include_path} \\\r
       ${END}\r
 \r
 #OBJECTS = ${BEGIN}$(OUTPUT_DIR)${separator}${object_file} \\\r
@@ -337,7 +337,7 @@ LIBS = ${BEGIN}$(BUILD_DIR)${separator}$(ARCH)${separator}${library_file} \\
        ${END}${BEGIN}${system_library} \\\r
        ${END}\r
 \r
-COMMON_DEPS = ${BEGIN}$(WORKSPACE)${separator}${common_dependency_file} \\\r
+COMMON_DEPS = ${BEGIN}${common_dependency_file} \\\r
               ${END}\r
 \r
 IMAGE_ENTRY_POINT = ${module_entry_point}\r
@@ -419,15 +419,16 @@ clean:
 #\r
 \r
 cleanall:\r
-\t${BEGIN}${cleanall_command}\r
-\t${END}${remove_file_command} *.pdb *.idb > NUL 2>&1\r
+${BEGIN}\t${cleanall_command}\r
+${END}\t$(RM) *.pdb *.idb > NUL 2>&1\r
+\t$(RM) $(BIN_DIR)${separator}$(MODULE_NAME).efi\r
 \r
 #\r
 # clean pre-compiled header files\r
 #\r
 \r
 cleanpch:\r
-\t${remove_file_command} $(OUTPUT_DIR)\*.pch > NUL 2>&1\r
+\t$(RM) $(OUTPUT_DIR)\*.pch > NUL 2>&1\r
 \r
 #\r
 # clean all dependent libraries built\r
@@ -460,8 +461,14 @@ TARGET = ${build_target}
 #\r
 # Build Directory Macro Definition\r
 #\r
-BUILD_DIR = ${platform_build_directory}${separator}${build_target}_${toolchain_tag}\r
-FV_DIR = ${platform_build_directory}${separator}${build_target}_${toolchain_tag}${separator}FV\r
+BUILD_DIR = ${platform_build_directory}\r
+FV_DIR = ${platform_build_directory}${separator}FV\r
+\r
+#\r
+# Shell Command Macro\r
+#\r
+${BEGIN}${shell_command_code} = ${shell_command}\r
+${END}\r
 \r
 MAKE = ${make_path}\r
 MAKE_FLAGS = ${make_flag}\r
@@ -498,21 +505,21 @@ fds: init build_fds
 # Build all libraries:\r
 #\r
 build_libraries:\r
-${BEGIN}\tcd $(WORKSPACE)${separator}${library_build_directory} && "$(MAKE)" $(MAKE_FLAGS) pbuild\r
+${BEGIN}\tcd ${library_build_directory} && "$(MAKE)" $(MAKE_FLAGS) pbuild\r
 ${END}\tcd $(BUILD_DIR)\r
 \r
 #\r
 # Build all modules:\r
 #\r
 build_modules:\r
-${BEGIN}\tcd $(WORKSPACE)${separator}${module_build_directory} && "$(MAKE)" $(MAKE_FLAGS) pbuild\r
+${BEGIN}\tcd ${module_build_directory} && "$(MAKE)" $(MAKE_FLAGS) pbuild\r
 ${END}\tcd $(BUILD_DIR)\r
 \r
 #\r
 # Build Flash Device Image\r
 #\r
 build_fds:\r
-\t-@echo Generating flash image, if any ...\r
+\t-@cd $(FV_DIR)\r
 ${BEGIN}\tGenFds -f ${fdf_file} -o $(BUILD_DIR) -t $(TOOLCHAIN_TAG) -b $(TARGET) -p ${active_platform} -a ${build_architecture_list} ${log_level}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv} ${END}${BEGIN} -y ${macro} ${END}\r
 \r
 #\r
@@ -527,22 +534,22 @@ run:
 # Clean intermediate files\r
 #\r
 clean:\r
-\t${BEGIN}cd $(WORKSPACE)${separator}${library_build_directory} && "$(MAKE)" $(MAKE_FLAGS) clean\r
-\t${END}${BEGIN}cd $(WORKSPACE)${separator}${module_build_directory} && "$(MAKE)" $(MAKE_FLAGS) clean\r
+\t${BEGIN}cd ${library_build_directory} && "$(MAKE)" $(MAKE_FLAGS) clean\r
+\t${END}${BEGIN}cd ${module_build_directory} && "$(MAKE)" $(MAKE_FLAGS) clean\r
 \t${END}cd $(BUILD_DIR)\r
 \r
 #\r
 # Clean all generated files except to makefile\r
 #\r
 cleanall:\r
-\t${BEGIN}${cleanall_command}\r
-\t${END}\r
+${BEGIN}\t${cleanall_command}\r
+${END}\r
 \r
 #\r
 # Clean all library files\r
 #\r
 cleanlib:\r
-\t${BEGIN}cd $(WORKSPACE)${separator}${library_build_directory} && "$(MAKE)" $(MAKE_FLAGS) cleanall\r
+\t${BEGIN}cd ${library_build_directory} && "$(MAKE)" $(MAKE_FLAGS) cleanall\r
 \t${END}cd $(BUILD_DIR)\r
 \r
 '''\r
@@ -606,9 +613,9 @@ class Makefile(object):
     ## Create necessary directory for makefile generation\r
     def PrepareDirectory(self):\r
         if self.ModuleBuild:\r
-            CreateDirectory(path.join(self.ModuleInfo.WorkspaceDir, self.PlatformInfo.BuildDir))\r
-            CreateDirectory(path.join(self.ModuleInfo.WorkspaceDir, self.ModuleInfo.BuildDir))\r
-            CreateDirectory(path.join(self.ModuleInfo.WorkspaceDir, self.ModuleInfo.DebugDir))\r
+            CreateDirectory(self.PlatformInfo.BuildDir)\r
+            CreateDirectory(self.ModuleInfo.BuildDir)\r
+            CreateDirectory(self.ModuleInfo.DebugDir)\r
 \r
     ## Create the makefile\r
     #\r
@@ -644,15 +651,6 @@ class Makefile(object):
         if "MAKE" not in PlatformInfo.ToolPath:\r
             EdkLogger.error("GenMake", OPTION_MISSING, "No MAKE command defined. Please check your tools_def.txt!")\r
 \r
-        OutputDir = PlatformInfo.OutputDir\r
-        if os.path.isabs(OutputDir):\r
-            self.PlatformBuildDirectory = OutputDir\r
-            CreateDirectory(self.PlatformBuildDirectory)\r
-        else:\r
-            self.PlatformBuildDirectory = "$(WORKSPACE)" + Separator + OutputDir\r
-            CreateDirectory(os.path.join(PlatformInfo.WorkspaceDir, OutputDir))\r
-\r
-\r
         self.IntermediateDirectoryList = ["$(BUILD_DIR)%s%s" % (Separator, Arch) for Arch in self.PlatformInfo]\r
         self.IntermediateDirectoryList.append("$(FV_DIR)")\r
 \r
@@ -685,12 +683,14 @@ class Makefile(object):
             "platform_version"          : PlatformInfo.Version,\r
             "platform_relative_directory": PlatformInfo.SourceDir,\r
             "platform_output_directory" : PlatformInfo.OutputDir,\r
-            "platform_build_directory"  : self.PlatformBuildDirectory,\r
+            "platform_build_directory"  : PlatformInfo.BuildDir,\r
 \r
             "toolchain_tag"             : PlatformInfo.ToolChain,\r
             "build_target"              : PlatformInfo.BuildTarget,\r
             "make_path"                 : PlatformInfo.ToolPath["MAKE"],\r
             "make_flag"                 : PlatformInfo.ToolOption["MAKE"],\r
+            "shell_command_code"        : gShellCommand[MakeType].keys(),\r
+            "shell_command"             : gShellCommand[MakeType].values(),\r
             "build_architecture_list"   : ",".join(ArchList),\r
             "architecture"              : self.PlatformInfo.keys(),\r
             "separator"                 : Separator,\r
@@ -715,11 +715,14 @@ class Makefile(object):
 \r
         FilePath = ""\r
         if File == None:\r
-            FilePath = path.join(PlatformInfo.WorkspaceDir, PlatformInfo.MakeFileDir, MakefileName)\r
+            os.chdir(PlatformInfo.MakeFileDir)\r
+            FilePath = MakefileName\r
         else:\r
             FilePath = File\r
 \r
-        return SaveFileOnChange(FilePath, str(AutoGenMakefile))\r
+        Result = SaveFileOnChange(FilePath, str(AutoGenMakefile))\r
+        os.chdir(PlatformInfo.WorkspaceDir)\r
+        return Result\r
 \r
     ## Create makefile of a module\r
     #\r
@@ -737,11 +740,6 @@ class Makefile(object):
         Separator = gDirectorySeparator[MakeType]\r
         PlatformInfo = self.PlatformInfo\r
 \r
-        if os.path.isabs(PlatformInfo.OutputDir):\r
-            self.PlatformBuildDirectory = PlatformInfo.OutputDir\r
-        else:\r
-            self.PlatformBuildDirectory = "$(WORKSPACE)" + Separator + PlatformInfo.OutputDir\r
-\r
         # break build if no source files and binary files are found\r
         if len(self.ModuleInfo.SourceFileList) == 0 and len(self.ModuleInfo.BinaryFileDict) == 0:\r
             EdkLogger.error("AutoGen", AUTOGEN_ERROR, "No files to be built in module [%s, %s, %s]"\r
@@ -833,7 +831,7 @@ class Makefile(object):
             "toolchain_tag"             : self.ModuleInfo.ToolChain,\r
             "build_target"              : self.ModuleInfo.BuildTarget,\r
 \r
-            "platform_build_directory"  : self.PlatformBuildDirectory,\r
+            "platform_build_directory"  : PlatformInfo.BuildDir,\r
 \r
             "separator"                 : Separator,\r
             "default_tool_flags"        : DefaultToolFlag,\r
@@ -882,11 +880,15 @@ class Makefile(object):
 \r
         FilePath = ""\r
         if File == None:\r
-            FilePath = path.join(self.ModuleInfo.WorkspaceDir, self.ModuleInfo.MakeFileDir, MakefileName)\r
+            os.chdir(self.ModuleInfo.PlatformInfo.BuildDir)\r
+            os.chdir(self.ModuleInfo.MakeFileDir)\r
+            FilePath = MakefileName\r
         else:\r
             FilePath = File\r
 \r
-        return SaveFileOnChange(FilePath, str(AutoGenMakefile))\r
+        Result = SaveFileOnChange(FilePath, str(AutoGenMakefile))\r
+        os.chdir(self.ModuleInfo.WorkspaceDir)\r
+        return Result\r
 \r
     ## Create customized makefile for a module\r
     #\r
@@ -899,12 +901,6 @@ class Makefile(object):
     #\r
     def GenerateCustomBuildMakefile(self, File=None, MakeType=gMakeType):\r
         Separator = gDirectorySeparator[MakeType]\r
-\r
-        if os.path.isabs(self.PlatformInfo.OutputDir):\r
-            self.PlatformBuildDirectory = self.PlatformInfo.OutputDir\r
-        else:\r
-            self.PlatformBuildDirectory = "$(WORKSPACE)" + Separator + self.PlatformInfo.OutputDir\r
-\r
         CustomMakefile = open(os.path.join(self.ModuleInfo.WorkspaceDir, self .ModuleInfo.CustomMakefile[MakeType]), 'r').read()\r
 \r
         MakefileName = gMakefileName[MakeType]\r
@@ -927,7 +923,7 @@ class Makefile(object):
             "toolchain_tag"             : self.ModuleInfo.ToolChain,\r
             "build_target"              : self.ModuleInfo.BuildTarget,\r
 \r
-            "platform_build_directory"  : self.PlatformBuildDirectory,\r
+            "platform_build_directory"  : self.PlatformInfo.BuildDir,\r
 \r
             "separator"                 : Separator,\r
             "default_tool_flags"        : self.PlatformInfo.ToolOption.values(),\r
@@ -978,6 +974,7 @@ class Makefile(object):
 \r
         CCodeFlag = False\r
         FileList = self.ModuleInfo.SourceFileList\r
+        SourceDir = os.path.join(self.ModuleInfo.WorkspaceDir, self.ModuleInfo.SourceDir)\r
         for FileInfo in FileList:\r
             F, SrcFileType, SrcFileBuildRule = FileInfo\r
             if SrcFileType == "C-Code-File":\r
@@ -991,10 +988,9 @@ class Makefile(object):
                 P = "$(OUTPUT_DIR)" + Separator + SrcFileDir\r
                 if P not in self.IntermediateDirectoryList:\r
                     self.IntermediateDirectoryList.append(P)\r
-            SrcFileRelativePath = os.path.join(self.ModuleInfo.SourceDir, F)\r
-\r
-            SrcFile, ExtraSrcFileList, DstFile, CommandList = SrcFileBuildRule.Apply(F, self.ModuleInfo.SourceDir, Separator)\r
+            SrcFileRelativePath = os.path.join(SourceDir, F)\r
 \r
+            SrcFile, ExtraSrcFileList, DstFile, CommandList = SrcFileBuildRule.Apply(F, SourceDir, Separator)\r
             if SrcFileType not in self.SourceFileDatabase:\r
                 self.SourceFileDatabase[SrcFileType] = []\r
             self.SourceFileDatabase[SrcFileType].append(SrcFile)\r
@@ -1079,6 +1075,7 @@ class Makefile(object):
                 break\r
             self.PendingBuildTargetList = TempBuildTargetList\r
 \r
+        # Build AutoGen files only if we have C source files\r
         if CCodeFlag == True:\r
             for F in self.ModuleInfo.AutoGenFileList:\r
                 SrcFileName = path.basename(F)\r
@@ -1143,8 +1140,8 @@ class Makefile(object):
         self.FileDependency = self.GetFileDependency(SourceFileList, ForceIncludedFile, self.ModuleInfo.IncludePathList)\r
         DepSet = None\r
         for File in self.FileDependency:\r
-            # skip AutoGen.c\r
-            if File.endswith("AutoGen.c") or not File.endswith(".c"):\r
+            # skip non-C files\r
+            if (not File.endswith(".c") and not File.endswith(".C")) or File.endswith("AutoGen.c"):\r
                 continue\r
             elif DepSet == None:\r
                 DepSet = set(self.FileDependency[File])\r
@@ -1160,10 +1157,8 @@ class Makefile(object):
         for F in self.FileDependency:\r
             NewDepSet = set(self.FileDependency[F])\r
             NewDepSet -= DepSet\r
-            if F.endswith("AutoGen.c") or not F.endswith(".c"):\r
-                self.FileDependency[F] = [Separator.join(["$(WORKSPACE)", dep]) for dep in self.FileDependency[F]]\r
-            else:\r
-                self.FileDependency[F] = ["$(COMMON_DEPS)"] + [Separator.join(["$(WORKSPACE)", dep]) for dep in NewDepSet]\r
+            if File.endswith(".c") or File.endswith(".C") or not File.endswith("AutoGen.c"):\r
+                self.FileDependency[F] = ["$(COMMON_DEPS)"] + list(NewDepSet)\r
 \r
         for File, TargetTemplate in self.FileBuildTargetList:\r
             if File not in self.FileDependency:\r
@@ -1209,10 +1204,7 @@ class Makefile(object):
 \r
     ## Determine the root directory for a platform build\r
     def GetPlatformBuildDirectory(self):\r
-        if os.path.isabs(self.PlatformInfo.OutputDir):\r
-            return self.PlatformInfo.OutputDir\r
-        else:\r
-            return os.path.join("$(WORKSPACE)", self.PlatformInfo.OutputDir)\r
+        return self.PlatformInfo.BuildDir\r
 \r
     ## Return a list containing source file's dependencies\r
     #\r
@@ -1223,12 +1215,9 @@ class Makefile(object):
     #   @retval     dict            The mapping between source file path and its dependencies\r
     #\r
     def GetFileDependency(self, FileList, ForceInculeList, SearchPathList):\r
-        WorkingDir = os.getcwd()\r
-        os.chdir(self.ModuleInfo.WorkspaceDir)\r
         Dependency = {}\r
         for F in FileList:\r
             Dependency[F] = self.GetDependencyList(F, ForceInculeList, SearchPathList)\r
-        os.chdir(WorkingDir)\r
         return Dependency\r
 \r
     ## Find dependencies for one source file\r
@@ -1244,9 +1233,6 @@ class Makefile(object):
     #   @retval     list            The list of files the given source file depends on\r
     #\r
     def GetDependencyList(self, File, ForceList, SearchPathList):\r
-        WorkingDir = os.getcwd()\r
-        os.chdir(self.ModuleInfo.WorkspaceDir)\r
-\r
         EdkLogger.debug(EdkLogger.DEBUG_1, "Try to get dependency files for %s" % File)\r
         EdkLogger.debug(EdkLogger.DEBUG_0, "Including %s" % " ".join(ForceList))\r
         FileStack = [File] + ForceList\r
@@ -1326,7 +1312,6 @@ class Makefile(object):
             DependencyList = list(DependencySet)  # remove duplicate ones\r
             DependencyList.append(File)\r
 \r
-        os.chdir(WorkingDir)\r
         return DependencyList\r
 \r
     ## Get the root directory list for intermediate files of all modules build\r
index 44467f9..ae98c65 100755 (executable)
@@ -190,6 +190,7 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
             Fd.close()\r
             return False\r
         Fd.close()\r
+        os.remove(File) # seems creating new file is faster than overwriting old one\r
     CreateDirectory(os.path.dirname(File))\r
     Fd = open(File, "w"+BinaryFlag)\r
     Fd.write(Content)\r
diff --git a/Source/Python/build/BuildSpawn.py b/Source/Python/build/BuildSpawn.py
deleted file mode 100644 (file)
index 654acb1..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#\r
-#  Copyright (c) 2007, Intel Corporation\r
-#\r
-#  All rights reserved. This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution.  The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-\r
-\r
-import os\r
-from threading import *\r
-from subprocess import *\r
-\r
-import Common.EdkLogger as EdkLogger\r
-\r
-\r
-class BuildSpawn(Thread):\r
-    def __init__(self, ReturnCode, Sem=None, Filename=None, Args=None, Num=0, Dir=None):\r
-        Thread.__init__(self)\r
-        self.sem=Sem\r
-        self.filename=Filename\r
-        self.args=Args\r
-        self.num=Num\r
-        self.returncode=ReturnCode\r
-        self.Dir=Dir\r
-        \r
-\r
-    def run(self):\r
-        self.sem.acquire()\r
-        p = Popen([self.filename, "/nologo", self.args], stdout=PIPE, stderr=PIPE, env=os.environ, cwd=self.Dir)\r
-        while p.poll() == None:\r
-            EdkLogger.info(p.stdout.readline()[:-2])\r
-        EdkLogger.info(p.stdout.read())\r
-        if p.returncode != 0:\r
-            self.returncode[0] = 1\r
-            EdkLogger.quiet(p.stderr.read())\r
-        self.sem.release()\r
index 17d976b..b826ebb 100644 (file)
@@ -867,51 +867,40 @@ class Build():
     #                                       for dependent modules/Libraries\r
     #\r
     def _Build(self, Target, Platform, Module, BuildTarget, ToolChain, Arch, CreateDepModuleCodeFile=True, CreateDepModuleMakeFile=True):\r
-        # skip file generation for some targets\r
-        if Target not in ['clean', 'cleanlib', 'cleanall', 'run']:\r
-            #\r
-            # no need to generate code/makefile for dependent modules/libraries\r
-            # if the target is 'fds'\r
-            #\r
-            if Target == 'fds':\r
-                CreateDepModuleCodeFile = False\r
-                CreateDepModuleMakeFile = False\r
-                CreateDepModuleAutoGenObject = True\r
-            else:\r
-                CreateDepModuleAutoGenObject = False\r
-\r
-            if Module != None:\r
-                self.Progress.Start("Generating code/makefile for module")\r
-                AutoGenResult = ModuleAutoGen.New(self.Ewb, Platform, Module, BuildTarget,\r
-                                                  ToolChain, Arch)\r
-            else:\r
-                self.Progress.Start("Generating code/makefile for platform")\r
-                AutoGenResult = PlatformAutoGen.New(self.Ewb, Platform, BuildTarget,\r
-                                                    ToolChain, Arch, CreateDepModuleAutoGenObject)\r
-            if AutoGenResult == None:\r
-                return\r
+        #\r
+        # no need to generate code/makefile for dependent modules/libraries\r
+        # if the target is 'fds'\r
+        #\r
+        if Target == 'fds':\r
+            CreateDepModuleCodeFile = False\r
+            CreateDepModuleMakeFile = False\r
+            CreateDepModuleAutoGenObject = True\r
+        else:\r
+            CreateDepModuleAutoGenObject = False\r
 \r
+        if Module != None:\r
+            AutoGenResult = ModuleAutoGen.New(self.Ewb, Platform, Module, BuildTarget,\r
+                                              ToolChain, Arch)\r
+        else:\r
+            AutoGenResult = PlatformAutoGen.New(self.Ewb, Platform, BuildTarget,\r
+                                                ToolChain, Arch, CreateDepModuleAutoGenObject)\r
+        if AutoGenResult == None:\r
+            return False\r
+\r
+        # skip file generation for cleanxxx targets and run target\r
+        if Target not in ['clean', 'cleanlib', 'cleanall', 'run']:    \r
+            self.Progress.Start("Generating code for " + str(AutoGenResult))\r
             # for target which must generate AutoGen code and makefile\r
             AutoGenResult.CreateCodeFile(CreateDepModuleCodeFile)\r
+            self.Progress.Stop("done!")\r
             if Target == "genc":\r
-                self.Progress.Stop("done!")\r
-                return\r
-\r
+                return True\r
+    \r
+            self.Progress.Start("Generating makefile for " + str(AutoGenResult))\r
             AutoGenResult.CreateMakeFile(CreateDepModuleMakeFile)\r
-            if Target == "genmake":\r
-                self.Progress.Stop("done!")\r
-                return\r
-\r
             self.Progress.Stop("done!")\r
-        else:\r
-            if Module != None:\r
-                AutoGenResult = ModuleAutoGen.New(self.Ewb, Platform, Module, BuildTarget,\r
-                                                  ToolChain, Arch)\r
-            else:\r
-                AutoGenResult = PlatformAutoGen.New(self.Ewb, Platform, BuildTarget,\r
-                                                    ToolChain, Arch, False)\r
-            if AutoGenResult == None:\r
-                return\r
+            if Target == "genmake":\r
+                return True\r
 \r
         EdkLogger.info("")\r
         BuildCommand = AutoGenResult.GetBuildCommand()\r
@@ -920,6 +909,7 @@ class Build():
 \r
         BuildCommand = BuildCommand + (Target,)\r
         LaunchCommand(BuildCommand, os.path.join(self.WorkspaceDir, AutoGenResult.GetMakeFileDir()))\r
+        return True\r
 \r
     ## Build active platform for different build targets and different tool chains\r
     #\r